61 lines
1.3 KiB
Makefile
61 lines
1.3 KiB
Makefile
CC := gcc
|
|
FLEX := flex
|
|
LEX := src/lexicalStructure.lex
|
|
EXE := alpha
|
|
CFLAGS :=
|
|
YACC := bison
|
|
|
|
TESTS-S1 := $(wildcard tests/sprint1/test/*.alpha)
|
|
TESTS-S2 := $(wildcard tests/sprint2/test/*.alpha)
|
|
|
|
compiler: clean runner
|
|
|
|
tmp/grammar.tab.c: src/grammar.y
|
|
mkdir -p tmp
|
|
$(YACC) -d src/grammar.y
|
|
mv grammar.tab.c tmp/
|
|
mv grammar.tab.h tmp/
|
|
|
|
tmp/lex.yy.c: src/lexicalStructure.lex tmp/grammar.tab.c
|
|
$(FLEX) -o tmp/lex.yy.c $(LEX)
|
|
mv flex.h tmp/
|
|
|
|
tmp/runner.o: src/runner.c src/runner.h tmp/flex.h
|
|
$(CC) $(CFLAGS) -o tmp/runner.o -c src/runner.c
|
|
|
|
tmp/symbol_table.o: src/symbol_table.c src/symbol_table.h
|
|
$(CC) $(CFLAGS) -o tmp/symbol_table.o -c src/symbol_table.c
|
|
|
|
parser : tmp/lex.yy.c tmp/grammar.tab.c
|
|
$(CC) -o parser tmp/lex.yy.c tmp/grammar.tab.c
|
|
|
|
runner: tmp/lex.yy.c tmp/runner.o tmp/symbol_table.o
|
|
$(CC) $(CFLAGS) -o $(EXE) tmp/runner.o tmp/lex.yy.c tmp/symbol_table.o
|
|
|
|
debug: CFLAGS += -DDEBUG=1
|
|
debug: clean compiler
|
|
|
|
test: test-s1 test-s2
|
|
|
|
test-s1:
|
|
chmod +x ./check.sh
|
|
$(foreach test, $(TESTS-S1), ./$(EXE) -tok $(test);)
|
|
./check.sh
|
|
|
|
test-s2:
|
|
chmod +x ./check.sh
|
|
$(foreach test, $(TESTS-S2), ./$(EXE) -tok $(test);)
|
|
./check.sh
|
|
|
|
clean:
|
|
rm -f *.o
|
|
rm -f lex.yy.c
|
|
rm -f $(EXE)
|
|
rm -f flex.h
|
|
rm -f *.tok
|
|
rm -f grammar.tab.c
|
|
rm -f grammar.tab.h
|
|
rm -f *.st
|
|
rm -rf out
|
|
rm -rf tmp
|
|
rm -f parser
|