Makefile 7.23 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
13

GAME?=hl2.exe
GAME_DIR?=C:\\Program Files (x86)\\Steam\\steamapps\\common\\GarrysMod\\
dylan grafmyre's avatar
snap    
dylan grafmyre committed
14
15
VBIN_DIR?=$(GAME_DIR)bin\\
MOD_DIR?=$(GAME_DIR)garrysmod\\
dylan grafmyre's avatar
dylan grafmyre committed
16
MOUNT_DIR?=.\\
17
VBIN_FLAGS?=-game "'$(MOD_DIR)'"
dylan grafmyre's avatar
dylan grafmyre committed
18

dylan grafmyre's avatar
dylan grafmyre committed
19
SUPERVISE_V_BIN?=./contrib/supervise-v
20
21
SUPERVISE_V_FLAGS?=--shlex
BSP_BIN?=$(SUPERVISE_V_BIN) $(SUPERVISE_V_FLAGS) "'$(VBIN_DIR)vbsp.exe'"
dylan grafmyre's avatar
dylan grafmyre committed
22
BSP_FLAGS?=$(VBIN_FLAGS)
23
VIS_BIN?=$(SUPERVISE_V_BIN) $(SUPERVISE_V_FLAGS) "'$(VBIN_DIR)vvis.exe'"
dylan grafmyre's avatar
dylan grafmyre committed
24
VIS_FLAGS?=$(VBIN_FLAGS) -fast
25
RAD_BIN?=$(SUPERVISE_V_BIN) $(SUPERVISE_V_FLAGS) "'$(VBIN_DIR)vrad.exe'"
dylan grafmyre's avatar
dylan grafmyre committed
26
27
RAD_FLAGS?=$(VBIN_FLAGS) -StaticPropLighting -bounce 2 -noextra
# -StaticPropSampleScale 0.25 
28
BSPZIP_BIN?=$(SUPERVISE_V_BIN) $(SUPERVISE_V_FLAGS) "'$(VBIN_DIR)bspzip.exe'"
29
BSPZIP_FLAGS?=$(VBIN_FLAGS)
30
GMAD_BIN?="$(VBIN_DIR)gmad.exe"
Dylan Grafmyre's avatar
Dylan Grafmyre committed
31
GMAD_FLAGS?=
32
GMPUBLISH_BIN?="$(VBIN_DIR)gmpublish.exe"
Dylan Grafmyre's avatar
Dylan Grafmyre committed
33
GMPUBLISH_FLAGS?=
dylan grafmyre's avatar
dylan grafmyre committed
34

dylan grafmyre's avatar
snap    
dylan grafmyre committed
35
GEN_BSPZIP_ADDLIST_BIN?=$(PYTHON_BIN) ./contrib/gen-bspzip-addlist
36
GEN_BSPZIP_ADDLIST_FLAGS?=--pack-used-local
dylan grafmyre's avatar
dylan grafmyre committed
37
38
GMA_INSTALL_BSPZIP_ADDLIST_BIN?=$(PYTHON_BIN) ./contrib/gma-install-bspzip-addlist
GMA_INSTALL_BSPZIP_ADDLIST_FLAGS?=
39

dylan grafmyre's avatar
snap    
dylan grafmyre committed
40
41
42
J2_BIN?=$(PYTHON_BIN) ./contrib/j2
J2_FLAGS?=

dylan grafmyre's avatar
dylan grafmyre committed
43
44
GMAD_TAR_BIN?=$(PYTHON_BIN) ./contrib/gmad-tar
GMAD_TAR_FLAGS?=
45
46
MOUNT_BIN?=$(PYTHON_BIN) ./contrib/mount
MOUNT_FLAGS?=--mod-dir "'$(MOD_DIR)'"
dylan grafmyre's avatar
dylan grafmyre committed
47
48

%_p.bsp: %.bsp
49
	$(BSPZIP_BIN) -addlist $^ $(^:.bsp=.bspzip-addlist) $@ $(BSPZIP_FLAGS) 
50
	cp $@ $(MOUNT_DIR)maps\\$(notdir $@)
dylan grafmyre's avatar
dylan grafmyre committed
51

52
53
54
%.bspzip-addlist: %.vmf
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $@

dylan grafmyre's avatar
dylan grafmyre committed
55
%.game: %.bsp
dylan grafmyre's avatar
snap    
dylan grafmyre committed
56
ifeq ($(GAME),0)
dylan grafmyre's avatar
dylan grafmyre committed
57
	echo "user disabled run game via GAME=0"
dylan grafmyre's avatar
snap    
dylan grafmyre committed
58
else
59
	$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) +ttt_preptime_seconds 3 +ttt_firstpreptime_seconds 3 +gamemode terrortown +ttt_debug_preventwin 1 +ttt_minimum_players 1 +map $(notdir $(basename $^))
dylan grafmyre's avatar
snap    
dylan grafmyre committed
60
endif
dylan grafmyre's avatar
dylan grafmyre committed
61

dylan grafmyre's avatar
dylan grafmyre committed
62
63
64
65
%.game-mount: addons/%/.mount
ifeq ($(GAME),0)
	echo "user disabled run game via GAME=0"
else
66
	$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) +ttt_preptime_seconds 3 +ttt_firstpreptime_seconds 3 +gamemode terrortown +ttt_debug_preventwin 1 +ttt_minimum_players 1 +map $(notdir $(^:/.mount=))
