# Makefile

NAME=frcup36
MAP_SRC=maps/$(NAME).map
MAP_BSP=maps/$(NAME).bsp
PK3_DST=~/.q3a/defrag/$(NAME).pk3
#DATA_LIST=levelshots maps scripts textures *.txt Makefile
DATA_LIST=levelshots $(MAP_SRC) $(MAP_BSP) scripts textures *.txt Makefile

Q3MAP2	= ~/q3a/radiant/netradiant-20110309-ubuntu64/q3map2.x86_64 -game quake3 -threads 4

all: pk3

remove-pk3:
	@rm -f $(PK3_DST)

pk3: remove-pk3
	@7z a -tzip -xr\!*.xcf.gz $(PK3_DST) $(DATA_LIST)
	@ls -l $(PK3_DST)

# building targets
# some helpers

$(MAP_SRC):
	@ls -l $(MAP_SRC)

bsp-meta-test: $(MAP_SRC)
	@echo Building META for test build...
	$(Q3MAP2) -meta -samplesize 16 $<

bsp-meta: $(MAP_SRC)
	@echo Building META...
	$(Q3MAP2) -meta -samplesize 8 $<

bsp-meta-final: $(MAP_SRC)
	@echo Building META for final build...
	$(Q3MAP2) -meta -samplesize 4 $<


bsp-vis-test: $(MAP_SRC)
	@echo Building VIS for test build...
	$(Q3MAP2) -vis -saveprt -fast $<

bsp-vis: $(MAP_SRC)
	@echo Building VIS for final build...
	$(Q3MAP2) -vis -saveprt $<

bsp-vis-final: bsp-vis


bsp-light-test: $(MAP_SRC)
	@echo Building LIGHT for test build...
	$(Q3MAP2) -light -fast -patchshadows -samples 2 $<

bsp-light: $(MAP_SRC)
	@echo Building LIGHT...
	$(Q3MAP2) -light -fast -patchshadows -samples 3 -gamma 2.2 -compensate 4.0 -dark -dirty -shade $<

bsp-light-final: $(MAP_SRC)
	@echo Building LIGHT for final build...
	$(Q3MAP2) -light -fast -patchshadows -samples 3 -gamma 2.2 -compensate 4.0 -dark -dirty -shade -bounce 8 -bouncegrid $<

# the useful ones

bsp-test: bsp-meta-test bsp-vis-test bsp-light-test
	@ls -l $(MAP_BSP)

bsp: bsp-meta bsp-vis bsp-light
	@ls -l $(MAP_BSP)

bsp-final: bsp-meta-final bsp-vis-final bsp-light-final
	@ls -l $(MAP_BSP)

