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

-- 
&Agr;&lgr;&eacgr;&xgr;&agr;&ngr;&dgr;&rgr;&ogr;&sfgr; &Kgr;&agr;&rgr;&ugr;&pgr;&iacgr;&dgr;&eegr;&sfgr;
&Pgr;&agr;&ngr;&egr;&pgr;&igr;&sgr;&tgr;&eeacgr;&mgr;&igr;&ogr; &THgr;&egr;&sgr;&sgr;&agr;&lgr;&iacgr;&agr;&sfgr;
&Tgr;&mgr;&eeacgr;&mgr;&agr; &Mgr;&eegr;&khgr;/&kgr;&ohacgr;&ngr; &EEgr;/&Ugr;, &Tgr;&eegr;&lgr;&egr;&pgr;&igr;&kgr;&ogr;&igr;&ngr;&ohgr;&ngr;&igr;&ohacgr;&ngr; & &Dgr;&igr;&kgr;&tgr;&uacgr;&ohgr;&ngr;

Alexandros Karypidis
University of Thessaly
Computer & Communications Engineering dept.



Reply via email to