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 / dllserve / makefile < prev    next >
Makefile  |  1997-09-09  |  9KB  |  251 lines

  1. #/*+=========================================================================
  2. #  File:       MAKEFILE
  3. #
  4. #  Summary:    Makefile for building the DLLSERVE.DLL executable. DLLSERVE
  5. #              is a COM Component Server DLL providing component versions
  6. #              of the COM objects in the DLLSERVE code sample: COCar,
  7. #              COUtilityCar, and COCruiseCar.  In addition a utility
  8. #              component is provided (COCarSample) to allow better
  9. #              integration of server with client as a code sample.
  10. #              DLLSERVE is meant to work in conjunction with the
  11. #              DLLCLIEN.EXE application produced in the DLLCLIEN lesson.
  12. #
  13. #              This Makefile creates a subdirectory (TEMP) for the
  14. #              .OBJ and .RES files used during the build process.  It also
  15. #              automatically registers the newly built DLL server
  16. #              as a COM server in the system Registry.  Since the build of
  17. #              this makefile does this registration you must build the
  18. #              REGISTER.EXE utility first (in sibling directory REGISTER).
  19. #
  20. #              For a comprehensive tutorial code tour of DLLSERVE's
  21. #              contents and offerings see the tutorial DLLSERVE.HTM
  22. #              file.  For more specific technical details see the comments
  23. #              dispersed throughout the DLLSERVE source code.
  24. #
  25. #              See also DLLCLIEN.HTM (in the main tutorial directory)
  26. #              for more details on the DLLCLIEN app and how it works with
  27. #              DLLSERVE.DLL itself.
  28. #
  29. #              In general, to set up your system to build and test the
  30. #              Win32 code samples in this COM Tutorial series, see the
  31. #              global TUTORIAL.HTM file for details.  This MAKEFILE is
  32. #              Microsoft NMAKE compatible and the 'debug' build can be
  33. #              achieved by simply issuing the NMAKE command in a
  34. #              command prompt window.
  35. #
  36. #  Builds:     DLLSERVE.DLL, DLLSERVE.LIB
  37. #
  38. #  Origin:     9-11-95: atrent - Editor-inheritance from the COMOBJ source.
  39. #
  40. #--Usage:-------------------------------------------------------------------
  41. #  NMAKE Options
  42. #
  43. #  Use the table below to determine the additional options for NMAKE to
  44. #  generate various application debugging, profiling and performance tuning
  45. #  information.
  46. #
  47. #  Application Information Type         Invoke NMAKE
  48. #  ----------------------------         ------------
  49. #  For No Debugging Info                nmake nodebug=1
  50. #  For Working Set Tuner Info           nmake tune=1
  51. #  For Call Attributed Profiling Info   nmake profile=1
  52. #
  53. #  Note: The three options above are mutually exclusive (you may use only
  54. #        one to compile/link the application).
  55. #
  56. #  Note: creating the environment variables NODEBUG, TUNE, and PROFILE
  57. #        is an alternate method to setting these options via the nmake
  58. #        command line.
  59. #
  60. #  Additional NMAKE Options             Invoke NMAKE
  61. #  ----------------------------         ------------
  62. #  For No ANSI NULL Compliance          nmake no_ansi=1
  63. #    (ANSI NULL is defined as PVOID 0)
  64. #  To compile for Unicode               nmake unicode=1
  65. #    (Default is ANSI)
  66. #  To clean up temporary binaries       nmake clean
  67. #  To clean up all generated files      nmake cleanall
  68. #  To register server                   nmake register
  69. #  To unregister server                 nmake unregister
  70. #
  71. #---------------------------------------------------------------------------
  72. #  This file is part of the Microsoft COM Tutorial Code Samples.
  73. #
  74. #  Copyright (C) Microsoft Corporation, 1997.  All rights reserved.
  75. #
  76. #  This source code is intended only as a supplement to Microsoft
  77. #  Development Tools and/or on-line documentation.  See these other
  78. #  materials for detailed information regarding Microsoft code samples.
  79. #
  80. #  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  81. #  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  82. #  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  83. #  PARTICULAR PURPOSE.
  84. #=========================================================================+*/
  85.  
  86. #  WIN32.MAK should be included at the front of every Win32 makefile.
  87. #
  88. #  Define APPVER = [ 3.50 | 3.51 | 4.0 ] prior to including win32.mak to get
  89. #  build time checking for version dependencies and to mark the executable
  90. #  with version information.
  91. #
  92. #  Define TARGETOS = [ WIN95 | WINNT | BOTH ] prior to including win32.mak
  93. #  to get some build time checking for platform dependencies.
  94. #
  95. APPVER=4.0
  96. TARGETOS=BOTH
  97. !include <win32.mak>
  98.  
  99. # Assign the main program name macros.
  100. DLL = dllserve
  101.  
  102. # Use a temporary sub-directory to store intermediate
  103. #   binary files like *.obj, *.res, *.map, etc.
  104. TDIR = TEMP
  105.  
  106. # Assign destination and consumer sibling directories.
  107. IDIR = ..\inc
  108. LDIR = ..\lib
  109.  
  110. REGEXE = ..\register\register.exe
  111.  
  112. # The sibling ..\INC and ..\LIB directories are added to the front of
  113. # the INCLUDE and LIB macros to inform the compiler and linker of
  114. # these application-specific locations for include and lib files.
  115. INCLUDE=$(IDIR);$(INCLUDE)
  116. LIB=$(LDIR);$(LIB)
  117.  
  118. LINK = $(link)
  119.  
  120. # If UNICODE=1 is defined then define UNICODE during Compiles.
  121. # The default is to compile with ANSI for running under both
  122. # Win95 and WinNT.
  123. !IFDEF UNICODE
  124. LINKFLAGS = $(ldebug)
  125. CDBG=$(cdebug) -DUNICODE -D_UNICODE
  126. RCFLAGS = -DWIN32 -DRC_INCLUDE -DUNICODE
  127. !ELSE
  128. LINKFLAGS = $(ldebug)
  129. CDBG=$(cdebug)
  130. RCFLAGS = -DWIN32 -DRC_INCLUDE
  131. !ENDIF
  132.  
  133. # If NODEBUG is not defined then define DEBUG during Compiles.
  134. # The default is to compile with debug symbols in the binaries.
  135. !IFNDEF NODEBUG
  136. CDBG = $(CDBG) -DDEBUG
  137. RCFLAGS = $(RCFLAGS) -DDEBUG
  138. !ENDIF
  139.  
  140. # APPLIBS are libraries used by this application that are outside
  141. # of its indigenous file set and are needed during the final link.
  142. APPLIBS = apputil.lib shell32.lib
  143.  
  144. # DLLOBJS is a macro that defines the object files for the DLL.
  145. DLLOBJS = $(TDIR)\$(DLL).obj $(TDIR)\server.obj $(TDIR)\factory.obj \
  146.   $(TDIR)\car.obj $(TDIR)\utilcar.obj $(TDIR)\crucar.obj $(TDIR)\sample.obj
  147.  
  148. # The final target.
  149. all: input tempdir output
  150.  
  151. # Check if prior builds were done.
  152. input:
  153.   @IF NOT EXIST $(REGEXE) echo !!!!!! You must build REGISTER first !!!!!!
  154.  
  155. # Make the temporary work sub-directory.
  156. tempdir:
  157.   -mkdir $(TDIR)
  158.  
  159. # The actual output products.
  160. # Register the server after it's DLL is built.
  161. output: $(DLL).dll
  162.   if exist $(DLL).DLL if exist $(REGEXE) $(REGEXE) $(DLL).dll
  163.  
  164. # Compilation/Dependency rules for the .DLL source files.
  165. #
  166. $(TDIR)\$(DLL).obj: $(DLL).cpp $(DLL).h server.h
  167.   $(cc) $(cvarsdll) $(cflags) $(CDBG) -Fo$@ $(DLL).cpp
  168.  
  169. $(TDIR)\server.obj: server.cpp server.h $(DLL).h
  170.   $(cc) $(cvarsdll) $(cflags) $(CDBG) -Fo$@ server.cpp
  171.  
  172. $(TDIR)\factory.obj: factory.cpp factory.h server.h $(DLL).h
  173.   $(cc) $(cvarsdll) $(cflags) $(CDBG) -Fo$@ factory.cpp
  174.  
  175. $(TDIR)\car.obj: car.cpp car.h server.h $(DLL).h
  176.   $(cc) $(cvarsdll) $(cflags) $(CDBG) -Fo$@ car.cpp
  177.  
  178. $(TDIR)\utilcar.obj: utilcar.cpp utilcar.h server.h $(DLL).h
  179.   $(cc) $(cvarsdll) $(cflags) $(CDBG) -Fo$@ utilcar.cpp
  180.  
  181. $(TDIR)\crucar.obj: crucar.cpp crucar.h server.h $(DLL).h
  182.   $(cc) $(cvarsdll) $(cflags) $(CDBG) -Fo$@ crucar.cpp
  183.  
  184. $(TDIR)\sample.obj: sample.cpp sample.h server.h $(DLL).h
  185.   $(cc) $(cvarsdll) $(cflags) $(CDBG) -Fo$@ sample.cpp
  186.  
  187. # Compile the DLL resources.
  188. $(TDIR)\$(DLL).res: $(DLL).rc $(DLL).ico server.h
  189.   rc $(RCFLAGS) -r -fo$@ $(DLL).rc
  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) $(TDIR)\$(DLL).res
  194.     $(LINK)  @<<
  195.     $(LINKFLAGS) $(dlllflags)
  196.     -out:$@
  197.     -base:0x1C000000
  198.     -def:$*.def
  199.     -implib:$*.lib
  200.     -map:$(TDIR)\$*.map
  201.     $(DLLOBJS)
  202.     $(TDIR)\$*.res
  203.     $(olelibsdll) $(APPLIBS)
  204. <<
  205.  
  206.  
  207. # Target to register the server
  208. register:
  209.   if exist $(DLL).DLL if exist $(REGEXE) $(REGEXE) $(DLL).dll
  210.  
  211. # Target to unregister the server
  212. unregister:
  213.   if exist $(DLL).DLL if exist $(REGEXE) $(REGEXE) /u $(DLL).dll
  214.  
  215. # Target to clean up binaries.
  216. clean:
  217.   -del $(DLL).exp
  218.   -del $(DLL).lib
  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.   -deltree /y $(TDIR)
  246.   -rmdir /s /q $(TDIR)
  247.   -deltree /y debug
  248.   -rmdir /s /q debug
  249.   -deltree /y release
  250.   -rmdir /s /q release
  251.