Commit fa5d4812 fa5d4812fc4936dd470ded17116c9d966d0d645e by Sergey Poznyakoff

Rewrite Makefile rules for lex and bison

The aim is to get rid of the explicit rules and use the Autmake framework
as much as possible, without hurting the flexibility.  To this effect, the
gylwrap tool is rewritten from scratch (in Perl).  In compatibility
mode it takes the same arguments as the standard ylwrap.  Additional
configuration is supplied in the configuration file gylwrap.conf, located
in the directory where the input file resides.

* mu-aux/gylwrap: Rewrite from scratch.
* configure.ac (MU_YLWRAP): New subst variable.
* libmailutils/base/.gitignore: Update.
* libmailutils/base/Makefile.am: Update.
* libmailutils/base/gylwrap.conf: New file.
* libmailutils/cfg/.gitignore: Update.
* libmailutils/cfg/Makefile.am: Use new YLWRAP
* libmailutils/cfg/cfg.h: Remove.
* libmailutils/cfg/gylwrap.conf: New file.
* libmailutils/cfg/lexer.l: Include mailutils/yyloc.h directly.
* libmailutils/cfg/parser.y: Likewise.
* libmu_sieve/Makefile.am: Use new YLWRAP
* libmu_sieve/gylwrap.conf: New file.
* libmu_sieve/sieve.y: Rename to libmu_sieve/sieve-gram.y
* libmu_sieve/sieve.l: Rename to libmu_sieve/sieve-lex.l
* mail/Makefile.am: Use new YLWRAP
* mh/.gitignore: Update.
* mh/Makefile.am: Use new YLWRAP
* mh/gylwrap.conf: New file.
* mh/mh_alias.y: Rename to mh/mh_alias_gram.y
* mh/mh_alias.l: Rename to mh/mh_alias_lex.l
* mh/pick.y: Rename to mh/pick-gram.y
* mimeview/.gitignore: Update.
* mimeview/Makefile.am: Use new YLWRAP
* mimeview/mimetypes.y: Rename to mimeview/grammar.y
* mimeview/gylwrap.conf: New file.
* mimeview/mimetypes.l: Rename to mimeview/lexer.l
* po/POTFILES.in: Update
1 parent 3a78309a
...@@ -71,6 +71,9 @@ AC_SUBST(MU_LIB_COMMON_INCLUDES,'-I${top_builddir} -I${top_srcdir}/include -I${ ...@@ -71,6 +71,9 @@ AC_SUBST(MU_LIB_COMMON_INCLUDES,'-I${top_builddir} -I${top_srcdir}/include -I${
71 71
72 AC_SUBST(MU_APP_COMMON_INCLUDES,'-I${srcdir} -I${top_srcdir}/include -I${top_srcdir}/lib -I${top_srcdir}/lib/gnu -I${top_builddir}/lib/gnu -I${top_builddir} -I${top_builddir}/include') 72 AC_SUBST(MU_APP_COMMON_INCLUDES,'-I${srcdir} -I${top_srcdir}/include -I${top_srcdir}/lib -I${top_srcdir}/lib/gnu -I${top_builddir}/lib/gnu -I${top_builddir} -I${top_builddir}/include')
73 73
74 # Use our replacement for the ylwrap tool
75 AC_SUBST([MU_YLWRAP],'$(mu_aux_dir)/gylwrap --compatibility --')
76
74 dnl Check for programs 77 dnl Check for programs
75 AC_PROG_CC 78 AC_PROG_CC
76 AM_PROG_CC_C_O 79 AM_PROG_CC_C_O
......
...@@ -54,7 +54,7 @@ libbase_la_SOURCES = \ ...@@ -54,7 +54,7 @@ libbase_la_SOURCES = \
54 observer.c\ 54 observer.c\
55 onexit.c\ 55 onexit.c\
56 opool.c\ 56 opool.c\
57 parsedate.c\ 57 parsedate.y\
58 permstr.c\ 58 permstr.c\
59 registrar.c\ 59 registrar.c\
60 refcount.c\ 60 refcount.c\
...@@ -82,17 +82,10 @@ AM_CPPFLAGS = \ ...@@ -82,17 +82,10 @@ AM_CPPFLAGS = \
82 -DLOCALEDIR=\"$(localedir)\" 82 -DLOCALEDIR=\"$(localedir)\"
83 83
84 84
85 YLWRAP = $(SHELL) $(mu_aux_dir)/gylwrap 85 YLWRAP = @MU_YLWRAP@
86 AM_YFLAGS=-vt 86 EXTRA_DIST = gylwrap.conf
87 AM_LFLAGS=-dp 87 AM_YFLAGS=
88 AM_LFLAGS=
88 89
89 EXTRA_DIST = parsedate.y
90
91 BUILT_SOURCES = parsedate.c
92
93 parsedate.c: $(srcdir)/parsedate.y
94 $(YLWRAP) "$(YACC) $(AM_YFLAGS)" $< \
95 y.tab.c parsedate.c y.output parsedate.y.output \
96 -- -yy pd_yy
97 90
98 91
......
1 # Configuration settings for gylwrap.
2 # See ../../mu-aux/gylwrap --help, for details.
3 yyrepl = pd_yy
1 lexer.c 1 lexer.c
2 parser.c 2 parser.c
3 parser.h 3 parser.h
4 parser.output
......
...@@ -20,9 +20,8 @@ noinst_LTLIBRARIES = libcfg.la ...@@ -20,9 +20,8 @@ noinst_LTLIBRARIES = libcfg.la
20 libcfg_la_SOURCES = \ 20 libcfg_la_SOURCES = \
21 driver.c\ 21 driver.c\
22 format.c\ 22 format.c\
23 lexer.c\ 23 lexer.l\
24 parser.c\ 24 parser.y
25 cfg.h
26 25
27 localedir = $(datadir)/locale 26 localedir = $(datadir)/locale
28 AM_CPPFLAGS = \ 27 AM_CPPFLAGS = \
...@@ -30,25 +29,15 @@ AM_CPPFLAGS = \ ...@@ -30,25 +29,15 @@ AM_CPPFLAGS = \
30 -DSYSCONFDIR=\"$(sysconfdir)\"\ 29 -DSYSCONFDIR=\"$(sysconfdir)\"\
31 -DLOCALEDIR=\"$(localedir)\" 30 -DLOCALEDIR=\"$(localedir)\"
32 31
33
34 EXTRA_DIST = \ 32 EXTRA_DIST = \
35 lexer.l\ 33 lexer.l\
36 parser.y\ 34 parser.y\
37 parser.h 35 parser.h\
36 gylwrap.conf
38 37
39 BUILT_SOURCES = parser.c parser.h lexer.c 38 BUILT_SOURCES = parser.c parser.h lexer.c
40 39
41 YLWRAP = $(SHELL) $(mu_aux_dir)/gylwrap 40 YLWRAP = @MU_YLWRAP@
42 AM_YFLAGS=-vt 41 AM_YFLAGS=-vdt
43 AM_LFLAGS=-dp 42 AM_LFLAGS=-dp
44 43
45 parser.c parser.h: $(srcdir)/parser.y
46 $(AM_V_GEN)$(YLWRAP) "$(YACC) $(AM_YFLAGS) -d" $< \
47 y.tab.c parser.c y.tab.h parser.h \
48 y.output parser.y.output \
49 -- -yy mu_cfg_yy
50
51 lexer.c: $(srcdir)/lexer.l parser.h
52 $(AM_V_GEN)$(YLWRAP) "$(LEX) $(AM_LFLAGS) $(LFLAGS)" \
53 $(srcdir)/lexer.l lex.yy.c lexer.c \
54 -- -yy mu_cfg_yy
......
1 #include <mailutils/yyloc.h>
1 # Configuration settings for gylwrap.
2 # See ../../mu-aux/gylwrap --help, for details.
3
4 yyrepl = mu_cfg_yy
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
41 #include <mailutils/locus.h> 41 #include <mailutils/locus.h>
42 #include <mailutils/stream.h> 42 #include <mailutils/stream.h>
43 #include <mailutils/stdstream.h> 43 #include <mailutils/stdstream.h>
44 #include "cfg.h" 44 #include <mailutils/yyloc.h>
45 #include "parser.h" 45 #include "parser.h"
46 46
47 void _mu_line_begin (void); 47 void _mu_line_begin (void);
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
40 #include <mailutils/stream.h> 40 #include <mailutils/stream.h>
41 #include <mailutils/stdstream.h> 41 #include <mailutils/stdstream.h>
42 #include <mailutils/cidr.h> 42 #include <mailutils/cidr.h>
43 #include "cfg.h" 43 #include <mailutils/yyloc.h>
44 44
45 int mu_cfg_parser_verbose; 45 int mu_cfg_parser_verbose;
46 static mu_list_t /* of mu_cfg_node_t */ parse_node_list; 46 static mu_list_t /* of mu_cfg_node_t */ parse_node_list;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
15 ## You should have received a copy of the GNU General Public License 15 ## You should have received a copy of the GNU General Public License
16 ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. 16 ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
17 17
18 YLWRAP = $(SHELL) $(mu_aux_dir)/gylwrap 18 YLWRAP = @MU_YLWRAP@
19 AM_YFLAGS = -dtv 19 AM_YFLAGS = -dtv
20 #AM_LEXFLAGS=-dvp 20 #AM_LEXFLAGS=-dvp
21 AM_CPPFLAGS =\ 21 AM_CPPFLAGS =\
...@@ -39,9 +39,8 @@ libmu_sieve_la_SOURCES = \ ...@@ -39,9 +39,8 @@ libmu_sieve_la_SOURCES = \
39 relational.c\ 39 relational.c\
40 require.c\ 40 require.c\
41 runtime.c\ 41 runtime.c\
42 sieve-gram.c\ 42 sieve-gram.y\
43 sieve-gram.h\ 43 sieve-lex.l\
44 sieve-lex.c\
45 strexp.c\ 44 strexp.c\
46 string.c\ 45 string.c\
47 tests.c\ 46 tests.c\
...@@ -50,24 +49,14 @@ libmu_sieve_la_SOURCES = \ ...@@ -50,24 +49,14 @@ libmu_sieve_la_SOURCES = \
50 libmu_sieve_la_LIBADD = ${MU_LIB_MAILUTILS} @LTDL_LIB@ 49 libmu_sieve_la_LIBADD = ${MU_LIB_MAILUTILS} @LTDL_LIB@
51 libmu_sieve_la_LDFLAGS = -version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@ 50 libmu_sieve_la_LDFLAGS = -version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
52 51
53 noinst_HEADERS = sieve-priv.h 52 noinst_HEADERS = sieve-priv.h sieve-gram.h
54 53
55 BUILT_SOURCES = \ 54 BUILT_SOURCES = \
56 sieve-gram.c sieve-gram.h \ 55 sieve-gram.c sieve-gram.h \
57 sieve-lex.c 56 sieve-lex.c
58 57
59 MAINTAINERCLEANFILES=$(BUILT_SOURCES) 58 EXTRA_DIST=gylwrap.conf
60
61 EXTRA_DIST = sieve.y sieve.l
62 59
63 sieve-lex.c: $(srcdir)/sieve.l sieve-gram.h 60 MAINTAINERCLEANFILES=$(BUILT_SOURCES)
64 $(AM_V_GEN)$(YLWRAP) "$(LEX) $(AM_LEXFLAGS) $(LEXFLAGS)" \
65 $(srcdir)/sieve.l lex.yy.c sieve-lex.c \
66 -- -yy mu_sieve_yy
67
68 sieve-gram.c sieve-gram.h: $(srcdir)/sieve.y
69 $(AM_V_GEN)$(YLWRAP) "$(YACC) $(AM_YFLAGS) $(YFLAGS)" $(srcdir)/sieve.y \
70 y.tab.c sieve-gram.c y.tab.h sieve-gram.h y.output y.output \
71 -- -yy mu_sieve_yy
72 61
73 62
......
1 # Configuration settings for gylwrap.
2 # See ../mu-aux/gylwrap --help, for details.
3
4 yyrepl=mu_sieve_yy
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 ## You should have received a copy of the GNU General Public License 15 ## You should have received a copy of the GNU General Public License
16 ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. 16 ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
17 17
18 YLWRAP = @MU_YLWRAP@
18 AM_YFLAGS=-vt 19 AM_YFLAGS=-vt
19 AM_CPPFLAGS = \ 20 AM_CPPFLAGS = \
20 @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@\ 21 @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@\
......
...@@ -14,8 +14,7 @@ forw ...@@ -14,8 +14,7 @@ forw
14 inc 14 inc
15 install-mh 15 install-mh
16 mark 16 mark
17 mh_alias.h 17 mh_alias_gram.[ch]
18 mh_alias_gram.c
19 mh_alias_lex.c 18 mh_alias_lex.c
20 mh_fmtgram.c 19 mh_fmtgram.c
21 mhl 20 mhl
......
...@@ -68,33 +68,33 @@ noinst_LIBRARIES = libmh.a ...@@ -68,33 +68,33 @@ noinst_LIBRARIES = libmh.a
68 libmh_a_SOURCES= \ 68 libmh_a_SOURCES= \
69 compcommon.c\ 69 compcommon.c\
70 mboxprop.c\ 70 mboxprop.c\
71 mh_alias_gram.c\ 71 mh_alias_gram.y\
72 mh_alias_lex.c\ 72 mh_alias_lex.l\
73 mh_getopt.c\ 73 mh_getopt.c\
74 mh_global.c\ 74 mh_global.c\
75 mh_format.c\ 75 mh_format.c\
76 mh_init.c\ 76 mh_init.c\
77 mh_list.c\ 77 mh_list.c\
78 mh_fmtgram.c\ 78 mh_fmtgram.y\
79 mh_msgset.c\ 79 mh_msgset.c\
80 mh_sequence.c\ 80 mh_sequence.c\
81 mh_stream.c\ 81 mh_stream.c\
82 mh_whatnow.c\ 82 mh_whatnow.c\
83 mh_whom.c\ 83 mh_whom.c\
84 whatnowenv.c 84 whatnowenv.c
85 noinst_HEADERS = mh.h mh_alias.h mh_format.h mh_getopt.h 85 noinst_HEADERS = mh.h mh_alias_gram.h mh_format.h mh_getopt.h
86 86
87 BUILT_SOURCES= \ 87 BUILT_SOURCES=\
88 mh_fmtgram.c \ 88 mh_fmtgram.c\
89 pick-gram.c \ 89 pick-gram.c\
90 pick-gram.h \ 90 pick-gram.h\
91 mh_alias_gram.c \ 91 mh_alias_gram.c\
92 mh_alias_lex.c \ 92 mh_alias_gram.h\
93 mh_alias.h 93 mh_alias_lex.c
94 94
95 MAINTAINERCLEANFILES=$(BUILT_SOURCES) 95 MAINTAINERCLEANFILES=$(BUILT_SOURCES)
96 96
97 EXTRA_DIST = mh_fmtgram.y pick.y mh_alias.y mh_alias.l 97 EXTRA_DIST = gylwrap.conf
98 98
99 mhlibdir = $(pkgdatadir)/mh 99 mhlibdir = $(pkgdatadir)/mh
100 100
...@@ -119,9 +119,9 @@ mh_LIBS = \ ...@@ -119,9 +119,9 @@ mh_LIBS = \
119 @MU_COMMON_LIBRARIES@ 119 @MU_COMMON_LIBRARIES@
120 LDADD = $(mh_LIBS) 120 LDADD = $(mh_LIBS)
121 scan_LDADD = $(mh_LIBS) @CURSES_LIBS@ 121 scan_LDADD = $(mh_LIBS) @CURSES_LIBS@
122 pick_SOURCES = pick.c pick.h pick-gram.c pick-gram.h 122 pick_SOURCES = pick.c pick.h pick-gram.y pick-gram.h
123 123
124 YLWRAP = $(SHELL) $(mu_aux_dir)/gylwrap 124 YLWRAP = @MU_YLWRAP@
125 AM_YFLAGS=-vt 125 AM_YFLAGS=-vt
126 126
127 inc_LDADD = \ 127 inc_LDADD = \
...@@ -144,29 +144,6 @@ inc_LDADD = \ ...@@ -144,29 +144,6 @@ inc_LDADD = \
144 ${MU_LIB_MAILUTILS}\ 144 ${MU_LIB_MAILUTILS}\
145 @MU_COMMON_LIBRARIES@ 145 @MU_COMMON_LIBRARIES@
146 146
147
148 pick-gram.c pick-gram.h: $(srcdir)/pick.y
149 $(AM_V_GEN)$(YLWRAP) "$(YACC) $(AM_YFLAGS) -d" $< \
150 y.tab.c pick-gram.c y.tab.h pick-gram.h \
151 y.output pick.output \
152 -- -yy pick_yy
153
154 mh_fmtgram.c: $(srcdir)/mh_fmtgram.y
155 $(AM_V_GEN)$(YLWRAP) "$(YACC) $(AM_YFLAGS)" $< \
156 y.tab.c mh_fmtgram.c y.output fmtgram.y.output \
157 -- -yy fmt_yy
158
159 mh_alias_gram.c mh_alias.h: $(srcdir)/mh_alias.y
160 $(AM_V_GEN)$(YLWRAP) "$(YACC) $(AM_YFLAGS) -d" $< \
161 y.tab.c mh_alias_gram.c y.tab.h mh_alias.h \
162 y.output mh_alias.output \
163 -- -yy ali_yy
164
165 mh_alias_lex.c: $(srcdir)/mh_alias.l mh_alias.h
166 $(AM_V_GEN)$(YLWRAP) "$(LEX) $(AM_LEXFLAGS) $(LEXFLAGS)" \
167 $(srcdir)/mh_alias.l lex.yy.c mh_alias_lex.c \
168 -- -yy ali_yy
169
170 install-exec-hook: 147 install-exec-hook:
171 @here=`pwd`; \ 148 @here=`pwd`; \
172 cd $(DESTDIR)$(bindir); \ 149 cd $(DESTDIR)$(bindir); \
......
1 # Configuration settings for gylwrap.
2 # See ../mu-aux/gylwrap --help, for details.
3
4 [pick-gram.y]
5 yyrepl = pick_yy
6 flags = -d
7 [mh_fmtgram.y]
8 yyrepl = fmt_yy
9 [mh_alias_gram.y]
10 yyrepl = ali_yy
11 flags = -d
12 [mh_alias_lex.l]
13 yyrepl = ali_yy
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
23 23
24 %{ 24 %{
25 #include <mh.h> 25 #include <mh.h>
26 #include <mh_alias.h> 26 #include <mh_alias_gram.h>
27 #include <sys/stat.h> 27 #include <sys/stat.h>
28 #include <mailutils/cctype.h> 28 #include <mailutils/cctype.h>
29 #include <mailutils/io.h> 29 #include <mailutils/io.h>
......
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
3 .libs 3 .libs
4 Makefile 4 Makefile
5 Makefile.in 5 Makefile.in
6 lex.yy.c 6 grammar.c
7 mimetypes-decl.h 7 grammar.h
8 mimetypes-gram.c 8 grammar.output
9 mimetypes-lex.c 9 lexer.c
10 mimetypes.output
11 mimeview 10 mimeview
12 y.output
13 y.tab.c
......
...@@ -25,28 +25,15 @@ AM_CPPFLAGS = \ ...@@ -25,28 +25,15 @@ AM_CPPFLAGS = \
25 bin_PROGRAMS = mimeview 25 bin_PROGRAMS = mimeview
26 mimeview_SOURCES = \ 26 mimeview_SOURCES = \
27 mimeview.c \ 27 mimeview.c \
28 mimetypes-gram.c \ 28 grammar.y \
29 mimetypes-lex.c \ 29 lexer.l \
30 mimetypes-decl.h \ 30 mimeview.h\
31 mimeview.h 31 grammar.h
32 32
33 YLWRAP = $(SHELL) $(mu_aux_dir)/gylwrap 33 YLWRAP = @MU_YLWRAP@
34 AM_YFLAGS=-vt 34 AM_YFLAGS=-vtd
35 AM_LEXFLAGS=-d 35 AM_LEXFLAGS=-d
36 EXTRA_DIST = mimetypes.y mimetypes.l 36 EXTRA_DIST = gylwrap.conf
37
38 mimetypes-gram.c mimetypes-decl.h: $(srcdir)/mimetypes.y
39 $(AM_V_GEN)$(YLWRAP) "$(YACC) $(AM_YFLAGS) -d" $< \
40 y.tab.c mimetypes-gram.c y.tab.h mimetypes-decl.h \
41 y.output mimetypes.output \
42 -- -yy mimetypes_yy
43
44 mimetypes-lex.c: $(srcdir)/mimetypes.l mimetypes-decl.h
45 $(AM_V_GEN)$(YLWRAP) "$(LEX) $(AM_LEXFLAGS) $(LEXFLAGS)" \
46 $(srcdir)/mimetypes.l lex.yy.c mimetypes-lex.c \
47 -- -yy mimetypes_yy
48
49 BUILT_SOURCES = mimetypes-gram.c mimetypes-lex.c mimetypes-decl.h
50 37
51 mimeview_LDADD = \ 38 mimeview_LDADD = \
52 ${MU_APP_LIBRARIES}\ 39 ${MU_APP_LIBRARIES}\
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
22 22
23 #include <mailutils/cctype.h> 23 #include <mailutils/cctype.h>
24 #include <mimeview.h> 24 #include <mimeview.h>
25 #include <mimetypes-decl.h> 25 #include <grammar.h>
26 #include <regex.h> 26 #include <regex.h>
27 27
28 static void 28 static void
......
1 # Configuration settings for gylwrap.
2 # See ../mu-aux/gylwrap --help, for details.
3 yyrepl = mimetypes_yy
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
26 #include <stdio.h> 26 #include <stdio.h>
27 #include <sys/stat.h> 27 #include <sys/stat.h>
28 #include <mimeview.h> 28 #include <mimeview.h>
29 #include <mimetypes-decl.h> 29 #include <grammar.h>
30 #include <mailutils/io.h> 30 #include <mailutils/io.h>
31 31
32 static mu_linetrack_t trk; 32 static mu_linetrack_t trk;
......
...@@ -43,8 +43,8 @@ libmu_sieve/prog.c ...@@ -43,8 +43,8 @@ libmu_sieve/prog.c
43 libmu_sieve/relational.c 43 libmu_sieve/relational.c
44 libmu_sieve/require.c 44 libmu_sieve/require.c
45 libmu_sieve/runtime.c 45 libmu_sieve/runtime.c
46 libmu_sieve/sieve.l 46 libmu_sieve/sieve-lex.l
47 libmu_sieve/sieve.y 47 libmu_sieve/sieve-gram.y
48 libmu_sieve/tests.c 48 libmu_sieve/tests.c
49 libmu_sieve/util.c 49 libmu_sieve/util.c
50 libmu_sieve/variables.c 50 libmu_sieve/variables.c
...@@ -174,8 +174,8 @@ mh/send.c ...@@ -174,8 +174,8 @@ mh/send.c
174 mh/whatnow.c 174 mh/whatnow.c
175 mh/whom.c 175 mh/whom.c
176 176
177 mimeview/mimetypes.l 177 mimeview/lexer.l
178 mimeview/mimetypes.y 178 mimeview/grammar.y
179 mimeview/mimeview.c 179 mimeview/mimeview.c
180 180
181 movemail/movemail.c 181 movemail/movemail.c
......