DEPTH = ../../../..

include $(DEPTH)/Makefile.os

PACKAGE?=freedoko-altenburg

TARGET_DIR?=/tmp/FreeDoko.packages
PACKAGE_DIR?=$(TARGET_DIR)/$(PACKAGE)-$(VERSION)

# Edited for Debian GNU/Linux.
DESTDIR = 

.PHONY: all release_directory package

all :

release_directory :
	-rm -rf $(PACKAGE_DIR)
	mkdir -p $(PACKAGE_DIR)
	# included packages
	for p in freedoko-binary freedoko-data freedoko-backgrounds freedoko-translation-de freedoko-translation-en freedoko-manual-base freedoko-manual-de freedoko-manual-en; do \
	  echo; \
	  echo "Subpackage $$p"; \
	  echo; \
	  export PACKAGE_DIR=$(PACKAGE_DIR)/subpackage \
	    && make -C ../$$p release_directory \
	    && cp -a $(PACKAGE_DIR)/subpackage/* $(PACKAGE_DIR) \
	    && rm -rf $(PACKAGE_DIR)/subpackage; \
	done
	# own files
	rm -rf $(PACKAGE_DIR)/debian
	cp -a . $(PACKAGE_DIR)/debian
	cp Makefile.install $(PACKAGE_DIR)/Makefile
	for f in FreeDoko.6 README.Debian conffiles docs freedoko.6 freedoko.sgml; do \
	  cp -a ../freedoko-binary/$$f $(PACKAGE_DIR)/debian/; \
	done
	sed "s/freedoko-binary/freedoko-altenburg/g" ../freedoko-binary/menu > $(PACKAGE_DIR)/debian/menu
	#   cardset Altenburg
	mkdir -p $(PACKAGE_DIR)/data/cardsets
	cp -a $(DEPTH)/data/cardsets/Altenburg $(PACKAGE_DIR)/data/cardsets/Altenburg

package : release_directory
	cd $(PACKAGE_DIR) \
	  && debuild --preserve-envvar CXX
