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${
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')
# Use our replacement for the ylwrap tool
AC_SUBST([MU_YLWRAP],'$(mu_aux_dir)/gylwrap --compatibility --')
dnl Check for programs
AC_PROG_CC
AM_PROG_CC_C_O
......
......@@ -54,7 +54,7 @@ libbase_la_SOURCES = \
observer.c\
onexit.c\
opool.c\
parsedate.c\
parsedate.y\
permstr.c\
registrar.c\
refcount.c\
......@@ -82,17 +82,10 @@ AM_CPPFLAGS = \
-DLOCALEDIR=\"$(localedir)\"
YLWRAP = $(SHELL) $(mu_aux_dir)/gylwrap
AM_YFLAGS=-vt
AM_LFLAGS=-dp
YLWRAP = @MU_YLWRAP@
EXTRA_DIST = gylwrap.conf
AM_YFLAGS=
AM_LFLAGS=
EXTRA_DIST = parsedate.y
BUILT_SOURCES = parsedate.c
parsedate.c: $(srcdir)/parsedate.y
$(YLWRAP) "$(YACC) $(AM_YFLAGS)" $< \
y.tab.c parsedate.c y.output parsedate.y.output \
-- -yy pd_yy
......
# Configuration settings for gylwrap.
# See ../../mu-aux/gylwrap --help, for details.
yyrepl = pd_yy
lexer.c
parser.c
parser.h
parser.output
......
......@@ -20,9 +20,8 @@ noinst_LTLIBRARIES = libcfg.la
libcfg_la_SOURCES = \
driver.c\
format.c\
lexer.c\
parser.c\
cfg.h
lexer.l\
parser.y
localedir = $(datadir)/locale
AM_CPPFLAGS = \
......@@ -30,25 +29,15 @@ AM_CPPFLAGS = \
-DSYSCONFDIR=\"$(sysconfdir)\"\
-DLOCALEDIR=\"$(localedir)\"
EXTRA_DIST = \
lexer.l\
parser.y\
parser.h
parser.h\
gylwrap.conf
BUILT_SOURCES = parser.c parser.h lexer.c
YLWRAP = $(SHELL) $(mu_aux_dir)/gylwrap
AM_YFLAGS=-vt
YLWRAP = @MU_YLWRAP@
AM_YFLAGS=-vdt
AM_LFLAGS=-dp
parser.c parser.h: $(srcdir)/parser.y
$(AM_V_GEN)$(YLWRAP) "$(YACC) $(AM_YFLAGS) -d" $< \
y.tab.c parser.c y.tab.h parser.h \
y.output parser.y.output \
-- -yy mu_cfg_yy
lexer.c: $(srcdir)/lexer.l parser.h
$(AM_V_GEN)$(YLWRAP) "$(LEX) $(AM_LFLAGS) $(LFLAGS)" \
$(srcdir)/lexer.l lex.yy.c lexer.c \
-- -yy mu_cfg_yy
......
#include <mailutils/yyloc.h>
# Configuration settings for gylwrap.
# See ../../mu-aux/gylwrap --help, for details.
yyrepl = mu_cfg_yy
......@@ -41,7 +41,7 @@
#include <mailutils/locus.h>
#include <mailutils/stream.h>
#include <mailutils/stdstream.h>
#include "cfg.h"
#include <mailutils/yyloc.h>
#include "parser.h"
void _mu_line_begin (void);
......
......@@ -40,7 +40,7 @@
#include <mailutils/stream.h>
#include <mailutils/stdstream.h>
#include <mailutils/cidr.h>
#include "cfg.h"
#include <mailutils/yyloc.h>
int mu_cfg_parser_verbose;
static mu_list_t /* of mu_cfg_node_t */ parse_node_list;
......
......@@ -15,7 +15,7 @@
## You should have received a copy of the GNU General Public License
## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
YLWRAP = $(SHELL) $(mu_aux_dir)/gylwrap
YLWRAP = @MU_YLWRAP@
AM_YFLAGS = -dtv
#AM_LEXFLAGS=-dvp
AM_CPPFLAGS =\
......@@ -39,9 +39,8 @@ libmu_sieve_la_SOURCES = \
relational.c\
require.c\
runtime.c\
sieve-gram.c\
sieve-gram.h\
sieve-lex.c\
sieve-gram.y\
sieve-lex.l\
strexp.c\
string.c\
tests.c\
......@@ -50,24 +49,14 @@ libmu_sieve_la_SOURCES = \
libmu_sieve_la_LIBADD = ${MU_LIB_MAILUTILS} @LTDL_LIB@
libmu_sieve_la_LDFLAGS = -version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
noinst_HEADERS = sieve-priv.h
noinst_HEADERS = sieve-priv.h sieve-gram.h
BUILT_SOURCES = \
sieve-gram.c sieve-gram.h \
sieve-lex.c
MAINTAINERCLEANFILES=$(BUILT_SOURCES)
EXTRA_DIST = sieve.y sieve.l
EXTRA_DIST=gylwrap.conf
sieve-lex.c: $(srcdir)/sieve.l sieve-gram.h
$(AM_V_GEN)$(YLWRAP) "$(LEX) $(AM_LEXFLAGS) $(LEXFLAGS)" \
$(srcdir)/sieve.l lex.yy.c sieve-lex.c \
-- -yy mu_sieve_yy
sieve-gram.c sieve-gram.h: $(srcdir)/sieve.y
$(AM_V_GEN)$(YLWRAP) "$(YACC) $(AM_YFLAGS) $(YFLAGS)" $(srcdir)/sieve.y \
y.tab.c sieve-gram.c y.tab.h sieve-gram.h y.output y.output \
-- -yy mu_sieve_yy
MAINTAINERCLEANFILES=$(BUILT_SOURCES)
......
# Configuration settings for gylwrap.
# See ../mu-aux/gylwrap --help, for details.
yyrepl=mu_sieve_yy
......@@ -15,6 +15,7 @@
## You should have received a copy of the GNU General Public License
## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
YLWRAP = @MU_YLWRAP@
AM_YFLAGS=-vt
AM_CPPFLAGS = \
@MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@\
......
......@@ -14,8 +14,7 @@ forw
inc
install-mh
mark
mh_alias.h
mh_alias_gram.c
mh_alias_gram.[ch]
mh_alias_lex.c
mh_fmtgram.c
mhl
......
......@@ -68,33 +68,33 @@ noinst_LIBRARIES = libmh.a
libmh_a_SOURCES= \
compcommon.c\
mboxprop.c\
mh_alias_gram.c\
mh_alias_lex.c\
mh_alias_gram.y\
mh_alias_lex.l\
mh_getopt.c\
mh_global.c\
mh_format.c\
mh_init.c\
mh_list.c\
mh_fmtgram.c\
mh_fmtgram.y\
mh_msgset.c\
mh_sequence.c\
mh_stream.c\
mh_whatnow.c\
mh_whom.c\
whatnowenv.c
noinst_HEADERS = mh.h mh_alias.h mh_format.h mh_getopt.h
noinst_HEADERS = mh.h mh_alias_gram.h mh_format.h mh_getopt.h
BUILT_SOURCES= \
mh_fmtgram.c \
pick-gram.c \
pick-gram.h \
mh_alias_gram.c \
mh_alias_lex.c \
mh_alias.h
BUILT_SOURCES=\
mh_fmtgram.c\
pick-gram.c\
pick-gram.h\
mh_alias_gram.c\
mh_alias_gram.h\
mh_alias_lex.c
MAINTAINERCLEANFILES=$(BUILT_SOURCES)
EXTRA_DIST = mh_fmtgram.y pick.y mh_alias.y mh_alias.l
EXTRA_DIST = gylwrap.conf
mhlibdir = $(pkgdatadir)/mh
......@@ -119,9 +119,9 @@ mh_LIBS = \
@MU_COMMON_LIBRARIES@
LDADD = $(mh_LIBS)
scan_LDADD = $(mh_LIBS) @CURSES_LIBS@
pick_SOURCES = pick.c pick.h pick-gram.c pick-gram.h
pick_SOURCES = pick.c pick.h pick-gram.y pick-gram.h
YLWRAP = $(SHELL) $(mu_aux_dir)/gylwrap
YLWRAP = @MU_YLWRAP@
AM_YFLAGS=-vt
inc_LDADD = \
......@@ -144,29 +144,6 @@ inc_LDADD = \
${MU_LIB_MAILUTILS}\
@MU_COMMON_LIBRARIES@
pick-gram.c pick-gram.h: $(srcdir)/pick.y
$(AM_V_GEN)$(YLWRAP) "$(YACC) $(AM_YFLAGS) -d" $< \
y.tab.c pick-gram.c y.tab.h pick-gram.h \
y.output pick.output \
-- -yy pick_yy
mh_fmtgram.c: $(srcdir)/mh_fmtgram.y
$(AM_V_GEN)$(YLWRAP) "$(YACC) $(AM_YFLAGS)" $< \
y.tab.c mh_fmtgram.c y.output fmtgram.y.output \
-- -yy fmt_yy
mh_alias_gram.c mh_alias.h: $(srcdir)/mh_alias.y
$(AM_V_GEN)$(YLWRAP) "$(YACC) $(AM_YFLAGS) -d" $< \
y.tab.c mh_alias_gram.c y.tab.h mh_alias.h \
y.output mh_alias.output \
-- -yy ali_yy
mh_alias_lex.c: $(srcdir)/mh_alias.l mh_alias.h
$(AM_V_GEN)$(YLWRAP) "$(LEX) $(AM_LEXFLAGS) $(LEXFLAGS)" \
$(srcdir)/mh_alias.l lex.yy.c mh_alias_lex.c \
-- -yy ali_yy
install-exec-hook:
@here=`pwd`; \
cd $(DESTDIR)$(bindir); \
......
# Configuration settings for gylwrap.
# See ../mu-aux/gylwrap --help, for details.
[pick-gram.y]
yyrepl = pick_yy
flags = -d
[mh_fmtgram.y]
yyrepl = fmt_yy
[mh_alias_gram.y]
yyrepl = ali_yy
flags = -d
[mh_alias_lex.l]
yyrepl = ali_yy
......@@ -23,7 +23,7 @@
%{
#include <mh.h>
#include <mh_alias.h>
#include <mh_alias_gram.h>
#include <sys/stat.h>
#include <mailutils/cctype.h>
#include <mailutils/io.h>
......
......@@ -3,11 +3,8 @@
.libs
Makefile
Makefile.in
lex.yy.c
mimetypes-decl.h
mimetypes-gram.c
mimetypes-lex.c
mimetypes.output
grammar.c
grammar.h
grammar.output
lexer.c
mimeview
y.output
y.tab.c
......
......@@ -25,28 +25,15 @@ AM_CPPFLAGS = \
bin_PROGRAMS = mimeview
mimeview_SOURCES = \
mimeview.c \
mimetypes-gram.c \
mimetypes-lex.c \
mimetypes-decl.h \
mimeview.h
grammar.y \
lexer.l \
mimeview.h\
grammar.h
YLWRAP = $(SHELL) $(mu_aux_dir)/gylwrap
AM_YFLAGS=-vt
YLWRAP = @MU_YLWRAP@
AM_YFLAGS=-vtd
AM_LEXFLAGS=-d
EXTRA_DIST = mimetypes.y mimetypes.l
mimetypes-gram.c mimetypes-decl.h: $(srcdir)/mimetypes.y
$(AM_V_GEN)$(YLWRAP) "$(YACC) $(AM_YFLAGS) -d" $< \
y.tab.c mimetypes-gram.c y.tab.h mimetypes-decl.h \
y.output mimetypes.output \
-- -yy mimetypes_yy
mimetypes-lex.c: $(srcdir)/mimetypes.l mimetypes-decl.h
$(AM_V_GEN)$(YLWRAP) "$(LEX) $(AM_LEXFLAGS) $(LEXFLAGS)" \
$(srcdir)/mimetypes.l lex.yy.c mimetypes-lex.c \
-- -yy mimetypes_yy
BUILT_SOURCES = mimetypes-gram.c mimetypes-lex.c mimetypes-decl.h
EXTRA_DIST = gylwrap.conf
mimeview_LDADD = \
${MU_APP_LIBRARIES}\
......
......@@ -22,7 +22,7 @@
#include <mailutils/cctype.h>
#include <mimeview.h>
#include <mimetypes-decl.h>
#include <grammar.h>
#include <regex.h>
static void
......
# Configuration settings for gylwrap.
# See ../mu-aux/gylwrap --help, for details.
yyrepl = mimetypes_yy
......@@ -26,7 +26,7 @@
#include <stdio.h>
#include <sys/stat.h>
#include <mimeview.h>
#include <mimetypes-decl.h>
#include <grammar.h>
#include <mailutils/io.h>
static mu_linetrack_t trk;
......
......@@ -43,8 +43,8 @@ libmu_sieve/prog.c
libmu_sieve/relational.c
libmu_sieve/require.c
libmu_sieve/runtime.c
libmu_sieve/sieve.l
libmu_sieve/sieve.y
libmu_sieve/sieve-lex.l
libmu_sieve/sieve-gram.y
libmu_sieve/tests.c
libmu_sieve/util.c
libmu_sieve/variables.c
......@@ -174,8 +174,8 @@ mh/send.c
mh/whatnow.c
mh/whom.c
mimeview/mimetypes.l
mimeview/mimetypes.y
mimeview/lexer.l
mimeview/grammar.y
mimeview/mimeview.c
movemail/movemail.c
......