Introduced -devel and -extras subpackages for gawk
[platform/upstream/gawk.git] / Makefile.am
1 #
2 # Makefile.am --- automake input file for gawk
3 #
4 # Copyright (C) 2000-2011 the Free Software Foundation, Inc.
5 #
6 # This file is part of GAWK, the GNU implementation of the
7 # AWK Programming Language.
8 #
9 # GAWK is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # GAWK is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
22 #
23
24 ## process this file with automake to produce Makefile.in
25
26 # This variable insures that aclocal runs
27 # correctly after changing configure.ac
28 ACLOCAL_AMFLAGS = -I m4
29
30 # This insures that make flags get passed down to child makes.
31 AM_MAKEFLAGS = 'CFLAGS=$(CFLAGS)' 'LDFLAGS=$(LDFLAGS)'
32
33 # Stuff to include in the dist that doesn't need it's own
34 # Makefile.am files
35 EXTRA_DIST = \
36         ChangeLog.0 \
37         COPYING \
38         FUTURES \
39         INSTALL \
40         LIMITATIONS \
41         NEWS \
42         NEWS.0 \
43         POSIX.STD \
44         PROBLEMS \
45         README_d \
46         bisonfix.awk \
47         config.guess \
48         config.rpath  \
49         config.sub \
50         depcomp \
51         extension \
52         m4 \
53         missing \
54         missing_d \
55         po/README \
56         pc \
57         posix \
58         regcomp.c \
59         regex_internal.c \
60         regex_internal.h \
61         regexec.c \
62         version.in \
63         vms \
64         ylwrap
65
66 # It's OK for the generated file `version.c' not to be removed by
67 # "make distclean".
68 distcleancheck_listfiles = \
69   find . -type f -print | grep -v '^\./version\.c$$'
70
71 # The order to do things in.
72 # Build explicitly in "." in order to build gawk first, so
73 # that `make check' without a prior `make' works.
74 SUBDIRS = \
75         . \
76         awklib \
77         doc \
78         po \
79         test
80
81 # what to make and install
82 bin_PROGRAMS = gawk pgawk dgawk
83
84 # sources for both gawk and pgawk
85 base_sources = \
86         array.c \
87         awk.h \
88         awkgram.y \
89         builtin.c \
90         custom.h \
91         dfa.c \
92         dfa.h \
93         ext.c \
94         field.c \
95         floatcomp.c \
96         floatmagic.h \
97         gawkmisc.c \
98         getopt.c \
99         getopt.h \
100         getopt1.c \
101         getopt_int.h \
102         gettext.h \
103         io.c \
104         mbsupport.h \
105         main.c \
106         msg.c \
107         node.c \
108         protos.h \
109         random.c \
110         random.h \
111         re.c \
112         regex.c \
113         regex.h \
114         replace.c \
115         version.c \
116         xalloc.h
117
118 gawk_SOURCES = $(base_sources) eval.c profile.c
119 pgawk_SOURCES = $(base_sources) eval_p.c profile_p.c
120 dgawk_SOURCES = $(base_sources) eval_d.c profile.c cmd.h command.y debug.c
121
122 # Get extra libs as needed, Automake will supply LIBINTL and SOCKET_LIBS.
123 LDADD = $(LIBSIGSEGV) $(LIBINTL) $(SOCKET_LIBS)
124 dgawk_LDADD = $(LDADD) @LIBREADLINE@
125
126 # Directory for gawk's data files. Automake supplies datadir.
127 pkgdatadir = $(datadir)/awk
128
129 # stuff for compiling gawk/pgawk
130 DEFPATH='".$(PATH_SEPARATOR)$(pkgdatadir)"'
131
132 DEFS= -DDEFPATH=$(DEFPATH) -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"$(datadir)/locale"'
133
134 # Get rid of core files when cleaning
135 CLEANFILES = core core.*
136
137 MAINTAINERCLEANFILES = version.c
138
139 # We want hard links for install-exec-hook, below
140 LN= ln
141
142 # First, add a link from gawk to gawk-X.Y.Z.
143 # Same for pgawk.
144 #
145 # For GNU systems where gawk is awk, add a link to awk.
146 # (This is done universally, which may not always be right, but
147 # there's no easy way to distinguish GNU from non-GNU systems.)
148 install-exec-hook:
149         (cd $(DESTDIR)$(bindir); \
150         $(LN) gawk$(EXEEXT) gawk-$(VERSION)$(EXEEXT) 2>/dev/null ; \
151         $(LN) pgawk$(EXEEXT) pgawk-$(VERSION)$(EXEEXT) 2>/dev/null ; \
152         if [ ! -f awk ]; \
153         then    $(LN_S) gawk$(EXEEXT) awk; \
154         fi; exit 0)
155
156 # Undo the above when uninstalling
157 uninstall-links:
158         (cd $(DESTDIR)$(bindir); \
159         if [ -f awk ] && cmp awk gawk$(EXEEXT) > /dev/null; then rm -f awk; fi ; \
160         rm -f gawk-$(VERSION)$(EXEEXT) pgawk-$(VERSION)$(EXEEXT); exit 0)
161
162 uninstall-recursive: uninstall-links
163
164 # force there to be a gawk executable before running tests
165 check-local: gawk$(EXEEXT) pgawk$(EXEEXT)
166
167 # A little extra clean up when making distributions.
168 # And additional set up for the pc directory.
169 dist-hook:
170         cd $(distdir)/extension ; rm -f *.o *.so
171         cd $(srcdir)/pc ; \
172         sed -n -f configpk.sed < ../configure.ac > tmp.sed ; \
173         sed -f config.sed < ../configh.in > config.tmp ; \
174         sed -f tmp.sed < config.tmp > config.h ; \
175         $(RM) tmp.sed config.tmp
176
177 # Special rules for individual files
178 # Use of awk instead of $(AWK) is deliberate, in case gawk doesn't build
179 # or work correctly.
180 awkgram.c: awkgram.y
181         $(YACC) $(AM_YFLAGS) $(YFLAGS) $<
182         sed 's/parse error/syntax error/g' < y.tab.c | awk -f $(srcdir)/bisonfix.awk awkgram > $*.c && rm y.tab.c
183         if test -f y.tab.h; then \
184         if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
185         else :; fi
186
187 version.c: config.status version.in
188         $(SHELL) ./config.status --file=version.c:version.in
189
190 command.c: command.y
191         $(YACC) -p zz $<
192         sed 's/parse error/syntax error/g' < y.tab.c | awk -f $(srcdir)/bisonfix.awk command > $*.c && rm y.tab.c
193
194 # This is for my development & testing.
195 efence: gawk
196         $(CC) $(LDFLAGS) -o gawk $$(ls *.o | grep -v '_p.o$$') $(LIBS) -lefence
197
198 diffout valgrind-scan:
199         @cd test && $(MAKE) $(AM_MAKEFLAGS) $@
200
201 valgrind:
202         cd test; rm -f log.[0-9]*; \
203         make check AWK="valgrind --leak-check=full --log-file=log.%p ../gawk"; \
204         make valgrind-scan