CPPFLAGS=$(shell llvm-config --cxxflags)
LDFLAGS=$(shell llvm-config --ldflags --libs)

kaleidoscope: lex.yy.o parser.tab.o ast.o
	clang++ -std=c++1 -Wall $(LDFLAGS) -o $@ $^
lex.yy.o: lex.yy.c parser.tab.hpp
	clang++ $(CPPFLAGS) -Wno-deprecated -c -o $@ $<
lex.yy.c: lexer.lex
	flex $<
parser.tab.o: parser.tab.cpp parser.tab.hpp ast.hpp
	clang++ $(CPPFLAGS) -c -o $@ $<
parser.tab.cpp parser.tab.hpp: parser.ypp
	bison -d -v $<
ast.o: ast.cpp ast.hpp
	clang++ $(CPPFLAGS) -c -o $@ $<

.PHONY: clean

clean:
	rm -f *~ *tab* lex.yy.c *.o *output kaleidoscope




