gnulib: update to latest; and use lib-ignore
[cppi/ericb.git] / src / Makefile.am
blob20dc017d456bd1d2b0f3ff8f84b289b27c8fd060
1 ## Process this file with automake to produce Makefile.in -*-Makefile-*-
3 bin_PROGRAMS = cppi
4 cppi_SOURCES = \
5   cppi.l \
6   system.h
8 AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
10 # Tell the linker to omit references to unused shared libraries.
11 AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
13 EXTRA_DIST = cpp.gp cpp-indent.pl cppi.l cpp-cond.c
14 MAINTAINERCLEANFILES = cpp-cond.c
15 CLEANFILES = cpp.h lex.backup
17 GPERF = gperf
19 AM_CPPFLAGS = -I$(top_srcdir)/lib
21 LDADD = ../lib/libcppi.a $(LIBINTL) ../lib/libcppi.a
23 GPERF_OPTIONS = \
24   -C -N cpp_cond_lookup -n -t -s 6 -k '*' --language=ANSI-C
26 cpp-cond.c: cpp.gp
27         $(AM_V_GEN)rm -f $@ $@-tmp
28         $(AM_V_at)$(GPERF) $(GPERF_OPTIONS) $< \
29           | perl -ne '/__GNUC_STDC_INLINE__/ and print "static\n"; print' \
30           > $@-tmp
31         $(AM_V_at)chmod a-w $@-tmp
32         $(AM_V_at)mv $@-tmp $@
34 localedir = $(datadir)/locale
35 BUILT_SOURCES = localedir.h
36 DISTCLEANFILES = localedir.h
37 localedir.h: Makefile
38         $(AM_V_GEN)rm -f $@-t
39         $(AM_V_at)echo '#define LOCALEDIR "$(localedir)"' >$@-t
40         $(AM_V_at)chmod a-w $@-t
41         $(AM_V_at)cmp $@-t $@ > /dev/null 2>&1 && rm -f $@-t \
42           || { rm -f $@; mv $@-t $@; }
44 # flex_debug = #-d
45 flex_debug = # -L # suppress #line directives
47 # This is required to avoid an infloop on certain 8-bit inputs.
48 # Without this option, the generated scanner would infloop on e.g.,
49 #   perl -e 'print "\300"' |./cppi
50 flex_8_bit = -8
52 flex_optimize = -Cfr -p -b
53 AM_LFLAGS = $(flex_debug) $(flex_optimize) $(flex_8_bit)
55 # Don't use automake's default .l.c rule.
56 # I prefer to make generated .c files unwritable.
57 cppi.c: cppi.l
58         $(AM_V_GEN)rm -f $@
59         $(AM_V_at)$(LEXCOMPILE) $(srcdir)/cppi.l
60         $(AM_V_at)chmod a-w $(LEX_OUTPUT_ROOT).c
61         $(AM_V_at)mv $(LEX_OUTPUT_ROOT).c $@
63 cpp.h: cpp.gp Makefile.am
64         $(AM_V_GEN)rm -f $@-tmp $@
65         $(AM_V_at)(                                                     \
66          echo '/* This file is generated automatically from cpp.gp.  */'; \
67          echo;                                                          \
68          echo 'enum Eic_type';                                          \
69          echo '{';                                                      \
70          sed -n '/.*, /{s///;s/.*/  &,/;p;};' $(srcdir)/cpp.gp;         \
71          echo '  EIC_OTHER';                                            \
72          echo '};';                                                     \
73          echo;                                                          \
74          echo 'static char const *const directive[] =';                 \
75          echo '{';                                                      \
76          sed -n '/,.*/{s///;s/.*/  "&",/;p;};' $(srcdir)/cpp.gp;        \
77          echo '  ""';                                                   \
78          echo '};';                                                     \
79         )                                                               \
80           > $@-tmp
81         $(AM_V_at)chmod -w $@-tmp
82         $(AM_V_at)mv $@-tmp $@
84 # This is required because we have broken inter-directory dependencies:
85 # in order to generate all man pages, require that cppi be built at
86 # distribution time.
87 dist-hook: cppi
88 .PHONY: dist-hook
90 BUILT_SOURCES += cpp-cond.c cpp.h
92 # The following rule is not designed to be portable,
93 # and relies on tools that not everyone has.
95 # Most functions in src/*.c should have static scope.
96 # Any that don't must be marked with `extern', but `main'
97 # and `usage' are exceptions.  They're always extern, but
98 # don't need to be marked.
100 # The second nm|grep checks for file-scope variables with `extern' scope.
101 sc_tight_scope: $(all_programs)
102         @t=exceptions-$$$$;                                             \
103         trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15;                  \
104         ( printf '^main$$\n^usage$$\n^cpp_cond_lookup$$\n^yy\n';        \
105           grep -h -A1 '^extern .*[^;]$$' $(SOURCES)                     \
106             | grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t; \
107         nm -e *.$(OBJEXT)                                               \
108             | sed -n 's/.* T //p'                                       \
109             | grep -Ev -f $$t &&                                        \
110           { echo 'the above functions should have static scope' 1>&2;   \
111             exit 1; } || : ;                                            \
112         ( printf '^program_name$$\n^yy\n';                                      \
113           test x"$(noinst_HEADERS)" = x ||                              \
114           sed -n 's/^extern int \([^ ][^ ]*\);$$/^\1$$/p'               \
115             $(noinst_HEADERS) ) > $$t;                                  \
116         nm -e *.$(OBJEXT)                                               \
117             | sed -n 's/.* [BD] //p'                                    \
118             | grep -Ev -f $$t &&                                        \
119           { echo 'the above variables should have static scope' 1>&2;   \
120             exit 1; } || :