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 / marshal / makefile < prev    next >
Encoding:
Makefile  |  1997-09-09  |  9.0 KB  |  258 lines

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