Speed up esyscmd with buffer reads.
[m4.git] / Makefile.am
blob01140c67ba77ba347824f99debb6b0e1f0628e83
1 ## Makefile.am - template for generating Makefile via Automake
2 ##
3 ## Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
4 ## Free Software Foundation, Inc.
5 ##
6 ## This file is part of GNU M4.
7 ##
8 ## GNU M4 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 3 of the License, or
11 ## (at your option) any later version.
13 ## GNU M4 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, see <http://www.gnu.org/licenses/>.
21 ## Written by Gary V. Vaughan <gary@gnu.org>
23 config_aux_dir  = build-aux
24 config_macro_dir= ltdl/m4
26 SUBDIRS         = po gnu . tests/gnu
28 ACLOCAL_AMFLAGS = -I ltdl/m4
29 AUTOMAKE_OPTIONS = nostdinc
31 # Prime the variables that will be augmented by libtool.
32 # FIXME - the -export-symbols-regex ".*" is a hack to work around the
33 # fact that on cygwin, the convenience library libltdl exports symbols,
34 # which effectively disables the auto-exporting of all other symbols.
35 # Revisit this if libtool on cygwin improves.
36 # See http://lists.gnu.org/archive/html/libtool-patches/2007-02/msg00062.html
37 AM_CPPFLAGS     =
38 AM_LDFLAGS      = -export-dynamic -export-symbols-regex ".*"
39 EXTRA_DIST      =
40 BUILT_SOURCES   =
41 CLEANFILES      =
42 DISTCLEANFILES  =
43 MOSTLYCLEANFILES=
45 include_HEADERS =
46 noinst_LTLIBRARIES=
47 lib_LTLIBRARIES =
48 EXTRA_LTLIBRARIES=
50 # Include Libtool's rules.
51 include ltdl/Makefile.inc
53 # Additional configuration.  Version management comes from suggestions
54 # given in build-aux/git-version-gen.
55 AM_CPPFLAGS    += -Ignu -I$(srcdir)/gnu \
56                   -Im4 -I$(srcdir)/m4
57 EXTRA_DIST     += bootstrap cfg.mk maint.mk .version \
58                   $(config_macro_dir)/gnulib-cache.m4
59 BUILT_SOURCES  += .version
60 .version:
61         echo $(VERSION) > $@-t && mv $@-t $@
62 dist-hook: dist-tarball-version
63 dist-tarball-version:
64         echo $(VERSION) > $(distdir)/.tarball-version
65 MAINTAINERCLEANFILES = \
66                   ABOUT-NLS INSTALL Makefile.in aclocal.m4 \
67                   config-h.in configure stamp-h.in \
68                   po/cat-id-tbl.c po/m4.pot po/stamp-cat-id
71 ## ------- ##
72 ## GNU M4. ##
73 ## ------- ##
75 bin_PROGRAMS    = src/m4
76 src_m4_SOURCES  = \
77                   src/xstrtoul.c \
78                   src/xstrtol-error.c \
79                   src/xstrtol.c \
80                   src/xstrtol.h \
81                   src/version-etc-fsf.c \
82                   src/version-etc.c \
83                   src/version-etc.h \
84                   src/main.c \
85                   src/m4.h \
86                   src/freeze.c
87 if GETOPT
88 src_m4_SOURCES += \
89                   src/getopt.c \
90                   src/getopt1.c
91 endif
92 if STACKOVF
93 src_m4_SOURCES += src/stackovf.c
94 endif
95 src_m4_CPPFLAGS = $(AM_CPPFLAGS) -Isrc -I$(srcdir)/src
96 src_m4_LDFLAGS  = $(AM_LDFLAGS) $(DLPREOPEN)
97 src_m4_LDADD    = m4/libm4.la
98 src_m4_DEPENDENCIES = $(PREOPEN_DEPENDENCIES) m4/libm4.la
100 ##                                                                      ##
101 ##                 --- PASTED MANUALLY FROM GNULIB ---                  ##
102 ##     To avoid adding unnecessary objects to libm4.la these gnulib     ##
103 ##     modules are not imported by gnulib-tool, but added manually.     ##
104 ##  (from: gnulib-tool --extract-automake-snippet getopt version-etc)   ##
105 ##                                                                      ##
106 BUILT_SOURCES  += src/$(GETOPT_H)
107 EXTRA_DIST     += src/getopt.in.h src/getopt_int.h
109 # We need the following in order to create an <getopt.h> when the
110 # system doesn't have one that works with the given compiler.
111 all-local: src/$(GETOPT_H)
112 src/getopt.h: src/getopt.in.h
113         cp $(srcdir)/src/getopt.in.h $@-t
114         mv $@-t $@
115 MOSTLYCLEANFILES += src/getopt.h src/getopt.h-t
116 ##                                                                      ##
117 ##                     --- END OF PASTED GNULIB ---                     ##
118 ##                                                                      ##
120 ## -------- ##
121 ## Modules. ##
122 ## -------- ##
124 pkgmodincludedir= $(pkgincludedir)/modules
126 ETAGS_ARGS      = --regex='/M4BUILTIN_HANDLER[ \t]*)\([^)]*\)/\1/'
128 module_ldflags  = -module $(AM_LDFLAGS)
129 module_libadd   = m4/libm4.la
131 pkgmodinclude_HEADERS = modules/m4.h
133 pkglibexec_LTLIBRARIES = \
134                   modules/gnu.la \
135                   modules/load.la \
136                   modules/m4.la \
137                   modules/traditional.la
139 EXTRA_modules_gnu_la_SOURCES    = modules/format.c
140 modules_gnu_la_LDFLAGS          = $(module_ldflags)
141 modules_gnu_la_LIBADD           = $(module_libadd)
142 EXTRA_DIST                     += $(EXTRA_modules_gnu_la_SOURCES)
144 modules_load_la_LDFLAGS         = $(module_ldflags)
145 modules_load_la_LIBADD          = $(module_libadd)
147 EXTRA_modules_m4_la_SOURCES     = modules/evalparse.c
148 modules_m4_la_LDFLAGS           = $(module_ldflags)
149 modules_m4_la_LIBADD            = $(module_libadd)
150 EXTRA_DIST                     += $(EXTRA_modules_m4_la_SOURCES)
152 modules_traditional_la_LDFLAGS  = $(module_ldflags)
153 modules_traditional_la_LIBADD   = $(module_libadd)
155 if USE_GMP
156 pkglibexec_LTLIBRARIES         += modules/mpeval.la
157 EXTRA_modules_mpeval_la_SOURCES = modules/evalparse.c
158 modules_mpeval_la_LDFLAGS       = $(module_ldflags)
159 modules_mpeval_la_LIBADD        = $(module_libadd) $(LIBADD_GMP)
160 endif
162 ## Disabled for now.  It is too fragile to be useful.
163 ## pkglibexec_LTLIBRARIES         += modules/perl.la
164 ## modules_perl_la_CPPFLAGS     = `$(PERL) -MExtUtils::Embed -e ccopts`
165 ## modules_perl_la_LDFLAGS              = \
166 ##                $(module_ldflags) `$(PERL) -MExtUtils::Embed -e ldopts`
167 ## modules_perl_la_LIBADD               = $(module_libadd)
168 ## BUILT_SOURCES                        = perlxsi.c
169 ## DISTCLEANFILES                      += $(BUILT_SOURCES)
171 ## perlxsi.c:
172 ##      $(PERL) -MExtUtils::Embed -e xsinit -- -o perlxsi.c
174 ## but we should still distribute it, because it is listed in POTFILES.in:
175 EXTRA_DIST += modules/perl.c
177 module_check    = -rpath /dev/null
178 check_LTLIBRARIES = \
179                   tests/import.la \
180                   tests/modtest.la \
181                   tests/shadow.la \
182                   tests/stdlib.la \
183                   tests/time.la
185 tests_import_la_LDFLAGS         = $(module_ldflags) $(module_check)
186 tests_import_la_LIBADD          = $(module_libadd)
187 tests_import_la_SOURCES         = modules/import.c
189 tests_modtest_la_LDFLAGS        = $(module_ldflags) $(module_check)
190 tests_modtest_la_LIBADD         = $(module_libadd)
191 tests_modtest_la_SOURCES        = modules/modtest.c
193 tests_shadow_la_LDFLAGS         = $(module_ldflags) $(module_check)
194 tests_shadow_la_LIBADD          = $(module_libadd)
195 tests_shadow_la_SOURCES         = modules/shadow.c
197 tests_stdlib_la_LDFLAGS         = $(module_ldflags) $(module_check)
198 tests_stdlib_la_LIBADD          = $(module_libadd)
199 tests_stdlib_la_SOURCES         = modules/stdlib.c
201 tests_time_la_LDFLAGS           = $(module_ldflags) $(module_check)
202 tests_time_la_LIBADD            = $(module_libadd)
203 tests_time_la_SOURCES           = modules/time.c
205 EXTRA_DIST     += \
206                   modules/modtest.m4 \
207                   modules/shadow.m4 \
208                   modules/time.m4 \
209                   modules/time2.m4 \
210                   modules/stdlib.m4
212 ## ----- ##
213 ## libm4 ##
214 ## ----- ##
216 lib_LTLIBRARIES += m4/libm4.la
218 nobase_include_HEADERS = \
219                   m4/m4module.h
220 nobase_pkginclude_HEADERS = \
221                   m4/hash.h \
222                   m4/system.h
223 m4_libm4_la_SOURCES     = \
224                   m4/builtin.c \
225                   m4/debug.c \
226                   m4/hash.c \
227                   m4/input.c \
228                   m4/m4.c \
229                   m4/m4private.h \
230                   m4/macro.c \
231                   m4/module.c \
232                   m4/output.c \
233                   m4/path.c \
234                   m4/resyntax.c \
235                   m4/symtab.c \
236                   m4/syntax.c \
237                   m4/utility.c
238 m4_libm4_la_LIBADD = gnu/libgnu.la \
239                   $(LIBLTDL) $(LTLIBINTL) $(LIBADD_DL)
240 m4_libm4_la_DEPENDENCIES = $(LTDLDEPS) gnu/libgnu.la
242 # This file needs to be regenerated at configure time.
243 dist-hook:
244         rm -f $(distdir)/m4/system.h
245 EXTRA_DIST     += m4/system_.h
248 ## -------------- ##
249 ## Documentation. ##
250 ## -------------- ##
252 info_TEXINFOS   = doc/m4.texinfo
253 doc_m4_TEXINFOS = doc/regexprops-generic.texi doc/fdl-1.3.texi doc/gpl-3.0.texi
254 dist_man_MANS   = $(srcdir)/doc/m4.1
255 EXTRA_DIST      += doc/gendocs_template
256 MAINTAINERCLEANFILES += doc/gendocs_template
257 HELP2MAN        = $(SHELL) $(srcdir)/$(config_aux_dir)/missing --run help2man
259 # Build the man page once in the srcdir, rather than in every VPATH build
260 # dir, to match how automake builds info pages.  This is safe for 'make
261 # distcheck' since it is distributed pre-built.
262 $(srcdir)/doc/m4.1: .version src/main.c
263         @if test -f src/m4$(EXEEXT); then \
264           echo "Updating the \`man' page \`$@'"; \
265           $(HELP2MAN) --name="macro processor" --source=FSF \
266             --info-page=m4 --output=$@ src/m4$(EXEEXT); \
267         else \
268           echo "WARNING: The \`man' page \`$@' cannot be updated yet."; \
269           echo "         Retry once the program executable is ready."; \
270         fi
272 ## Disabled for now.  Clashes with earlier definition.
273 ## TAGS_FILES   = $(infos_TEXINFOS)
274 ## TAGS_DEPENDENCIES = $(TAGS_FILES)
275 ## ETAGS_ARGS   = --language=none --regex='/@node \([^,]*\)/\1/' $(TAGS_FILES)
277 MAINTAINERCLEANFILES += $(dist_man_MANS)
280 ## --------- ##
281 ## Examples. ##
282 ## --------- ##
284 EXTRA_DIST     += \
285                   examples/WWW/Makefile \
286                   examples/WWW/_footer.htm \
287                   examples/WWW/_header.htm \
288                   examples/WWW/m4lib/bugs.m4 \
289                   examples/WWW/m4lib/changelog.m4 \
290                   examples/WWW/m4lib/download.m4 \
291                   examples/WWW/m4lib/features.m4 \
292                   examples/WWW/m4lib/feedback.m4 \
293                   examples/WWW/m4lib/html.m4 \
294                   examples/WWW/m4lib/index.m4 \
295                   examples/WWW/m4lib/layout.m4 \
296                   examples/WWW/m4lib/lists.m4 \
297                   examples/WWW/m4lib/menu.m4 \
298                   examples/WWW/m4lib/modules.m4 \
299                   examples/WWW/m4lib/news.m4 \
300                   examples/WWW/m4lib/readme.m4 \
301                   examples/WWW/m4lib/setup.m4 \
302                   examples/WWW/m4lib/test.m4 \
303                   examples/WWW/m4lib/thanks.m4 \
304                   examples/WWW/m4lib/thissite.m4 \
305                   examples/WWW/m4lib/tmpl.m4 \
306                   examples/WWW/m4lib/todo.m4 \
307                   examples/WWW/m4lib/uses.m4 \
308                   examples/WWW/m4lib/visions.m4 \
309                   examples/WWW/m4lib/whatis.m4
311 dist_pkgdata_DATA = \
312                   examples/capitalize.m4 \
313                   examples/capitalize2.m4 \
314                   examples/comments.m4 \
315                   examples/curry.m4 \
316                   examples/ddivert.m4 \
317                   examples/debug.m4 \
318                   examples/esyscmd.m4 \
319                   examples/exp.m4 \
320                   examples/foreach.m4 \
321                   examples/foreach2.m4 \
322                   examples/foreachq.m4 \
323                   examples/foreachq2.m4 \
324                   examples/foreachq3.m4 \
325                   examples/foreachq4.m4 \
326                   examples/forloop.m4 \
327                   examples/forloop2.m4 \
328                   examples/forloop3.m4 \
329                   examples/fstab.m4 \
330                   examples/hanoi.m4 \
331                   examples/incl-test.m4 \
332                   examples/incl.m4 \
333                   examples/include.m4 \
334                   examples/indir.m4 \
335                   examples/join.m4 \
336                   examples/loop.m4 \
337                   examples/misc.m4 \
338                   examples/multiquotes.m4 \
339                   examples/patsubst.m4 \
340                   examples/pushpop.m4 \
341                   examples/quote.m4 \
342                   examples/regexp.m4 \
343                   examples/reverse.m4 \
344                   examples/stack.m4 \
345                   examples/stack_sep.m4 \
346                   examples/sysv-args.m4 \
347                   examples/trace.m4 \
348                   examples/translit.m4 \
349                   examples/undivert.incl \
350                   examples/undivert.m4 \
351                   examples/wrap.m4 \
352                   examples/wrapfifo.m4 \
353                   examples/wraplifo.m4 \
354                   examples/wraplifo2.m4
356 ## ----------- ##
357 ## Test suite. ##
358 ## ----------- ##
360 # Use `$(srcdir)' for the benefit of non-GNU makes: this is
361 # how `testsuite' appears in our dependencies.
362 TESTSUITE = $(srcdir)/tests/testsuite
363 TESTSUITE_AT    = \
364                   tests/builtins.at \
365                   tests/freeze.at \
366                   $(srcdir)/tests/generated.at \
367                   tests/macros.at \
368                   tests/modules.at \
369                   tests/options.at \
370                   tests/others.at \
371                   tests/testsuite.at
373 EXTRA_DIST     += $(TESTSUITE) $(TESTSUITE_AT) $(OTHER_FILES) \
374                   tests/atlocal.in \
375                   tests/generate.awk \
376                   $(srcdir)/tests/package.m4
378 # Using variables so that this snippet is not too wide and can
379 # be used as is in Texinfo @example/@end example.
380 m4_texinfo  = $(srcdir)/doc/m4.texinfo
381 generate    = $(AWK) -f $(srcdir)/tests/generate.awk
382 $(srcdir)/tests/generated.at: tests/generate.awk $(m4_texinfo)
383         $(generate) $(m4_texinfo) >$@t
384         mv $@t $@
386 AUTOM4TE = $(SHELL) $(srcdir)/$(config_aux_dir)/missing --run autom4te
387 AUTOTEST = $(AUTOM4TE) --language=autotest
388 $(TESTSUITE): $(srcdir)/tests/package.m4 $(TESTSUITE_AT)
389         $(AUTOTEST) -I '$(srcdir)/tests' -o $@.tmp $@.at
390         mv $@.tmp $@
392 # The leading :; works around a bug in {}>f in some bash versions.
393 $(srcdir)/tests/package.m4: .version
394         :; \
395         { \
396           echo '# Signature of the current package.'; \
397           echo 'm4_define([AT_PACKAGE_NAME],      [@PACKAGE_NAME@])'; \
398           echo 'm4_define([AT_PACKAGE_TARNAME],   [@PACKAGE_TARNAME@])'; \
399           echo 'm4_define([AT_PACKAGE_VERSION],   [@PACKAGE_VERSION@])'; \
400           echo 'm4_define([AT_PACKAGE_STRING],    [@PACKAGE_STRING@])'; \
401           echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
402         } > $(srcdir)/tests/package.m4
404 tests/atconfig: config.status
405         $(SHELL) ./config.status tests/atconfig
406 DISTCLEANFILES += tests/atconfig
408 # Hook the test suite into the check rule
409 check-local: tests/atconfig tests/atlocal tests/m4 $(TESTSUITE) \
410                 $(check_LTLIBRARIES)
411         $(SHELL) '$(srcdir)/tests/testsuite' -C tests $(TESTSUITEFLAGS)
413 # Run the test suite on the *installed* tree, including any renames
414 # the user requested.
415 installcheck-local: tests/atconfig tests/atlocal $(TESTSUITE) \
416                 $(check_LTLIBRARIES)
417         $(SHELL) '$(srcdir)/tests/testsuite' -C tests \
418           AUTOTEST_PATH="$(bindir)" \
419           M4="`echo m4 | sed '$(program_transform_name)'`" $(TESTSUITEFLAGS)
421 # Enough users install GNU M4 as gm4 that we make sure 'make installcheck'
422 # will handle that, as part of making a release.
423 DISTCHECK_CONFIGURE_FLAGS = --disable-assert --program-prefix=g
425 # We need to remove any file droppings left behind by testsuite.
426 clean-local-tests:
427         test ! -f '$(srcdir)/tests/testsuite' || \
428           $(SHELL) '$(srcdir)/tests/testsuite' -C tests --clean
430 OTHER_FILES     = tests/iso8859.m4 tests/stackovf.test \
431                 tests/null.m4 tests/null.out tests/null.err
433 DISTCLEANFILES += tests/atconfig tests/atlocal tests/m4
434 MAINTAINERCLEANFILES += $(srcdir)/tests/generated.at '$(TESTSUITE)'
436 clean-local: clean-local-tests