-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
56 lines (40 loc) · 1.35 KB
/
Copy pathmakefile
File metadata and controls
56 lines (40 loc) · 1.35 KB
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
#Configurasi Compiler
CXX = g++
CXXFLAGS = -Wall -Wextra -std=c++17 -g -O0 -fsanitize=address -fsanitize=undefined
TARGET = jeecompiler
SRC_DIR = src
BUILD_DIR = build
CODEGEN_DIR = src/codegen
INTERPRETER_DIR = src/interpreter
CODEGEN_BUILD_DIR = build/codegen
INTERPRETER_BUILD_DIR = build/interpreter
SRCS = $(SRC_DIR)/main.cpp\
$(wildcard $(SRC_DIR)/common/*.cpp)\
$(wildcard $(SRC_DIR)/lexer/*.cpp)\
$(wildcard $(SRC_DIR)/syntax/*.cpp)\
$(wildcard $(SRC_DIR)/semantic/*.cpp)\
$(wildcard $(CODEGEN_DIR)/*.cpp)\
$(wildcard $(INTERPRETER_DIR)/*.cpp)
HDRS = $(shell find $(SRC_DIR) -name '*.hpp')
# Menentuka file Object (.o)
# Mengubah path src/xxx/file.cpp menjadi build/xxx/file.o
OBJS = $(patsubst src/%,build/%,$(SRCS:.cpp=.o))
all: $(TARGET)
run: $(TARGET)
./$(TARGET)
# Proses Linking (Menyatukan file .o menjadi program aplikasi)
$(TARGET) : $(OBJS)
echo "Linking file.."
$(CXX) $(CXXFLAGS) -o $@ $^
@echo "Build sukses! Jalankan dengan ./$(TARGET)"
# Proses Compile merubah .cpp menjadi .o
build/%.o: src/%.cpp $(HDRS)
@mkdir -p $(dir $@)
@echo "Compiling $<..."
$(CXX) $(CXXFLAGS) -c $< -o $@
# Membersihkan File Hasil Compile (Dijalankan dengan 'make clean')
clean:
@echo "Membersihkan file build..."
rm -rf $(BUILD_DIR)/*
# Memberitahu make bahwa 'all', 'run' dan 'clean' bukanlah nama file
.PHONY: all run clean