home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / DMAKE37S.ZIP / DMAKE / MAKEFILE.MK < prev    next >
Encoding:
Makefile  |  1991-05-06  |  10.3 KB  |  284 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. # For valid values for the above macros consult the readme/* files or type
  11. # 'make' by itself to get a summary of what is available.
  12.  
  13. # First target in the makefile, do this so that targets declared in the
  14. # included files are never marked as being the first *default* target.
  15. first : all ;
  16.  
  17. #Enable keeping of state for future compiles
  18. .KEEP_STATE := _state.mk
  19.  
  20. # Pull in the configuration macros, from the environment.  OS is required,
  21. # OSRELEASE, and OSENVIRONMENT are optional.
  22. .IF $(OS) == $(NULL)
  23.    .IMPORT : OS
  24. .END
  25. .IMPORT .IGNORE : OSRELEASE OSENVIRONMENT TMPDIR
  26.  
  27. # Define $(PUBLIC)
  28. _osenv  := $(OSENVIRONMENT)$(DIRSEPSTR)
  29. _osre   := $(OSRELEASE)$(DIRSEPSTR)$(!null,$(OSENVIRONMENT) $(_osenv))
  30. ENVDIR   = $(OS)$(DIRSEPSTR)$(!null,$(OSRELEASE) $(_osre))
  31. PUBLIC   = $(ENVDIR)public.h
  32. STARTUP := startup.mk
  33.  
  34. # Define the source files
  35. SRC =\
  36.     infer.c make.c stat.c expand.c dmstring.c hash.c dag.c dmake.c\
  37.     path.c imacs.c sysintf.c parse.c getinp.c quit.c state.c\
  38.     basename.c dmdump.c macparse.c rulparse.c percent.c function.c
  39.  
  40. # Common Include files.
  41. HDR = dmake.h extern.h struct.h vextern.h patchlvl.h version.h
  42.  
  43. # Define the TARGET we are making, and where the OBJECT files go.
  44. OBJDIR := objects
  45. TARGET  = dmake$E
  46. CFLAGS += -I.
  47.  
  48. # Meta rule for making .o's from .c's (give our own so we can move object
  49. # to objects directory in a portable, compiler independent way)
  50. # Define it before the .INCLUDE so that different OS combinations can redefine
  51. # it.
  52. %$O : %.c
  53.     %$(CC) -c $(CFLAGS) $<
  54.     mv $(@:f) $(OBJDIR)
  55.  
  56. # Pull in the proper configuration files, based on the value of OS.
  57. .INCLUDE : $(OS)/config.mk
  58. .INCLUDE : dbug/dbug.mk
  59.  
  60. # Set the .SOURCE targets so that we look for things in the right place.
  61. .SOURCE.c :^ .NULL
  62. .SOURCE.h :^ .NULL
  63. .SOURCE$O :^ $(OBJDIR)
  64. .PRECIOUS : $(HDR)
  65.  
  66. # Must come after the above INCLUDE so that it gets ALL objects.
  67. OBJECTS    := {$(ASRC:b) $(SRC:b)}$O
  68.  
  69. # The main target, make sure the objects directory exists first.
  70. # LDARGS is defined in config.mk file of each OS/OSRELEASE combination.
  71. all : $(TARGET) $(STARTUP);
  72. $(TARGET)  : $(OBJDIR)
  73. $(TARGET)  : $(OBJECTS);$(LD) $(LDARGS)
  74. $(STARTUP) : $(ENVDIR)$(STARTUP); +$(eq,$(SHELL),$(COMSPEC) copy cp) $< $@
  75.  
  76. # how to make public.h
  77. public .PHONY : $(PUBLIC);
  78. $(PUBLIC) .SHELL .NOSTATE: $(SRC); genpub -n DMAKE $< >$@
  79.  
  80. # Other obvious targets...
  81. $(OBJDIR):;+-$(eq,$(SHELL),$(COMSPEC) md mkdir) $@
  82.  
  83. # remaining dependencies should be automatically generated
  84. sysintf$O  : $(OS)/sysintf.h
  85. ruletab$O  : $(OS)/startup.h  #khc 01NOV90 - dependency was missing
  86. $(OBJECTS) : $(HDR)
  87.  
  88. clean:;+- $(RM) -rf dmake$E dbdmake$E objects* $(STARTUP)
  89.  
  90. # Rules for making the manual pages.
  91. man .SETDIR=man : dmake.nc ;
  92. dmake.nc : dmake.p ; scriptfix < $< > $@
  93. dmake.p  : dmake.tf; typeset -man -Tdumb $< > $@
  94.  
  95. #--------------------------------------------------------------------------
  96. # Make the various archives for shipping the thing around.
  97. #
  98. archives : zoo tar shar;
  99.  
  100. zoo  .PHONY : dmake.zoo ;
  101. shar .PHONY : dmake.shar;
  102. tar  .PHONY : dmake.tar;
  103.  
  104. dmake.zoo  : dir-copy
  105. [
  106.     find dmake -type f -print | zoo aI $@
  107.     $(RM) -rf src-list dmake
  108. ]
  109.  
  110. dmake.shar : dir-copy
  111. [
  112.     find dmake -type f -print >src-list
  113.     xshar -vc -o$@ -l40 `cat src-list`
  114.     $(RM) -rf src-list dmake
  115. ]
  116.  
  117. dmake.tar : dir-copy
  118. [
  119.     tar cf $@ dmake
  120.     $(RM) -rf src-list dmake
  121. ]
  122.  
  123. dir-copy .PHONY : src-list
  124. [
  125.     echo 'tmp.tar .SILENT :$$(ALLSRC) ;tar -cf tmp.tar $$(ALLSRC)' >> $<
  126.     $(MAKECMD) -f $< tmp.tar
  127.     mkdir dmake
  128.     cd dmake
  129.     tar xf ../tmp.tar; chmod -R u+rw .
  130.     cd ..
  131.     /bin/rm -f tmp.tar
  132. ]
  133.  
  134. src-list : clean man
  135.     echo 'ALLSRC = \' >$@
  136.     find . -type f -print |\
  137.     sed -e 's/RCS\///' -e 's/,v//' -e 's/$$/\\/' -e 's/^\.\// /'|\
  138.     sort -u |\
  139.     grep -v tst | grep -v $@ | grep -v LICENSE | grep -v '*state*\.mk' |\
  140.     grep -v '\.zoo' | grep -v '\.tar'| grep -v '\.shar' >> $@
  141.     echo ' LICENSE' >> $@
  142.  
  143. #--------------------------------------------------------------------------
  144. # This section can be used to make the necessary script files so that dmake
  145. # can be bootstrapped.
  146. #
  147. #    dmake scripts    -- makes all the script files at once.
  148. #
  149. SH_n = $(@:s/swp-/-/:s,-,/,:s/scripts/${SCRIPTFILE}/)
  150. MS_n = MAKESTARTUP=$(@:s/swp-/-/:s,-,/,:s/scripts/startup.mk/)
  151. SH = $(SH_n:s/c40d/cd/:s/c50d/cd/:s/c51d/cd/:s/c60d/cd/)
  152. MS = $(MS_n:s/c40d/cd/:s/c50d/cd/:s/c51d/cd/:s/c60d/cd/)
  153. FIX-SH = $(SH:s,fix/,,)
  154.  
  155. scripts: unix-scripts atari-tos-scripts msdos-scripts os2-scripts
  156.  
  157. # To add a new environment for UNIX, simply create the appropriate entry
  158. # in the style below for the macro which contains the OS, OSRELEASE and
  159. # OSENVIRONMENT flags.  Then add the entry as a recipe line for the target
  160. # unix-scripts.
  161. #
  162. unix-bsd43-scripts-flags   = OS=unix OSRELEASE=bsd43  OSENVIRONMENT=
  163. unix-sysvr4-scripts-flags  = OS=unix OSRELEASE=sysvr4 OSENVIRONMENT=
  164. unix-sysvr3-scripts-flags  = OS=unix OSRELEASE=sysvr3 OSENVIRONMENT=
  165. unix-sysvr1-scripts-flags  = OS=unix OSRELEASE=sysvr1 OSENVIRONMENT=
  166. unix-386ix-scripts-flags   = OS=unix OSRELEASE=386ix  OSENVIRONMENT=
  167. unix-bsd43-uw-scripts-flags= OS=unix OSRELEASE=bsd43  OSENVIRONMENT=uw
  168. unix-bsd43-vf-scripts-flags= OS=unix OSRELEASE=bsd43  OSENVIRONMENT=vf
  169. tos--scripts-flags         = OS=tos  OSRELEASE=       OSENVIRONMENT=
  170.  
  171. unix-scripts .SWAP : clean
  172.     $(MAKE) SCRIPTFILE=make.sh unix-bsd43-scripts
  173.     $(MAKE) SCRIPTFILE=make.sh unix-bsd43-uw-scripts
  174.     $(MAKE) SCRIPTFILE=make.sh unix-bsd43-vf-scripts
  175.     $(MAKE) SCRIPTFILE=make.sh unix-sysvr4-scripts
  176.     $(MAKE) SCRIPTFILE=make.sh unix-sysvr3-scripts
  177.     $(MAKE) SCRIPTFILE=make.sh unix-sysvr1-scripts
  178.     $(MAKE) SCRIPTFILE=make.sh unix-386ix-scripts
  179.  
  180. unix-%-scripts .SWAP :
  181.     $(MAKECMD) -s $($@-flags) .KEEP_STATE:= public
  182.     $(MAKECMD) -ns .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
  183.  
  184. tos-%-scripts  .SWAP :
  185.     $(MAKECMD) -s $($@-flags) .KEEP_STATE:= public
  186.     $(MAKECMD) -ns .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
  187.  
  188. atari-tos-scripts .SWAP : clean
  189.     $(MAKE) SCRIPTFILE=make.sh tos--scripts
  190.  
  191. # We make the standard dos scripts here, but we have to go and fix up the
  192. # mkXX.bat file since it contains names of temporary files for the response
  193. # files required by the linker.  We need to also construct the response file
  194. # contents.  These two functions are performed by the fix-msdos-%-scripts
  195. # meta-target.
  196. #
  197. # To add a new DOS environment just do what is described for adding a new
  198. # unix environment, and then make certain that the fix-msdos-%-scripts target
  199. # performs the correct function for the new environment.
  200. msdos-cf = OS=msdos OSENVIRONMENT=
  201. msdos-tccdos-scripts-flags = $(msdos-cf) OSRELEASE=tccdos SWAP=n
  202. msdos-tccdosswp-scripts-flags = $(msdos-cf) OSRELEASE=tccdos
  203. msdos-bccdos-scripts-flags = $(msdos-cf) OSRELEASE=bccdos SWAP=n
  204. msdos-bccdosswp-scripts-flags = $(msdos-cf) OSRELEASE=bccdos
  205. msdos-msc40dos-scripts-flags= $(msdos-cf) OSRELEASE=mscdos SWAP=n MSC_VER=4.0
  206. msdos-msc40dosswp-scripts-flags = $(msdos-cf) OSRELEASE=mscdos MSC_VER=4.0
  207. msdos-msc50dos-scripts-flags= $(msdos-cf) OSRELEASE=mscdos SWAP=n MSC_VER=5.0
  208. msdos-msc50dosswp-scripts-flags = $(msdos-cf) OSRELEASE=mscdos MSC_VER=5.0
  209. msdos-msc51dos-scripts-flags= $(msdos-cf) OSRELEASE=mscdos SWAP=n MSC_VER=5.1
  210. msdos-msc51dosswp-scripts-flags = $(msdos-cf) OSRELEASE=mscdos MSC_VER=5.1
  211. msdos-msc60dos-scripts-flags= $(msdos-cf) OSRELEASE=mscdos SWAP=n MSC_VER=6.0
  212. msdos-msc60dosswp-scripts-flags = $(msdos-cf) OSRELEASE=mscdos MSC_VER=6.0
  213.  
  214. msdos-scripts: clean msdos-tcc-scripts msdos-bcc-scripts msdos-msc-scripts;
  215.  
  216. msdos-tcc-scripts .SWAP :
  217.     $(MAKE) SCRIPTFILE=mk.bat msdos-tccdos-scripts
  218.     $(MAKE) SCRIPTFILE=mkswp.bat msdos-tccdosswp-scripts
  219.  
  220. msdos-bcc-scripts .SWAP :
  221.     $(MAKE) SCRIPTFILE=mk.bat msdos-bccdos-scripts
  222.     $(MAKE) SCRIPTFILE=mkswp.bat msdos-bccdosswp-scripts
  223.  
  224. msdos-msc-scripts .SWAP :! 40 50 51 60
  225.     $(MAKE) SCRIPTFILE=mk$?.bat msdos-msc$?dos-scripts
  226.     $(MAKE) SCRIPTFILE=mk$?swp.bat msdos-msc$?dosswp-scripts
  227.  
  228. msdos-%-scripts .SWAP .SILENT:
  229.     $(MAKE) -s $($@-flags) .KEEP_STATE:= public
  230.     $(MAKE) -ns SHELL=command.com COMSPEC=command.com .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
  231.     $(MAKE) -s $(MAKEMACROS) $(MS) $($@-flags) fix-msdos-$*-scripts
  232.  
  233.  
  234. # We make the standard OS/2 scripts here, but we have to go and fix up the
  235. # mkXX.bat file since it contains names of temporary files for the response
  236. # files required by the linker.  We need to also construct the response file
  237. # contents.  These two functions are performed by the fix-msdos-%-scripts
  238. # meta-target.
  239. #
  240. # To add a new OS/2 environment just do what is described for adding a new
  241. # unix environment, and then make certain that the fix-msdos-%-scripts target
  242. # performs the correct function for the new environment.
  243. os2-cf = OS=os2 OSENVIRONMENT=
  244. os2-msc40dos-scripts-flags= $(os2-cf) OSRELEASE=mscdos SWAP=n MSC_VER=4.0
  245. os2-msc50dos-scripts-flags= $(os2-cf) OSRELEASE=mscdos SWAP=n MSC_VER=5.0
  246. os2-msc51dos-scripts-flags= $(os2-cf) OSRELEASE=mscdos SWAP=n MSC_VER=5.1
  247. os2-msc60dos-scripts-flags= $(os2-cf) OSRELEASE=mscdos SWAP=n MSC_VER=6.0
  248.  
  249. os2-scripts: clean os2-msc-scripts;
  250.  
  251. os2-msc-scripts .SWAP :! 40 50 51 60
  252.     $(MAKE) SCRIPTFILE=mk$?.cmd os2-msc$?dos-scripts
  253.  
  254. os2-%-scripts .SWAP :
  255.     $(MAKE) -s $($@-flags) .KEEP_STATE:= public
  256.     $(MAKE) -ns .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
  257.     $(MAKE) -s $(MAKEMACROS) $(MS) $($@-flags) fix-os2-$*-scripts
  258.  
  259. # Signify NULL targets for the various MSC compiler versions.
  260. 40 50 51 60:;
  261.  
  262. # Go over the created script file and make sure all the '/' that are in
  263. # filenames are '\', and make sure the final link command line looks
  264. # reasonable.
  265. MAPOBJ = obj$(SWAP:s/y/swp/:s/n//).rsp
  266. MAPLIB = lib$(SWAP:s/y/swp/:s/n//).rsp
  267. OBJRSP = $(SH:s,fix/,,:s,${SCRIPTFILE},${MAPOBJ},)
  268. LIBRSP = $(SH:s,fix/,,:s,${SCRIPTFILE},${MAPLIB},)
  269. DOSOBJ = $(CSTARTUP) $(OBJDIR)/{$(OBJECTS)}
  270. fix-%-scripts:
  271.     tail -r $(FIX-SH) >tmp-sh-r
  272.     tail +2 tmp-sh-r | sed -e 's,/,\\,g' >tmp-out
  273.     tail -r tmp-out >$(FIX-SH)
  274.     head -1 tmp-sh-r |\
  275.     sed -e 's,\\tmp\\mkA..[0-9]*,$(OBJRSP),'\
  276.         -e 's,\\tmp\\mkB..[0-9]*,$(LIBRSP),' |\
  277.     sed -e 's,$(OS)/,$(OS)\\,g'\
  278.         -e 's,$(OS)/$(OSRELEASE)/,$(OS)\\$(OSRELEASE)\\,g'\
  279.         -e 's,$(OS)\\$(OSRELEASE)/,$(OS)\\$(OSRELEASE)\\,g'\
  280.         -e 's,$(OS)/$(OSRELEASE)\\,$(OS)\\$(OSRELEASE)\\,g' >>$(FIX-SH)
  281.     rm -f tmp-sh-r tmp-out
  282.     mv <+$(DOSOBJ:s,/,\\,:t"+\n")\n+> $(OBJRSP)
  283.     mv <+$(LDLIBS:s,/,\\,:t"+\n")\n+> $(LIBRSP)
  284.