summaryrefslogtreecommitdiff
path: root/impl/Makefile
blob: 831857d62e2eebf768c74eeddf8fc1ea344430c7 (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
40
41
42
43
44
45
46
47
CC=gcc
CPP=g++
BUILD=build
PARSER=parser
CHECKER_FLAGS=-Wall -Werror -Wextra -pedantic
FLAGS=-lantlr3c -fno-exceptions -lrt $(CHECKER_FLAGS)
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) $(CHECKER_FLAGS) -o /tmp/null -x c++ $(CHK_SOURCES)
# the - is to ignore the return code.

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

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

main.o: main.cpp *.hpp *.h
	$(CPP) -c main.cpp $(NORMAL_FLAGS)

MCFSimplex.o: MCFSimplex.cpp *.h
	$(CPP) -c MCFSimplex.cpp $(NORMAL_FLAGS)

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

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

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

clean:
	rm -rf $(BUILD)
	rm -rf $(PARSER)
	rm -rf *.o