Makefile 10 KB
Newer Older
dylan grafmyre's avatar
dylan grafmyre committed
1
.SECONDARY:
dylan grafmyre's avatar
dylan grafmyre committed
2
#
dylan grafmyre's avatar
dylan grafmyre committed
3
PROJECT_DIR?=C:\\hammer\ttt_terrorcon
dylan grafmyre's avatar
dylan grafmyre committed
4
5

PYTHON_BIN?=./env/scripts/python
6
7
8
SHLEX_BIN?=./contrib/shlex
SHLEX_FLAGS?=

dylan grafmyre's avatar
dylan grafmyre committed
9
10
#SHELL=C:\\Program\ Files\\Git\\bin\\bash.exe
#.SHELLFLAGS=-c
11
12

GAME?=hl2.exe
dylan grafmyre's avatar
dylan grafmyre committed
13
14
CONSOLE_LOG?=garrysmod/console.log

15
GAME_TTT_FLAGS?=+ttt_preptime_seconds 3 +ttt_firstpreptime 3 +gamemode terrortown +ttt_debug_preventwin 1
dylan grafmyre's avatar
dylan grafmyre committed
16
17
GAME_PLAY_FLAGS?=+mat_specular 1 +mat_hdr_level 2 $(GAME_TTT_FLAGS)
GAME_FLAGS?=-condebug
18
19
# gmod desktop ignores rcon listening
# -usercon +rcon_password runme
20
GAME_DIR?=C:\\Program Files (x86)\\Steam\\steamapps\\common\\GarrysMod\\
dylan grafmyre's avatar
snap    
dylan grafmyre committed
21
22
VBIN_DIR?=$(GAME_DIR)bin\\
MOD_DIR?=$(GAME_DIR)garrysmod\\
dylan grafmyre's avatar
dylan grafmyre committed
23
MOUNT_DIR?=.\\
24
VBIN_FLAGS?=-game "'$(MOD_DIR)'"
dylan grafmyre's avatar
dylan grafmyre committed
25
26
27
28
	# windows is insufferable
	# ALL bins have a space in the name and NO WINDOWS SHELL
	# can handle bins with spaces in the name, WTF
SHLEX_HL2LOG_FLAGS?=--tail-bin CPROGRAMFILES/Git/usr/bin/tail.exe  --tail CPROGRAMFILESOLD\\steam\\steamapps\\common\\garrysmod\\$(CONSOLE_LOG)
dylan grafmyre's avatar
dylan grafmyre committed
29

dylan grafmyre's avatar
dylan grafmyre committed
30
SUPERVISE_V_BIN?=./contrib/supervise-v
31
32
SUPERVISE_V_FLAGS?=--shlex
BSP_BIN?=$(SUPERVISE_V_BIN) $(SUPERVISE_V_FLAGS) "'$(VBIN_DIR)vbsp.exe'"
dylan grafmyre's avatar
dylan grafmyre committed
33
BSP_FLAGS?=$(VBIN_FLAGS)
34
VIS_BIN?=$(SUPERVISE_V_BIN) $(SUPERVISE_V_FLAGS) "'$(VBIN_DIR)vvis.exe'"
dylan grafmyre's avatar
dylan grafmyre committed
35
VIS_FLAGS?=$(VBIN_FLAGS) -fast
36
RAD_BIN?=$(SUPERVISE_V_BIN) $(SUPERVISE_V_FLAGS) "'$(VBIN_DIR)vrad.exe'"
dylan grafmyre's avatar
dylan grafmyre committed
37
RAD_FLAGS?=$(VBIN_FLAGS) -StaticPropLighting -bounce 2 -noextra
38
# -StaticPropSampleScale 0.25
39
BSPZIP_BIN?=$(SUPERVISE_V_BIN) $(SUPERVISE_V_FLAGS) "'$(VBIN_DIR)bspzip.exe'"
40
BSPZIP_FLAGS?=$(VBIN_FLAGS)
41
GMAD_BIN?="$(VBIN_DIR)gmad.exe"
Dylan Grafmyre's avatar
Dylan Grafmyre committed
42
GMAD_FLAGS?=
dylan grafmyre's avatar
dylan grafmyre committed
43
44
GMPUBLISH_BIN?="'$(VBIN_DIR)gmpublish.exe'"
GMPUBLISH_FLAGS?="update -id 2600874638"  # or "create"
dylan grafmyre's avatar
dylan grafmyre committed
45

