-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
46 lines (41 loc) · 1.38 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
PROGRAM = parser
GRAMMARFOLDER = ./Linux/
BUILDFOLDER = build/
BUILDIO = build/io
NASM = nasm
BUILDIOEXIST = $(shell if [ -d $(BUILDIO) ]; then echo "exist"; else echo "notexist"; fi;)
GRAMMAREXIST = $(shell if [ -d $(GRAMMARFOLDER) ]; then echo "exist"; else echo "notexist"; fi;)
BUILDEXIST = $(shell if [ -d $(BUILDFOLDER) ]; then echo "exist"; else echo "notexist"; fi;)
DEPS = $(shell find ./ -name "*.h")
SRC = $(shell find ./ -name "*.cpp")
OBJ = $(SRC:%.cpp=%.o)
CXX = g++
FLEX = flex
BISON = bison
CXXVER = c++11
$(PROGRAM): $(OBJ)
$(CXX) -o $(PROGRAM) $(OBJ) -std=$(CXXVER) -g
grammar: lexer.l grammar.y
ifeq ($(GRAMMAREXIST),notexist)
mkdir $(GRAMMARFOLDER)
endif
$(BISON) --output="./Linux/grammar.tab.cpp" --defines="./Linux/grammar.tab.h" grammar.y
$(FLEX) --outfile="./Linux/lexer.flex.cpp" lexer.l
sed -i "1i\#include \"../common/trees.h\"" ./Linux/grammar.tab.h
%.o: %.cpp $(DEPS)
$(CXX) -c $< -o $@ -std=$(CXXVER) -g
clean:
rm -rf $(GRAMMARFOLDER) $(OBJ) $(PROGRAM) $(BUILDFOLDER) common/util/io/asm_io.o
build:
ifeq ($(BUILDEXIST),notexist)
mkdir $(BUILDFOLDER)
endif
ifeq ($(BUILDIOEXIST),notexist)
mkdir $(BUILDIO)
endif
$(NASM) -f elf -d ELF_TYPE common/util/io/asm_io.asm -o common/util/io/asm_io.o
cp $(PROGRAM) $(BUILDFOLDER)
cp common/util/io/asm_io.o $(BUILDIO)
cp common/util/io/asm_io.inc $(BUILDIO)
cp -r test/ $(BUILDFOLDER)
cp example/Makefile $(BUILDFOLDER)