# ----- Definitions ----- CC := gcc FLEX := flex BISON = bison CFLAGS := -ggdb -g -O0 #-fsanitize=address # LDFLAGS := -fsanitize=address BISONFLAGS := -d -Wcounterexamples LEX := src/lexicalStructure.lex YACC := src/grammar.y EXE := alpha OBJS := tmp/runner.o tmp/symbol_table.o tmp/grammar.tab.o tmp/lex.yy.o tmp/intermediate_code.o tmp/codegen.o # ---------- # ----- Targets ----- all: compiler compiler: clean tmp $(OBJS) $(CC) $(CFLAGS) -o $(EXE) $(OBJS) $(LDFLAGS) clean: rm -f $(EXE) rm -rf out rm -rf tmp rm -f *.s rm -f *.out tmp: mkdir -p tmp tmp/grammar.tab.c tmp/grammar.tab.h: $(YACC) $(BISON) $(BISONFLAGS) -o tmp/grammar.tab.c $(YACC) tmp/lex.yy.c tmp/flex.h: $(LEX) tmp/grammar.tab.h $(FLEX) -o tmp/lex.yy.c $(LEX) mv flex.h tmp/flex.h # ----------- # ----- Create Objs ----- tmp/grammar.tab.o: tmp/grammar.tab.c $(CC) $(CFLAGS) -c tmp/grammar.tab.c -o tmp/grammar.tab.o tmp/lex.yy.o: tmp/lex.yy.c $(CC) $(CFLAGS) -c tmp/lex.yy.c -o tmp/lex.yy.o tmp/symbol_table.o: src/symbol_table.c src/symbol_table.h $(CC) $(CFLAGS) -c src/symbol_table.c -o tmp/symbol_table.o tmp/intermediate_code.o: src/intermediate_code.c src/intermediate_code.h $(CC) $(CFLAGS) -c src/intermediate_code.c -o tmp/intermediate_code.o tmp/codegen.o: src/codegen.c src/codegen.h $(CC) $(CFLAGS) -c src/codegen.c -o tmp/codegen.o tmp/runner.o: src/runner.c src/runner.h tmp/flex.h tmp/grammar.tab.h $(CC) $(CFLAGS) -c src/runner.c -o tmp/runner.o # ----------- # ----- Tests ----- test: chmod +x ./test.sh ./test.sh tests/sprint1/test/ -diff ./test.sh tests/sprint2/test/ -diff ./test.sh tests/sprint3/test/ -diff ./test.sh tests/sprint4/test/ -diff ./test.sh tests/given/test/ -diff test-s1: chmod +x ./test.sh ./test.sh tests/sprint1/test/ -diff test-s2: chmod +x ./test.sh ./test.sh tests/sprint2/test/ -diff test-s3: chmod +x ./test.sh ./test.sh tests/sprint3/test/ -diff test-s4: chmod +x ./test.sh ./test.sh tests/sprint4/test/ -diff test-given: chmod +x ./test.sh ./test.sh tests/given/test/ -diff # -----------