[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LEX & YACC support
From: |
Alexandros Karypidis |
Subject: |
Re: LEX & YACC support |
Date: |
Sat, 9 Nov 2002 14:01:46 +0200 |
User-agent: |
KMail/1.4.7 |
Just a clarification. I am asking if there is a "smart" way to do this with
Makefile.am, with "smart" meaning something which does not "manually" do
this. For example, evidently the dumbest way would be:
INCLUDES = $(all_includes)
bin_PROGRAMS = mysh
wfssh_SOURCES = mysh.h mysh.c parser.y scanner.l
YFLAGS = -d
wfssh_LDADD = -lfl
mysh.o: mysh.c mysh.h parser.o scanner.o
$(COMPILE) mysh.c -c -o mysh.o
parser.h: parser.y
bison $(YFLAGS) parser.y && mv parser.tab.h parser.h && mv
parser.tab.c parser.c
parser.o: parser.y
$(COMPILE) parser.c -c -o parser.o
scanner.o: parser.h scanner.l
flex scanner.l && mv lex.yy.c scanner.c
$(COMPILE) scanner.c -c -o scanner.o
On Saturday 09 November 2002 13:39, Alexandros Karypidis wrote:
> Hi all,
>
> I am unsatisfied with the "Makefile.am" I have built, due to the fact that
> whenever I change my bison file to add a %token, I have to run make TWICE
> to get a correct build. This is because the header file with token
> declarations which is generated when yacc is run, also affects the lexical
> scanner -- therfore it needs to be rebuilt as well. However, this is only
> detected after the fist "make" command.
>
> Now, I was reading in the automake manual (section 9.7 Yacc and Lex
> support):
>
> "You should never explicitly mention the intermediate (`C' or `C++')
> file in any `SOURCES' variable; only list the source file."
>
> So I created a Makefile.am such as:
>
> === CUT HERE ===
> INCLUDES = $(all_includes)
> bin_PROGRAMS = mysh
> mysh_SOURCES = mysh.h mysh.c parser.y scanner.l
> YFLAGS = -d
> === CUT HERE ===
>
> when I change "%token" declarations in "parser.y" and run "make", the
> generated file "parser.h" is altered. But ONLY parser.c is rebuilt. I have
> to run "make" one more time in order for scanner.c to be rebuilt.
>
> I am looking for a set of Makefile.am declarations which would generate
> some kind of Makefile such as:
>
> all: wfssh
> wfssh: wfssh.c parser.o scanner.o
> gcc wfssh.c parser.o scanner.o -o wfssh -lfl
> parser.h: parser.y
> bison -d parser.y
> mv parser.tab.h parser.h
> mv parser.tab.c parser.c
> parser.o: parser.h parser.c
> gcc parser.c -o parser.o
> scanner.o: scanner.l parser.h
> flex scanner.l
> gcc scanner.c -o scanner.o
--
Αλέξανδρος Καρυπίδης
Πανεπιστήμιο Θεσσαλίας
Τμήμα Μηχ/κών Η/Υ, Τηλεπικοινωνιών & Δικτύων
Alexandros Karypidis
University of Thessaly
Computer & Communications Engineering dept.