summaryrefslogtreecommitdiff
path: root/impl/Makefile
blob: 213657b0a06280c7a03a4607837c7cc9f6c6473c (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
CC=gcc
CPP=g++
BUILD=build
PARSER=parser
FLAGS=-Wall -Werror -Wextra -pedantic -lantlr3c -std=c++11
NORMAL_FLAGS=$(FLAGS) -g -pg
OPTIMISED_FLAGS=$(FLAGS) -O3

all: $(BUILD)/main

main: $(BUILD)/main
fast: $(BUILD)/fast

.PHONY: check-syntax
check-syntax: $(PARSER)
	-$(CPP) $(FLAGS) -o /tmp/null -x c++ $(CHK_SOURCES)
# the - is to ignore the return code.

$(BUILD)/main: $(BUILD) $(PARSER) main.cpp *.hpp
	$(CPP) main.cpp $(PARSER)/*.o -o $(BUILD)/main $(NORMAL_FLAGS)

$(BUILD)/fast: $(BUILD) $(PARSER) main.cpp *.hpp
	$(CPP) main.cpp $(PARSER)/*.o -o $(BUILD)/fast $(OPTIMISED_FLAGS)

$(PARSER): EquationSystem.g
	mkdir -p $(PARSER)
	java -jar ../antlr/antlr-3.4-complete.jar -o $(PARSER) EquationSystem.g
	cd $(PARSER); $(CC) *.c -c -lantrl3c

$(BUILD):
	mkdir -p $(BUILD)

.PHONY: test
test: $(BUILD)/main
	bash ./test/run ./build/main

clean:
	rm -rf $(BUILD)
	rm -rf $(PARSER)