dylan grafmyre's avatar
dylan grafmyre committed
67
68
endif

69
%.game-only:
70
	$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) +ttt_preptime_seconds 3 +ttt_firstpreptime_seconds 3 +gamemode terrortown +ttt_debug_preventwin 1 +ttt_minimum_players 1 +map $(notdir $(basename $@))
71

dylan grafmyre's avatar
dylan grafmyre committed
72

dylan grafmyre's avatar
snap    
dylan grafmyre committed
73
74
maps/%.bsp: %.bsp
	cp $^ $@
dylan grafmyre's avatar
dylan grafmyre committed
75
76

# hammer default flags
dylan grafmyre's avatar
snap    
dylan grafmyre committed
77
%.bsp: %.vmf
dylan grafmyre's avatar
dylan grafmyre committed
78
79
80
81
	# default
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) $(VBIN_FLAGS) $(basename $^)
82
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
83
84
85
86
87
88
89

%_fast.bsp: %.vmf
	# fast
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) -fast $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) -bounce 2 -noextra $(VBIN_FLAGS) $(basename $^) 
	mv  $(@:_fast.bsp=.bsp) $@
90
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
91
92
93
94
95
96
97

%_hdr.bsp: %.vmf
	# hdr
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) -both $(VBIN_FLAGS) $(basename $^)
	mv $(@:_hdr.bsp=.bsp) $@
98
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
99
100
101
102
103
104
105

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

dylan grafmyre's avatar
dylan grafmyre committed
108
109
110
111
112
113
114
115
116
117
118
%.cubeldr: %.bsp
	$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) \
		+mat_specular 0 +map $(notdir $(basename $^)) \
		+sv_cheats 1 +buildcubemaps +disconnect +mat_specular 1 +quit
%.cubehdr: %.bsp
	$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) \
		+mat_specular 0 +map $(notdir $(basename $^)) \
		+sv_cheats 1 +buildcubemaps +disconnect +sv_cheats 0 \
		+mat_hdr_level 0 +map $(notdir $(basename $^)) \
		+sv_cheats 1 +buildcubemaps +disconnect +mat_specular 1 +quit

dylan grafmyre's avatar
dylan grafmyre committed
119
120
121
122
123
124
# 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
125

dylan grafmyre's avatar
snap    
dylan grafmyre committed
126
127
128
129

# create gma files for publishing
# testing requirest then extracting the gma and mounting it via 
# Garrysmod/garrysmod/cfg/mount.cfg
dylan grafmyre's avatar
dylan grafmyre committed
130
131
#
# todo: pack bsp-zip list with gma instead (non _p variants? only)
dylan grafmyre's avatar
snap    
dylan grafmyre committed
132
133
#
	#$(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
134
	#$(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
135
136
137
138
	#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
139
	# 	addons-src/maps/*.res
dylan grafmyre's avatar
dylan grafmyre committed
140
	# $(GMAD_BIN) $(GMAD_FLAGS) create -folder "addons-src" -out "$@"
dylan grafmyre's avatar
snap    
dylan grafmyre committed
141
addons/%.gma: %.bsp addons-src/addon.json
dylan grafmyre's avatar
snap    
dylan grafmyre committed
142
143
	rm -rv \
		addons-src/maps/*.bsp \
dylan grafmyre's avatar
snap    
dylan grafmyre committed
144
		addons-src/maps/thumb/*.png \
dylan grafmyre's avatar
snap    
dylan grafmyre committed
145
		|| true
dylan grafmyre's avatar
snap    
dylan grafmyre committed
146
	cp $(word 1, $^) addons-src/maps/
dylan grafmyre's avatar
dylan grafmyre committed
147
	cp thumbnail_map_128.png addons-src/maps/thumb/$(basename $(word 1, $^)).png
dylan grafmyre's avatar
dylan grafmyre committed
148
	$(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
149
	$(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
150

dylan grafmyre's avatar
snap    
dylan grafmyre committed
151
152
153
154
155
156
157
addons/%/.d: addons/%.gma
	tar -C addons -xvf $(^:.gma=.tar)
	touch $@

addons/%: addons/%/.d
	true

dylan grafmyre's avatar
dylan grafmyre committed
158
159
160
161
mount:
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS)

mount-dev:
dylan grafmyre's avatar
dylan grafmyre committed
162
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS) --set-mount ttt_terrorcon "'$(PROJECT_DIR)'" --normpath
dylan grafmyre's avatar
dylan grafmyre committed
163
164

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

dylan grafmyre's avatar
snap    
dylan grafmyre committed
167
168
169
170
171
172
# 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
173

dylan grafmyre's avatar
dylan grafmyre committed
174
175
176
177
178
179
#publish: addons/ttt_terrorcon_v2_hdr_final_p.gma
#	$(GMPUBLISH_BIN) $(GMPUBLISH_FLAGS) create -addon "$^" -icon "addons/512x512.jpg"

# custom rules

.DEFAULT: all
180
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
181
182
fast: lint maps/ttt_terrorcon_v2_fast.bsp ttt_terrorcon_v2_fast.game

183
install-bsp: maps/ttt_terrorcon_v2_hdr_final.bsp maps/thumb/ttt_terrorcon_v2_hdr_final.png
dylan grafmyre's avatar
dylan grafmyre committed
184
185
186
	cp -v $(word 1, $^) $(MOD_DIR)maps\\
	cp -v $(word 2, $^) $(MOD_DIR)maps\\thumb\\

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

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