-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (40 loc) · 989 Bytes
/
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
CXX := /usr/bin/g++
CXXFLAGS := -O3 -Wall -Werror -std=c++20 -g
# For GCC
#LDFLAGS := -L/usr/lib -lstdc++ -lm
# For Clang
LDFLAGS :=
BUILD := ./build
OBJ_DIR := $(BUILD)/objects
APP_DIR := $(BUILD)/apps
TARGET := SonicField
INCLUDE := -I.
SRC := \
$(wildcard src/*.cpp) \
$(wildcard src/music/*.cpp) \
$(wildcard src/test/*.cpp)
OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o)
all: build $(APP_DIR)/$(TARGET)
$(OBJ_DIR)/%.o: %.cpp
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@ $(LDFLAGS)
$(APP_DIR)/$(TARGET): $(OBJECTS)
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -o $(APP_DIR)/$(TARGET) $^ $(LDFLAGS)
.PHONY: all build clean debug release test
build:
@mkdir -p $(APP_DIR)
@mkdir -p $(OBJ_DIR)
debug: CXXFLAGS += -DDEBUG -g
debug: all
release: CXXFLAGS += -O3 -g
test: kill_main
release: all
test: CXXFLAGS += -DSF_TESTS
test: kill_main
test: all
kill_main:
-@rm -vf $(OBJ_DIR)/src/main.o
clean:
-@rm -rvf $(OBJ_DIR)/*
-@rm -rvf $(APP_DIR)/*