-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile_Test
More file actions
57 lines (44 loc) · 1.87 KB
/
Copy pathMakefile_Test
File metadata and controls
57 lines (44 loc) · 1.87 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
56
57
CXX := g++
CXXFLAGS :=
AR := ar
ARFLAGS := -rv
INC := include
BIN := bin
SRC := src
OBJ := obj
LIB := lib
SDL_INC := i686-w64-mingw32/include/SDL2
SDL_LIB := i686-w64-mingw32/lib
INCLUDE_PATHS := -I$(SRC) -I$(INC)/SDL2-2.0.12/$(SDL_INC) -I$(INC)/SDL2_image-2.0.5/$(SDL_INC) -I$(INC)/SDL2_ttf-2.0.15/$(SDL_INC)
LIBRARY_PATHS := -L$(INC)/SDL2-2.0.12/$(SDL_LIB) -L$(INC)/SDL2_image-2.0.5/$(SDL_LIB) -L$(INC)/SDL2_ttf-2.0.15/$(SDL_LIB)
LINKER_FLAGS := -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf
GAME_LIBRARY := -L$(LIB) -lGameEngine
DEPFLAGS := -MM $(INCLUDE_PATHS)
# Get all header file dependencies relative to ./ and convert to .cpp
SOURCES = $(shell realpath --relative-to ./ $(patsubst %.h,%.cpp,$(filter $(SRC)/%.h, $(shell $(CXX) $(DEPFLAGS) $1))))
# Filter out missing .cpp files
EXIST = $(filter $(foreach file,$(call SOURCES,$1),$(wildcard $(file))),$(call SOURCES,$1))
# Get all .d and .o files
DEPS = $(patsubst $(SRC)/%.cpp,$(OBJ)/%.d,$(call EXIST,$1))
OBJS = $(patsubst $(SRC)/%.cpp,$(OBJ)/%.o,$(call EXIST,$1))
# Get all .d/.o plus the input file
DEPS_ALL = $(patsubst $(SRC)/%.cpp,$(OBJ)/%.d,$1) $(call DEPS,$1)
OBJS_ALL = $(patsubst $(SRC)/%.cpp,$(OBJ)/%.o,$1) $(call OBJS,$1)
.PHONY: all
all: Debug
@$(BIN)/Debug
$(OBJ)/%.o: $(SRC)/%.cpp
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@ $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(LINKER_FLAGS)
.PHONY: GameLibrary
GameLibrary: $(LIB)/libGameEngine.a
$(LIB)/libGameEngine.a: $(call OBJS,$(SRC)/Includes.h)
@mkdir -p $(@D)
$(AR) $(ARFLAGS) $@ $^
-include $(call DEPS,$(SRC)/Includes.h)
testing: testing.cpp
$(CXX) $(CXXFLAGS) $< -o $@ $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(LINKER_FLAGS)
DEBUG_TARGET := $(SRC)/Test/IdleWizard.cpp
Debug: $(call OBJS_ALL,$(DEBUG_TARGET)) $(LIB)/libGameEngine.a
$(CXX) $(CXXFLAGS) $^ -o $(BIN)/$@ $(INCLUDE_PATHS) $(GAME_LIBRARY) $(LIBRARY_PATHS) $(LINKER_FLAGS)
-include $(call DEPS_ALL,$(DEBUG_TARGET))