diff --git a/Makefile b/Makefile index 87e50e5..c5213ff 100644 --- a/Makefile +++ b/Makefile @@ -1,33 +1,10 @@ +export SCONSFLAGS := -Q -SHELL := bash +all: + @scons -TARGET := fart -ifdef WIN32 -export CPPFLAGS += -I"$(shell cd)" -else -export CPPFLAGS += -I"$(shell pwd)" -endif -export CXXFLAGS := -Wall -O2 - -LDFLAGS := -lfl -lpthread -lfreeimage - -SUBDIRS := util shapes main parser distrib - -all: $(TARGET) - -.PHONY: $(TARGET) -$(TARGET): - @for d in $(SUBDIRS); \ - do $(MAKE) -C $$d; \ - ret=$$?; \ - if [[ $$ret != 0 ]]; then \ - exit $$ret; \ - fi; \ - done - $(CXX) -o $@ $(patsubst %,%/*.o,$(SUBDIRS)) $(CXXFLAGS) $(LDFLAGS) +install: + @scons $@ clean: - @for d in $(SUBDIRS); \ - do $(MAKE) -C $$d clean CLEAN=1; \ - done - -rm -f $(TARGET) + @scons -c diff --git a/SConstruct b/SConstruct new file mode 100644 index 0000000..2197b32 --- /dev/null +++ b/SConstruct @@ -0,0 +1,25 @@ +# vim:syntax=python + +import os + +target = 'fart' +subdirs = ['util', 'shapes', 'main', 'distrib'] +parser_sources = Glob('parser/*.cc') +sources = map(lambda x: Glob(x + '/*.cc'), subdirs) +lexer_source = 'parser/lex.yy.cc' +parser_source = 'parser/parser.tab.cc' +for f in parser_sources: + if str(f) != lexer_source and str(f) != parser_source: + sources.append(f) +sources += [lexer_source, parser_source] + +env = Environment(CPPFLAGS = '-I.', + CXXFLAGS = '-Wall -O2', + YACCFLAGS = '-d', + LIBS = ['-lfl', '-lpthread', '-lfreeimage']) + +lexer = env.CXXFile(lexer_source, 'parser/parser.ll') +parser = env.CXXFile(parser_source, 'parser/parser.yy') +env.Depends(lexer, parser_source) + +env.Program(target, sources) diff --git a/distrib/Makefile b/distrib/Makefile deleted file mode 100644 index a210eec..0000000 --- a/distrib/Makefile +++ /dev/null @@ -1,23 +0,0 @@ - -OBJS := $(patsubst %.cc,%.o,$(wildcard *.cc)) -DEPS := $(OBJS:.o=.dep) - -all: $(DEPS) $(OBJS) - -%.o: %.cc - $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $< - -# Make dependency files -%.dep: %.cc - @set -e; rm -f $@; \ - $(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -clean: - -$(RM) -f *.o *.dep - -# Include dependency files -ifndef CLEAN --include $(DEPS) -endif diff --git a/main/Makefile b/main/Makefile deleted file mode 100644 index a210eec..0000000 --- a/main/Makefile +++ /dev/null @@ -1,23 +0,0 @@ - -OBJS := $(patsubst %.cc,%.o,$(wildcard *.cc)) -DEPS := $(OBJS:.o=.dep) - -all: $(DEPS) $(OBJS) - -%.o: %.cc - $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $< - -# Make dependency files -%.dep: %.cc - @set -e; rm -f $@; \ - $(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -clean: - -$(RM) -f *.o *.dep - -# Include dependency files -ifndef CLEAN --include $(DEPS) -endif diff --git a/parser/Makefile b/parser/Makefile deleted file mode 100644 index d44b564..0000000 --- a/parser/Makefile +++ /dev/null @@ -1,37 +0,0 @@ - -FLEX := flex -BISON := bison - -PARSER := parser - -OBJS := lex.yy.o $(PARSER).tab.o $(patsubst %.cc,%.o,$(wildcard *.cc)) -DEPS := $(OBJS:.o=.dep) - -all: $(DEPS) $(OBJS) - -%.o: %.cc - $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $< - -$(PARSER).tab.cc $(PARSER).tab.hh: $(PARSER).yy - $(BISON) -d $< - -lex.yy.o: lex.yy.cc - -lex.yy.cc: $(PARSER).tab.hh -lex.yy.cc: $(PARSER).lex - $(FLEX) -o $@ $< - -# Make dependency files -%.dep: %.cc - @set -e; rm -f $@; \ - $(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -clean: - -rm -f lex.yy.cc $(PARSER).tab.cc $(PARSER).tab.hh *~ *.o *.dep - -# Include dependency files -ifndef CLEAN --include $(DEPS) -endif diff --git a/parser/parser.lex b/parser/parser.ll similarity index 100% rename from parser/parser.lex rename to parser/parser.ll diff --git a/shapes/Makefile b/shapes/Makefile deleted file mode 100644 index b26680d..0000000 --- a/shapes/Makefile +++ /dev/null @@ -1,23 +0,0 @@ - -OBJS := $(patsubst %.cc,%.o,$(wildcard *.cc)) -DEPS := $(OBJS:.o=.dep) - -all: $(DEPS) $(OBJS) - -%.o: %.cc - $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $< - -# Make dependency files -%.dep: %.cc - @set -e; rm -f $@; \ - $(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -clean: - -$(RM) -f *.o *.dep - -# Include dependency files -ifndef clean --include $(DEPS) -endif diff --git a/util/Makefile b/util/Makefile deleted file mode 100644 index a210eec..0000000 --- a/util/Makefile +++ /dev/null @@ -1,23 +0,0 @@ - -OBJS := $(patsubst %.cc,%.o,$(wildcard *.cc)) -DEPS := $(OBJS:.o=.dep) - -all: $(DEPS) $(OBJS) - -%.o: %.cc - $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $< - -# Make dependency files -%.dep: %.cc - @set -e; rm -f $@; \ - $(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -clean: - -$(RM) -f *.o *.dep - -# Include dependency files -ifndef CLEAN --include $(DEPS) -endif