-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
113 lines (86 loc) · 2.69 KB
/
Makefile
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
CXX=clang++
CXXFLAGS=-std=c++17 -Wall -g
parser_files = src/generated_parser.cpp src/generated_parser.hpp src/generated_parser.output
scanner_files = src/scanner.cpp
generated_files = $(parser_files) $(scanner_files)
generated_headers = src/generated_parser.hpp
generated_srcs = src/scanner.cpp src/generated_parser.cpp
generated_objs = $(patsubst src/%.cpp,build/%.o,$(generated_srcs))
# Arquivos de bibliotecas
src_lib=$(wildcard src/*.cpp)
objs=$(sort $(patsubst src/%.cpp,build/%.o,$(src_lib)) $(generated_objs) )
# Arquivos de executáveis
src_main=$(wildcard main/*.cpp)
mains=$(patsubst main/%.cpp,bin/%,$(src_main))
src_custom=$(wildcard custom/*.cpp)
customs=$(patsubst custom/%.cpp,bin/custom/%,$(src_custom))
all: exe
# TODO separate dependencies on binaries
test-parsing: exe
@./run_parsing_tests.sh
render-asts: exe
@./run_render_asts.sh
test-codegen: exe
./run_codegen_tests.sh factorial
./run_codegen_tests.sh if-else
./run_codegen_tests.sh and-or
./run_codegen_tests.sh matrix
./run_codegen_tests.sh vector-access
format:
clang-format -i src/**.cpp src/**.hpp
doxygen:
doxygen
cp=cp3
pdf:
pandoc ./relatorio-dope-$(cp).md -o ./relatorio-dope-$(cp).pdf
name="compiladores-dope-$(cp)"
zip:
@# zip -r compiladores-dope-$(cp).zip ./ -x '.git/*' 'tmp/*' 'doxy/*' '.dep/*'
git archive --prefix=$(name)/ -o $(name).zip HEAD
clean:
rm -f -r ./.dep
rm -f -r ./bin
rm -f -r ./build
rm -f -r ./doxy
rm -f $(generated_files)
show-versions:
make --version
@echo
flex --version
@echo
bison --version
@echo
clang --version
@echo
node --version
@echo
flex: $(scanner_files)
bison: $(parser_files)
exe: $(mains) $(customs)
# bin/dump-tokens: src/scanner.cpp custom/dump-tokens.cpp
# mkdir -p ./bin
# $(CXX) $(CXXFLAGS) -o "$@" $^ -D DUMP_TOKENS
$(parser_files): src/parser.y
cd src/; bison -v "parser.y"
$(scanner_files): src/scanner.l src/generated_parser.hpp
cd src/; flex "scanner.l"
$(objs) $(customs): $(generated_headers)
$(mains): $(objs)
# Compila bibliotecas de src/ para build/
build/%.o: src/%.cpp
@ mkdir -p build/ $(dir .dep/src/%)
$(CXX) $(CXXFLAGS) -o $@ -c $<
@ $(CXX) $(CXXFLAGS) -MM -MT $@ $< > .dep/$<.d
# Compila de main/ para para bin/
bin/%: main/%.cpp $(objs)
@ mkdir -p bin/ build/main/ $(dir ./.dep/main/%)
$(CXX) $(CXXFLAGS) -I "./src/" -c -o build/main/$*.o $<
$(CXX) $(CXXFLAGS) -I "./src/" -o $@ build/main/$*.o $(objs)
@ $(CXX) $(CXXFLAGS) -I "./src/" -MM -MT $@ $< > .dep/$<.d
# Compila de main/ para para bin/
bin/custom/%: custom/%.cpp
@ mkdir -p bin/custom/ $(dir ./.dep/custom/%)
$(CXX) $(CXXFLAGS) -I "./src/" -o $@ $<
@ $(CXX) $(CXXFLAGS) -I "./src/" -MM -MT $@ $< > .dep/$<.d
# Inclui as listas de dependências
include $(wildcard .dep/**/*)