Hello,
I was part of the FAD, Pune held on 24th Sept. Following this I tried to use autotools with a small code that I am working on. The issue is that it uses lex and yacc and I haven't been able to make it work.
The present Makefile that I am using does the following: CC=cc LEXFLAG=-ll YACCFLAG=-ly appname=lp
$(appname): y.tab.o lex.yy.o lp.o lp.h $(CC) -o $(appname) lex.yy.o y.tab.o lp.o $(LEXFLAG) $(YACCFLAG)
y.tab.o: y.tab.c $(CC) -c y.tab.c $(YACCFLAG)
lex.yy.o: lex.yy.c $(CC) -c lex.yy.c $(LEXFLAG)
lex.yy.c: ie.l lex ie.l
y.tab.c: ie_parser.y yacc -d ie_parser.y
lp.o: lp.c $(CC) -c lp.c
My configure.ac file reads as follows AC_INIT([language-parser],[1.0],gautam.akiwate@gmail.com) AM_INIT_AUTOMAKE(dist-bzip2) AM_MAINTAINER_MODE AC_PROG_CC AC_PROG_INSTALL AC_PROG_YACC AM_PROG_LEX AC_OUTPUT([Makefile])
And the Makefile.am file has the following content AM_YFLAGS = -d BUILT_SOURCES = ie_parser.h bin_PROGRAMS = lparser lparser_SOURCES = ie.l ie_parser.y lp.h lp.c noinst_HEADERS = lp.h
The following commands go through without error $aclocal $autoconf $automake -a -c $./configure
But when I do a make it generates an error saying that it is unable to find yylwrap etc.
Can somebody please help me with this?
PS: Apologies for the long mail.
Regards Gautam
Hi,
--- On Mon, Sep 26, 2011 at 10:01 PM, Gautam Akiwate gautam.akiwate@gmail.com wrote: | But when I do a make it generates an error saying that it is unable to find | yylwrap etc. --
In addition, I also got the error 'undefined reference to yyerror' when I tried your language-parser-1.0 sources that you had sent. I added the following in ie_parser.c after the inclusion of lp.h:
=== CODE ===
/* Line 189 of yacc.c */ #line 20 "ie_parser.y"
#include<stdio.h> #include "lp.h"
+ void yyerror (char *s) + { + fprintf (stderr, "%s\n", s); + }
=== END ===
I also added a yywrap() before the main() function in ie_parser.c:
=== CODE ===
+ int yywrap() + { + return (1); + }
main(){ do { yyparse(); } while(!feof(yyin)); }
=== END ===
I was then able to build, and test run it:
$ aclocal; autoconf; automake -a -c $ ./configure; make $ ./lparser < learn.txt
SK
On Mon, Sep 26, 2011 at 10:01 PM, Gautam Akiwate gautam.akiwate@gmail.com wrote:
AC_PROG_YACC AM_PROG_LEX
The problem with these macros are that they only generate warnings and do not die with an error. So if you want to surely die if there is no lex/yacc on the system, then you will need to add additional checks. The autotools info doc has more information on how you can do this.