Makefile 9.19 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
15
16
17
CONSOLE_LOG?=garrysmod/console.log

GAME_TTT_FLAGS?=+ttt_preptime_seconds 3 +ttt_firstpreptime_seconds 3 +gamemode terrortown +ttt_debug_preventwin 1
GAME_PLAY_FLAGS?=+mat_specular 1 +mat_hdr_level 2 $(GAME_TTT_FLAGS)
GAME_FLAGS?=-condebug
18
GAME_DIR?=C:\\Program Files (x86)\\Steam\\steamapps\\common\\GarrysMod\\
dylan grafmyre's avatar
snap    
dylan grafmyre committed
19
20
VBIN_DIR?=$(GAME_DIR)bin\\
MOD_DIR?=$(GAME_DIR)garrysmod\\
dylan grafmyre's avatar
dylan grafmyre committed
21
MOUNT_DIR?=.\\
22
VBIN_FLAGS?=-game "'$(MOD_DIR)'"
dylan grafmyre's avatar
dylan grafmyre committed
23
24
25
26
	# 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
27

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

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

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

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

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

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

dylan grafmyre's avatar
dylan grafmyre committed
64
%.game: %.bsp
dylan grafmyre's avatar
snap    
dylan grafmyre committed
65
ifeq ($(GAME),0)
dylan grafmyre's avatar
dylan grafmyre committed
66
	echo "user disabled run game via GAME=0"
dylan grafmyre's avatar
snap    
dylan grafmyre committed
67
else
dylan grafmyre's avatar
dylan grafmyre committed
68
69
	$(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
70
endif
dylan grafmyre's avatar
dylan grafmyre committed
71

dylan grafmyre's avatar
dylan grafmyre committed
72
73
74
75
%.game-mount: addons/%/.mount
ifeq ($(GAME),0)
	echo "user disabled run game via GAME=0"
else
dylan grafmyre's avatar
dylan grafmyre committed
76
77
	$(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
78
79
endif

80
%.game-only:
dylan grafmyre's avatar
dylan grafmyre committed
81
82
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_PLAY_FLAGS) +map $(notdir $(basename $@))
83

dylan grafmyre's avatar
dylan grafmyre committed
84

dylan grafmyre's avatar
snap    
dylan grafmyre committed
85
maps/%.bsp: %.bsp
86
	ln -f $^ $@
dylan grafmyre's avatar
dylan grafmyre committed
87
88

# hammer default flags
dylan grafmyre's avatar
snap    
dylan grafmyre committed
89
%.bsp: %.vmf
dylan grafmyre's avatar
dylan grafmyre committed
90
91
92
93
	# default
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) $(VBIN_FLAGS) $(basename $^)
94
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
95
96
97
98
99

%_fast.bsp: %.vmf
	# fast
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) -fast $(VBIN_FLAGS) $(basename $^)
100
	$(RAD_BIN) -bounce 2 -noextra $(VBIN_FLAGS) $(basename $^)
101
	ln -f $(@:_fast.bsp=.vmf) $(@:_fast.bsp=_fast.vmf)
dylan grafmyre's avatar
dylan grafmyre committed
102
	mv  $(@:_fast.bsp=.bsp) $@
103
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
104
105
106
107
108
109

%_hdr.bsp: %.vmf
	# hdr
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) -both $(VBIN_FLAGS) $(basename $^)
110
	ln -f $(@:_hdr.bsp=.vmf) $(@:_hdr.bsp=_hdr.vmf)
dylan grafmyre's avatar
dylan grafmyre committed
111
	mv $(@:_hdr.bsp=.bsp) $@
112
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
113
114
115
116
117
118

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

dylan grafmyre's avatar
dylan grafmyre committed
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#	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 
	./workarounds/buildcubemaps.exe &
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) +sv_cheats 1 \
		+mat_specular 0 +map $(notdir $(basename $^))

%.cubehdr: %.bsp %.cubeldr
	./workarounds/buildcubemaps.exe &
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) +sv_cheats 1 \
		+mat_specular 0 +mat_hdr_level 0 +map $(notdir $(basename $^))

