1 # //// Makefile for DMAKE. \\\\
2 # The target system is characterized by the following macros imported from
5 # OS - gives the class of operating system
6 # OSRELEASE - optionally specifies the particular release of the OS
7 # OSENVIRONMENT - optionally specifies the environment under which the
8 # OS and OSENVIRONMENT are running.
10 # For valid values for the above macros consult the doc/* files or type
11 # 'make' by itself to get a summary of what is available.
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.
17 #Enable keeping of state for future compiles
18 .KEEP_STATE
*:= _state.mk
21 _osenv
:= $(OSENVIRONMENT
)$/
22 _osre
:= $(OSRELEASE
)$/$(!null
,$(OSENVIRONMENT
) $(_osenv
))
26 ENVDIR
= $(OS
)$/$(!null
,$(OSRELEASE
) $(_osre
))
27 PUBLIC
= $(ENVDIR
)public.h
28 MKCONFIG
:= startup
/config.mk
30 # Define the source files
32 infer.c make.c stat.c expand.c dmstring.c hash.c dag.c dmake.c\
33 path.c imacs.c sysintf.c parse.c getinp.c quit.c state.c\
34 dmdump.c macparse.c rulparse.c percent.c function.c
36 # Common Include files.
37 HDR
= dmake.h extern.h struct.h vextern.h
39 # Define the TARGET we are making, and where the OBJECT files go.
42 CFLAGS
+= $(SWITCHAR
)I.
44 # Meta rule for making .o's from .c's (give our own so we can move object
45 # to objects directory in a portable, compiler independent way)
46 # Define it before the .INCLUDE so that different OS combinations can redefine
50 %$(CC
) $(CFLAGS
) -o
:$(OBJDIR
:s
,/,:,):$@
$<
52 %$(CC
) $(SWITCHAR
)c
$(CFLAGS
) $<
53 .IF
$(SHELL
) != $(COMSPEC
)
56 +copy
$(@
:f
) $(OBJDIR
)
61 # Pull in the proper configuration files, based on the value of OS.
62 .INCLUDE
: $(OS
)/config.mk
63 .INCLUDE
: dbug
/dbug.mk
65 # Set the .SOURCE targets so that we look for things in the right place.
68 .SOURCE
$O :^
$(OBJDIR
)
71 # Must come after the above INCLUDE so that it gets ALL objects.
72 OBJECTS
:= {$(ASRC
:b
) $(SRC
:b
)}$O
74 # The main target, make sure the objects directory exists first.
75 # LDARGS is defined in config.mk file of each OS/OSRELEASE combination.
76 all : $(TARGET
) $(MKCONFIG
);
78 $(TARGET
) : $(OBJECTS
);$(LD
) $(LDARGS
)
80 # Use this for install targets
82 $(MKCONFIG
) : template.mk
83 duplicate
:$(<:s
,/,:,) $@
85 $(MKCONFIG
) : template.mk
86 $(eq
,$(SHELL
),$(COMSPEC
) +copy cp
) $< $(eq
,$(SHELL
),$(COMSPEC
) $(@
:s
,/,\
,) $@
)
89 # how to make public.h
90 public .PHONY
: $(PUBLIC
);
91 $(PUBLIC
) .GROUP .NOSTATE
: $(SRC
)
92 genpub
-n DMAKE
$< >$@
93 # drcsclean ./rcsclean.awk $@ > /dev/null
95 # Other obvious targets...
97 $(OBJDIR
):;-newfolder
$@
99 $(OBJDIR
):;-$(eq
,$(SHELL
),$(COMSPEC
) +md mkdir
) $@
102 # remaining dependencies should be automatically generated
103 sysintf
$O : sysintf.h
104 ruletab
$O : startup.h
#khc 01NOV90 - dependency was missing
107 clean:;+- $(RM
:f
) -rf dmake
$E dbdmake
$E objects
* _
*state
*.mk startup
/config.mk
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
; groff
-man
-Tascii
$< > $@
114 compress
-b
12 dmake.p
116 uuencode dmake.Z dmake.Z
>dmake.uue
119 template.mk
".SETDIR=$(ENVDIR)" .USESHELL
: $$(TMD
)/startup
/template.mk
121 sed
-e
's/xxOSxx/$(OS)/' |\
122 sed
-e
's/xxOSRELEASExx/$(OSRELEASE)/' |\
123 sed
-e
's/xxOSENVIRONMENTxx/$(OSENVIRONMENT)/' > $@
125 #--------------------------------------------------------------------------
126 # Make the various archives for shipping the thing around.
129 $(RM
) -rf src-list dmake
131 zip .PHONY
: dmake.zip
;
132 shar .PHONY
: dmake.
shar;
133 tar .PHONY
: dmake.
tar;
138 dmake.
shar : dir-copy
139 find dmake
-type f
-print >src-list
140 xshar
-vc
-o
$@
-L40
`cat src-list`
145 dir-copy .PHONY
: src-list
147 echo
'tmp.tar .SILENT :$$(ALLSRC) ;tar -cf tmp.tar $$(ALLSRC)' >> $<
148 $(MAKECMD
) -f
$< tmp.
tar
151 tar xf ..
/tmp.
tar; chmod
-R u
+rw .
157 echo
'MAXLINELENGTH := 65536' > $@
158 echo
'ALLSRC = \' >>$@
159 find . -type f -print |\
164 grep -v tst | grep -v $@ | grep -v license |\
165 grep -v CVS | grep -v RCS |\
166 grep -v '\.zip
' | grep -v '\.
tar'| grep -v '\.
shar' >> $@
167 echo ' doc
/license.txt
' >> $@
169 #--------------------------------------------------------------------------
170 # This section can be used to make the necessary script files so that dmake
171 # can be bootstrapped.
173 # dmake scripts -- makes all the script files at once.
175 FIX-SH = $(SH:s,fix/,,)
176 FIX95-SH = $(SH:s,fix95nt/,,)
177 SH = $(SH_n:s/c40d/cd/:s/c50d/cd/:s/c51d/cd/:s/c60d/cd/)
178 SH_n = $(@:s/swp-/-/:s,-,/,:s/scripts/${SCRIPTFILE}/)
179 MS = MAKESTARTUP=startup/startup.mk
180 FS := "SHELL := $(SHELL)" "SHELLFLAGS := -ce"
181 SET-TMP:= TMPDIR:=/tmp
183 scripts: unix-scripts\
184 atari-tos-scripts apple-mac-scripts qssl-qnx-scripts\
185 msdos-scripts win95-scripts os2-scripts;
187 # To add a new environment for UNIX, simply create the appropriate entry
188 # in the style below for the macro which contains the OS, OSRELEASE and
189 # OSENVIRONMENT flags. Then add the entry as a recipe line for the target
192 unix-bsd43-scripts-flags = OS=unix OSRELEASE=bsd43 OSENVIRONMENT=
193 unix-linux-gnu-scripts-flags = OS=unix OSRELEASE=linux OSENVIRONMENT=gnu
194 unix-solaris-scripts-flags = OS=unix OSRELEASE=solaris OSENVIRONMENT=
195 unix-solaris-gnu-scripts-flags = OS=unix OSRELEASE=solaris OSENVIRONMENT=gnu
196 unix-bsd43-uw-scripts-flags= OS=unix OSRELEASE=bsd43 OSENVIRONMENT=uw
197 unix-bsd43-vf-scripts-flags= OS=unix OSRELEASE=bsd43 OSENVIRONMENT=vf
198 unix-sysvr4-scripts-flags = OS=unix OSRELEASE=sysvr4 OSENVIRONMENT=
199 unix-sysvr3-scripts-flags = OS=unix OSRELEASE=sysvr3 OSENVIRONMENT=
200 unix-sysvr3-pwd-scripts-flags = OS=unix OSRELEASE=sysvr3 OSENVIRONMENT=pwd
201 unix-xenix-scripts-flags = OS=unix OSRELEASE=xenix OSENVIRONMENT=
202 unix-xenix-pwd-scripts-flags = OS=unix OSRELEASE=xenix OSENVIRONMENT=pwd
203 unix-sysvr1-scripts-flags = OS=unix OSRELEASE=sysvr1 OSENVIRONMENT=
204 unix-386ix-scripts-flags = OS=unix OSRELEASE=386ix OSENVIRONMENT=
205 unix-coherent-ver40-scripts-flags= OS=unix OSRELEASE=coherent OSENVIRONMENT=ver40
206 unix-coherent-ver42-scripts-flags= OS=unix OSRELEASE=coherent OSENVIRONMENT=ver42
207 unix-macosx-gnu-scripts-flags = OS=unix OSRELEASE=macosx OSENVIRONMENT=gnu
208 qssl--scripts-flags = OS=qssl OSRELEASE= OSENVIRONMENT=
209 tos--scripts-flags = OS=tos OSRELEASE= OSENVIRONMENT=
210 mac--scripts-flags = OS=mac OSRELEASE= OSENVIRONMENT=
212 unix-scripts .SWAP : clean
213 $(MAKE) SCRIPTFILE=make.sh unix-bsd43-scripts
214 $(MAKE) SCRIPTFILE=make.sh unix-bsd43-uw-scripts
215 $(MAKE) SCRIPTFILE=make.sh unix-bsd43-vf-scripts
216 $(MAKE) SCRIPTFILE=make.sh unix-linux-gnu-scripts
217 $(MAKE) SCRIPTFILE=make.sh unix-solaris-scripts
218 $(MAKE) SCRIPTFILE=make.sh unix-solaris-gnu-scripts
219 $(MAKE) SCRIPTFILE=make.sh unix-sysvr4-scripts
220 $(MAKE) SCRIPTFILE=make.sh unix-sysvr3-scripts
221 $(MAKE) SCRIPTFILE=make.sh unix-sysvr3-pwd-scripts
222 $(MAKE) SCRIPTFILE=make.sh unix-xenix-scripts
223 $(MAKE) SCRIPTFILE=make.sh unix-xenix-pwd-scripts
224 $(MAKE) SCRIPTFILE=make.sh unix-sysvr1-scripts
225 $(MAKE) SCRIPTFILE=make.sh unix-386ix-scripts
226 $(MAKE) SCRIPTFILE=make.sh unix-coherent-ver40-scripts
227 $(MAKE) SCRIPTFILE=make.sh unix-coherent-ver42-scripts
228 $(MAKE) SCRIPTFILE=make.sh unix-macosx-gnu-scripts
230 atari-tos-scripts .SWAP : clean
231 $(MAKE) SCRIPTFILE=make.sh tos--scripts
233 qssl-qnx-scripts .SWAP : clean
234 $(MAKE) SCRIPTFILE=make.sh qssl--scripts
236 apple-mac-scripts .SWAP : clean
237 $(MAKE) SCRIPTFILE=make.sh mac--scripts
239 unix-%-scripts .SWAP :
240 $(MAKECMD) -su $($@-flags) .KEEP_STATE:= $(FS) public template.mk
241 $(MAKECMD) -ns .KEEP_STATE:= $(MS) $($@-flags) >/tmp/dmscr
242 dfold </tmp/dmscr >$(SH)
244 qssl-%-scripts .SWAP :
245 $(MAKECMD) -su $($@-flags) .KEEP_STATE:= $(FS) public template.mk
246 $(MAKECMD) -ns .KEEP_STATE:= $(MS) $($@-flags) >/tmp/dmscr
247 dfold </tmp/dmscr >$(SH)
249 tos-%-scripts .SWAP :
250 $(MAKECMD) -su $($@-flags) .KEEP_STATE:= $(FS) public template.mk
251 $(MAKECMD) -ns .KEEP_STATE:= $(MS) $($@-flags) >/tmp/dmscr
252 dfold </tmp/dmscr >$(SH)
254 mac-%-scripts .SWAP :
255 $(MAKECMD) -su $($@-flags) .KEEP_STATE:= $(FS) public template.mk
256 $(MAKECMD) -ns .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
257 sed 's
/ mac\
/\
(.
*\
)$$/ :mac
:\
1/' <$(SH) | dfold >/tmp/dmscr
258 /bin/mv /tmp/dmscr $(SH)
260 # We make the standard dos scripts here, but we have to go and fix up the
261 # mkXX.bat file since it contains names of temporary files for the response
262 # files required by the linker. We need to also construct the response file
263 # contents. These two functions are performed by the fix-msdos-%-scripts
266 # To add a new DOS environment just do what is described for adding a new
267 # unix environment, and then make certain that the fix-msdos-%-scripts target
268 # performs the correct function for the new environment.
273 msdos-borland-tcc20swp-scripts-flags = $(msdos-cf) OSRELEASE=borland OSENVIRONMENT=tcc20
274 msdos-borland-bcc30-scripts-flags = $(msdos-cf) OSRELEASE=borland OSENVIRONMENT=bcc30 SWAP=n
275 msdos-borland-bcc30swp-scripts-flags = $(msdos-cf) OSRELEASE=borland OSENVIRONMENT=bcc30
276 msdos-borland-bcc40swp-scripts-flags = $(msdos-cf) OSRELEASE=borland OSENVIRONMENT=bcc40
277 msdos-borland-bcc45swp-scripts-flags = $(msdos-cf) OSRELEASE=borland OSENVIRONMENT=bcc45
278 msdos-borland-bcc50swp-scripts-flags = $(msdos-cf) OSRELEASE=borland OSENVIRONMENT=bcc50
279 msdos-borland-bcc32-scripts-flags = $(msdos-cf) OSRELEASE=borland OSENVIRONMENT=bcc32 SWAP=n
280 msdos-microsft-msc51-scripts-flags= $(msdos-cf) OSRELEASE=microsft SWAP=n MSC_VER=5.1 OSENVIRONMENT=msc51
281 msdos-microsft-msc51swp-scripts-flags = $(msdos-cf) OSRELEASE=microsft MSC_VER=5.1 OSENVIRONMENT=msc51
282 msdos-microsft-msc60-scripts-flags= $(msdos-cf) OSRELEASE=microsft SWAP=n MSC_VER=6.0 OSENVIRONMENT=msc60
283 msdos-microsft-msc60swp-scripts-flags = $(msdos-cf) OSRELEASE=microsft MSC_VER=6.0 OSENVIRONMENT=msc60
284 msdos-zortech-scripts-flags= $(msdos-cf) OSRELEASE=zortech SWAP=n OSENVIRONMENT=
285 msdos-zortechswp-scripts-flags= $(msdos-cf) OSRELEASE=zortech OSENVIRONMENT=
286 win95-borland-bcc50-scripts-flags = $(win95-cf) OSRELEASE=borland OSENVIRONMENT=bcc50 SWAP=n
287 win95-microsft-vpp40-scripts-flags = $(win95-cf) OSRELEASE=microsft OSENVIRONMENT=vpp40 SWAP=n
289 winnt-borland-bcc50-scripts-flags = $(winnt-cf) OSRELEASE=borland OSENVIRONMENT=bcc50 SWAP=n
290 winnt-microsft-vpp40-scripts-flags = $(winnt-cf) OSRELEASE=microsft OSENVIRONMENT=vpp40 SWAP=n
293 msdos-scripts: clean\
294 msdos-borland-turbo-scripts\
295 msdos-borland-c++-scripts\
296 msdos-microsoft-scripts;
298 win95-scripts: clean\
299 win95-borland-c++-scripts\
300 win95-microsft-vc++-scripts;
302 winnt-scripts: clean\
303 winnt-borland-c++-scripts\
304 winnt-microsft-vc++-scripts;
306 msdos-borland-turbo-scripts .SWAP :
307 $(MAKECMD) SCRIPTFILE=mkswp.bat msdos-borland-tcc20swp-scripts
309 msdos-borland-c++-scripts .SWAP :! 30 40 45 50
310 $(MAKECMD) SCRIPTFILE=mkswp.bat msdos-borland-bcc$?swp-scripts
312 msdos-microsoft-scripts .SWAP :! 51 60
313 $(MAKECMD) SCRIPTFILE=mk.bat msdos-microsft-msc$?-scripts
314 $(MAKECMD) SCRIPTFILE=mkswp.bat msdos-microsft-msc$?swp-scripts
316 msdos-zortech-scripts .SWAP :
317 $(MAKECMD) SCRIPTFILE=mk.bat msdos-zortech-scripts
318 $(MAKECMD) SCRIPTFILE=mkswp.bat msdos-zortechswp-scripts
320 win95-borland-c++-scripts .SWAP :! 50
321 $(MAKECMD) SCRIPTFILE=mk.bat win95-borland-bcc$?-scripts
323 win95-microsft-vc++-scripts .SWAP :! 40
324 $(MAKECMD) SCRIPTFILE=mk.bat win95-microsft-vpp$?-scripts
326 winnt-borland-c++-scripts .SWAP :! 50
327 $(MAKECMD) SCRIPTFILE=mk.cmd winnt-borland-bcc$?-scripts
329 winnt-microsft-vc++-scripts .SWAP :! 40
330 $(MAKECMD) SCRIPTFILE=mk.cmd winnt-microsft-vpp$?-scripts
332 msdos-%-scripts .SWAP .SILENT:
333 $(MAKECMD) -su $($@-flags) .KEEP_STATE:= $(FS) public template.mk
334 $(MAKECMD) -ns DIRSEPSTR:=$(DIRSEPSTR) SHELL=command.com COMSPEC=command.com .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
335 $(MAKECMD) -s $(MAKEMACROS) $(MS) $($@-flags) $(SET-TMP) fix-msdos-$*-scripts
337 win95-borland-%-scripts .SWAP .SILENT:
338 $(MAKECMD) -u $($@-flags) .KEEP_STATE:= $(FS) public template.mk
339 $(MAKECMD) -n DIRSEPSTR:=$(DIRSEPSTR) SHELL=command.com COMSPEC=command.com .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
340 $(MAKECMD) -s $(MAKEMACROS) $(MS) $($@-flags) $(SET-TMP) fix-win95-borland-$*-scripts
342 win95-microsft-%-scripts .SWAP .SILENT:
343 $(MAKECMD) -su $($@-flags) .KEEP_STATE:= $(FS) public template.mk
344 $(MAKECMD) -ns DIRSEPSTR:=$(DIRSEPSTR) SHELL=command.com COMSPEC=command.com .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
345 $(MAKECMD) -s $(MAKEMACROS) $(MS) $($@-flags) $(SET-TMP) fix95nt-win95-microsft-$*-scripts
347 winnt-borland-%-scripts .SWAP .SILENT:
348 $(MAKECMD) -su $($@-flags) .KEEP_STATE:= $(FS) public template.mk
349 $(MAKECMD) -ns DIRSEPSTR:=$(DIRSEPSTR) SHELL=cmd.exe COMSPEC=cmd.exe .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
350 $(MAKECMD) -s $(MAKEMACROS) $(MS) $($@-flags) $(SET-TMP) fix-winnt-borland-$*-scripts
352 winnt-microsft-%-scripts .SWAP .SILENT:
353 $(MAKECMD) -su $($@-flags) .KEEP_STATE:= $(FS) public template.mk
354 $(MAKECMD) -ns DIRSEPSTR:=$(DIRSEPSTR) SHELL=cmd.exe COMSPEC=cmd.exe .KEEP_STATE:= $(MS) $($@-flags) >$(SH)
355 $(MAKECMD) -s $(MAKEMACROS) $(MS) $($@-flags) $(SET-TMP) fix95nt-winnt-microsft-$*-scripts
358 # We make the standard OS/2 scripts here, but we have to go and fix up the
359 # mkXX.cmd file since it contains names of temporary files for the response
360 # files required by the linker. We need to also construct the response file
361 # contents. These two functions are performed by the fix-msdos-%-scripts
364 # To add a new OS/2 environment just do what is described for adding a new
365 # unix environment, and then make certain that the fix-msdos-%-scripts target
366 # performs the correct function for the new environment.
368 os2-ibm-icc-scripts-flags= $(os2-cf) OSRELEASE=ibm OSENVIRONMENT=icc
370 os2-scripts: clean os2-ibm-scripts;
372 os2-ibm-scripts .SWAP :! icc
373 $(MAKECMD) SCRIPTFILE=mk.cmd os2-ibm-$?-scripts
375 os2-%-scripts .SWAP :
376 $(MAKECMD) -su $($@-flags) .KEEP_STATE:= $(FS) public template.mk
377 $(MAKECMD) -ns DIRSEPSTR:=$(DIRSEPSTR) SHELL=cmd.exe COMSPEC=cmd.exe .KEEP_STATE:= $(MS) SWITCHAR:=- $($@-flags) >$(SH)
378 $(MAKECMD) -s $(MAKEMACROS) $(MS) $($@-flags) $(SET-TMP) fix-os2-$*-scripts
379 cat $(SH) | sed -e 's
, -, /,g
' >tmp-out
382 # Signify NULL targets for the various Compiler versions.
383 icc 30 40 45 50 51 60 .PHONY:;
385 # Go over the created script file and make sure all the '/' that are in
386 # filenames are '\', and make sure the final link command line looks
388 MAPOBJ
= obj
$(SWAP
:s
/y
/swp
/:s
/n
//).rsp
389 MAPLIB
= lib
$(SWAP
:s
/y
/swp
/:s
/n
//).rsp
390 OBJRSP
= $(SH
:s
,fix
/,,:s
,${SCRIPTFILE},${MAPOBJ},)
391 LIBRSP
= $(SH
:s
,fix
/,,:s
,${SCRIPTFILE},${MAPLIB},)
392 OBJRSP95
= $(SH
:s
,fix95nt
/,,:s
,${SCRIPTFILE},${MAPOBJ},)
393 LIBRSP95
= $(SH
:s
,fix95nt
/,,:s
,${SCRIPTFILE},${MAPLIB},)
394 DOSOBJ
= $(CSTARTUP
) $(OBJDIR
)/{$(OBJECTS
)}
396 # Use group recipes, as SHELL has an invalid value in some platform instances.
397 fix-
%-scripts .GROUP
:
398 tac
$(FIX-SH
) >tmp-sh-r
399 tail
+3 tmp-sh-r | sed
-e
's,/,\\,g' >tmp-out
401 sed
-e
's,\\nologo,/nologo,g' >$(FIX-SH
)
403 sed
-e
's,\\tmp\\mkA[a-zA-Z0-9]*,$(OBJRSP:s,/,\\),'\
404 -e
's,\\tmp\\mkB[a-zA-Z0-9]*,$(LIBRSP:s,/,\\),'\
405 -e
's,\\tmp\\mk[0-9]*a[a-z]*,$(OBJRSP:s,/,\\),'\
406 -e
's,\\tmp\\mk[0-9]*b[a-z]*,$(LIBRSP:s,/,\\),'\
408 -e
's,\\nologo,/nologo,g'\
411 rm -f tmp-sh-r tmp-out
412 mv
<+$(DOSOBJ
:s
,/,\\,:t
"+\n")\n+> $(OBJRSP
)
413 mv
<+$(LDLIBS
:s
,/,\\,:t
"+\n")\n+> $(LIBRSP
)
415 # Use group recipes, as SHELL has an invalid value in some platform instances.
416 fix95nt-
%-scripts .GROUP
:
417 tac
$(FIX95-SH
) >tmp-sh-r
418 tail
+3 tmp-sh-r | sed
-e
's,/,\\,g' >tmp-out
420 sed
-e
's,\\nologo,/nologo,g' >$(FIX95-SH
)
422 sed
-e
's,\\tmp\\mkA[a-zA-Z0-9]*,$(OBJRSP95:s,/,\\),'\
423 -e
's,\\tmp\\mkB[a-zA-Z0-9]*,$(LIBRSP95:s,/,\\),'\
424 -e
's,\\tmp\\mk[0-9]*a[a-z]*,$(OBJRSP95:s,/,\\),'\
425 -e
's,\\tmp\\mk[0-9]*b[a-z]*,$(LIBRSP95:s,/,\\),'\
427 -e
's,\\nologo,/nologo,g'\
430 rm -f tmp-sh-r tmp-out
431 mv
<+$(DOSOBJ
:s
,/,\\,:t
"\n")\n+> $(OBJRSP95
)
432 mv
<+$(LDLIBS
:s
,/,\\,:t
"\n")\n+> $(LIBRSP95
)