1 ## Process this file with automake to produce Makefile.in -*-Makefile-*-
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
19 AM_CPPFLAGS = -I$(top_srcdir)/lib
21 LDADD = ../lib/libcppi.a $(LIBINTL) ../lib/libcppi.a
24 -C -N cpp_cond_lookup -n -t -s 6 -k '*' --language=ANSI-C
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' \
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
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 $@; }
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
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.
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 $@
66 echo '/* This file is generated automatically from cpp.gp. */'; \
68 echo 'enum Eic_type'; \
70 sed -n '/.*, /{s///;s/.*/ &,/;p;};' $(srcdir)/cpp.gp; \
74 echo 'static char const *const directive[] ='; \
76 sed -n '/,.*/{s///;s/.*/ "&",/;p;};' $(srcdir)/cpp.gp; \
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
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; \
108 | sed -n 's/.* T //p' \
109 | grep -Ev -f $$t && \
110 { echo 'the above functions should have static scope' 1>&2; \
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; \
117 | sed -n 's/.* [BD] //p' \
118 | grep -Ev -f $$t && \
119 { echo 'the above variables should have static scope' 1>&2; \