Makefile 4.87 KB
Newer Older
dylan grafmyre's avatar
dylan grafmyre committed
1
#
dylan grafmyre's avatar
dylan grafmyre committed
2
GAME?=hl2.exe
dylan grafmyre's avatar
dylan grafmyre committed
3
4

PYTHON_BIN?=./env/scripts/python
dylan grafmyre's avatar
snap    
dylan grafmyre committed
5
6
7
GAME_DIR?=D:\\Steam\\steamapps\\common\\GarrysMod\\
VBIN_DIR?=$(GAME_DIR)bin\\
MOD_DIR?=$(GAME_DIR)garrysmod\\
dylan grafmyre's avatar
dylan grafmyre committed
8
MOUNT_DIR?=.\\
dylan grafmyre's avatar
dylan grafmyre committed
9
10
VBIN_FLAGS?=-game $(MOD_DIR)

dylan grafmyre's avatar
dylan grafmyre committed
11
SUPERVISE_V_BIN?=./contrib/supervise-v
dylan grafmyre's avatar
dylan grafmyre committed
12
BSP_BIN?=$(SUPERVISE_V_BIN) $(VBIN_DIR)vbsp.exe
dylan grafmyre's avatar
dylan grafmyre committed
13
BSP_FLAGS?=$(VBIN_FLAGS)
dylan grafmyre's avatar
dylan grafmyre committed
14
VIS_BIN?=$(SUPERVISE_V_BIN) $(VBIN_DIR)vvis.exe
dylan grafmyre's avatar
dylan grafmyre committed
15
VIS_FLAGS?=$(VBIN_FLAGS) -fast
dylan grafmyre's avatar
dylan grafmyre committed
16
RAD_BIN?=$(SUPERVISE_V_BIN) $(VBIN_DIR)vrad.exe
dylan grafmyre's avatar
dylan grafmyre committed
17
18
RAD_FLAGS?=$(VBIN_FLAGS) -StaticPropLighting -bounce 2 -noextra
# -StaticPropSampleScale 0.25 
19
20
BSPZIP_BIN?=$(SUPERVISE_V_BIN) $(VBIN_DIR)bspzip.exe
BSPZIP_FLAGS?=$(VBIN_FLAGS)
Dylan Grafmyre's avatar
Dylan Grafmyre committed
21
22
23
24
GMAD_BIN?=$(VBIN_DIR)gmad.exe
GMAD_FLAGS?=
GMPUBLISH_BIN?=$(VBIN_DIR)gmpublish.exe
GMPUBLISH_FLAGS?=
dylan grafmyre's avatar
dylan grafmyre committed
25

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

dylan grafmyre's avatar
snap    
dylan grafmyre committed
29
30
31
J2_BIN?=$(PYTHON_BIN) ./contrib/j2
J2_FLAGS?=

dylan grafmyre's avatar
dylan grafmyre committed
32
33
GMAD_TAR_BIN?=$(PYTHON_BIN) ./contrib/gmad-tar
GMAD_TAR_FLAGS?=
dylan grafmyre's avatar
dylan grafmyre committed
34
35

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

39
40
41
%.bspzip-addlist: %.vmf
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $@

dylan grafmyre's avatar
dylan grafmyre committed
42
%.game: %.bsp
dylan grafmyre's avatar
snap    
dylan grafmyre committed
43
ifeq ($(GAME),0)
dylan grafmyre's avatar
dylan grafmyre committed
44
	echo "user disabled run game via GAME=0"
dylan grafmyre's avatar
snap    
dylan grafmyre committed
45
else
dylan grafmyre's avatar
snap    
dylan grafmyre committed
46
	$(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
47
endif
dylan grafmyre's avatar
dylan grafmyre committed
48

dylan grafmyre's avatar
dylan grafmyre committed
49

dylan grafmyre's avatar
snap    
dylan grafmyre committed
50
51
maps/%.bsp: %.bsp
	cp $^ $@
dylan grafmyre's avatar
dylan grafmyre committed
52
53
54
55
56
57
58
59

# hammer default flags
%_default.bsp: %.vmf
	# default
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) $(VBIN_FLAGS) $(basename $^)
	mv $(@:_default.bsp=.bsp) $@
60
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
61
62
63
64
65
66
67

%_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) $@
68
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
69
70
71
72
73
74
75

%_hdr.bsp: %.vmf
	# hdr
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) -both $(VBIN_FLAGS) $(basename $^)
	mv $(@:_hdr.bsp=.bsp) $@
76
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
77
78
79
80
81
82
83

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

dylan grafmyre's avatar
dylan grafmyre committed
86
87
88
89
90
91
# 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
92

dylan grafmyre's avatar
snap    
dylan grafmyre committed
93
94
95
96
97
98
99
100
101
102
103
104

# 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
	#$(J2_BIN) $(J2_FLAGS) <addons-src/maps/template.res.j2 $(basename $^) >addons-src/maps/$(basename $^).res
	#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/maps/*.res
	#	addons-src/materials/vgui/maps/*.vmt
	#	addons-src/materials/vgui/maps/*.vtf
dylan grafmyre's avatar
dylan grafmyre committed
105
106

	# $(GMAD_BIN) $(GMAD_FLAGS) create -folder "addons-src" -out "$@"
dylan grafmyre's avatar
snap    
dylan grafmyre committed
107
addons/%.gma: %.bsp addons-src/addon.json Makefile
dylan grafmyre's avatar
snap    
dylan grafmyre committed
108
109
	rm -rv \
		addons-src/maps/*.bsp \
dylan grafmyre's avatar
snap    
dylan grafmyre committed
110
		addons-src/maps/thumb/*.png \
dylan grafmyre's avatar
snap    
dylan grafmyre committed
111
		|| true
dylan grafmyre's avatar
snap    
dylan grafmyre committed
112
	cp $(word 1, $^) addons-src/maps/
dylan grafmyre's avatar
dylan grafmyre committed
113
114
	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
115
116
117
118
119
120
121

# 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
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
#publish: addons/ttt_terrorcon_v2_hdr_final_p.gma
#	$(GMPUBLISH_BIN) $(GMPUBLISH_FLAGS) create -addon "$^" -icon "addons/512x512.jpg"

# custom rules

.DEFAULT: all
all: lint maps/ttt_terrorcon_v2_hdr_final_p.bsp addons/ttt_terrorcon_v2_hdr_final_p.gma ttt_terrorcon_v2_hdr_final_p.game
fast: lint maps/ttt_terrorcon_v2_fast.bsp ttt_terrorcon_v2_fast.game

install-bsp: maps/ttt_terrorcon_v2_hdr_final_p.bsp maps/thumb/ttt_terrorcon_v2_hdr_final_p.png
	cp -v $(word 1, $^) $(MOD_DIR)maps\\
	cp -v $(word 2, $^) $(MOD_DIR)maps\\thumb\\

# gmod dosn't allow this
# so instead, i've got a parallel artifact being built that can be installed to garrysmod
#install-gma: addons/ttt_terrocon_v2_hdr_final_p.gma
#	cp -v $^ $(MOD_DIR)addons\\
Dylan Grafmyre's avatar
Dylan Grafmyre committed
140

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