-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathMakefile
64 lines (48 loc) · 1.34 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
# Configurables
BIN_PATH = bin
BIN_NAME = game
ifdef MINGW
CXX = i686-w64-mingw32-g++
endif
CXX ?= g++
SRC_PATH = src
OBJ_PATH = obj
# Do it Do it
INCLUDES =
ifdef MINGW
PKG_CONFIG ?= i686-w64-mingw32-pkg-config
endif
PKG_CONFIG ?= pkg-config
COMPILER_FLAGS = -Wall -Wno-comment -g `${PKG_CONFIG} --cflags sdl2` -DSQLITE_OMIT_LOAD_EXTENSION
LINK_FLAGS = `${PKG_CONFIG} --libs sdl2` -lSDL2_image -lSDL2_mixer -lsqlite3 -lm -lpthread
CFLAGS = $(COMPILER_FLAGS)
ifeq ($(OS), Windows_NT)
CFLAGS += -lmingw32 -lSDL2main
endif
rwildcard = $(wildcard $1$2)$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
SRC = $(call rwildcard,src/,*.cpp)
# SRC = $(wildcard $(SRC_PATH)/*.cpp)
# SRC = $(shell find $(SRC_PATH) -name '*.cpp' -printf '%T@\t%p\n' | sort -k 1nr | cut -f2-)
OBJ = $(SRC:$(SRC_PATH)/%.cpp=$(OBJ_PATH)/%.o)
DEP = $(OBJ:.o=.d)
.PHONY: all
all: dirs game
@$(RM) $(BIN_NAME)
@ln -s $(BIN_PATH)/$(BIN_NAME) $(BIN_NAME)
game : $(OBJ)
$(CXX) $(OBJ) $(CFLAGS) $(LINK_FLAGS) -o $(BIN_PATH)/$(BIN_NAME)
ifdef MINGW
cp /usr/i686-w64-mingw32/bin/*.dll .
endif
-include $(DEPS)
$(OBJ_PATH)/%.o: $(SRC_PATH)/%.cpp
@echo "Compiling: $< -> $@"
$(CXX) $(CFLAGS) $(INCLUDES) -MP -MMD -c $< -o $@
.PHONY: dirs
dirs:
@mkdir -p $(dir $(OBJ))
@mkdir -p $(BIN_PATH)
.PHONY: clean
clean:
@$(RM) -r $(OBJ_PATH)
@$(RM) -f $(BIN_PATH)/$(BIN_NAME) *.dll