maint: update bootstrap from gnulib
[cppi.git] / src / local.mk
blobc43c32e7d3ac7f4934f3f8d24ac341f61079e149
1 bin_PROGRAMS = src/cppi
2 src_cppi_SOURCES = \
3 src/cppi.l \
4 src/system.h
6 # Tell the linker to omit references to unused shared libraries.
7 AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
9 EXTRA_DIST += \
10 src/cpp.gp \
11 src/cpp-indent.pl \
12 src/cppi.l \
13 src/cpp-cond.c
15 MAINTAINERCLEANFILES += src/cpp-cond.c
16 CLEANFILES += lex.backup
17 DISTCLEANFILES += src/cpp.h
19 GPERF = gperf
21 AM_CPPFLAGS += -I$(top_srcdir)/lib -Isrc -I$(top_srcdir)/src
23 LDADD = $(top_builddir)/lib/libcppi.a $(LIBINTL) $(top_builddir)/lib/libcppi.a
25 GPERF_OPTIONS = \
26 -C -N cpp_cond_lookup -n -t -s 6 -k '*' --language=ANSI-C
28 src/cpp-cond.c: src/cpp.gp
29 $(AM_V_GEN)rm -f $@ $@-t
30 $(AM_V_at)$(GPERF) $(GPERF_OPTIONS) $< \
31 | perl -0777 -p \
32 -e 's/const struct KW \*\ncpp_cond_lookup/static\n$$&/' \
33 > $@-t
34 $(AM_V_at)chmod a-w $@-t
35 $(AM_V_at)mv $@-t $@
37 localedir = $(datadir)/locale
38 BUILT_SOURCES += src/localedir.h
39 DISTCLEANFILES += src/localedir.h
40 src/localedir.h: src/local.mk
41 $(AM_V_GEN)rm -f $@-t
42 $(AM_V_at)echo '#define LOCALEDIR "$(localedir)"' >$@-t
43 $(AM_V_at)chmod a-w $@-t
44 $(AM_V_at)cmp $@-t $@ > /dev/null 2>&1 && rm -f $@-t \
45 || { rm -f $@; mv $@-t $@; }
47 # flex_debug = #-d
48 flex_debug = # -L # suppress #line directives
50 # This is required to avoid an infloop on certain 8-bit inputs.
51 # Without this option, the generated scanner would infloop on e.g.,
52 # perl -e 'print "\300"' |./cppi
53 flex_8_bit = -8
55 flex_optimize = -Cfr -p -b
56 AM_LFLAGS = $(flex_debug) $(flex_optimize) $(flex_8_bit)
58 # Don't use automake's default .l.c rule.
59 # I prefer to make generated .c files unwritable.
60 src/cppi.c: src/cppi.l
61 $(AM_V_GEN)rm -f $@
62 $(AM_V_at)$(LEXCOMPILE) $(top_srcdir)/src/cppi.l
63 $(AM_V_at)chmod a-w $(LEX_OUTPUT_ROOT).c
64 $(AM_V_at)mv $(LEX_OUTPUT_ROOT).c $@
66 src/cpp.h: src/cpp.gp src/local.mk
67 $(AM_V_GEN)rm -f $@-t $@
68 $(AM_V_at)( \
69 echo '/* This file is generated automatically from cpp.gp. */'; \
70 echo; \
71 echo 'enum Eic_type'; \
72 echo '{'; \
73 sed -n '/.*, /{s///;s/.*/ &,/;p;};' $(srcdir)/src/cpp.gp; \
74 echo ' EIC_OTHER'; \
75 echo '};'; \
76 echo; \
77 echo 'static char const *const directive[] ='; \
78 echo '{'; \
79 sed -n '/,.*/{s///;s/.*/ "&",/;p;};' $(srcdir)/src/cpp.gp; \
80 echo ' ""'; \
81 echo '};'; \
82 ) \
83 > $@-t
84 $(AM_V_at)chmod -w $@-t
85 $(AM_V_at)mv $@-t $@
87 BUILT_SOURCES += src/cpp-cond.c src/cpp.h