1 # Makefile for GNU Awk.
3 # Copyright (C) 1986, 1988-2000 the Free Software Foundation, Inc.
5 # This file is part of GAWK, the GNU implementation of the
6 # AWK Programming Language.
8 # GAWK is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # GAWK is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
24 MAKEINFO = makeinfo --no-split
33 INSTALL_PROGRAM = @INSTALL_PROGRAM@
34 INSTALL_DATA = @INSTALL_DATA@
44 exec_prefix = @exec_prefix@
52 mandir = @mandir@/man$(manexta)
55 datadir = @datadir@/awk
56 libexecdir = @libexecdir@/awk
58 DEFPATH = ".:$(datadir)"
63 COMPFLAGS = -DGAWK -I. -I$(srcdir) $(CPPFLAGS) @DEFS@ $(CFLAGS)
66 AWKOBJS = array.o builtin.o eval.o field.o gawkmisc.o io.o main.o \
67 missing.o msg.o node.o re.o version.o
69 ALLOBJS = $(AWKOBJS) awktab.o
72 # GNU and other stuff that gawk uses as library routines.
73 LIBOBJS= getopt.o getopt1.o regex.o dfa.o random.o $(ALLOCA)
75 # source and documentation files
76 SRC = array.c builtin.c eval.c field.c gawkmisc.c io.c main.c \
77 missing.c msg.c node.c re.c version.c
79 ALLSRC= $(SRC) awktab.c
81 AWKSRC= awk.h awk.y custom.h $(ALLSRC) patchlevel.h protos.h random.h
83 LIBSRC = alloca.c dfa.c dfa.h regex.c regex.h getopt.h getopt.c getopt1.c random.c
85 COPIES = missing/system.c missing/tzset.c \
86 missing/memcmp.c missing/memcpy.c missing/memset.c \
87 missing/strncasecmp.c missing/strchr.c \
88 missing/strerror.c missing/strtod.c \
89 missing/strftime.c missing/strftime.3
91 DOCS= doc/gawk.1 doc/gawk.texi doc/texinfo.tex
93 TEXFILES= doc/gawk.aux doc/gawk.cp doc/gawk.cps doc/gawk.fn doc/gawk.fns \
94 doc/gawk.ky doc/gawk.kys doc/gawk.pg doc/gawk.pgs doc/gawk.toc \
95 doc/gawk.tp doc/gawk.tps doc/gawk.vr doc/gawk.vrs
97 MISC = NEWS COPYING FUTURES Makefile.in PROBLEMS README PORTS POSIX.STD \
98 configure configure.in acconfig.h configh.in ACKNOWLEDGMENT \
99 ChangeLog INSTALL LIMITATIONS install-sh mkinstalldirs aclocal.m4 \
102 OTHERS= doc pc atari vms README_d posix awklib
104 ALLDOC= doc/gawk.dvi $(TEXFILES) doc/gawk.info*
106 MAKEFILEIN = Makefile.in awklib/Makefile.in doc/Makefile.in test/Makefile.in
108 # Release of gawk. There can be no leading or trailing white space here!
111 # clear out suffixes list
116 $(CC) -c $(COMPFLAGS) $<
118 # rules to build gawk
119 all: gawk awklib/all doc/all
121 # stuff to make sure that configure has been run.
122 $(srcdir)/configure: configure.in aclocal.m4
123 cd $(srcdir) && autoconf
125 # autoheader might not change confh.in, so touch a stamp file
126 $(srcdir)/configh.in: stamp-h.in
127 $(srcdir)/stamp-h.in: configure.in aclocal.m4 acconfig.h
128 cd $(srcdir) && autoheader
129 date > $(srcdir)/stamp-h.in
132 stamp-h: configh.in config.status
133 $(SHELL) ./config.status
135 Makefile: $(MAKEFILEIN) config.status
136 $(SHELL) ./config.status
138 config.status: configure
139 $(SHELL) ./config.status --recheck
141 # Note: if you need something at both compile time and link time, like -pg,
142 # you will have to edit the Makefile manually to set LDFLAGS.
143 gawk: $(ALLOBJS) $(LIBOBJS) $(REOBJS)
144 $(CC) -o gawk $(CFLAGS) $(LDFLAGS) $(ALLOBJS) $(LIBOBJS) $(REOBJS) $(LIBS)
146 $(ALLOBJS): awk.h dfa.h regex.h config.h custom.h
148 $(LIBOBJS): config.h custom.h
150 # SunOS make's (at least) VPATH doesn't do subdirectories...
151 # Solaris make doesn't allow $< in the actual rule
152 gawkmisc.o: $(srcdir)/atari/gawkmisc.atr \
153 $(srcdir)/pc/gawkmisc.pc $(srcdir)/posix/gawkmisc.c \
154 $(srcdir)/vms/gawkmisc.vms
155 $(CC) -c $(COMPFLAGS) -DDEFPATH='$(DEFPATH)' $(srcdir)/gawkmisc.c
166 $(YACC) -v $(srcdir)/awk.y && \
167 if test -f y.tab.c ; then mv y.tab.c ytab.c ; else true ; fi && \
168 sed '/^extern char .malloc(), .realloc();$$/d' ytab.c >awktab.c && \
171 # VMS POSIX make won't apply the default .c.o rule to awktab.o for some reason
172 awktab.o: awktab.c awk.h
173 $(CC) -c $(COMPFLAGS) $(srcdir)/awktab.c
177 install: gawk info installdirs
178 -rm -f $(bindir)/gawk
179 fullname=gawk-$(REL).`./gawk '{print $$3}' $(srcdir)/patchlevel.h` ; \
180 $(INSTALL_PROGRAM) gawk $(bindir)/$$fullname ; \
181 (cd $(bindir); $(LN) $$fullname gawk)
184 then $(LN_S) gawk awk; \
186 cd doc && $(MAKE) install
187 cd awklib && $(MAKE) install
189 installdirs: mkinstalldirs
190 $(srcdir)/mkinstalldirs $(bindir) $(datadir) \
191 $(libdir) $(infodir) $(mandir) $(libexecdir)
194 $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
198 if [ -f awk ] && cmp awk gawk > /dev/null; then rm -f awk; fi)
199 (fullname=gawk-$(REL).`gawk '{print $$3}' $(srcdir)/patchlevel.h` ; \
201 if cmp gawk $$fullname; then rm -f gawk; fi ; \
202 rm -f $(bindir)/$$fullname)
203 cd doc && $(MAKE) uninstall
204 cd awklib && $(MAKE) uninstall
205 -rmdir $(datadir) $(libexecdir)
207 # auxiliary rules for release maintenance
209 lint -hcbax $(COMPFLAGS) $(ALLSRC)
212 cxref -c $(COMPFLAGS) $(ALLSRC) | grep -v ' /' >xref
215 : mostly clean does nothing for gawk
216 : use "make clean" to really clean things out
219 rm -rf gawk *.o core */core y.output
220 cd doc && $(MAKE) clean
221 cd test && $(MAKE) clean
222 cd awklib && $(MAKE) clean
225 rm -f Makefile *.orig *.rej */*.orig */*.rej awk.output \
226 gmon.out make.out config.h config.status config.cache \
227 config.log stamp-h tags TAGS *~
229 distclean: clean local-distclean
230 cd doc && $(MAKE) distclean
231 cd awklib && $(MAKE) distclean
232 cd test && $(MAKE) distclean
234 maintainer-clean: clean local-distclean
235 @echo "This command is intended for maintainers to use; it"
236 @echo "deletes files that may require special tools to rebuild."
238 cd doc && $(MAKE) maintainer-clean
239 cd test && $(MAKE) maintainer-clean
240 cd awklib && $(MAKE) maintainer-clean
242 clobber: maintainer-clean
250 dvi: $(srcdir)/doc/gawk.texi
251 cd doc && $(MAKE) dvi
253 info: $(srcdir)/doc/gawk.texi
254 cd doc && $(MAKE) info
257 cd doc && $(MAKE) all
260 cd awklib && $(MAKE) CFLAGS="$(CFLAGS)" all
262 dist: $(AWKSRC) $(LIBSRC) $(DOCS) $(MISC) $(COPIES) awklib/stamp-eg info distclean
264 dir=gawk-$(REL).`gawk '{print $$3}' patchlevel.h` && \
266 cp -pr $(AWKSRC) $(LIBSRC) $(MISC) $$dir && \
267 mkdir $$dir/missing && \
268 cp -p $(COPIES) $$dir/missing && \
269 for i in $(OTHERS); \
273 cp -pr test $$dir && \
274 find $$dir -type d -exec chmod 777 {} ';' && \
275 find $$dir -print | doschk && \
276 tar -cf - $$dir | gzip > $$dir.tar.gz && \
280 cd awklib ; $(MAKE) stamp-eg