| 1 |
# Makefile for gawk (GNU awk) Dec 2010 |
| 2 |
# |
| 3 |
# - for GNU C (mingw32) [Windows32 executable for Windows 9x/NT/2K/XP/7] |
| 4 |
|
| 5 |
# Tested with GNU make on Windows, OS/2 and DOS. |
| 6 |
|
| 7 |
# Copyright (C) 1989-2019, 2021 Free Software Foundation, Inc. |
| 8 |
|
| 9 |
# This Makefile is free software; the Free Software Foundation |
| 10 |
# gives unlimited permission to copy and/or distribute it, |
| 11 |
# with or without modifications, as long as this notice is preserved. |
| 12 |
|
| 13 |
# This program is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without |
| 15 |
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 16 |
# PARTICULAR PURPOSE. |
| 17 |
|
| 18 |
default: |
| 19 |
@echo "Enter $(MAK) target " |
| 20 |
@echo " where 'target' is chosen from " |
| 21 |
@echo " mingw32 . Windows32 exe [Mingw32 GNU C] " |
| 22 |
@echo " mingw32-readline . Like mingw32, but with readline " |
| 23 |
@echo " [You will need to have GNU readline library installed.] " |
| 24 |
@echo " mingw32-mpfr . Like mingw32, but with MPFR " |
| 25 |
@echo " [You will need to have GNU MPFR library installed.] " |
| 26 |
@echo " mingw32-readline-mpfr . mingw32 with readline and MPFR " |
| 27 |
@echo " ----------------------------------------------------- " |
| 28 |
@echo " test .... Perform tests (see README_d/README.pc) " |
| 29 |
@echo " install . Install gawk under $(prefix)/ " |
| 30 |
@echo " doc ..... Create documentation " |
| 31 |
|
| 32 |
# Support dropped in 4.0 |
| 33 |
# - for MS-Visual C/C++ 4.x [Windows32 executable for Windows 9x/NT] |
| 34 |
# - for Microsoft C 7 [16bit ececutable for DOS] |
| 35 |
# - for Microsoft C 6.00A [16bit executable for OS/2 or DOS] |
| 36 |
# @echo " msc ..... DOS exe [Microsoft C 7 & 8 (AKA 1.52)] " |
| 37 |
# @echo " msc6 .... DOS exe [Microsoft C 6.00a] " |
| 38 |
# @echo " msc6os2 . OS/2 exe [Microsoft C 6.00a] " |
| 39 |
# @echo " msc6bnd . OS/2 and DOS exe [Microsoft C 6.00a] " |
| 40 |
# @echo " vcWin32 . Windows32 exe [Microsoft Visual C] " |
| 41 |
# Support dropped in 3.0 |
| 42 |
# - for Microsoft C 5.1 [16bit executable for OS/2 or DOS] |
| 43 |
# @echo " msc51 DOS exe [Microsoft C 5.1] " |
| 44 |
# @echo " msc51bnd OS/2 and DOS exe [Microsoft C 5.1] " |
| 45 |
|
| 46 |
#======================= Configuration ================================== |
| 47 |
RSPFILE = gawk.rsp |
| 48 |
# |
| 49 |
# Choose method for passing arguments to the linker. |
| 50 |
# |
| 51 |
# If compiling under OS/2 or if make can pass long lines |
| 52 |
#LDRSP = $(GAWKOBJS) |
| 53 |
#LNKRSP = $(LDRSP) |
| 54 |
# |
| 55 |
# else use brain-dead approach |
| 56 |
RSP = $(RSPFILE) |
| 57 |
LDRSP = @$(RSP) |
| 58 |
LNKRSP = $(LDRSP) |
| 59 |
#------------------------------------------------------------------------ |
| 60 |
# Some makes do not define MAKE (and ndmake does not allow a define). |
| 61 |
# Define MAK to be your make command. |
| 62 |
#MAKE = dmake |
| 63 |
MAK = $(MAKE) $(MAKEFILE) |
| 64 |
#MAK = $(MAKE) |
| 65 |
#MAKEFILE = -f Makefile |
| 66 |
#MAK = make45 $(MAKEFILE) |
| 67 |
#------------------------------------------------------------------------ |
| 68 |
# Define the base directory for the install. "make install" will install |
| 69 |
# in bin, lib/awk, man, and info under $(prefix)/. Most likely, you should |
| 70 |
# edit config.h so that $(prefix)/lib/awk appears as part of DEFPATH. |
| 71 |
#prefix = |
| 72 |
prefix = c:/gnu |
| 73 |
pkgdatadir = $(prefix)/lib/awk |
| 74 |
pkgextensiondir = $(prefix)/lib/gawk |
| 75 |
DEFPATH = "\".;$(pkgdatadir);c:/lib/awk;c:/gnu/lib/awk\"" |
| 76 |
DEFLIBPATH = "\"$(pkgextensiondir)\"" |
| 77 |
LOCALEDIR="\"$(prefix)/share/locale\"" |
| 78 |
SHLIBEXT = "\"dll\"" |
| 79 |
infodir = $(prefix)/share/info |
| 80 |
mandir = $(prefix)/share/man |
| 81 |
# |
| 82 |
# Define the install method. Method 1 is Unix-like (and requires cat |
| 83 |
# and cp); method 2 uses gawk and batch files. |
| 84 |
install = 1 |
| 85 |
#------------------------------------------------------------------------ |
| 86 |
# To work around command-line length problems, this makefile assumes |
| 87 |
# that $($X) can be expanded. |
| 88 |
DO_LNK = $($(LNK)) |
| 89 |
DO_BIND= $($(BIND)) |
| 90 |
#------------------------------------------------------------------------ |
| 91 |
# To allow Make find files in the support subdirectory. |
| 92 |
VPATH = .;./support;./support/malloc |
| 93 |
#======================================================================== |
| 94 |
# End of general configuration. Some platform-specific configuration |
| 95 |
# notes appear below. |
| 96 |
|
| 97 |
#======================================================================== |
| 98 |
#========================== MINGW32 ===================================== |
| 99 |
#======================================================================== |
| 100 |
|
| 101 |
LMINGW32 = $(CC) $(LF) -o $@ $(GAWKOBJS) $(LF2) |
| 102 |
# The following might work around command-line length limitations: |
| 103 |
#LMINGW32 = $(CC) $(LF) -o $@ *.o $(LF2) |
| 104 |
|
| 105 |
mingw32: |
| 106 |
$(MAK) all \ |
| 107 |
CC=gcc O=.o CF="-D__USE_MINGW_ANSI_STDIO -O2 -gdwarf-2 -g3 -Wno-deprecated-declarations" \ |
| 108 |
OBJ=popen.o LNK=LMINGW32 LF="-gdwarf-2 -g3" \ |
| 109 |
LF2="-lws2_32" RSP= |
| 110 |
|
| 111 |
mingw32-readline: |
| 112 |
$(MAK) all \ |
| 113 |
CC=gcc O=.o \ |
| 114 |
CF="-D__USE_MINGW_ANSI_STDIO -DHAVE_LIBREADLINE -O2 -gdwarf-2 -g3 -Wno-deprecated-declarations" \ |
| 115 |
OBJ=popen.o LNK=LMINGW32 LF="-gdwarf-2 -g3" \ |
| 116 |
LF2="-lreadline -lws2_32 -Wl,--enable-auto-import" RSP= |
| 117 |
|
| 118 |
mingw32-mpfr: |
| 119 |
$(MAK) all \ |
| 120 |
CC=gcc O=.o \ |
| 121 |
CF="-D__USE_MINGW_ANSI_STDIO -DHAVE_MPFR -O2 -gdwarf-2 -g3 -Wno-deprecated-declarations" \ |
| 122 |
OBJ=popen.o LNK=LMINGW32 LF="-gdwarf-2 -g3" \ |
| 123 |
LF2="-lmpfr -lgmp -lws2_32 -Wl,--enable-auto-import" RSP= |
| 124 |
|
| 125 |
mingw32-readline-mpfr: |
| 126 |
$(MAK) all \ |
| 127 |
CC=gcc O=.o \ |
| 128 |
CF="-D__USE_MINGW_ANSI_STDIO -DHAVE_LIBREADLINE -DHAVE_MPFR -O2 -gdwarf-2 -g3 -Wno-deprecated-declarations" \ |
| 129 |
OBJ=popen.o LNK=LMINGW32 LF="-gdwarf-2 -g3" \ |
| 130 |
LF2="-lmpfr -lgmp -lreadline -lws2_32 -Wl,--enable-auto-import" RSP= |
| 131 |
|
| 132 |
# Define BIND for BINDless compiles, otherwise $($(BIND)) may break. |
| 133 |
BIND = EMPTY |
| 134 |
PBIND = EMPTY |
| 135 |
EMPTY= |
| 136 |
|
| 137 |
CFLAGS = $(CF) -DGAWK -I. -I./support -DHAVE_CONFIG_H -DDEFPATH=$(DEFPATH) -DDEFLIBPATH=$(DEFLIBPATH) -DSHLIBEXT=$(SHLIBEXT) -DLOCALEDIR=$(LOCALEDIR) |
| 138 |
|
| 139 |
# object files |
| 140 |
AWKOBJS1 = array$O builtin$O eval$O field$O floatcomp$O gawkmisc$O io$O main$O |
| 141 |
AWKOBJS2 = ext$O msg$O node$O profile$O re$O replace$O version$O symbol$O |
| 142 |
AWKOBJS3 = debug$O cint_array$O int_array$O mpfr$O str_array$O command$O |
| 143 |
AWKOBJS4 = gawkapi$O printf$O |
| 144 |
AWKOBJS = $(AWKOBJS1) $(AWKOBJS2) $(AWKOBJS3) $(AWKOBJS4) |
| 145 |
|
| 146 |
ALLOBJS = $(AWKOBJS) awkgram$O getid$O $(OBJ) |
| 147 |
|
| 148 |
# LIBOBJS |
| 149 |
# GNU and other stuff that gawk uses as library routines. |
| 150 |
DYNOBJS= dynarray_resize$O dynarray_emplace_enlarge$O dynarray_finalize$O \ |
| 151 |
dynarray_at_failure$O dynarray_resize_clear$O |
| 152 |
|
| 153 |
LIBOBJS= getopt$O getopt1$O dfa$O random$O localeinfo$O regex$O $(DYNOBJS) |
| 154 |
|
| 155 |
GAWKOBJS = $(ALLOBJS) $(LIBOBJS) |
| 156 |
|
| 157 |
# clear out suffixes list |
| 158 |
# .SUFFIXES: |
| 159 |
.SUFFIXES: .c $O |
| 160 |
|
| 161 |
.c$O: |
| 162 |
$(CC) -c $(CFLAGS) $< |
| 163 |
|
| 164 |
# rules to build gawk |
| 165 |
all : gawk.exe |
| 166 |
|
| 167 |
gawk.exe:: $(GAWKOBJS) $(RSP) |
| 168 |
$(DO_LNK) |
| 169 |
$(DO_BIND) |
| 170 |
|
| 171 |
$(RSPFILE) : $(GAWKOBJS) |
| 172 |
echo $(AWKOBJS1)$P > $@ |
| 173 |
echo $(AWKOBJS2)$P >> $@ |
| 174 |
echo $(AWKOBJS3)$P >> $@ |
| 175 |
echo $(AWKOBJS4)$P >> $@ |
| 176 |
echo awkgram$O getid$O $(OBJ) $(LIBOBJS)$P >> $@ |
| 177 |
|
| 178 |
# Notes to dependencies: |
| 179 |
# 1. The dependency on getopt.h is because unistd.h includes it, |
| 180 |
# and we have -I. on the compiler command line. unistd.h is |
| 181 |
# included by awk.h. |
| 182 |
# 2. custom.h is not mentioned because pc ports don't use it. |
| 183 |
$(ALLOBJS) $(LIBOBJS) $(DYNOBJS): \ |
| 184 |
awk.h regex.h config.h gettext.h protos.h dfa.h getopt.h nonposix.h |
| 185 |
|
| 186 |
$(DYNOBJS) regex$O: dynarray.h libc-config.h malloc/dynarray.h malloc/dynarray-skeleton.c |
| 187 |
|
| 188 |
builtin$O: floatmagic.h random.h popen.h |
| 189 |
|
| 190 |
random$O: random.h |
| 191 |
|
| 192 |
node$O: floatmagic.h |
| 193 |
|
| 194 |
command$O debug$O: cmd.h |
| 195 |
|
| 196 |
dfa$O: xalloc.h |
| 197 |
|
| 198 |
gawkmisc$O: pc/gawkmisc.pc socket.h |
| 199 |
|
| 200 |
getopt$O getopt1$O : getopt_int.h |
| 201 |
|
| 202 |
io$O: popen.h socket.h in.h |
| 203 |
|
| 204 |
regex$O: regcomp.c regexec.c regex_internal.c regex_internal.h |
| 205 |
|
| 206 |
eval$O: interpret.h |
| 207 |
|
| 208 |
localeinfo$O: localeinfo.h |
| 209 |
|
| 210 |
# A bug in ndmake requires the following rule |
| 211 |
awkgram$O: awk.h awkgram.c |
| 212 |
$(CC) -c $(CFLAGS) awkgram.c |
| 213 |
|
| 214 |
awkgram.c: awkgram.y |
| 215 |
bison -o awkgram.tmp awkgram.y |
| 216 |
sed "s/parse error/syntax error/g" < awkgram.tmp > $@ |
| 217 |
|
| 218 |
alloca$O: alloca.c |
| 219 |
|
| 220 |
popen$O: popen.h |
| 221 |
|
| 222 |
install: install$(install) |
| 223 |
-$(MAKE) -C extension install-extensions |
| 224 |
|
| 225 |
install1: |
| 226 |
-mkdir "$(prefix)" |
| 227 |
-mkdir "$(prefix)/include" |
| 228 |
-mkdir "$(prefix)/bin" |
| 229 |
-mkdir "$(prefix)/share" |
| 230 |
-mkdir "$(prefix)/share/man" |
| 231 |
-mkdir "$(prefix)/lib" |
| 232 |
-mkdir "$(pkgdatadir)" "$(prefix)/share/man/man1" "$(prefix)/share/info" |
| 233 |
-mkdir "$(prefix)/lib/gawk" |
| 234 |
cp gawk.exe $(prefix)/bin/awk.exe |
| 235 |
cp *awk.exe $(prefix)/bin |
| 236 |
cp gawkapi.h $(prefix)/include |
| 237 |
cp awklib/eg/lib/* $(pkgdatadir) |
| 238 |
cp doc/*.1 $(prefix)/share/man/man1 |
| 239 |
cp doc/*.info $(prefix)/share/info |
| 240 |
cp doc/*.png $(prefix)/share/info |
| 241 |
cp doc/*.txt $(prefix)/share/info |
| 242 |
rm -f $(prefix)/share/info/awkforai.txt |
| 243 |
|
| 244 |
# install2 is equivalent to install1, but doesn't require cp, sed, etc. |
| 245 |
install2: |
| 246 |
gawk -v prefix=$(prefix) -f install.awk |
| 247 |
|
| 248 |
install-strip: install$(install) |
| 249 |
strip "$(prefix)/bin"/*.exe |
| 250 |
-$(MAKE) -C extension $@ |
| 251 |
|
| 252 |
clean: |
| 253 |
-rm -rf gawk *.exe gawk.map *.o *.obj core a.out $(RSPFILE) $(PRSPFILE) $(DRSPFILE) $(DYN_EXP) awkgram.tmp |
| 254 |
# cd doc && $(MAKE) clean |
| 255 |
# cd test && $(MAKE) clean |
| 256 |
# cd awklib && $(MAKE) clean |
| 257 |
|
| 258 |
awklib/eg: doc/gawk.texi |
| 259 |
rm -fr awklib/eg |
| 260 |
sh -c "cd awklib && ../gawk -f extract.awk ../doc/gawk.texi" |
| 261 |
|
| 262 |
check: |
| 263 |
@echo "Running the tests requires several unix-like utilities. The" |
| 264 |
@echo "recommendation is to copy pc/Makefile.tst to test/Makefile. Under" |
| 265 |
@echo "DOS, it may be necessary to run make from the test directory." |
| 266 |
# The `-k' option to make should be unnecessary if using pc/Makefile.tst. |
| 267 |
sh -c "cd test && $(MAK) -k AWK=../gawk.exe" |
| 268 |
# sh -c "cd test && $(MAK) AWK=../gawk.exe bigtest extra" |
| 269 |
|
| 270 |
test: check |
| 271 |
|
| 272 |
# for those who have the necessary tools: |
| 273 |
TAGS: |
| 274 |
etags awk.h *.y custom.h *.c *.h |
| 275 |
|
| 276 |
tags: |
| 277 |
ctags awk.h *.y custom.h *.c *.h |
| 278 |
|
| 279 |
#======================================================================== |
| 280 |
#================================= DOC ================================== |
| 281 |
#======================================================================== |
| 282 |
|
| 283 |
DVIS = ./doc/gawk.dvi ./doc/gawkinet.dvi |
| 284 |
PDFS = ./doc/gawk.pdf ./doc/gawkinet.pdf |
| 285 |
PSS = ./doc/gawk.ps ./doc/gawkinet.ps |
| 286 |
HTMLS = ./doc/gawk.html ./doc/gawkinet.html |
| 287 |
INFOS = ./doc/gawk.info ./doc/gawkinet.info |
| 288 |
TEXINFOS = ./doc/gawk.texi ./doc/gawkinet.texi |
| 289 |
|
| 290 |
TEXI2DVI = texi2dvi --build-dir=./doc |
| 291 |
TEXI2PDF = $(TEXI2DVI) --pdf --batch |
| 292 |
DVIPS = dvips |
| 293 |
MAKEINFO = makeinfo --no-split --force |
| 294 |
MAKEINFOHTML = $(MAKEINFO) --html |
| 295 |
|
| 296 |
TROFF = groff -t -Tps -U |
| 297 |
#SEDME = sed -e "s/^level0 restore/level0 restore flashme 100 72 moveto (Copyright `date '+%m-%d-%y %T'`, FSF, Inc. (all)) show/" \ |
| 298 |
# -e "s/^\/level0 save def/\/level0 save def 30 -48 translate/" |
| 299 |
|
| 300 |
SEDME = sed "s/^\/level0 save def/\/level0 save def 30 -48 translate/" |
| 301 |
|
| 302 |
SEDME2 = sed "/%%Page: 10 10/,/0 Cg EP/d" |
| 303 |
|
| 304 |
.SUFFIXES: .dvi .html .info .pdf .ps .texi |
| 305 |
|
| 306 |
.texi.info: |
| 307 |
$(MAKEINFO) -o $@ $< |
| 308 |
|
| 309 |
.texi.html: |
| 310 |
$(MAKEINFOHTML) -o $@ $< |
| 311 |
|
| 312 |
.texi.dvi: |
| 313 |
$(TEXI2DVI) -o $@ $< |
| 314 |
|
| 315 |
.texi.pdf: |
| 316 |
$(TEXI2PDF) -o $@ $< |
| 317 |
|
| 318 |
.dvi.ps: |
| 319 |
$(DVIPS) -o $@ $< |
| 320 |
|
| 321 |
./doc/awkcard.tr: ./doc/awkcard.in |
| 322 |
cd doc |
| 323 |
sed "s,SRCDIR,.," < awkcard.in > awkcard.tr |
| 324 |
cd .. |
| 325 |
|
| 326 |
./doc/awkcard.nc: export GROFF_TMPDIR ?= . |
| 327 |
./doc/awkcard.nc: ./doc/macros ./doc/cardfonts ./doc/no.colors ./doc/awkcard.tr ./doc/ad.block ./doc/awkcard.in ./doc/setter.outline |
| 328 |
cd doc |
| 329 |
$(TROFF) ./macros ./cardfonts ./no.colors awkcard.tr | $(SEDME) | cat ./setter.outline - | $(SEDME2) > awkcard.ps |
| 330 |
cd .. |
| 331 |
|
| 332 |
./doc/awkcard.ps: ./doc/awkcard.nc |
| 333 |
cd doc |
| 334 |
touch awkcard.nc |
| 335 |
cd .. |
| 336 |
|
| 337 |
./doc/awkcard.pdf: ./doc/awkcard.ps |
| 338 |
cd doc |
| 339 |
ps2pdf ./awkcard.ps ./awkcard.pdf |
| 340 |
cd .. |
| 341 |
|
| 342 |
doc: $(INFOS) $(DVIS) $(HTMLS) $(PSS) $(PDFS) ./doc/awkcard.ps ./doc/awkcard.pdf |