65 lines
1.5 KiB
Makefile
65 lines
1.5 KiB
Makefile
CC := gcc
|
|
FLEX := flex
|
|
LEX := src/lexicalStructure.lex
|
|
EXE := alpha
|
|
CFLAGS :=
|
|
YACC := bison
|
|
|
|
TESTS-S1 := $(wildcard tests/sprint1/test/*.alpha)
|
|
TESTS-S3 := $(wildcard tests/sprint3/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
|
|
|
|
runner: tmp/lex.yy.c tmp/runner.o tmp/symbol_table.o
|
|
$(CC) $(CFLAGS) -o $(EXE) tmp/runner.o tmp/grammar.tab.c tmp/lex.yy.c
|
|
|
|
debug: CFLAGS += -DDEBUG=1
|
|
debug: clean compiler
|
|
|
|
test: test-s1 test-s2 test-s3
|
|
|
|
test-s1:
|
|
chmod +x ./check.sh
|
|
for test in $(TESTS-S1); do ./$(EXE) -tok $$test || echo "Test $$test failed but continuing"; done
|
|
./check.sh
|
|
|
|
test-s2:
|
|
chmod +x ./check.sh
|
|
for test in $(TESTS-S2); do ./$(EXE) -st $$test || echo "Test $$test failed but continuing"; done
|
|
./check.sh
|
|
|
|
test-s3:
|
|
chmod +x ./check.sh
|
|
for test in $(TESTS-S3); do ./$(EXE) -st $$test || echo "Test $$test failed but continuing"; done
|
|
./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
|