146
147
148
149
150
151
	# 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
152
	# open vmf in hammer
153
154
	"$(VBIN_DIR)/hammer.exe" "$(MOD_DIR)/mapsrc/setphys.vmf" &
	sleep 2
155
	./workarounds/setphys.exe &
dylan grafmyre's avatar
dylan grafmyre committed
156
157
158
	# 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) \
159
		+sv_cheats 1 +map_edit setphys
160
161
	rm -v "$(MOD_DIR)/maps/setphys.bsp"
	rm -i "$(MOD_DIR)/mapsrc/setphys.vmf"
162
163
164
165
166
167
168
169

%.nav: %.bsp
	./workarounds/nav_generate.exe &
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) \
		+sv_cheats 1 +nav_edit 1 +map $(notdir $(basename $^))
	cp -v "$(MOD_DIR)/maps/$(notdir $(basename $^)).nav" $@

dylan grafmyre's avatar
dylan grafmyre committed
170

dylan grafmyre's avatar
dylan grafmyre committed
171
172
173
174
175
176
# 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
177

dylan grafmyre's avatar
snap    
dylan grafmyre committed
178
179

# create gma files for publishing
180
# testing requirest then extracting the gma and mounting it via
dylan grafmyre's avatar
snap    
dylan grafmyre committed
181
# Garrysmod/garrysmod/cfg/mount.cfg
dylan grafmyre's avatar
dylan grafmyre committed
182
183
#
# todo: pack bsp-zip list with gma instead (non _p variants? only)
dylan grafmyre's avatar
snap    
dylan grafmyre committed
184
185
#
	#$(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
186
	#$(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
187
188
189
190
	#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
191
	# 	addons-src/maps/*.res
dylan grafmyre's avatar
dylan grafmyre committed
192
	# $(GMAD_BIN) $(GMAD_FLAGS) create -folder "addons-src" -out "$@"
dylan grafmyre's avatar
snap    
dylan grafmyre committed
193
addons/%.gma: %.bsp addons-src/addon.json
dylan grafmyre's avatar
snap    
dylan grafmyre committed
194
195
	rm -rv \
		addons-src/maps/*.bsp \
dylan grafmyre's avatar
snap    
dylan grafmyre committed
196
		addons-src/maps/thumb/*.png \
dylan grafmyre's avatar
snap    
dylan grafmyre committed
197
		|| true
dylan grafmyre's avatar
snap    
dylan grafmyre committed
198
	cp $(word 1, $^) addons-src/maps/
dylan grafmyre's avatar
dylan grafmyre committed
199
	cp thumbnail_map_128.png addons-src/maps/thumb/$(basename $(word 1, $^)).png
dylan grafmyre's avatar
dylan grafmyre committed
200
	$(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
201
	$(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
202

dylan grafmyre's avatar
snap    
dylan grafmyre committed
203
204
205
206
207
208
209
addons/%/.d: addons/%.gma
	tar -C addons -xvf $(^:.gma=.tar)
	touch $@

addons/%: addons/%/.d
	true

dylan grafmyre's avatar
dylan grafmyre committed
210
211
212
213
mount:
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS)

mount-dev:
dylan grafmyre's avatar
dylan grafmyre committed
214
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS) --set-mount ttt_terrorcon "'$(PROJECT_DIR)'" --normpath
dylan grafmyre's avatar
dylan grafmyre committed
215
216

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

dylan grafmyre's avatar
snap    
dylan grafmyre committed
219
220
221
222
223
224
# 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
225

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

dylan grafmyre's avatar
dylan grafmyre committed
229
230
231
232

# custom rules

.DEFAULT: all
233
all: lint maps/ttt_terrorcon_v2_hdr_final.bsp addons/ttt_terrorcon_v2_hdr_final.gma ttt_terrorcon_v2_hdr_final.game
dylan grafmyre's avatar
dylan grafmyre committed
234
235
fast: lint maps/ttt_terrorcon_v2_fast.bsp ttt_terrorcon_v2_fast.game

236
237
238
239
	# 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
240

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

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