home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dmake40.zip / makefile.mk < prev    next >
Makefile  |  1994-10-23  |  13KB  |  346 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.     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. .IF $(SHELL) == mpw
  54.     %$(CC) $(CFLAGS) -o :$(OBJDIR:s,/,:,):$@ $<
  55. .ELSE
  56.     %$(CC) -c $(CFLAGS) $<
  57. .IF $(SHELL) != $(COMSPEC)
  58.     mv $(@:f) $(OBJDIR)
  59. .ELSE
  60.     +copy $(@:f) $(OBJDIR)
  61.     +del $(@:f)
  62. .ENDIF
  63. .ENDIF
  64.  
  65. # Pull in the proper configuration files, based on the value of OS.
  66. .INCLUDE : $(OS)/config.mk
  67. .INCLUDE : dbug/dbug.mk
  68.  
  69. # Set the .SOURCE targets so that we look for things in the right place.
  70. .SOURCE.c :^ .NULL
  71. .SOURCE.h :^ .NULL
  72. .SOURCE$O :^ $(OBJDIR)
  73. .PRECIOUS : $(HDR)
  74.  
  75. # Must come after the above INCLUDE so that it gets ALL objects.
  76. OBJECTS    := {$(ASRC:b) $(SRC:b)}$O
  77.  
  78. # The main target, make sure the objects directory exists first.
  79. # LDARGS is defined in config.mk file of each OS/OSRELEASE combination.
  80. all : $(TARGET) $(STARTUP);
  81. $(TARGET)  : $(OBJDIR)
  82. $(TARGET)  : $(OBJECTS);$(LD) $(LDARGS)
  83. .IF $(SHELL) == mpw
  84. $(STARTUP) : $(ENVDIR)$(STARTUP); duplicate :$(<:s,/,:,) $@
  85. .ELSE
  86. $(STARTUP) : $(ENVDIR)$(STARTUP); $(eq,$(SHELL),$(COMSPEC) +copy cp) $< $@
  87. .ENDIF
  88.  
  89. # how to make public.h
  90. public .PHONY : $(PUBLIC);
  91. $(PUBLIC) .SHELL .NOSTATE: $(SRC)
  92.     genpub -n DMAKE $< >$@
  93.     rcsclean $@ > /dev/null
  94.  
  95. # Other obvious targets...
  96. .IF $(SHELL) == mpw
  97. $(OBJDIR):;-newfolder $@
  98. .ELSE
  99. $(OBJDIR):;-$(eq,$(SHELL),$(COMSPEC) +md mkdir) $@
  100. .ENDIF
  101.  
  102. # remaining dependencies should be automatically generated
  103. sysintf$O  : $(OS)/sysintf.h
  104. ruletab$O  : $(OS)/startup.h  #khc 01NOV90 - dependency was missing
  105. $(OBJECTS) : $(HDR)
  106.  
  107. clean:;+- $(RM) -rf dmake$E dbdmake$E objects* $(STARTUP) _*state*.mk
  108.  
  109. # Rules for making the manual pages.
  110. man .SETDIR=man : dmake.nc dmake.uue ;
  111. dmake.nc : dmake.p ; scriptfix < $< > $@
  112. dmake.p  : dmake.tf; typeset -man -Tdumb $< > $@
  113. dmake.uue : dmake.p
  114.     compress -b 12 dmake.p
  115.     mv dmake.p.Z dmake.Z
  116.     uuencode dmake.Z dmake.Z >dmake.uue
  117.     /bin/rm -f dmake.Z
  118.  
  119. #--------------------------------------------------------------------------
  120. # Make the various archives for shipping the thing around.
  121. #
  122. archives : zip tar shar
  123.     $(RM) -rf src-list dmake
  124.  
  125. zip  .PHONY : dmake.zip ;
  126. shar .PHONY : dmake.shar;
  127. tar  .PHONY : dmake.tar;
  128.  
  129. dmake.zip  : dir-copy
  130.     zip -r $(@:b) $(@:b)
  131.  
  132. dmake.shar : dir-copy
  133.     find dmake -type f -print >src-list
  134.     xshar -vc -o$@ -L40 `cat src-list`
  135.  
  136. dmake.tar : dir-copy
  137.     tar cf $@ dmake
  138.  
  139. dir-copy .PHONY : src-list
  140. [
  141.     echo 'tmp.tar .SILENT :$$(ALLSRC) ;tar -cf tmp.tar $$(ALLSRC)' >> $<
  142.     $(MAKECMD) -f $< tmp.tar
  143.     mkdir dmake
  144.     cd dmake
  145.     tar xf ../tmp.tar; chmod -R u+rw .
  146.     cd ..
  147.     /bin/rm -f tmp.tar
  148. ]
  149.  
  150. src-list : clean man
  151.     echo 'ALLSRC = \' >$@
  152.     find . -type f -print |\
  153.     sed -e 's/RCS\///' -e 's/,v//' -e 's/$$/\\/' -e 's/^\.\// /'|\
  154.     sort -u |\
  155.     grep -v tst | grep -v $@ | grep -v license |\
  156.     grep -v '\.zip' | grep -v '\.tar'| grep -v '\.shar' >> $@
  157.     echo ' license' >> $@
  158.  
  159. #--------------------------------------------------------------------------
  160. # This section can be used to make the necessary script files so that dmake
  161. # can be bootstrapped.
  162. #
  163. #    dmake scripts    -- makes all the script files at once.
  164. #
  165. SH_n = $(@:s/swp-/-/:s,-,/,:s/scripts/${SCRIPTFILE}/)
  166. MS_n = MAKESTARTUP=$(@:s/swp-/-/:s,-,/,:s/scripts/startup.mk/)
  167. SH = $(SH_n:s/c40d/cd/:s/c50d/cd/:s/c51d/cd/:s/c60d/cd/:s/ibmc2/ibm/)
  168. MS = $(MS_n:s/c40d/cd/:s/c50d/cd/:s/c51d/cd/:s/c60d/cd/:s/ibmc2/ibm/)
  169. FIX-SH = $(SH:s,fix/,,)
  170.  
  171. scripts: unix-scripts atari-tos-scripts msdos-scripts os2-scripts\
  172.      apple-mac-scripts quantum-qnx-scripts;
  173.  
  174. # To add a new environment for UNIX, simply create the appropriate entry
  175. # in the style below for the macro which contains the OS, OSRELEASE and
  176. # OSENVIRONMENT flags.  Then add the entry as a recipe line for the target
  177. # unix-scripts.
  178. #
  179. unix-bsd43-scripts-flags   = OS=unix OSRELEASE=bsd43  OSENVIRONMENT=
  180. unix-solaris-scripts-flags = OS=unix OSRELEASE=solaris OSENVIRONMENT=
  181. unix-solaris-gcc-scripts-flags = OS=unix OSRELEASE=solaris OSENVIRONMENT=gcc
  182. unix-bsd43-uw-scripts-flags= OS=unix OSRELEASE=bsd43  OSENVIRONMENT=uw
  183. unix-bsd43-vf-scripts-flags= OS=unix OSRELEASE=bsd43  OSENVIRONMENT=vf
  184. unix-sysvr4-scripts-flags  = OS=unix OSRELEASE=sysvr4 OSENVIRONMENT=
  185. unix-sysvr3-scripts-flags  = OS=unix OSRELEASE=sysvr3 OSENVIRONMENT=
  186. unix-sysvr3-pwd-scripts-flags  = OS=unix OSRELEASE=sysvr3 OSENVIRONMENT=pwd
  187. unix-xenix-scripts-flags  = OS=unix OSRELEASE=xenix OSENVIRONMENT=
  188. unix-xenix-pwd-scripts-flags  = OS=unix OSRELEASE=xenix OSENVIRONMENT=pwd
  189. unix-sysvr1-scripts-flags  = OS=unix OSRELEASE=sysvr1 OSENVIRONMENT=
  190. unix-386ix-scripts-flags   = OS=unix OSRELEASE=386ix  OSENVIRONMENT=
  191. unix-coherent-scripts-flags= OS=unix OSRELEASE=coherent OSENVIRONMENT=
  192. qnx--scripts-flags         = OS=qnx  OSRELEASE=       OSENVIRONMENT=
  193. tos--scripts-flags         = OS=tos  OSRELEASE=       OSENVIRONMENT=
  194. mac--scripts-flags         = OS=mac  OSRELEASE=       OSENVIRONMENT=
  195.  
  196. unix-scripts .SWAP : clean
  197.     $(MAKE) SCRIPTFILE=make.sh unix-bsd43-scripts
  198.     $(MAKE) SCRIPTFILE=make.sh unix-solaris-scripts
  199.     $(MAKE) SCRIPTFILE=make.sh unix-solaris-gcc-scripts
  200.     $(MAKE) SCRIPTFILE=make.sh unix-bsd43-uw-scripts
  201.     $(MAKE) SCRIPTFILE=make.sh unix-bsd43-vf-scripts
  202.     $(MAKE) SCRIPTFILE=make.sh unix-sysvr4-scripts
  203.     $(MAKE) SCRIPTFILE=make.sh unix-sysvr3-scripts
  204.     $(MAKE) SCRIPTFILE=make.sh unix-sysvr3-pwd-scripts
  205.     $(MAKE) SCRIPTFILE=make.sh unix-xenix-scripts
  206.     $(MAKE) SCRIPTFILE=make.sh unix-xenix-pwd-scripts
  207.     $(MAKE) SCRIPTFILE=make.sh unix-sysvr1-scripts
  208.     $(MAKE) SCRIPTFILE=make.sh unix-386ix-scripts
  209.     $(MAKE) SCRIPTFILE=make.sh unix-coherent-scripts
  210.  
  211. unix-%-scripts .SWAP :
  212.     $(MAKECMD) -s $($@-flags) .KEEP_STATE:= public
  213.     $(MAKECMD) -ns .KEEP_STATE:= $(MS) $($@-flags) >/tmp/dmscr
  214.     dfold </tmp/dmscr >$(SH)
  215.  
  216. qnx-%-scripts .SWAP :
  217.     $(MAKECMD) -s $($@-flags) .KEEP_STATE:= public
  218.     $(MAKECMD) -ns .KEEP_STATE:= $(MS) $($@-flags) >/tmp/dmscr
  219.     dfold </tmp/dmscr >$(SH)
  220.  
  221. tos-%-scripts .SWAP :
  222.     $(MAKECMD) -s $($@-flags) .KEEP_STATE:= public
  223.     $(MAKECMD) -ns .KEEP_STATE:= $(MS) $($@-flags) >/tmp/dmscr
  224.     dfold </tmp/dmscr >$(SH)
  225.  
  226. atari-tos-scripts .SWAP : clean
  227.     $(MAKE) SCRIPTFILE=make.sh tos--scripts
  228.  
  229. quantum-qnx-scripts .SWAP : clean
  230.     $(MAKE) SCRIPTFILE=make.sh qnx--scripts
  231.  
  232. apple-mac-scripts .SWAP : clean
  233.     $(MAKE) SCRIPTFILE=make.sh mac--scripts
  234.  
  235. mac-%-scripts .SWAP :
  236.     $(MAKECMD) -s $($@-flags) .KEEP_STATE:= public
  237.     $(MAKECMD) -ns .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
  238.     sed 's/ mac\/\(.*\)$$/ :mac:\1/' <$(SH) | dfold >/tmp/dmscr
  239.     /bin/mv /tmp/dmscr $(SH)
  240.  
  241. # We make the standard dos scripts here, but we have to go and fix up the
  242. # mkXX.bat file since it contains names of temporary files for the response
  243. # files required by the linker.  We need to also construct the response file
  244. # contents.  These two functions are performed by the fix-msdos-%-scripts
  245. # meta-target.
  246. #
  247. # To add a new DOS environment just do what is described for adding a new
  248. # unix environment, and then make certain that the fix-msdos-%-scripts target
  249. # performs the correct function for the new environment.
  250. msdos-cf = OS=msdos OSENVIRONMENT=
  251. msdos-tccdos-scripts-flags = $(msdos-cf) OSRELEASE=tccdos SWAP=n
  252. msdos-tccdosswp-scripts-flags = $(msdos-cf) OSRELEASE=tccdos
  253. msdos-bccdos-scripts-flags = $(msdos-cf) OSRELEASE=bccdos SWAP=n
  254. msdos-bccdosswp-scripts-flags = $(msdos-cf) OSRELEASE=bccdos
  255. msdos-msc40dos-scripts-flags= $(msdos-cf) OSRELEASE=mscdos SWAP=n MSC_VER=4.0
  256. msdos-msc40dosswp-scripts-flags = $(msdos-cf) OSRELEASE=mscdos MSC_VER=4.0
  257. msdos-msc50dos-scripts-flags= $(msdos-cf) OSRELEASE=mscdos SWAP=n MSC_VER=5.0
  258. msdos-msc50dosswp-scripts-flags = $(msdos-cf) OSRELEASE=mscdos MSC_VER=5.0
  259. msdos-msc51dos-scripts-flags= $(msdos-cf) OSRELEASE=mscdos SWAP=n MSC_VER=5.1
  260. msdos-msc51dosswp-scripts-flags = $(msdos-cf) OSRELEASE=mscdos MSC_VER=5.1
  261. msdos-msc60dos-scripts-flags= $(msdos-cf) OSRELEASE=mscdos SWAP=n MSC_VER=6.0
  262. msdos-msc60dosswp-scripts-flags = $(msdos-cf) OSRELEASE=mscdos MSC_VER=6.0
  263. msdos-ztcdos-scripts-flags= $(msdos-cf) OSRELEASE=ztcdos SWAP=n
  264. msdos-ztcdosswp-scripts-flags= $(msdos-cf) OSRELEASE=ztcdos
  265.  
  266. msdos-scripts: clean\
  267.            msdos-tcc-scripts msdos-bcc-scripts\
  268.            msdos-msc-scripts msdos-ztc-scripts;
  269.  
  270. msdos-tcc-scripts .SWAP :
  271.     $(MAKE) SCRIPTFILE=mk.bat msdos-tccdos-scripts
  272.     $(MAKE) SCRIPTFILE=mkswp.bat msdos-tccdosswp-scripts
  273.  
  274. msdos-bcc-scripts .SWAP :
  275.     $(MAKE) SCRIPTFILE=mk.bat msdos-bccdos-scripts
  276.     $(MAKE) SCRIPTFILE=mkswp.bat msdos-bccdosswp-scripts
  277.  
  278. msdos-msc-scripts .SWAP :! 40 50 51 60
  279.     $(MAKE) SCRIPTFILE=mk$?.bat msdos-msc$?dos-scripts
  280.     $(MAKE) SCRIPTFILE=mk$?swp.bat msdos-msc$?dosswp-scripts
  281.  
  282. msdos-ztc-scripts .SWAP :
  283.     $(MAKE) SCRIPTFILE=mk.bat msdos-ztcdos-scripts
  284.     $(MAKE) SCRIPTFILE=mkswp.bat msdos-ztcdosswp-scripts
  285.  
  286. msdos-%-scripts .SWAP .SILENT:
  287.     $(MAKE) -s $($@-flags) .KEEP_STATE:= public
  288.     $(MAKE) -ns DIRSEPSTR:=$(DIRSEPSTR) SHELL=command.com COMSPEC=command.com .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
  289.     $(MAKE) -s $(MAKEMACROS) $(MS) $($@-flags) fix-msdos-$*-scripts
  290.  
  291.  
  292. # We make the standard OS/2 scripts here, but we have to go and fix up the
  293. # mkXX.cmd file since it contains names of temporary files for the response
  294. # files required by the linker.  We need to also construct the response file
  295. # contents.  These two functions are performed by the fix-msdos-%-scripts
  296. # meta-target.
  297. #
  298. # To add a new OS/2 environment just do what is described for adding a new
  299. # unix environment, and then make certain that the fix-msdos-%-scripts target
  300. # performs the correct function for the new environment.
  301. os2-cf = OS=os2 OSENVIRONMENT=
  302. os2-msc40dos-scripts-flags= $(os2-cf) OSRELEASE=mscdos SWAP=n MSC_VER=4.0
  303. os2-msc50dos-scripts-flags= $(os2-cf) OSRELEASE=mscdos SWAP=n MSC_VER=5.0
  304. os2-msc51dos-scripts-flags= $(os2-cf) OSRELEASE=mscdos SWAP=n MSC_VER=5.1
  305. os2-msc60dos-scripts-flags= $(os2-cf) OSRELEASE=mscdos SWAP=n MSC_VER=6.0
  306. os2-ibmc2-scripts-flags=    $(os2-cf) OSRELEASE=ibm SWAP=n MSC_VER=5.1
  307.  
  308. os2-scripts: clean os2-msc-scripts os2-ibm-scripts;
  309.  
  310. os2-msc-scripts .SWAP :! 40 50 51 60
  311.     $(MAKE) SCRIPTFILE=mk$?.cmd os2-msc$?dos-scripts
  312.  
  313. os2-ibm-scripts .SWAP :! c2
  314.     $(MAKE) SCRIPTFILE=mk$?.cmd os2-ibm$?-scripts
  315.  
  316. os2-%-scripts .SWAP :
  317.     $(MAKE) -s $($@-flags) .KEEP_STATE:= public
  318.     $(MAKE) -ns DIRSEPSTR:=$(DIRSEPSTR) SHELL=cmd.exe COMSPEC=cmd.exe .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
  319.     $(MAKE) -s $(MAKEMACROS) $(MS) $($@-flags) fix-os2-$*-scripts
  320.  
  321. # Signify NULL targets for the various MSC compiler versions.
  322. c2 40 50 51 60:;
  323.  
  324. # Go over the created script file and make sure all the '/' that are in
  325. # filenames are '\', and make sure the final link command line looks
  326. # reasonable.
  327. MAPOBJ = obj$(SWAP:s/y/swp/:s/n//).rsp
  328. MAPLIB = lib$(SWAP:s/y/swp/:s/n//).rsp
  329. OBJRSP = $(SH:s,fix/,,:s,${SCRIPTFILE},${MAPOBJ},)
  330. LIBRSP = $(SH:s,fix/,,:s,${SCRIPTFILE},${MAPLIB},)
  331. DOSOBJ = $(CSTARTUP) $(OBJDIR)/{$(OBJECTS)}
  332. fix-%-scripts:
  333.     tail -r $(FIX-SH) >tmp-sh-r
  334.     tail +3 tmp-sh-r | sed -e 's,/,\\,g' >tmp-out
  335.     tail -r tmp-out >$(FIX-SH)
  336.     head -2 tmp-sh-r |\
  337.     sed -e 's,\\tmp\\mkA[a-zA-Z0-9]*,$(OBJRSP),'\
  338.         -e 's,\\tmp\\mkB[a-zA-Z0-9]*,$(LIBRSP),' |\
  339.     sed -e 's,$(OS)/,$(OS)\\,g'\
  340.         -e 's,$(OS)/$(OSRELEASE)/,$(OS)\\$(OSRELEASE)\\,g'\
  341.         -e 's,$(OS)\\$(OSRELEASE)/,$(OS)\\$(OSRELEASE)\\,g'\
  342.         -e 's,$(OS)/$(OSRELEASE)\\,$(OS)\\$(OSRELEASE)\\,g' >>$(FIX-SH)
  343.     rm -f tmp-sh-r tmp-out
  344.     mv <+$(DOSOBJ:s,/,\\,:t"+\n")\n+> $(OBJRSP)
  345.     mv <+$(LDLIBS:s,/,\\,:t"+\n")\n+> $(LIBRSP)
  346.