diff options
author | John-Mark Bell <jmb@netsurf-browser.org> | 2012-09-05 11:43:42 +0100 |
---|---|---|
committer | John-Mark Bell <jmb@netsurf-browser.org> | 2012-09-05 11:43:42 +0100 |
commit | 1c7bc7e17ace1e457c4c0336353f142aef36d254 (patch) | |
tree | 5aa8a948e25d05bd8f0ba0ab271d4f4f946d2d33 /src/Makefile | |
parent | d908eab7b9976c2b402cb92fa5ac77a89a112de4 (diff) | |
download | nsgenbind-1c7bc7e17ace1e457c4c0336353f142aef36d254.tar.gz nsgenbind-1c7bc7e17ace1e457c4c0336353f142aef36d254.tar.bz2 |
Fix up bison usage
Diffstat (limited to 'src/Makefile')
-rw-r--r-- | src/Makefile | 67 |
1 files changed, 23 insertions, 44 deletions
diff --git a/src/Makefile b/src/Makefile index 6b328ae..232a7dd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,42 +1,9 @@ -# +CFLAGS := $(CFLAGS) -I$(BUILDDIR) -Isrc/ -#CFLAGS+=-Wall - -#.PHONY: all clean - -#all: genjsbind - -#genjsbind: genjsbind.o genbind-parser.o genbind-lexer.o webidl-parser.o webidl-lexer.o -# $(CC) -o $@ $^ - -#webidl-parser.o: webidl-parser.c webidl-parser.h webidl-lexer.h - -#webidl-parser.h webidl-parser.c: webidl-parser.y -# bison -t $< - -#webidl-lexer.h: webidl-lexer.c - -#webidl-lexer.c: webidl-lexer.l -# flex $< - - -#genbind-parser.o: genbind-parser.c genbind-parser.h genbind-lexer.h - -#genbind-parser.h genbind-parser.c: genbind-parser.y -# bison -t $< - -#genbind-lexer.h: genbind-lexer.c - -#genbind-lexer.c: genbind-lexer.l -# flex $< - - -#genjsbind.o: webidl-parser.h genbind-parser.h - -#clean: -# $(RM) genjsbind genjsbind.o webidl-parser.c webidl-lexer.c webidl-lexer.h webidl-parser.h genbind-parser.c genbind-lexer.c genbind-lexer.h genbind-parser.h *.o +# Sources in this directory +DIR_SOURCES := genjsbind.c -CFLAGS+=-I$(BUILDDIR) -Isrc/ +SOURCES := $(SOURCES) $(BUILDDIR)/genbind-parser.c $(BUILDDIR)/genbind-lexer.c $(BUILDDIR)/webidl-parser.c $(BUILDDIR)/webidl-lexer.c $(BUILDDIR)/%-lexer.c $(BUILDDIR)/%-lexer.h: src/%-lexer.l $(VQ)$(ECHO) " FLEX: $<" @@ -44,15 +11,27 @@ $(BUILDDIR)/%-lexer.c $(BUILDDIR)/%-lexer.h: src/%-lexer.l $(BUILDDIR)/%-lexer.c: $(BUILDDIR)/%-parser.h +# Bison 2.6 and later require api.prefix, but this breaks Bison 2.5 and earlier. +bisonvsn := $(word 4,$(shell bison --version)) +bisonmaj := $(word 1,$(subst ., ,$(bisonvsn))) +bisonmin := $(word 2,$(subst ., ,$(bisonvsn))) +ifeq ($(bisonmaj),1) + BISON_DEFINES = --name-prefix=$(*F)_ +else + ifeq ($(bisonmaj),2) + ifneq ($(findstring $(bisonmin),"0 1 2 3 4 5"),) + BISON_DEFINES = --name-prefix=$(*F)_ + else + BISON_DEFINES = --define=api.prefix=$(*F)_ + endif + else + BISON_DEFINES = --define=api.prefix=$(*F)_ + endif +endif + $(BUILDDIR)/%-parser.c $(BUILDDIR)/%-parser.h: src/%-parser.y $(VQ)$(ECHO) " BISON: $<" - $(Q)bison -d -t --output=$(BUILDDIR)/$(*F)-parser.c --defines=$(BUILDDIR)/$(*F)-parser.h $< - - -# Sources in this directory -DIR_SOURCES := genjsbind.c - -SOURCES := $(SOURCES) $(BUILDDIR)/genbind-parser.c $(BUILDDIR)/genbind-lexer.c $(BUILDDIR)/webidl-parser.c $(BUILDDIR)/webidl-lexer.c + $(Q)bison -d -t $(BISON_DEFINES) --output=$(BUILDDIR)/$(*F)-parser.c --defines=$(BUILDDIR)/$(*F)-parser.h $< # Grab the core makefile include $(NSBUILD)/Makefile.subdir |