#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk

PACKAGE = fluxbox

DEB_CONFIGURE_SYSCONFDIR := /etc/X11/fluxbox

DEB_STYLE_DIR = /usr/share/fluxbox/styles/

DEB_CONFIGURE_EXTRA_FLAGS := `./debian/configure-flags.sh $(DEB_CONFIGURE_SYSCONFDIR) $(DEB_STYLE_DIR)`

# Rules for fetching the upstream tarball
CURRENT_TREEISH =$(shell dpkg-parsechangelog | sed -rne 's,^Version: .*git.{9}([^-]+).*,\1,p')
CURVER=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p')

SOURCE_DIR=fluxbox-$(CURVER)
TARBALL=fluxbox_$(CURVER).orig.tar.gz

CXXFLAGS := -O2 -ffunction-sections

#fix FTBFS with binutils-gold
LDFLAGS=-lfontconfig

build:
	./theme/setup.sh
	autoreconf -i --force

clean::
	rm -f *.cdbs-config_list
	rm -f Makefile config.log config.status data/Makefile data/styles/Makefile
	rm -fr .pc src/defaults.cc
	find -name Makefile -delete

install/fluxbox::
	# We use the menu file generated by the 'menu' package.
	rm -f ./debian/fluxbox/usr/bin/fluxbox-generate_menu

$(SOURCE_DIR):
	git clone git://git.fluxbox.org/fluxbox.git $(SOURCE_DIR)
	if [ x$(CURRENT_TREEISH) = x ]; then \
		cd $(SOURCE_DIR) && git checkout v$(CURVER); \
	else \
		cd $(SOURCE_DIR) && git checkout $(CURRENT_TREEISH); \
	fi


$(TARBALL): $(SOURCE_DIR)
	tar czvf $(TARBALL) $(SOURCE_DIR)

get-orig-source: $(TARBALL)
	rm -rf $(SOURCE_DIR) $(SOURCE_DIR).temp


