bison, flex and make problem
Im trying to get bison and flex to compile using my makefile, but i just cant get it to work. This is the makefile i use...
what make is this? gnu? This does not look like a gnu make file to me.
is this windows? linux?
what do you mind compile? are you compiling bison/flex? or compiling a program that uses a flex generated lexer and a bison parser?
You're going to have to explain what you are doing.
Oh sorry. Its a gnu make file for linux and im trying to compile a bison and flex grammer file. I just cant figure out how to fit it into the makefile, and get it to work right. My biggest problem is getting it to compile the bison file before the flex file so that it can use the .h file produced by bison.
Below is a simple makefile to compile a program called 'programmenu'. programmenu was a small floating gtk gui menu that used a XML grammer parser that was made with flex and bison.
The first target, 'all' is always the default target. That is the target that is built if none is specified.
note that I have a target called lex.yy.c. This is the lexer source that flex produces. There is also a target called lex.yy.o. Look at it's dependencies 'lex.yy.c' and 'y.tab.h'. 'y.tab.h' is generated by bison by default, and is needed for compiling the lexer source generated by flex.
I think you read the bison, flex manpages if you haven't already and look closely at the dependency tree in the makefile below.
CC = gcc
LDFLAGS = `gtk-config --libs`
CFLAGS = `gtk-config --cflags` -g -Wall
PROGRAM = programmenu
programmenu: menu.o y.tab.o lex.yy.o tree.o
$(CC) $(LDFLAGS) menu.o y.tab.o lex.yy.o tree.o -o $(PROGRAM)
$(CC) $(CFLAGS) -c menu.c
$(CC) $(CFLAGS) -c y.tab.c
lex.yy.o: lex.yy.c y.tab.h
$(CC) $(CFLAGS) -Wno-unused -c lex.yy.c
tree.o: tree.c tree.h
$(CC) $(CFLAGS) -c tree.c
bison -ydv menu.y
flex -i menu.lex
/bin/rm -f $(PROGRAM) *.o lex.yy.c y.tab.c y.tab.h y.output core
My problem with the makefile in your post though is that you have to write out the dependencies yourself. In mine, for each file it will create a .d file with the dependencies in the file, then you just include the file, and it does all by itself. If i did it your way, it would be easy. But id like to fit it into mine.
|All times are GMT -5. The time now is 06:42 PM.|