diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-06-11 13:33:18 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-06-11 13:33:18 +0100 |
commit | 768988d88470ffc1c64c35d6f9d3c37a9a6f75da (patch) | |
tree | e1af2f6bf6b69583bdf25e3cbb83e2c842d925d8 /src/Makefile | |
parent | 602a6b133f83e2349a4b233536fdca90446638cd (diff) | |
download | libnslog-768988d88470ffc1c64c35d6f9d3c37a9a6f75da.tar.gz libnslog-768988d88470ffc1c64c35d6f9d3c37a9a6f75da.tar.bz2 |
Simple parser for filter syntax
Diffstat (limited to 'src/Makefile')
-rw-r--r-- | src/Makefile | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile index 7fbad1c..3ca70cd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,3 +1,37 @@ DIR_SOURCES := core.c filter.c +CFLAGS := $(CFLAGS) -I$(BUILDDIR) -Isrc/ + +SOURCES := $(SOURCES) $(BUILDDIR)/filter-parser.c $(BUILDDIR)/filter-lexer.c + +$(BUILDDIR)/%-lexer.c $(BUILDDIR)/%-lexer.h: src/%-lexer.l + $(VQ)$(ECHO) " FLEX: $<" + $(Q)$(FLEX) --outfile=$(BUILDDIR)/$(*F)-lexer.c --header-file=$(BUILDDIR)/$(*F)-lexer.h $< + +$(BUILDDIR)/%-lexer.c: $(BUILDDIR)/%-parser.h + +# Bison 3.0 and later require api.prefix in curly braces +# Bison 2.6 and later require api.prefix +# Bison 2.5 and earlier require name-prefix switch +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 $(BISON_DEFINES) --report=all --output=$(BUILDDIR)/$(*F)-parser.c --defines=$(BUILDDIR)/$(*F)-parser.h $< + include $(NSBUILD)/Makefile.subdir |