Commit | Line | Data |
---|---|---|
0305d25e AD |
1 | ## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software |
2 | ## Foundation, Inc. | |
3 | ||
4 | ## This program is free software: you can redistribute it and/or modify | |
5 | ## it under the terms of the GNU General Public License as published by | |
6 | ## the Free Software Foundation, either version 3 of the License, or | |
7 | ## (at your option) any later version. | |
8 | ## | |
9 | ## This program is distributed in the hope that it will be useful, | |
10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | ## GNU General Public License for more details. | |
13 | ## | |
14 | ## You should have received a copy of the GNU General Public License | |
15 | ## along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | AUTOMAKE_OPTIONS = subdir-objects | |
18 | ||
19 | AM_CPPFLAGS = -I$(top_srcdir)/lib | |
20 | # Find builddir/src/scan-code.c etc. | |
21 | AM_CPPFLAGS += -I$(top_builddir) | |
22 | ||
23 | AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) | |
24 | ||
25 | LDADD = $(top_builddir)/lib/libbison.a $(LIBINTL) | |
26 | ||
27 | # Use our own Bison to build the parser. Of course, you ought to | |
28 | # keep a sane version of Bison nearby... | |
29 | YACC = $(top_builddir)/tests/bison -y | |
30 | AM_YFLAGS = -dv --warnings=all,error --report=all | |
31 | ||
32 | bin_PROGRAMS = src/bison | |
33 | bin_SCRIPTS = $(YACC_SCRIPT) | |
34 | EXTRA_SCRIPTS = src/yacc | |
35 | ||
36 | src_bison_SOURCES = \ | |
37 | src/LR0.c \ | |
38 | src/LR0.h \ | |
39 | src/assoc.c \ | |
40 | src/assoc.h \ | |
41 | src/closure.c \ | |
42 | src/closure.h \ | |
43 | src/complain.c \ | |
44 | src/complain.h \ | |
45 | src/conflicts.c \ | |
46 | src/conflicts.h \ | |
47 | src/derives.c \ | |
48 | src/derives.h \ | |
49 | src/files.c \ | |
50 | src/files.h \ | |
51 | src/flex-scanner.h \ | |
52 | src/getargs.c \ | |
53 | src/getargs.h \ | |
54 | src/gram.c \ | |
55 | src/gram.h \ | |
56 | src/graphviz.c \ | |
57 | src/graphviz.h \ | |
58 | src/lalr.c \ | |
59 | src/lalr.h \ | |
60 | src/location.c \ | |
61 | src/location.h \ | |
62 | src/main.c \ | |
63 | src/muscle_tab.c \ | |
64 | src/muscle_tab.h \ | |
65 | src/nullable.c \ | |
66 | src/nullable.h \ | |
67 | src/output.c \ | |
68 | src/output.h \ | |
69 | src/parse-gram.h \ | |
70 | src/parse-gram.y \ | |
71 | src/print-xml.c \ | |
72 | src/print-xml.h \ | |
73 | src/print.c \ | |
74 | src/print.h \ | |
75 | src/print_graph.c \ | |
76 | src/print_graph.h \ | |
77 | src/reader.c \ | |
78 | src/reader.h \ | |
79 | src/reduce.c \ | |
80 | src/reduce.h \ | |
81 | src/relation.c \ | |
82 | src/relation.h \ | |
83 | src/scan-code-c.c \ | |
84 | src/scan-code.h \ | |
85 | src/scan-gram-c.c \ | |
86 | src/scan-gram.h \ | |
87 | src/scan-skel-c.c \ | |
88 | src/scan-skel.h \ | |
89 | src/state.c \ | |
90 | src/state.h \ | |
91 | src/symlist.c \ | |
92 | src/symlist.h \ | |
93 | src/symtab.c \ | |
94 | src/symtab.h \ | |
95 | src/system.h \ | |
96 | src/tables.c \ | |
97 | src/tables.h \ | |
98 | src/uniqstr.c \ | |
99 | src/uniqstr.h | |
100 | ||
101 | EXTRA_src_bison_SOURCES = \ | |
102 | src/scan-code.l \ | |
103 | src/scan-gram.l \ | |
104 | src/scan-skel.l | |
105 | ||
106 | BUILT_SOURCES += \ | |
107 | src/parse-gram.c \ | |
108 | src/parse-gram.h \ | |
109 | src/scan-code.c \ | |
110 | src/scan-gram.c \ | |
111 | src/scan-skel.c | |
112 | ||
113 | MOSTLYCLEANFILES = src/yacc | |
114 | ||
115 | src/yacc: | |
116 | rm -f $@ $@.tmp | |
117 | echo '#! /bin/sh' >$@.tmp | |
118 | echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@.tmp | |
119 | chmod a+x $@.tmp | |
120 | mv $@.tmp $@ | |
121 | ||
122 | echo: | |
123 | echo $(src_bison_SOURCES) $(noinst_HEADERS) | |
124 | ||
125 | # The following rule is not designed to be portable, | |
126 | # and relies on tools that not everyone has. | |
127 | ||
128 | # Most functions in src/*.c should have static scope. | |
129 | # Any that don't must be marked with `extern', but `main' | |
130 | # and `usage' are exceptions. They're always extern, but | |
131 | # don't need to be marked. | |
132 | # | |
133 | # The second nm|grep checks for file-scope variables with `extern' scope. | |
134 | sc_tight_scope: $(all_programs) | |
135 | @t=exceptions-$$$$; \ | |
136 | trap 's=$$?; rm -f $$t; exit $$s' 0 1 2 13 15; \ | |
137 | ( printf '^main$$\n^usage$$\n'; \ | |
138 | grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \ | |
139 | | grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t; \ | |
140 | if nm -e *.$(OBJEXT) \ | |
141 | | sed -n 's/.* T //p' \ | |
142 | | grep -Ev -f $$t; then \ | |
143 | echo 'the above functions should have static scope' 1>&2; \ | |
144 | exit 1; \ | |
145 | fi; \ | |
146 | ( printf '^program_name$$\n'; \ | |
147 | sed -n 's/^extern .*[* ]\([a-zA-Z_][a-zA-Z_0-9]*\);$$/^\1$$/p' \ | |
148 | $$(ls $(SOURCES) | grep '\.h$$') /dev/null) > $$t; \ | |
149 | if nm -e *.$(OBJEXT) \ | |
150 | | sed -n 's/.* [BD] //p' \ | |
151 | | grep -Ev -f $$t; then \ | |
152 | echo 'the above variables should have static scope' 1>&2; \ | |
153 | exit 1; \ | |
154 | fi |