# Qfusion root makefile

include source/Makefile.inc


# Variables

PACKS = base.pk3 rotmirror5.pk3

QF_TGZ=qfusion-$(VERSION)-$(ARCH)-1.tar.gz
QF_BZ2=qfusion-$(VERSION)-$(ARCH)-1.tar.bz2
QF_ZIP=qfusionr$(VERSION_MINOR)_src.zip


# Targets

default: debug release packing

dist: zip tgz

debug:
	@$(MAKE) -C source debug

release:
	@$(MAKE) -C source release

packing: $(PACKS)

tgz: $(QF_TGZ)

bz2: $(QF_BZ2)


zip: $(QF_ZIP)


clean: clean-debug clean-release clean-packing clean-tgz clean-bz2 clean-zip

clean-debug:
	@$(MAKE) -C source clean-debug

clean-release:
	@$(MAKE) -C source clean-release

clean-packing:
	@rm -f base.pk3

clean-tgz:
	@rm -f $(QF_TGZ)
clean-bz2:
	@rm -f $(QF_BZ2)

clean-zip:
	@rm -f $(QF_ZIP)

distclean:
	@$(MAKE) -C source distclean
	@$(MAKE) clean-packing clean-tgz clean-bz2 clean-zip
	@-rmdir -p $(BUILD_DEBUG_DIR)/baseqf $(BUILD_RELEASE_DIR)/baseqf


# Rules

base.pk3:
	@echo
	@echo "> Packing $@"
	@rm -f $@
	@zip -9 $@ default.cfg huds/*.hud scripts/*.shader

$(QF_TGZ): release packing
	@echo
	@echo "> Packing $@"
	@rm -f $@
	@cp -f $(PACKS) $(BUILD_RELEASE_DIR)/baseqf && \
		cd $(BUILD_RELEASE_DIR) && \
		tar czvf ../$@ ../doc/*.* qfusion qfds baseqf/*.*

$(QF_BZ2): release packing
	@echo
	@echo "> Packing $@"
	@rm -f $@
	cp -f $(PACKS) $(BUILD_RELEASE_DIR)/baseqf/ && \
		cd $(BUILD_RELEASE_DIR) && \
		tar cjvf ../$@ ../doc/*.* qfusion qfds baseqf/*.*

$(QF_ZIP): distclean
	@echo
	@echo "> Packing $@"
	@rm -f $@
	@zip -r9 $@ * -x '*CVS/*' '*.cvsignore'
