-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
69 lines (51 loc) · 1.45 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
TARGET_EXEC ?= program
BUILD_DIR ?= ./out
SRC_DIRS ?= ./src
SRCS := $(shell find $(SRC_DIRS) -name '*.cpp' -or -name '*.c' -or -name '*.s')
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
#$(pkg-config --cflags --libs sdl2)
#-Wall
# -ffast-math -funsafe-math-optimizations -ffinite-math-only
#-fprofile-generate
#-fprofile-use
LDFLAGS ?= -lm -std=c++17 -Ofast -frename-registers -funroll-loops
CFLAGS = -Wall
#CXXFLAGS = -Wall -Wextra -Werror
CXXFLAGS = -Wall -std=c++17 -Ofast -frename-registers -funroll-loops
CC = g++
CXX = g++
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
$(CC) $(OBJS) -o $@ $(LDFLAGS)
./$(BUILD_DIR)/$(TARGET_EXEC)
# assembly
$(BUILD_DIR)/%.s.o: %.s
$(MKDIR_P) $(dir $@)
$(AS) $(ASFLAGS) -c $< -o $@
# c source
$(BUILD_DIR)/%.c.o: %.c
$(MKDIR_P) $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
# c++ source
$(BUILD_DIR)/%.cpp.o: %.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
.PHONY: clean run auto $(BUILD_DIR)/$(TARGET_EXEC)
clean:
-$(RM) -r $(BUILD_DIR)
-$(RM) -r .vscode
run:
./$(BUILD_DIR)/$(TARGET_EXEC)
memcheck:
valgrind --leak-check=yes ./$(BUILD_DIR)/$(TARGET_EXEC)
memcheck_full:
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./$(BUILD_DIR)/$(TARGET_EXEC)
bear: clean
make -B
view:
convert image.ppm image.png
-include $(DEPS)
MKDIR_P ?= mkdir -p