-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
172 lines (134 loc) · 4.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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Compiler
CC:=gcc
WINCC:=x86_64-w64-mingw32-$(CC)
CXX:=g++
WINCXX:=x86_64-w64-mingw32-$(CXX)
# Flags
CSTD:=-std=gnu17
CXXSTD:=-std=gnu++20
WFLAGS:=-Wall -Wextra
OFLAGS:=-O3 -flto -fwhole-program
IFLAGS:=-I "include/"
CFLAGS:=$(CSTD) $(WFLAGS) $(OFLAGS) $(IFLAGS)
CXXFLAGS:=$(CXXSTD) $(WFLAGS) $(OFLAGS) $(IFLAGS)
LIBFLAGS:=-lm
# Query
QUERY_LEECH=leechgem/leechquery
QUERY_MANAGEM=managem/mgquery-alone managem/mgquery-amps managem/mgquery-setup managem/mgquery-omnia
QUERY_CRIT=$(basename $(wildcard critgem/critquery*.cpp))
QUERY_KILLGEM=killgem/kgquery-alone killgem/kgquery-amps killgem/kgquery-setup killgem/kgquery-omnia
QUERY_MGNGEM=managem/mgquery-ngems
QUERY_KGNGEM=killgem/kgquery-ngems
QUERY_BLEED=bleedgem/bleedquery
QUERY_DIST=$(QUERY_LEECH) $(QUERY_MANAGEM) $(QUERY_CRIT) $(QUERY_KILLGEM) $(QUERY_BLEED)
QUERY_ALL=$(QUERY_DIST) $(QUERY_MGNGEM) $(QUERY_KGNGEM)
# Build
BUILD_LEECH=leechgem/leechbuild
BUILD_MANAGEM=$(basename $(wildcard managem/mgbuild-*.cpp))
BUILD_CRIT=$(basename $(wildcard critgem/critbuild*.cpp))
BUILD_KILLGEM=$(basename $(wildcard killgem/kgbuild-*.cpp))
BUILD_BLEED=bleedgem/bleedbuild
BUILD_ALL=$(BUILD_LEECH) $(BUILD_MANAGEM) $(BUILD_CRIT) $(BUILD_KILLGEM) $(BUILD_BLEED)
# Combine
COMBINE_LEECH=leechgem/leechcombine
COMBINE_MANAGEM=$(basename $(wildcard managem/mgcombine-*.cpp))
COMBINE_CRIT=critgem/critcombine
COMBINE_KILLGEM=$(basename $(wildcard killgem/kgcombine-*.cpp))
COMBINE_BLEED=bleedgem/bleedcombine
COMBINE_ALL=$(COMBINE_LEECH) $(COMBINE_MANAGEM) $(COMBINE_CRIT) $(COMBINE_KILLGEM) $(COMBINE_BLEED)
# Type aggregates
LEECH_ALL=$(QUERY_LEECH) $(BUILD_LEECH) $(COMBINE_LEECH)
MANAGEM_ALL=$(QUERY_MANAGEM) $(QUERY_MGNGEM) $(BUILD_MANAGEM) $(COMBINE_MANAGEM)
CRIT_ALL=$(QUERY_CRIT) $(BUILD_CRIT) $(COMBINE_CRIT)
KILLGEM_ALL=$(QUERY_KILLGEM) $(QUERY_KGNGEM) $(BUILD_KILLGEM) $(COMBINE_KILLGEM)
BLEED_ALL=$(QUERY_BLEED) $(BUILD_BLEED) $(COMBINE_BLEED)
# Lilybill
LILYBILL=$(basename $(wildcard lilybill/*.cpp))
# Utilities
UTILITIES=$(basename $(wildcard utilities/*.cpp))
# All
DEV_ALL=$(QUERY_ALL) $(BUILD_ALL) $(COMBINE_ALL) $(UTILITIES)
# Folders
BINDIR:=bin
WINDIR:=$(BINDIR)/win
TABLES_DIR:=gem_tables
INCLUDE_DIR:=include
DEPS_DIR:=.deps
# Version
VERSION:=$(shell git describe --tags | rev | cut -d '-' -f2- | rev)
# General targets
dev: $(DEV_ALL)
dev-move: dev
$(MAKE) move
all: dev tables
all-move: all
$(MAKE) move
dist: $(QUERY_DIST) tables
$(MAKE) move
@echo "Setup completed, the programs can be found in the \"$(BINDIR)/\" folder"
analyze:
scan-build -V -analyze-headers $(MAKE)
.PHONY: dev dev-move all all-move dist analyze
# Aggregates
set-query: $(QUERY_ALL)
set-build: $(BUILD_ALL)
set-combine: $(COMBINE_ALL)
set-leech: $(LEECH_ALL)
set-managem: $(MANAGEM_ALL)
set-crit: $(CRIT_ALL)
set-killgem: $(KILLGEM_ALL)
set-bleed: $(BLEED_ALL)
utilities: $(UTILITIES)
lilybill: $(LILYBILL)
.PHONY: set-query set-build set-combine set-leech set-managem set-crit set-killgem
# Windows
windows: CXX:=$(WINCXX)
windows: $(QUERY_DIST) windows-tables | $(WINDIR)
$(foreach file, $(QUERY_DIST), mv -v $(file).exe $(WINDIR);)
cp LICENSE.txt $(WINDIR)/LICENSE.txt
cp README.md $(WINDIR)/README.txt
zip -FSrT "gemforce-win-$(VERSION).zip" "$(WINDIR)"
windows-tables: $(TABLES_DIR)/table_* | $(TABLES_DIR) $(WINDIR)
@cp -vr $(TABLES_DIR)/ $(WINDIR)/
$(WINDIR):
mkdir -p $(WINDIR)
.PHONY: windows windows-tables
# Move
move: | $(BINDIR)
@for exe in $(DEV_ALL); do \
[ -e "$${exe}" ] && mv -v $${exe} "$(BINDIR)/"; \
done; \
: # noop so make doesn't choke
move-white: | $(BINDIR)
@if [ -d "white" ]; then \
find "white/" -type f -executable -exec mv -v {} "$(BINDIR)/white/" \; ; \
fi
$(BINDIR):
mkdir $(BINDIR)
.PHONY: move move-white
# Include deps folder
-include $(wildcard $(DEPS_DIR)/*.d)
# Compilation targets
$(DEV_ALL): %: %.cpp | $(DEPS_DIR)
$(CXX) $(CXXFLAGS) -MMD -MF $(DEPS_DIR)/$(<F).d -MT $@ $< $(LIBFLAGS) -o $@
$(DEPS_DIR):
mkdir -p $(DEPS_DIR)
# Tables
tables: $(TABLES_DIR)/table_* | $(TABLES_DIR) $(BINDIR)
@cp -vr $(TABLES_DIR)/ $(BINDIR)/
$(TABLES_DIR):
@echo \"$(TABLES_DIR)\" directory not found. Aborting...
@false
.PHONY: tables
# Clean
clean:
@rm -vf $(DEV_ALL)
@rm -f $(DEPS_DIR)/*
clean-white:
@if [ -d "white" ]; then \
find "white/" -type f -executable -delete; \
fi
clean-windows:
@rm -vrf $(WINDIR)
clean-all: clean clean-white clean-windows
.PHONY: clean clean-white clean-windows clean-all