home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / tutsamp / dcdmarsh / makefile < prev    next >
Makefile  |  1997-09-09  |  9KB  |  255 lines

  1. #/*+=========================================================================
  2. #  File:       MAKEFILE
  3. #
  4. #  Summary:    Makefile for building the DCDMARSH.DLL marshaling server
  5. #              that provides the necessary Proxys and Stubs to provide
  6. #              standard marshaling for the IPaper custom interface.
  7. #              PAPINT.IDL is the primary source for this lesson. It
  8. #              contains the interface specifications in the MIDL language.
  9. #              During the build, MIDL creates the following intermediate
  10. #              source files that are compiled to produce the final
  11. #              DCDMARSH.DLL: PAPINT.H, PAPINT_I.C, PAPINT_P.C, and
  12. #              DLLDATA.C. The generated PAPINT.H file is included by
  13. #              modules in other programs that make use of IPaper.
  14. #
  15. #              This Makefile creates a subdirectory (TEMP) for the
  16. #              .OBJ and .RES files used during the build process.  It also
  17. #              automatically registers the newly built DLL server in the
  18. #              system Registry.  Since the build of this makefile does this
  19. #              registration you must build the REGISTER.EXE utility first
  20. #              (in sibling directory REGISTER).
  21. #
  22. #              For a comprehensive tutorial code tour of DCDMARSH's
  23. #              contents and offerings see the tutorial DCDMARSH.HTM
  24. #              file.  For more specific technical details see the comments
  25. #              dispersed throughout the DCDMARSH source code.
  26. #
  27. #              See also DCOMDRAW.HTM and DCDSERVE.HTM (in the main
  28. #              tutorial directory) for more details on this client/server
  29. #              pair works with DCDMARSH.DLL marshaling server.
  30. #
  31. #              In general, to set up your system to build and test the
  32. #              Win32 code samples in this COM Tutorial series, see the
  33. #              global TUTORIAL.HTM file for details.  This MAKEFILE is
  34. #              Microsoft NMAKE compatible and the 'debug' build can be
  35. #              achieved by simply issuing the NMAKE command in a command
  36. #              prompt window.
  37. #
  38. #  Builds:     DCDMARSH.DLL, DCDMARSH.LIB, PAPINT.H, PAPINT_I.C, PAPINT_P.C,
  39. #              DLLDATA.C.
  40. #
  41. #  Origin:     8-23-97: atrent - Editor-inheritance from MARSHAL source.
  42. #
  43. #--Usage:-------------------------------------------------------------------
  44. #  NMAKE Options
  45. #
  46. #  Use the table below to determine the additional options for NMAKE to
  47. #  generate various application debugging, profiling and performance tuning
  48. #  information.
  49. #
  50. #  Application Information Type         Invoke NMAKE
  51. #  ----------------------------         ------------
  52. #  For No Debugging Info                nmake nodebug=1
  53. #  For Working Set Tuner Info           nmake tune=1
  54. #  For Call Attributed Profiling Info   nmake profile=1
  55. #
  56. #  Note: The three options above are mutually exclusive (you may use only
  57. #        one to compile/link the application).
  58. #
  59. #  Note: creating the environment variables NODEBUG, TUNE, and PROFILE
  60. #        is an alternate method to setting these options via the nmake
  61. #        command line.
  62. #
  63. #  Additional NMAKE Options             Invoke NMAKE
  64. #  ----------------------------         ------------
  65. #  For No ANSI NULL Compliance          nmake no_ansi=1
  66. #    (ANSI NULL is defined as PVOID 0)
  67. #  To compile for Unicode               nmake unicode=1
  68. #    (Default is ANSI)
  69. #  To clean up temporary binaries       nmake clean
  70. #  To clean up all generated files      nmake cleanall
  71. #  To register DLL                      nmake register
  72. #  To unregister DLL                    nmake unregister
  73. #
  74. #---------------------------------------------------------------------------
  75. #  This file is part of the Microsoft COM Tutorial Code Samples.
  76. #
  77. #  Copyright (C) Microsoft Corporation, 1997.  All rights reserved.
  78. #
  79. #  This source code is intended only as a supplement to Microsoft
  80. #  Development Tools and/or on-line documentation.  See these other
  81. #  materials for detailed information regarding Microsoft code samples.
  82. #
  83. #  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  84. #  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  85. #  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  86. #  PARTICULAR PURPOSE.
  87. #=========================================================================+*/
  88.  
  89. #  WIN32.MAK should be included at the front of every Win32 makefile.
  90. #
  91. #  Define APPVER = [ 3.50 | 3.51 | 4.0 ] prior to including win32.mak to get
  92. #  build time checking for version dependencies and to mark the executable
  93. #  with version information.
  94. #
  95. #  Define TARGETOS = [ WIN95 | WINNT | BOTH ] prior to including win32.mak
  96. #  to get some build time checking for platform dependencies.
  97. #
  98. APPVER=4.0
  99. TARGETOS=BOTH
  100. !include <win32.mak>
  101.  
  102. # Assign the main program name macros.
  103. DLL = dcdmarsh
  104.  
  105. # Use a temporary sub-directory to store intermediate
  106. # binary files like *.obj, *.res, *.map, etc.
  107. TDIR = TEMP
  108.  
  109. # Assign destination and consumer sibling directories.
  110. IDIR = ..\inc
  111. LDIR = ..\lib
  112.  
  113. REGEXE = ..\register\register.exe
  114.  
  115. # The sibling ..\INC and ..\LIB directories are added to the front of
  116. # the INCLUDE and LIB macros to inform the compiler and linker of
  117. # these application-specific locations for include and lib files.
  118. INCLUDE=$(IDIR);$(INCLUDE)
  119. LIB=$(LDIR);$(LIB)
  120.  
  121. LINK = $(link)
  122.  
  123. # If UNICODE=1 is defined then define UNICODE during Compiles.
  124. # The default is to compile with ANSI for running under both
  125. # Win95 and WinNT.
  126. !IFDEF UNICODE
  127. LINKFLAGS = $(ldebug)
  128. CDBG=$(cdebug) -DUNICODE -D_UNICODE
  129. RCFLAGS = -DWIN32 -DRC_INCLUDE -DUNICODE
  130. !ELSE
  131. LINKFLAGS = $(ldebug)
  132. CDBG=$(cdebug)
  133. RCFLAGS = -DWIN32 -DRC_INCLUDE
  134. !ENDIF
  135.  
  136. # If NODEBUG is not defined then define DEBUG during Compiles.
  137. # The default is to compile with debug symbols in the binaries.
  138. !IFNDEF NODEBUG
  139. CDBG = $(CDBG) -DDEBUG
  140. RCFLAGS = $(RCFLAGS) -DDEBUG
  141. !ENDIF
  142.  
  143. # APPLIBS are libraries used by this application that are outside
  144. # of its indigenous file set and are needed during the final link.
  145. APPLIBS = rpcrt4.lib
  146.  
  147. # DLLOBJS is a macro that defines the object files for the DLL.
  148. DLLOBJS = $(TDIR)\dlldata.obj $(TDIR)\papint_p.obj $(TDIR)\papint_i.obj
  149.  
  150. # The final target.
  151. all: input tempdir output
  152.  
  153. # Check if prior builds were done.
  154. input:
  155.   @IF NOT EXIST $(REGEXE) echo !!!!!! You must build REGISTER first !!!!!!
  156.  
  157. # Make the temporary work sub-directory.
  158. tempdir:
  159.   -mkdir $(TDIR)
  160.  
  161. # Generate the proxy/stub source from the .IDL file.
  162. # PAPINT.IDL is the primary driving source for this entire proxy/stub DLL.
  163. papint.h papint_p.c papint_i.c dlldata.c: papint.idl
  164.   midl /app_config papint.idl
  165.  
  166. # The actual output products.
  167. # Register the server after it's DLL is built.
  168. output: papint.h papint_p.c papint_i.c dlldata.c $(DLL).dll
  169.   if exist $(DLL).DLL if exist $(REGEXE) $(REGEXE) $(DLL).dll
  170.   if exist papint.h copy papint.h $(IDIR)
  171.  
  172. # Compilation/Dependency rules for the .DLL source files.
  173. #
  174. $(TDIR)\papint_i.obj: papint.h
  175.   $(cc) $(cvarsdll) $(cflags) $(CDBG) -Fo$@ papint_i.c
  176.  
  177. $(TDIR)\papint_p.obj: papint.h
  178.   $(cc) $(cvarsdll) $(cflags) $(CDBG) -Fo$@ papint_p.c
  179.  
  180. # Note the compiler switch that defines REGISTER_PROXY_DLL.
  181. # This turns on conditional compilaiton of default definitions for the
  182. # DllMain, DllRegisterServer, and DllUnregisterServer functions. This
  183. # means that these functions do not need to be explicitly defined
  184. # in a separate source module.
  185. $(TDIR)\dlldata.obj: papint.h
  186.   $(cc) $(cvarsdll) $(cflags) $(CDBG) -DREGISTER_PROXY_DLL -Fo$@ dlldata.c
  187.  
  188. # Link the object and resource binaries into the target DLL binary.
  189. # Build the import LIB file so apps can link to and use this DLL.
  190. $(DLL).dll: $(DLLOBJS)
  191.     $(LINK)  @<<
  192.     $(LINKFLAGS) $(dlllflags)
  193.     -out:$@
  194.     -base:0x1C000000
  195.     -def:$*.def
  196.     -implib:$*.lib
  197.     -map:$(TDIR)\$*.map
  198.     $(DLLOBJS)
  199.     $(olelibsdll) $(APPLIBS)
  200. <<
  201.  
  202.  
  203. # Target to register the server
  204. register:
  205.   if exist $(DLL).DLL if exist $(REGEXE) $(REGEXE) $(DLL).dll
  206.  
  207. # Target to unregister the server
  208. unregister:
  209.   if exist $(DLL).DLL if exist $(REGEXE) $(REGEXE) /u $(DLL).dll
  210.  
  211. # Target to clean up binaries.
  212. clean:
  213.   -del $(DLL).exp
  214.   -del $(DLL).lib
  215.   -del papint.h
  216.   -del papint_i.c
  217.   -del papint_p.c
  218.   -del dlldata.c
  219.   -deltree /y $(TDIR)
  220.   -rmdir /s /q $(TDIR)
  221.  
  222. # Target to clean up all generated files.
  223. cleanall:
  224.   -del *.aps
  225.   -del *.bsc
  226.   -del *.dll
  227.   -del *.dsp
  228.   -del *.dsw
  229.   -del *.exe
  230.   -del *.exp
  231.   -del *.lib
  232.   -del *.mak
  233.   -del *.map
  234.   -del *.mdp
  235.   -del *.ncb
  236.   -del *.obj
  237.   -del *.opt
  238.   -del *.pch
  239.   -del *.pdb
  240.   -del *.plg
  241.   -del *.res
  242.   -del *.sbr
  243.   -del *.vcp
  244.   -del resource.h
  245.   -del papint.h
  246.   -del papint_i.c
  247.   -del papint_p.c
  248.   -del dlldata.c
  249.   -deltree /y $(TDIR)
  250.   -rmdir /s /q $(TDIR)
  251.   -deltree /y debug
  252.   -rmdir /s /q debug
  253.   -deltree /y release
  254.   -rmdir /s /q release
  255.