-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (43 loc) · 1.42 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
CXX = g++
LD = g++
COMMON_FLAGS = -Wall
COMMON_FLAGS += -pedantic
COMMON_FLAGS += -std=c++17
COMMON_FLAGS += -I$(SOURCE_DIR)
CXX_FLAGS = $(COMMON_FLAGS)
CXX_FLAGS += -c
CXX_FLAGS += -O1
CXX_FLAGS += -MMD
LD_FLAGS = $(COMMON_FLAGS)
LD_FLAGS += -lpthread
SOURCE_DIR = src
BINARY_DIR = bin
TEST_DIR = test
EXTERNAL_DIR = src/External
REGISTER_MACHINE_DIR = registerMachine/registerMachine
MAIN = $(SOURCE_DIR)/Main.cpp
ALL_SOURCES = $(shell find $(SOURCE_DIR) -type f -name *.cpp ! -iname Parser.cpp ! -iname Scanner.cpp)
ALL_TESTS = $(shell find $(TEST_DIR) -type d)
SOURCES = $(filter-out $(MAIN), $(ALL_SOURCES))
OBJECTS := $(patsubst %.cpp,%.o,$(SOURCES))
OBJECTS := $(patsubst $(SOURCE_DIR)/%,$(BINARY_DIR)/%,$(OBJECTS))
all: start kompilator
.PHONY : kompilator
start:
flex -o $(EXTERNAL_DIR)/Scanner.cpp $(EXTERNAL_DIR)/scanner.l
bison -d -o $(EXTERNAL_DIR)/Parser.cpp $(EXTERNAL_DIR)/parser.y
kompilator: $(MAIN) $(OBJECTS)
$(LD) $(LD_FLAGS) $(OBJECTS) $(MAIN) -o $@
(cd $(REGISTER_MACHINE_DIR) && make maszyna-rejestrowa)
(mv $(REGISTER_MACHINE_DIR)/maszyna-rejestrowa emulator.exe)
echo $(ALL_TESTS) | xargs -n 1 cp kompilator
echo $(ALL_TESTS) | xargs -n 1 cp emulator.exe
echo $(ALL_TESTS) | xargs -n 1 cp emulator.py
$(BINARY_DIR)/%.o: $(SOURCE_DIR)/%.cpp | $(dir $@)
@mkdir -p $(dir $@)
$(CXX) $(CXX_FLAGS) $< -o $@
clear:
rm -rf $(BINARY_DIR)/
rm kompilator
rm *.exe
-include $(OBJECTS:%.o=%.d)