dylan grafmyre's avatar
snap    
dylan grafmyre committed
46
GEN_BSPZIP_ADDLIST_BIN?=$(PYTHON_BIN) ./contrib/gen-bspzip-addlist
47
GEN_BSPZIP_ADDLIST_FLAGS?=--pack-used-local
dylan grafmyre's avatar
dylan grafmyre committed
48
49
GMA_INSTALL_BSPZIP_ADDLIST_BIN?=$(PYTHON_BIN) ./contrib/gma-install-bspzip-addlist
GMA_INSTALL_BSPZIP_ADDLIST_FLAGS?=
50

dylan grafmyre's avatar
snap    
dylan grafmyre committed
51
52
53
J2_BIN?=$(PYTHON_BIN) ./contrib/j2
J2_FLAGS?=

dylan grafmyre's avatar
dylan grafmyre committed
54
55
GMAD_TAR_BIN?=$(PYTHON_BIN) ./contrib/gmad-tar
GMAD_TAR_FLAGS?=
56
57
MOUNT_BIN?=$(PYTHON_BIN) ./contrib/mount
MOUNT_FLAGS?=--mod-dir "'$(MOD_DIR)'"
dylan grafmyre's avatar
dylan grafmyre committed
58
59

%_p.bsp: %.bsp
60
	$(BSPZIP_BIN) -addlist $^ $(^:.bsp=.bspzip-addlist) $@ $(BSPZIP_FLAGS)
61
	cp $@ $(MOUNT_DIR)maps\\$(notdir $@)  # ?
dylan grafmyre's avatar
dylan grafmyre committed
62

63
64
65
%.bspzip-addlist: %.vmf
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $@

66
67
68
69
game:
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_PLAY_FLAGS)

dylan grafmyre's avatar
dylan grafmyre committed
70
%.game: %.bsp
dylan grafmyre's avatar
snap    
dylan grafmyre committed
71
ifeq ($(GAME),0)
dylan grafmyre's avatar
dylan grafmyre committed
72
	echo "user disabled run game via GAME=0"
dylan grafmyre's avatar
snap    
dylan grafmyre committed
73
else
dylan grafmyre's avatar
dylan grafmyre committed
74
75
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_PLAY_FLAGS) +map $(notdir $(basename $^))
dylan grafmyre's avatar
snap    
dylan grafmyre committed
76
endif
dylan grafmyre's avatar
dylan grafmyre committed
77

dylan grafmyre's avatar
dylan grafmyre committed
78
79
80
81
%.game-mount: addons/%/.mount
ifeq ($(GAME),0)
	echo "user disabled run game via GAME=0"
else
dylan grafmyre's avatar
dylan grafmyre committed
82
83
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_PLAY_FLAGS) +map $(notdir $(^:/.mount=))
dylan grafmyre's avatar
dylan grafmyre committed
84
85
endif

86
%.game-only:
dylan grafmyre's avatar
dylan grafmyre committed
87
88
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_PLAY_FLAGS) +map $(notdir $(basename $@))
89

dylan grafmyre's avatar
dylan grafmyre committed
90

dylan grafmyre's avatar
snap    
dylan grafmyre committed
91
maps/%.bsp: %.bsp
92
	ln -f $^ $@
dylan grafmyre's avatar
dylan grafmyre committed
93
94

# hammer default flags
dylan grafmyre's avatar
snap    
dylan grafmyre committed
95
%.bsp: %.vmf
dylan grafmyre's avatar
dylan grafmyre committed
96
97
98
99
	# default
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) $(VBIN_FLAGS) $(basename $^)
100
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
101
102
103
104
105

%_fast.bsp: %.vmf
	# fast
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) -fast $(VBIN_FLAGS) $(basename $^)
106
	$(RAD_BIN) -bounce 2 -noextra $(VBIN_FLAGS) $(basename $^)
