-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
139 lines (107 loc) · 4.74 KB
/
Makefile
File metadata and controls
139 lines (107 loc) · 4.74 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Copyright (c) 2020-present Caps Collective & contributors
# Originally authored by Jonathan Moallem (@jonjondev) & Aryeh Zinn (@Raelr)
#
# This code is released under an unmodified zlib license.
# For conditions of distribution and use, please see:
# https://opensource.org/licenses/Zlib
include make/Functions.mk
include make/Platform.mk
# Set debugging build flags
DEBUG ?= 1
ifeq ($(DEBUG), 1)
override CXXFLAGS += -g -DDEBUG -DCC_LOG_LEVEL=2
else
override CXXFLAGS += -DNDEBUG -DCC_LOG_LEVEL=0 -O3
endif
# Set platform vars
ifeq ($(platform), windows)
linkFlags += -Wl,--allow-multiple-definition -pthread -lopengl32 -lgdi32 -lwinmm -mwindows -static -static-libgcc -static-libstdc++
export packageScript = powershell -executionpolicy bypass $(scriptsDir)/package.ps1 --pkg-name $1 --exe-name $2 --output-dir $3 --build-dir $4 $5
else ifeq ($(platform), linux)
linkFlags += -Wl,--no-as-needed -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi -no-pie
formatScript = $(scriptsDir)/format.sh
else ifeq ($(platform), macos)
linkFlags += -framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL
formatScript = $(scriptsDir)/format.sh
endif
# Set directories
export libDir := $(abspath lib)
export makeDir := $(abspath make)
export binDir := $(abspath bin)
export vendorDir := $(abspath vendor)
export scriptsDir := $(abspath scripts)
export outputDir := $(abspath output)
export engineDir := $(abspath engine)
export testsDir := $(abspath tests)
export packerDir := $(abspath packer)
export examplesDir := $(abspath examples)
# Set top level targets
export utilsLib := $(libDir)/libutils.a
export resourcesLib := $(libDir)/libresources.a
export windowLib := $(libDir)/libwindow.a
export coreLib := $(libDir)/libcore.a
export renderLib := $(libDir)/librender.a
export testApp := $(binDir)/tests/build/app
export packerApp := $(binDir)/packer/build/app
export exampleGameApp := $(binDir)/examples/game/build/app
export exampleRenderApp := $(binDir)/examples/render/build/app
export exampleTilemapApp := $(binDir)/examples/tilemap/build/app
# Set build vars
export compileFlags := -Wall -std=c++17
export linkFlags += -L $(libDir)
buildFlagsFile:=.buildflags
.PHONY: all packerapp testapp gameapp renderapp tilemapapp package-gameapp package-renderapp package-tilemapapp buildFlags clean format
all: packerapp testapp package-gameapp package-renderapp package-tilemapapp
$(utilsLib): buildFlags
"$(MAKE)" -C $(engineDir)/utils CXXFLAGS="$(CXXFLAGS)"
$(resourcesLib): buildFlags $(utilsLib)
"$(MAKE)" -C $(engineDir)/resources CXXFLAGS="$(CXXFLAGS)"
$(windowLib): buildFlags $(utilsLib)
"$(MAKE)" -C $(engineDir)/window CXXFLAGS="$(CXXFLAGS)"
$(coreLib): buildFlags $(utilsLib)
"$(MAKE)" -C $(engineDir)/core CXXFLAGS="$(CXXFLAGS)"
$(renderLib): buildFlags $(utilsLib) $(windowLib)
"$(MAKE)" -C $(engineDir)/render CXXFLAGS="$(CXXFLAGS)"
$(packerApp): buildFlags $(utilsLib) $(resourcesLib)
"$(MAKE)" -C $(packerDir) CXXFLAGS="$(CXXFLAGS)"
$(testApp): buildFlags $(utilsLib) $(coreLib) $(packerApp)
"$(MAKE)" -C $(testsDir) CXXFLAGS="$(CXXFLAGS)"
$(exampleGameApp): buildFlags $(renderLib) $(coreLib) $(packerApp)
"$(MAKE)" -C $(examplesDir)/game CXXFLAGS="$(CXXFLAGS)"
$(exampleRenderApp): buildFlags $(renderLib) $(packerApp)
"$(MAKE)" -C $(examplesDir)/render CXXFLAGS="$(CXXFLAGS)"
$(exampleTilemapApp): buildFlags $(renderLib) $(packerApp)
"$(MAKE)" -C $(examplesDir)/tilemap CXXFLAGS="$(CXXFLAGS)"
testapp: $(testApp)
packerapp: $(packerApp)
gameapp: $(exampleGameApp)
renderapp: $(exampleRenderApp)
tilemapapp: $(exampleTilemapApp)
package-gameapp: gameapp
"$(MAKE)" package -C $(examplesDir)/game CXXFLAGS="$(CXXFLAGS)"
package-renderapp: renderapp
"$(MAKE)" package -C $(examplesDir)/render CXXFLAGS="$(CXXFLAGS)"
package-tilemapapp: tilemapapp
"$(MAKE)" package -C $(examplesDir)/tilemap CXXFLAGS="$(CXXFLAGS)"
# Check to invalidate the build if flags have changed
buildFlags:
$(call BUILD_FLAGS_SCRIPT, $(buildFlagsFile), $(CXXFLAGS), $(libDir) $(binDir))
# Run cleanup across project
clean:
$(RM) $(call platformpth,$(libDir))
$(RM) $(call platformpth,$(binDir))
$(RM) $(call platformpth,$(outputDir))
$(RM) $(call platformpth,$(buildFlagsFile))
clean-deps:
git submodule foreach --recursive git clean -xfd
git submodule foreach --recursive git reset --hard
$(RM) $(call platformpth,$(vendorDir)/include)
$(RM) $(call platformpth,$(vendorDir)/vulkan/include)
$(RM) $(call platformpth,$(vendorDir)/vulkan/lib)
clean-all: clean clean-deps
# Check file formatting program across all source files
format-check:
$(formatScript) "$(engineDir) $(examplesDir) $(testsDir) $(packerDir)" --check
# Run file formatting program across all source files
format:
$(formatScript) "$(engineDir) $(examplesDir) $(testsDir) $(packerDir)"