Makefile 5.67 KB
Newer Older
dylan grafmyre's avatar
dylan grafmyre committed
1
2
3
#

PYTHON_BIN?=./env/scripts/python
4
5
6
7
8
9
10
11
SHLEX_BIN?=./contrib/shlex
SHLEX_FLAGS?=

SHELL=C:\\Program\ Files\\Git\\bin\\bash.exe
.SHELLFLAGS=-c

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

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

dylan grafmyre's avatar
snap    
dylan grafmyre committed
33
GEN_BSPZIP_ADDLIST_BIN?=$(PYTHON_BIN) ./contrib/gen-bspzip-addlist
34
35
GEN_BSPZIP_ADDLIST_FLAGS?=--pack-used-local

dylan grafmyre's avatar
snap    
dylan grafmyre committed
36
37
38
J2_BIN?=$(PYTHON_BIN) ./contrib/j2
J2_FLAGS?=

dylan grafmyre's avatar
dylan grafmyre committed
39
40
GMAD_TAR_BIN?=$(PYTHON_BIN) ./contrib/gmad-tar
GMAD_TAR_FLAGS?=
41
42
MOUNT_BIN?=$(PYTHON_BIN) ./contrib/mount
MOUNT_FLAGS?=--mod-dir "'$(MOD_DIR)'"
dylan grafmyre's avatar
dylan grafmyre committed
43
44

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

48
49
50
%.bspzip-addlist: %.vmf
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $@

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

58
%.game-only:
59
	$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) +map $(notdir $(basename $@)) +gamemode terrortown +ttt_debug_preventwin 1 +ttt_preptime_seconds 10 +ttt_minimum_players 1
60

dylan grafmyre's avatar
dylan grafmyre committed
61

dylan grafmyre's avatar
snap    
dylan grafmyre committed
62
63
maps/%.bsp: %.bsp
	cp $^ $@
dylan grafmyre's avatar
dylan grafmyre committed
64
65

# hammer default flags
dylan grafmyre's avatar
snap    
dylan grafmyre committed
66
%.bsp: %.vmf
dylan grafmyre's avatar
dylan grafmyre committed
67
68
69
70
	# default
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) $(VBIN_FLAGS) $(basename $^)
71
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
72
73
74
75
76
77
78

%_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) $@
79
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
80
81
82
83
84
85
86

%_hdr.bsp: %.vmf
	# hdr
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) -both $(VBIN_FLAGS) $(basename $^)
	mv $(@:_hdr.bsp=.bsp) $@
87
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
88
89
90
91
92
93
94

%_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) $@
95
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
96

dylan grafmyre's avatar
dylan grafmyre committed
97
98
99
100
101
102
# 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
103

dylan grafmyre's avatar
snap    
dylan grafmyre committed
104
105
106
107
108
109

# create gma files for publishing
# testing requirest then extracting the gma and mounting it via 
# Garrysmod/garrysmod/cfg/mount.cfg
#
	#$(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
110
	#$(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
111
112
113
114
	#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
115
	# 	addons-src/maps/*.res
dylan grafmyre's avatar
dylan grafmyre committed
116
	# $(GMAD_BIN) $(GMAD_FLAGS) create -folder "addons-src" -out "$@"
dylan grafmyre's avatar
snap    
dylan grafmyre committed
117
addons/%.gma: %.bsp addons-src/addon.json
dylan grafmyre's avatar
snap    
dylan grafmyre committed
118
119
	rm -rv \
		addons-src/maps/*.bsp \
dylan grafmyre's avatar
snap    
dylan grafmyre committed
120
		addons-src/maps/thumb/*.png \
dylan grafmyre's avatar
snap    
dylan grafmyre committed
121
		|| true
dylan grafmyre's avatar
snap    
dylan grafmyre committed
122
	cp $(word 1, $^) addons-src/maps/
dylan grafmyre's avatar
dylan grafmyre committed
123
124
	cp thumbnail_map_128.png addons-src/maps/thumb/$(basename $(word 1, $^)).png
	$(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
125

dylan grafmyre's avatar
snap    
dylan grafmyre committed
126
127
128
129
130
131
132
addons/%/.d: addons/%.gma
	tar -C addons -xvf $(^:.gma=.tar)
	touch $@

addons/%: addons/%/.d
	true

dylan grafmyre's avatar
snap    
dylan grafmyre committed
133
134
135
136
137
138
# 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
139

dylan grafmyre's avatar
dylan grafmyre committed
140
141
142
143
144
145
#publish: addons/ttt_terrorcon_v2_hdr_final_p.gma
#	$(GMPUBLISH_BIN) $(GMPUBLISH_FLAGS) create -addon "$^" -icon "addons/512x512.jpg"

# custom rules

.DEFAULT: all
146
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
147
148
fast: lint maps/ttt_terrorcon_v2_fast.bsp ttt_terrorcon_v2_fast.game

149
install-bsp: maps/ttt_terrorcon_v2_hdr_final.bsp maps/thumb/ttt_terrorcon_v2_hdr_final.png
dylan grafmyre's avatar
dylan grafmyre committed
150
151
152
	cp -v $(word 1, $^) $(MOD_DIR)maps\\
	cp -v $(word 2, $^) $(MOD_DIR)maps\\thumb\\

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

dylan grafmyre's avatar
dylan grafmyre committed
159
lint: ttt_terrorcon_v2.bspzip-addlist
dylan grafmyre's avatar
dylan grafmyre committed
160
	$(PYTHON_BIN) ./contrib/bspzip-lint $^ 2>&1 | tee $^.lint
161
162
mount:
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS)