-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
89 lines (73 loc) · 2.2 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
MAIN = $(wildcard src/*.cc)
SRC = src/main.cc
IMGUI = $(wildcard include/imgui/*.cpp) include/imgui/backends/imgui_impl_sdl.cpp include/imgui/backends/imgui_impl_opengl3.cpp
BUILD = build
CC = g++
INCLUDE_PATHS = ./include ./include/imgui ./include/imgui/backends ./include/imgui_club
INCLUDES = $(addprefix -I, $(INCLUDE_PATHS))
FLAGS = -Wall
OUT = $(BUILD)/yagb-emu
CACHE = $(BUILD)/cache
# Windows / Linux Variables
ifeq ($(OS),Windows_NT)
$(info Windows Variables Init)
INCLUDES += -I C:\MinGW\SDL2\include -L C:\MinGW\SDL2\lib\x86
#FLAGS += -w -Wl,-subsystem,windows -lmingw32 -lSDL2main -lSDL2
FLAGS += -w -lmingw32 -lSDL2main -lSDL2
else
$(info Non-Windows Variables Init)
FLAGS += $(shell sdl2-config --cflags --libs) $(shell pkg-config --libs glew)
endif
all: build
build-debug: prebuild
$(info Building Debug Binary)
$(CC) $(MAIN) $(IMGUI) $(INCLUDES) $(FLAGS) -g -o $(OUT)
# Cached Version of the Build
build-cached:
ifneq ($(wildcard $(CACHE)),)
$(info Building Binary from Cache)
$(CC) $(SRC) $(CACHE)/*.o $(INCLUDES) $(FLAGS) -o $(OUT)
endif
# Builds a Development Binary of the Application
build: prebuild
$(info Building Binary)
$(CC) $(MAIN) $(IMGUI) $(INCLUDES) $(FLAGS) -o $(OUT)
# CACHE SECTION #
CACHE_INCLUDES = $(addprefix -I../../, $(INCLUDE_PATHS))
cache-all: cache-utils cache-imgui
# Caches Source file includes to main.cc
CACHE_UTILS = $(addprefix ../../, $(filter-out $(SRC), $(MAIN)))
cache-utils: prebuild
$(info Building App Object Files as Cache)
cd $(CACHE); \
$(CC) $(CACHE_UTILS) $(CACHE_INCLUDES) $(FLAGS) -c
# Caches ImGui - Object Files
CACHE_IMGUI = $(addprefix ../../, $(IMGUI))
cache-imgui: prebuild
$(info Building ImGUI Object Files as Cache)
cd $(CACHE); \
$(CC) $(CACHE_IMGUI) $(CACHE_INCLUDES) $(FLAGS) -c
# Cleans up the Build Directory
prebuild:
ifeq ($(wildcard $(BUILD)),)
$(shell mkdir $(BUILD))
$(shell mkdir $(CACHE))
endif
ifneq (,$(wildcard $(OUT)))
ifeq ($(OS),Windows_NT)
$(info Windows Remove Pre-build)
$(shell del /F /A $(OUT))
else
$(info Removing Build Pre-build)
rm $(OUT)
endif
endif
# Cleans up everything
clean:
ifeq ($(OS),Windows_NT)
$(info Windows Remove)
$(shell rmdir /Q /S $(BUILD))
else
$(info Removing Build)
rm -rf $(BUILD)
endif