107
	ln -f $(@:_fast.bsp=.vmf) $(@:_fast.bsp=_fast.vmf)
dylan grafmyre's avatar
dylan grafmyre committed
108
	mv  $(@:_fast.bsp=.bsp) $@
109
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
110
111
112
113
114
115

%_hdr.bsp: %.vmf
	# hdr
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) -both $(VBIN_FLAGS) $(basename $^)
116
	ln -f $(@:_hdr.bsp=.vmf) $(@:_hdr.bsp=_hdr.vmf)
dylan grafmyre's avatar
dylan grafmyre committed
117
	mv $(@:_hdr.bsp=.bsp) $@
118
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
119
120
121
122
123
124

%_hdr_final.bsp: %.vmf
	# hdr-final
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) -both -final $(VBIN_FLAGS) $(basename $^)
125
	ln -f $(@:_hdr_final.bsp=.vmf) $(@:_hdr_final.bsp=_hdr_final.vmf)
dylan grafmyre's avatar
dylan grafmyre committed
126
	mv $(@:_hdr_final.bsp=.bsp) $@
127
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
128

dylan grafmyre's avatar
dylan grafmyre committed
129
130
131
132
133
134
135
136
137
138
139
140
#	note, most of the console is blocked
#	https://wiki.facepunch.com/gmod/Blocked_ConCommands
#	see workarounds/
#	note, lua scripts do not use cfg/mount.cfg like other hl2 engine mod content
# example run lua on bsp
#	ln -f lua/cubeldr.lua "$(MOD_DIR)/lua/autorun/runme.lua"
#	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
#		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) +sv_cheats 1 \
#		+map $(notdir $(basename $^))
#	rm "$(MOD_DIR)/lua/autorun/runme.lua"

%.cubeldr: %.bsp 
141
	ln -f "$^" "$(MOD_DIR)/maps/cubeldr.bsp"
dylan grafmyre's avatar
dylan grafmyre committed
142
143
144
	./workarounds/buildcubemaps.exe &
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) +sv_cheats 1 \
145
146
		+mat_specular 0 +map cubeldr
	rm -v "$(MOD_DIR)/maps/cubeldr.bsp"
dylan grafmyre's avatar
dylan grafmyre committed
147
148

%.cubehdr: %.bsp %.cubeldr
149
	ln -f "$(word 1, $^)" "$(MOD_DIR)/maps/cubehdr.bsp"
dylan grafmyre's avatar
dylan grafmyre committed
150
151
152
	./workarounds/buildcubemaps.exe &
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) +sv_cheats 1 \
153
154
		+mat_specular 0 +mat_hdr_level 0 +map cubehdr
	rm -v "$(MOD_DIR)/maps/cubehdr.bsp"
dylan grafmyre's avatar
dylan grafmyre committed
155

156
157
158
159
160
161
	# settle physics
%.setphys: %.bsp
	# precompile map from vmf
	mkdir -p "$(MOD_DIR)/mapsrc"
	ln -f "$^" "$(MOD_DIR)/maps/setphys.bsp"
	ln -f "$(^:.bsp=.vmf)" "$(MOD_DIR)/mapsrc/setphys.vmf"
dylan grafmyre's avatar
dylan grafmyre committed
162
	# open vmf in hammer
163
164
	"$(VBIN_DIR)/hammer.exe" "$(MOD_DIR)/mapsrc/setphys.vmf" &
	sleep 2
165
	./workarounds/setphys.exe &
dylan grafmyre's avatar
dylan grafmyre committed
166
167
168
	# open bsp in game via map_edit
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) \
169
		+sv_cheats 1 +map_edit setphys
170
171
	rm -v "$(MOD_DIR)/maps/setphys.bsp"
	rm -i "$(MOD_DIR)/mapsrc/setphys.vmf"
172
173

%.nav: %.bsp
174
175
176
	ln -f "$^" "$(MOD_DIR)/maps/navgen.bsp"
	cp -v lua/nav_generate.txt "$(MOD_DIR)/data/runme.txt"
	ln -f lua/nav_generate.lua "$(MOD_DIR)/lua/autorun/runme.lua"
