home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / DMAKE35X.ZIP / MAKEFILE.MK < prev    next >
Makefile  |  1990-08-15  |  7KB  |  199 lines

  1. #             //// Makefile for DMAKE. \\\\
  2. # The target system is characterized by the following macros imported from
  3. # the environment.
  4. #
  5. #    OS          - gives the class of operating system
  6. #    OSRELEASE     - optionally gives the particular release of the OS above.
  7. #    OSENVIRONMENT - optionally gives the environment under which the above
  8. #            OS is in use.
  9. #
  10. # Valid values for the above macros are:
  11. #
  12. #    OS            - unix, msdos
  13. #       OSRELEASE     - bsd43, sysvr3, 386ix
  14. #              - tccdos, mscdos  (valid only of OS == msdos)
  15. #       OSENVIRONMENT - uw {valid for unix, bsd43 configuration only.}
  16. #            dynix (valid for unix, bsd43 configuration only.)
  17. #
  18. # See the config.mk file in the relevant subdirectories for additional
  19. # comments describing when a setting is applicable.
  20.  
  21. # First target in the makefile, do this so that targets declared in the
  22. # included files are never marked as being the first *default* target.
  23. first : all ;
  24.  
  25. # Pull in the configuration macros, from the environment.  OS is required,
  26. # OSRELEASE, and OSENVIRONMENT are optional.
  27. .IMPORT         : OS
  28. .IMPORT .IGNORE : OSRELEASE OSENVIRONMENT TMPDIR
  29.  
  30. # Define the source files
  31. SRC =\
  32.     infer.c make.c stat.c expand.c string.c hash.c dag.c dmake.c\
  33.     path.c imacs.c sysintf.c parse.c getinp.c quit.c\
  34.     basename.c dump.c macparse.c rulparse.c percent.c
  35.  
  36. # Common Include files.
  37. HDR = dmake.h extern.h struct.h vextern.h patchlvl.h version.h
  38.  
  39. # Define the TARGET we are making, and where the OBJECT files go.
  40. OBJDIR := objects
  41. TARGET  = dmake$E
  42. CFLAGS += -DHELP -I. -Icommon
  43.  
  44. # Pull in the proper configuration file, based on the value of OS.
  45. .INCLUDE : $(OS)/config.mk
  46.  
  47. # Set the .SOURCE targets so that we look for things in the right place.
  48. .SOURCE.c :^ .NULL
  49. .SOURCE.h :^ .NULL
  50. .SOURCE$O :^ $(OBJDIR)
  51. .PRECIOUS : $(HDR)
  52.  
  53. # Must come after the above INCLUDE so that it gets ALL objects.
  54. OBJECTS    := {$(SRC:b)}$O
  55.  
  56. # The main target, make sure the objects directory exists first.
  57. # LDARGS is defined in config.mk file of each OS/OSRELEASE combination.
  58. all : $(TARGET);
  59. $(TARGET) : $(OBJDIR)
  60. $(TARGET) : $(OBJECTS); $(LD) $(LDARGS)
  61.  
  62. # Other obvious targets...
  63. $(OBJDIR):;- mkdir $@
  64.  
  65. # Meta rule for making .o's from .c's (give our own so we can move object
  66. # to objects directory in a portable, compiler independent way)
  67. %$O: %.c
  68.     $(CC) -c $(CFLAGS) $<
  69.     mv $(@:f) $(OBJDIR)
  70.  
  71. # remaining dependencies should be automatically generated
  72. sysintf$O  : $(OS)/sysintf.h
  73. $(OBJECTS) : $(HDR)
  74. .SOURCE.h  : common
  75.  
  76. # Define the macros for printing the source, and pull in the
  77. # makefile portion.
  78. PRINTEXCLUDE = $(OBJDIR) $(OBJDIR).dbg test RCS control man common
  79. .INCLUDE : common/print.mk
  80.  
  81. clean:; $(RM) -rf dmake dbdmake objects*
  82.  
  83.  
  84. #--------------------------------------------------------------------------
  85. # Make the various archives for shipping the thing around.
  86. #
  87. zoo   : dmake.zoo ;
  88. shar  : dmake.shar;
  89. tar   : dmake.tar;
  90. unzoo : dmake.zoo ; zoo xO// dmake.zoo
  91. dmake.zoo  .SILENT: src-list
  92. [
  93.     echo "" >> $<
  94.     echo -n '$@ : $$(ALLSRC);@ zoo aI $$@ < ' >> $<
  95.         echo -n '<' >> $<
  96.         echo -n '+' >> $<
  97.         echo -n '$$(ALLSRC:t"\n")\n' >> $<
  98.         echo -n '+' >> $<
  99.         echo '>' >> $<
  100.     $(MAKECMD) -f $< $@
  101.     $(RM) -f $<
  102. ]
  103.  
  104. dmake.shar .SILENT : src-list-shar
  105. [
  106.     echo '$@:$$(ALLSRC) ;xshar -vc -o$@ -l40 $$(ALLSRC)' >> $<
  107.     $(MAKECMD) -f $< $@
  108.     $(RM) -f $<
  109. ]
  110.  
  111. dmake.tar .SILENT : src-list
  112. [
  113.     echo '$@:$$(ALLSRC) ;tar -cvf $@ $$(ALLSRC)' >> $<
  114.     $(MAKECMD) -f $< $@
  115.     $(RM) -f $<
  116. ]
  117.  
  118. src-list .SILENT: clean
  119.     echo 'ALLSRC = \' >$@
  120.     find . -type f -print |\
  121.     sed -e 's/RCS\///' -e 's/,v//' -e 's/$$/\\/' -e 's/^\.\// /'|\
  122.     sort -u |\
  123.     grep -v tst | grep -v $@ | grep -v LICENSE |\
  124.     grep -v '\.zoo' | grep -v '\.tar'| grep -v '\.shar' >> $@
  125.     echo ' LICENSE' >> $@
  126.  
  127. src-list-shar .SILENT: clean
  128.     echo 'ALLSRC = \' >$@
  129.     find . -print |\
  130.     sed -e 's/RCS\///' -e 's/,v//' -e 's/$$/\\/' -e 's/^\.\// /'|\
  131.     sort -ur |\
  132.     grep -v tst | grep -v $@ | grep -v LICENSE | grep -v RCS |\
  133.     grep -v '^\.\\$$' | grep -v '\.zoo' | grep -v '\.tar'|\
  134.     grep -v '\.shar' >> $@
  135.     echo ' LICENSE' >> $@
  136.  
  137.  
  138. #--------------------------------------------------------------------------
  139. # This section can be used to make the necessary script files so that dmake
  140. # can be bootstrapped.
  141. #
  142. #    dmake scripts    -- makes all the script files at once.
  143. #
  144. SH = $(@:s,-,/,:s/scripts/${SCRIPTFILE})
  145. MS = MAKESTARTUP=$(@:s,-,/,:s/scripts/startup.mk)
  146.  
  147. scripts: unix-scripts msdos-scripts
  148.  
  149. # To add a new environment for UNIX, simply create the appropriate entry
  150. # in the style below for the macro which contains the OS, OSRELEASE and
  151. # OSENVIRONMENT flags.  Then add the entry as a recipe line for the target
  152. # unix-scripts.
  153. #
  154. unix-bsd43-scripts-flags       = OS=unix OSRELEASE=bsd43  OSENVIRONMENT=
  155. unix-sysvr3-scripts-flags      = OS=unix OSRELEASE=sysvr3 OSENVIRONMENT=
  156. unix-386ix-scripts-flags       = OS=unix OSRELEASE=386ix  OSENVIRONMENT=
  157. unix-bsd43-uw-scripts-flags    = OS=unix OSRELEASE=bsd43  OSENVIRONMENT=uw
  158. unix-bsd43-dynix-scripts-flags = OS=unix OSRELEASE=bsd43  OSENVIRONMENT=dynix
  159.  
  160. unix-scripts:
  161.     $(MAKE) SCRIPTFILE=make.sh unix-bsd43-scripts
  162.     $(MAKE) SCRIPTFILE=make.sh unix-bsd43-uw-scripts
  163.     $(MAKE) SCRIPTFILE=make.sh unix-bsd43-dynix-scripts
  164.     $(MAKE) SCRIPTFILE=make.sh unix-sysvr3-scripts
  165.     $(MAKE) SCRIPTFILE=make.sh unix-386ix-scripts
  166.  
  167. unix-%-scripts:; $(MAKECMD) -nus $(MS) $($@-flags) >$(SH)
  168.  
  169. # We make the standard dos scripts here, but we have to go and fix up the
  170. # make.bat file since it contains names of temporary files for the response
  171. # files required by the linker.  We need to also construct the response file
  172. # contents.  These two functions are performed by the fix-msdos-%-scripts
  173. # meta-target.
  174. #
  175. # To add a new DOS environment just do what is described for adding a new
  176. # unix environment, and then make certain that the fix-msdos-%-scripts target
  177. # performs the correct function for the new environment.
  178. msdos-tccdos-scripts-flags = OS=msdos OSRELEASE=tccdos  OSENVIRONMENT=
  179. msdos-mscdos-scripts-flags = OS=msdos OSRELEASE=mscdos  OSENVIRONMENT=
  180.  
  181. msdos-scripts:
  182.     $(MAKE) SCRIPTFILE=make.bat msdos-tccdos-scripts
  183.     $(MAKE) SCRIPTFILE=make.bat msdos-mscdos-scripts
  184.  
  185. msdos-%-scripts:
  186.     $(MAKE) -nus $(MS) $($@-flags) >$(SH)
  187.     $(MAKE) -s $(MAKEMACROS) $(MS) $($@-flags) fix-msdos-$*-scripts
  188.  
  189. OBJRSP = $(SH:s,fix/,,:s,${SCRIPTFILE},${*:s/dos/obj/}.rsp,)
  190. LIBRSP = $(SH:s,fix/,,:s,${SCRIPTFILE},${*:s/dos/lib/}.rsp,)
  191. DOSOBJ = $(CSTARTUP) $(OBJDIR)/{$(OBJECTS)}
  192. fix-msdos-%-scripts:
  193.     sed -e 's,/tmp/mkA..[0-9]*,$(SH:s,fix/,,:d)$(*:s/dos/obj).rsp,'\
  194.         -e 's,/tmp/mkB..[0-9]*,$(SH:s,fix/,,:d)$(*:s/dos/lib).rsp,'\
  195.         -e 's,/,\\,g' <$(SH:s,fix/,,) >tmp-out
  196.     mv -f tmp-out $(SH:s,fix/,,)
  197.     mv <+$(DOSOBJ:s,/,\\,:t"+\n")\n+> $(OBJRSP)
  198.     mv <+$(LDLIBS:s,/,\\,:t"+\n")\n+> $(LIBRSP)
  199.