source: trunk/essentials/sys-apps/gawk/pc/Makefile

Last change on this file was 3076, checked in by bird, 19 years ago

gawk 3.1.5

File size: 13.7 KB
Line 
1# Makefile for gawk (GNU awk) Dec 2000
2#
3# - for GNU C (djgpp) [32bit executable for DOS]
4# - for GNU C (emx) [32bit executable for OS/2 or DOS or Windows32]
5# - for GNU C (mingw32) [Windows32 executable for Windows 9x/NT]
6# - for MS-Visual C/C++ 4.x [Windows32 executable for Windows 9x/NT]
7# - for Microsoft C 7 [16bit ececutable for DOS]
8# - for Microsoft C 6.00A [16bit executable for OS/2 or DOS]
9
10# Tested with GNU make and dmake-3.8 under OS/2 and DOS, and ndmake and
11# Microsoft nmake under DOS. Compiling with dmake under DOS may require the
12# DOS-only version of dmake (so that swapping works). nmake requires a
13# few edits in the configuration section below.
14
15default:
16 @echo "Enter $(MAK) target "
17 @echo " where 'target' is chosen from "
18 @echo " djgpp ... DOS 32-bit exe [GNU C, Delorie, v2] "
19 @echo " djgppv1 . DOS 32-bit exe [GNU C, Delorie, v1] "
20 @echo " emx ..... OS/2 32-bit exe [emx/gcc; uses emxlibc.dll] "
21 @echo " emxnt ... NT exe [emx/gcc with RSXNT] "
22 @echo " emxbnd .. OS/2 and DOS 32-bit exe [emx/gcc] "
23 @echo " mingw32 . Windows32 exe [Mingw32 GNU C] "
24 @echo " msc ..... DOS exe [Microsoft C 7 & 8 (AKA 1.52)] "
25 @echo " msc6 .... DOS exe [Microsoft C 6.00a] "
26 @echo " msc6os2 . OS/2 exe [Microsoft C 6.00a] "
27 @echo " msc6bnd . OS/2 and DOS exe [Microsoft C 6.00a] "
28 @echo " vcWin32 . Windows32 exe [Microsoft Visual C] "
29 @echo " ----------------------------------------------------- "
30 @echo " test .... Perform tests (see README_d/README.pc) "
31 @echo " install . Install gawk under $(prefix)/ "
32
33# Support dropped in 3.0
34# - for Microsoft C 5.1 [16bit executable for OS/2 or DOS]
35# @echo " msc51 DOS exe [Microsoft C 5.1] "
36# @echo " msc51bnd OS/2 and DOS exe [Microsoft C 5.1] "
37
38#======================= Configuration ==================================
39RSPFILE = gawk.rsp
40PRSPFILE = pgawk.rsp
41#
42# Choose method for passing arguments to the linker.
43#
44# If compiling under OS/2 or if make can pass long lines
45#LDRSP = $(GAWKOBJS)
46#LNKRSP = $(LDRSP)
47#
48# else if make == dmake
49# Response files for linker: dmake allows the macro expansion
50# $(macro_name:modifier_list:modifier_list:...)
51# The macro mktmp creates a temporary file for the linker.
52# The 't' modifier is for tokenization.
53#LDRSP = @$(mktmp $(<:t"\n"))
54#LNKRSP = @$(mktmp $(<:t"+\n") ) # Space before final paren req
55#
56# else use brain-dead approach (emxbnd will need 'tr').
57RSP = $(RSPFILE)
58PRSP = $(PRSPFILE)
59LDRSP = @$(RSP)
60PLDRSP = @$(PRSP)
61LNKRSP = $(LDRSP)
62#------------------------------------------------------------------------
63# Some makes do not define MAKE (and ndmake does not allow a define).
64# Define MAK to be your make command.
65#MAKE = dmake
66MAK = $(MAKE) $(MAKEFILE)
67#MAK = $(MAKE)
68#MAKEFILE = -f Makefile
69#MAK = make45 $(MAKEFILE)
70#------------------------------------------------------------------------
71# Define the base directory for the install. "make install" will install
72# in bin, lib/awk, man, and info under $(prefix)/. Most likely, you should
73# edit config.h so that $(prefix)/lib/awk appears as part of DEFPATH.
74#prefix =
75prefix = c:/gnu
76#
77# Define the install method. Method 1 is Unix-like (and requires cat,
78# cp, mkdir, sed, and sh); method 2 uses gawk and batch files.
79install = 1
80#------------------------------------------------------------------------
81# To work around command-line length problems, this makefile assumes
82# that $($X) can be expanded. If using a make (such as nmake) which
83# cannot handle such macros, define DO_LNK and DO_BIND for your target
84# as $(L<target>) and $(B<target>), resp.; e.g.,
85#DO_LNK = $(LvcWin32)
86#DO_PLNK = $(PLvcWin32)
87# and then comment the following:
88DO_LNK = $($(LNK))
89DO_BIND= $($(BIND))
90DO_PLNK = $($(PLNK))
91DO_PBIND= $($(PBIND))
92#------------------------------------------------------------------------
93# For dynamic extension support, uncomment these lines
94# pick the appropriate .def file entry for your compiler
95#DYN_FLAGS=-DDYNAMIC
96#DYN_EXP=gawk.exp
97#DYN_OBJ=dlfcn$O $(DYN_EXP)
98#DYN_MAKEXP=$(DMEvcWin32)
99#DYN_MAKEXP=$(DMEmingw32)
100#
101#========================================================================
102# End of general configuration. Some platform-specific configuration
103# notes appear below.
104
105#========================================================================
106#========================== DJGPP =======================================
107#========================================================================
108
109LDJG = $(CC) $(LF) -o gawk.exe $(LDRSP) $(LF2)
110PLDJG = $(CC) $(LF) -o pgawk.exe $(PLDRSP) $(LF2)
111BDJG = stubify -g awk.exe | stubedit awk.exe runfile=gawk
112
113djgpp:
114 $(MAK) all \
115 CC=gcc O=.o CF=-O2 \
116 LNK=LDJG PLNK=PLDJG LF=-s LF2=-lm \
117 BIND=BDJG PBIND=''
118
119djgpp-debug:
120 $(MAK) all \
121 CC=gcc O=.o CF='-O2 -g' \
122 LNK=LDJG PLNK=PLDJG LF2=-lm \
123 BIND=BDJG PBIND=''
124
125LDJGv1 = $(CC) $(LF) -o gawk $(LDRSP) $(LF2)
126#BDJGv1 = coff2exe -s /djgpp/bin/go32.exe gawk
127BDJGv1 = coff2exe gawk
128
129djgppv1:
130 $(MAK) all \
131 CC=gcc O=.o CF=-O \
132 LNK=LDJGv1 LF=-s LF2=-lm \
133 BIND=BDJGv1
134
135#========================================================================
136#========================== EMX =========================================
137#========================================================================
138
139# Link command for OS/2 versions.
140LEMX = $(CC) $(LF) -o $@ $(GAWKOBJS) gawk.def -lbsd $(LF2)
141
142# Link and bind for DOS and OS/2 versions.
143# emx-09 needs '-p' emx option here or in EMXOPT environ var.
144# The following works with 0.9a or newer
145LEMXBND = $(CC) $(LF) -o gawk $(LDRSP) gawk.def -lbsd $(LF2)
146BEMX = emxbind -bs gawk -p
147# The following works with 0.9c or newer
148#LEMXBND = $(CC) $(LF) -o a.out $(LDRSP) gawk.def -lbsd $(LF2)
149#BEMX = emxbind -bs -o $@ a.out -p
150#BEMX = emxbind -bs /emx/bin/emx.exe a.out $@ -p
151BEMXD = emxbind -b -o $@ a.out -p
152
153emx:
154 $(MAK) all \
155 "CC=gcc -Zomf" O=.obj "CF=-O -DOS2" \
156 LNK=LEMX "LF=-s -Zcrtdll -Zstack 512" RSP=
157
158emxnt:
159 $(MAK) all \
160 "CC=gcc -Zwin32 -Zcrtdll=rsxntcs" O=.o "CF=-O -DOS2" \
161 LNK=LEMX "LF=-s -Zstack 512" RSP=
162
163emxbnd:
164 $(MAK) all \
165 CC=gcc O=.o "CF=-O -DOS2 -DMSDOS" OBJ=popen.o \
166 LNK=LEMXBND \
167 BIND=BEMX "P=|tr \" \" \"\n\""
168
169emxbnd-debug:
170 $(MAK) all \
171 CC=gcc O=.o "CF=-g -DOS2 -DMSDOS" OBJ=popen.o \
172 LNK=LEMXBND \
173 BIND=BEMXD "P=|tr \" \" \"\n\""
174
175#========================================================================
176#========================== MINGW32 =====================================
177#========================================================================
178
179DMEmingw32 = dlltool -D gawk.exe -d gawkw32.def -e gawk.exp -l libgawk.a
180
181LMINGW32 = $(CC) $(LF) -o $@ $(GAWKOBJS) $(LF2)
182PLMINGW32 = $(CC) $(LF) -o $@ $(PGAWKOBJS) $(LF2)
183# The following might work around command-line length limitations:
184#LMINGW32 = $(CC) $(LF) -o $@ *.o $(LF2)
185
186mingw32:
187 $(MAK) all \
188 CC=gcc O=.o CF=-O OBJ=popen.o \
189 LNK=LMINGW32 PLNK=PLMINGW32 LF=-s RSP=
190
191#========================================================================
192#========================== MSC =========================================
193#========================================================================
194
195# stdargv, glob, and director are from Stewartson's sh. These provide
196# globbing and enhanced argument-passing. MSC setargv.obj is a
197# more limited alternative (and it will permit a bound version).
198#STDARGV = stdargv.obj glob.obj director.obj
199STDARGV = setargv.obj
200
201# Optimization and library options:
202# Os == optimize for size, Ot == optimize for speed, G2 == 286 or better
203#MSCOPT = -Gt3600 -Os -G2
204# MSC seems to be more stable with -Od than with -Ot, but then regexec.c gives
205# "code segment too large" error when compiling. Adding -G2y fixes this and
206# lets us keep the -Od.
207MSCOPT = -Gt3600 -Od -G2y
208# Alternate lib, does not use math coprocessor.
209#MSCLIB = llibca
210#MSCCL = -FPa
211# Emulator lib, uses math coprocessor if present.
212MSCLIB = llibce
213MSCCL = -FPi
214#MSCCL = -FPc
215
216# If the stack gets much smaller than 3000, the "longwrds" test fails.
217LMSC = link $(LF) $(LNKRSP) $(STDARGV)/NOE,$@,,/NOD:llibce $(MSCLIB)$(LF2)/STACK:0x2eb0,nul
218
219
220# CLMSC-linking works when building under OS/2
221CLMSC = $(CC) -o $@ $(LF) $(GAWKOBJS) $(STDARGV) $(LF2) -link /NOE/NOI/STACK:0x6f00
222
223BMSC = bind $@ /n DOSMAKEPIPE DOSCWAIT
224
225
226# Ugly hack: config.h defines __STDC__ if not defined on command-line.
227# OS/2 versions can't use -Za in getid.c. MSC7 uses stub headers in pc/
228# due to ANSI conflicts. MSC 5.1 defines __STDC__=0 regardless of ANSI flag.
229
230# dmake-3.8 runs out of memory under DOS. Request that dmake
231# swap itself out on these targets. Note that this won't have
232# any affect on the bound OS/2 and DOS version of dmake-3.8.
233
234.SWAP: msc msc-debug msc6 msc6os2 msc6bnd msc51 check
235
236msc:
237 $(MAK) all \
238 "CC=cl -nologo $(MSCCL)" O=.obj "CF=-AL -Ze -Ipc/include $(MSCOPT)" \
239 OBJ=popen.obj \
240 LNK=LMSC P=+
241Lmsc = $(LMSC) # for broken makes (nmake) which cannot expand $($X)
242Bmsc =
243
244msc-debug:
245 $(MAK) all \
246 "CC=cl $(MSCCL)" O=.obj "CF=-AL -Ze -Ipc/include -W2 -Zi -Od" \
247 OBJ=popen.obj \
248 LNK=LMSC LF2=/CO P=+
249
250msc6:
251# $(MAK) builtin.obj \
252# "CC=cl -nologo $(MSCCL)" O=.obj "CF=-AL -Za $(MSCOPT) -Od"
253 $(MAK) all \
254 "CC=cl -nologo $(MSCCL)" O=.obj "CF=-AL -Za $(MSCOPT)" \
255 OBJ=popen.obj \
256 LNK=LMSC P=+
257Lmsc6 = $(LMSC) # for broken makes (nmake) which cannot expand $($X)
258Bmsc6 =
259
260msc6os2:
261# $(MAK) builtin.obj \
262# "CC=cl -nologo $(MSCCL)" O=.obj "CF=-AL -DOS2 -UMSDOS $(MSCOPT) -Od"
263 $(MAK) all \
264 "CC=cl $(MSCCL)" O=.obj "CF=-AL -DOS2 -UMSDOS $(MSCOPT)" \
265 LNK=LMSC "LF2=p,gawk.def" P=+
266
267msc6bnd:
268# $(MAK) builtin.obj \
269# "CC=cl -nologo $(MSCCL)" O=.obj "CF=-AL -DOS2 $(MSCOPT) -Od"
270 $(MAK) all \
271 "CC=cl $(MSCCL)" O=.obj "CF=-AL -DOS2 $(MSCOPT)" \
272 OBJ=popen.obj \
273 LNK=LMSC "LF2=p,gawk.def" P=+ \
274 BIND=BMSC
275Lmsc6bnd = $(LMSC) # for broken makes (nmake) which cannot expand $($X)
276Bmsc6bnd = $(BMSC)
277
278
279# Windows '9x / NT
280DMEvcWin32 = lib /def:gawkw32.def /name:gawk.exe /out:gawk.lib
281LvcWin32 = link -nologo -subsystem:console -release -out:$@ $(LNKRSP)
282PLvcWin32 = link -nologo -subsystem:console -release -out:$@ $(PLDRSP)
283
284vcWin32:
285 $(MAK) all \
286 "CC=cl -nologo" O=.obj "CF=-o2 -DWIN32 -D__STDC__=0" \
287 OBJ=popen.obj \
288 LNK=LvcWin32
289
290
291# Support dropped in 3.0
292#msc51:
293# $(MAK) all \
294# "CC=cl $(MSCCL)" O=.obj "CF=-AL -Za -D_MSC_VER=510 $(MSCOPT)" \
295# OBJ=popen.obj \
296# LNK=LMSC P=+
297#
298#msc51bnd:
299# $(MAK) all \
300# "CC=cl -AL ($MSCCL)" O=.obj "CF=-DOS2 -D_MSC_VER=510 $(MSCOPT)" \
301# OBJ=popen.obj \
302# LNK=CLMSC "LF=-Lp -Fb" "LF2=gawk.def"
303
304#========================================================================
305
306# Define BIND for BINDless compiles, otherwise $($(BIND)) may break.
307BIND = EMPTY
308PBIND = EMPTY
309EMPTY=
310
311# bitwise operations (-DBITOPS) and non-decimal input data (-DNONDECDATA) are
312# undocumented in 3.0.3. They may be enabled in config.h, or added to CFLAGS.
313CFLAGS = $(CF) -DGAWK -I. -DHAVE_CONFIG_H $(DYN_FLAGS)
314
315# object files
316AWKOBJS1 = array$O builtin$O eval$O field$O gawkmisc$O io$O main$O
317AWKOBJS2 = ext$O msg$O node$O profile$O re$O version$O $(DYN_OBJ)
318PAWKOBJS1 = array$O builtin$O eval_p$O field$O gawkmisc$O io$O main$O
319PAWKOBJS2 = ext$O msg$O node$O profile_p$O re$O version$O $(DYN_OBJ)
320AWKOBJS = $(AWKOBJS1) $(AWKOBJS2)
321
322ALLOBJS = $(AWKOBJS) awkgram$O getid$O $(OBJ)
323
324# LIBOBJS
325# GNU and other stuff that gawk uses as library routines.
326LIBOBJS= getopt$O getopt1$O dfa$O regex$O random$O
327
328GAWKOBJS = $(ALLOBJS) $(LIBOBJS)
329PGAWKOBJS = $(PAWKOBJS1) $(PAWKOBJS2) $(LIBOBJS) awkgram$O getid$O $(OBJ)
330
331# clear out suffixes list
332# .SUFFIXES:
333.SUFFIXES: .c $O
334
335.c$O:
336 $(CC) -c $(CFLAGS) $<
337
338# rules to build gawk
339all : gawk.exe pgawk.exe
340
341gawk.exe:: $(GAWKOBJS) $(RSP)
342 $(DO_LNK)
343 $(DO_BIND)
344
345pgawk.exe:: $(PGAWKOBJS) $(PRSP)
346 $(DO_PLNK)
347 $(DO_PBIND)
348
349$(RSPFILE) : $(GAWKOBJS)
350 echo $(AWKOBJS1)$P > $@
351 echo $(AWKOBJS2)$P >> $@
352 echo awkgram$O getid$O $(OBJ) $(LIBOBJS)$P >> $@
353
354$(PRSPFILE) : $(PGAWKOBJS)
355 echo $(PAWKOBJS1)$P > $@
356 echo $(PAWKOBJS2)$P >> $@
357 echo awkgram$O getid$O $(OBJ) $(LIBOBJS)$P >> $@
358
359$(ALLOBJS) eval_p$O profile_p$O: awk.h regex.h config.h
360
361gawkmisc$O: pc/gawkmisc.pc
362
363getopt$O: getopt.h
364
365getopt1$O: getopt.h
366
367gawk.exp: gawkw32.def
368 $(DYN_MAKEXP)
369
370eval_p$O: eval.c
371
372profile_p$O: profile.c
373
374# A bug in ndmake requires the following rule
375awkgram$O: awk.h awkgram.c
376 $(CC) -c $(CFLAGS) awkgram.c
377
378awkgram.c: awkgram.y
379 bison -o $@ awkgram.y
380
381alloca$O: alloca.c
382
383
384install: install$(install)
385
386install1:
387 echo extproc sh $(prefix)/bin/igawk.cmd > igawk.cmd
388 echo shift >> igawk.cmd
389 cat pc/awklib/igawk >> igawk.cmd
390 sed "s;igawk;$(prefix)/bin/igawk;" pc/awklib/igawk.bat > igawk.bat
391 sh mkinstal.sh $(prefix)/bin
392 sh mkinstal.sh $(prefix)/lib/awk $(prefix)/man/man1 $(prefix)/info
393 cp *awk.exe igawk.bat igawk.cmd pc/awklib/igawk $(prefix)/bin
394 cp awklib/eg/lib/* pc/awklib/igawk.awk $(prefix)/lib/awk
395 cp doc/*.1 $(prefix)/man/man1
396 cp doc/gawk.info $(prefix)/info
397
398# install2 is equivalent to install1, but doesn't require cp, sed, etc.
399install2:
400 gawk -v prefix=$(prefix) -f install.awk
401
402clean:
403 rm -rf gawk pgawk *.exe gawk.map *.o *.obj core a.out $(RSPFILE) $(PRSPFILE) $(DYN_EXP)
404# cd doc && $(MAKE) clean
405# cd test && $(MAKE) clean
406# cd awklib && $(MAKE) clean
407
408awklib/eg: doc/gawk.texi
409 rm -fr awklib/eg
410 sh -c "cd awklib && ../gawk -f extract.awk ../doc/gawk.texi"
411
412check:
413 @echo "Running the tests requires several unix-like utilities. The"
414 @echo "recommendation is to copy pc/Makefile.tst to test/Makefile. Under"
415 @echo "DOS, it may be necessary to run make from the test directory."
416# The `-k' option to make should be unnecessary if using pc/Makefile.tst.
417 sh -c "cd test && $(MAK) -k AWK=../gawk.exe"
418# sh -c "cd test && $(MAK) AWK=../gawk.exe bigtest extra"
419
420test: check
421
422# for those who have the necessary tools:
423TAGS:
424 etags awk.h *.y custom.h *.c *.h
425
426tags:
427 ctags awk.h *.y custom.h *.c *.h
Note: See TracBrowser for help on using the repository browser.