177
178
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) \
179
		+sv_cheats 1 +nav_edit 1 +map navgen
dylan grafmyre's avatar
dylan grafmyre committed
180
	# todo: check  "$(MOD_DIR)/data/runme.txt" for content "ng_f", to trigger kill hl2.exe
181
182
183
184
185
186
187
	cp -v "$(MOD_DIR)/maps/navgen.nav" $@
	rm -v \
		"$(MOD_DIR)/lua/autorun/runme.lua" \
		"$(MOD_DIR)/maps/navgen.bsp"
	mkdir -p maps/graphs
	cp -v "$(MOD_DIR)/maps/graphs/navgen.ain" $(basename $@).ain
	rm -v "$(MOD_DIR)/maps/graphs/navgen.ain"
188

dylan grafmyre's avatar
dylan grafmyre committed
189

dylan grafmyre's avatar
dylan grafmyre committed
190
191
192
193
194
195
# only ents works on an existing bsp,
# which are not typically left "in place" for this operation
#%_ents.bsp: %.vmf
#	# only-ents
#	$(BSP_BIN) -onlyents $(VBIN_FLAGS) $(basename $^)
#	mv $(@:_ents.bsp=.bsp) $@
Dylan Grafmyre's avatar
Dylan Grafmyre committed
196

dylan grafmyre's avatar
snap    
dylan grafmyre committed
197
198

# create gma files for publishing
199
# testing requirest then extracting the gma and mounting it via
dylan grafmyre's avatar
snap    
dylan grafmyre committed
200
# Garrysmod/garrysmod/cfg/mount.cfg
dylan grafmyre's avatar
dylan grafmyre committed
201
202
#
# todo: pack bsp-zip list with gma instead (non _p variants? only)
dylan grafmyre's avatar
snap    
dylan grafmyre committed
203
204
#
	#$(J2_BIN) $(J2_FLAGS) <addons-src/512x512.vmt.j2 $(basename $^).vmt >addons-src/materials/vgui/maps/menu_thumb_$(basename $^).vmt
dylan grafmyre's avatar
snap    
dylan grafmyre committed
205
	#$(J2_BIN) $(J2_FLAGS) <addons-src/maps/template.res.j2 $(basename $(word 1, $^)) >addons-src/maps/$(basename $(word 1, $^)).res
dylan grafmyre's avatar
snap    
dylan grafmyre committed
206
207
208
209
	#cp addons-src/512x512.vtf addons-src/materials/vgui/maps/menu_thumb_$(basename $^).vtf
	#cp addons-src/128x128.png addons-src/maps/thumb/$(basename $^).png
	#	addons-src/materials/vgui/maps/*.vmt
	#	addons-src/materials/vgui/maps/*.vtf
dylan grafmyre's avatar
snap    
dylan grafmyre committed
210
	# 	addons-src/maps/*.res
dylan grafmyre's avatar
dylan grafmyre committed
211
	# $(GMAD_BIN) $(GMAD_FLAGS) create -folder "addons-src" -out "$@"
212
addons/%.gma: %.bsp %.nav %.cubehdr addons-src/addon.json
dylan grafmyre's avatar
snap    
dylan grafmyre committed
213
214
	rm -rv \
		addons-src/maps/*.bsp \
dylan grafmyre's avatar
snap    
dylan grafmyre committed
215
		addons-src/maps/thumb/*.png \
dylan grafmyre's avatar
snap    
dylan grafmyre committed
216
		|| true
dylan grafmyre's avatar
snap    
dylan grafmyre committed
217
	cp $(word 1, $^) addons-src/maps/
218
219
220
	cp $(word 2, $^) addons-src/maps/
	mkdir -p addons-src/maps/graphs/
	cp $(basename $(word 2, $^)).ain addons-src/maps/graphs/
dylan grafmyre's avatar
dylan grafmyre committed
221
	cp thumbnail_map_128.png addons-src/maps/thumb/$(basename $(word 1, $^)).png
dylan grafmyre's avatar
dylan grafmyre committed
222
	$(GMA_INSTALL_BSPZIP_ADDLIST_BIN) $(GMA_INSTALL_BSPZIP_ADDLIST_FLAGS) --bspzip-addlist $(basename $(word 1, $^)).bspzip-addlist --dst-prefix addons-src
dylan grafmyre's avatar
dylan grafmyre committed
223
	$(GMAD_TAR_BIN) addons-src/ --output-tar $(@:.gma=.tar) --tar-prefix $(basename $(word 1, $^)) --gmad-bin $(GMAD_BIN) --output-gma $@ --output-index $(@:.gma=.tar-index) --output-digest $(@:.gma=.tar-sha1sums)
dylan grafmyre's avatar
snap    
dylan grafmyre committed
224

dylan grafmyre's avatar
snap    
dylan grafmyre committed
225
226
227
228
229
230
231
addons/%/.d: addons/%.gma
	tar -C addons -xvf $(^:.gma=.tar)
	touch $@

addons/%: addons/%/.d
	true

dylan grafmyre's avatar
dylan grafmyre committed
232
233
234
235
mount:
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS)

mount-dev:
dylan grafmyre's avatar
dylan grafmyre committed
236
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS) --set-mount ttt_terrorcon "'$(PROJECT_DIR)'" --normpath
dylan grafmyre's avatar
dylan grafmyre committed
237
238

addons/%/.mount: addons/%/.d
dylan grafmyre's avatar
dylan grafmyre committed
239
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS) --set-mount ttt_terrorcon "'$(PROJECT_DIR)\\$(basename $@)'" --normpath
dylan grafmyre's avatar
dylan grafmyre committed
240

dylan grafmyre's avatar
snap    
dylan grafmyre committed
241
242
243
244
245
246
# garrysmod refuses to load gma files untill after thier published and live
# so no use trying to test them
#.PHONY: install-addons
#
#install-addons:
#	cp -var addons/*.gma $(MOD_DIR)/addons/
dylan grafmyre's avatar
snap    
dylan grafmyre committed
247

dylan grafmyre's avatar
dylan grafmyre committed
248
publish: addons/ttt_terrorcon_v2_hdr_final.gma
249
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(GMPUBLISH_BIN) $(GMPUBLISH_FLAGS) -icon "'C:\\hammer\\ttt_terrorcon\\addons\\512x512.jpg'" -addon "$^"
dylan grafmyre's avatar
dylan grafmyre committed
250

dylan grafmyre's avatar
dylan grafmyre committed
251
252
253
254

# custom rules

.DEFAULT: all
255
all: lint addons/ttt_terrorcon_v2_hdr_final.gma ttt_terrorcon_v2_hdr_final.game-mount
dylan grafmyre's avatar
dylan grafmyre committed
256
257
fast: lint maps/ttt_terrorcon_v2_fast.bsp ttt_terrorcon_v2_fast.game

258
259
260
261
	# use mount-dev instead
#install-bsp: maps/ttt_terrorcon_v2_hdr_final.bsp maps/thumb/ttt_terrorcon_v2_hdr_final.png
#	cp -v $(word 1, $^) $(MOD_DIR)maps\\
#	cp -v $(word 2, $^) $(MOD_DIR)maps\\thumb\\
dylan grafmyre's avatar
dylan grafmyre committed
262

dylan grafmyre's avatar
snap    
dylan grafmyre committed
263
# gmod dosn't allow mounting gma files
dylan grafmyre's avatar
dylan grafmyre committed
264
# so instead, i've got a parallel artifact being built that can be installed to garrysmod
dylan grafmyre's avatar
snap    
dylan grafmyre committed
265
# tar files are produced, these can be extracted and added as a garrysmod mount to test
dylan grafmyre's avatar
dylan grafmyre committed
266
267
#install-gma: addons/ttt_terrocon_v2_hdr_final_p.gma
#	cp -v $^ $(MOD_DIR)addons\\
Dylan Grafmyre's avatar
Dylan Grafmyre committed
268

dylan grafmyre's avatar
dylan grafmyre committed
269
lint: ttt_terrorcon_v2.bspzip-addlist
dylan grafmyre's avatar
dylan grafmyre committed
270
	$(PYTHON_BIN) ./contrib/bspzip-lint $^ 2>&1 | tee $^.lint
271
272