#!/usr/bin/make -f

# DEB_TAR_SRCDIR = fluxbox-1.1.1

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

DEBLOGO_WALLPAPER_SRC	:= debian/extra/backgrounds/wallpaper-flux-debian-lighting-black-1600x1200.svg
DEBLOGO_WALLPAPER_PNG	:= $(DEBLOGO_WALLPAPER_SRC:%.svg=%.png)

DEB_CONFIGURE_SYSCONFDIR := /etc/X11/fluxbox

DEB_CONFIGURE_EXTRA_FLAGS := --enable-xinerama --enable-nls \
		--with-apps=$(DEB_CONFIGURE_SYSCONFDIR)/apps \
	     	--with-keys=$(DEB_CONFIGURE_SYSCONFDIR)/keys \
	     	--with-init=$(DEB_CONFIGURE_SYSCONFDIR)/init \
		--with-overlay=$(DEB_CONFIGURE_SYSCONFDIR)/overlay \
	     	--with-menu=$(DEB_CONFIGURE_SYSCONFDIR)/fluxbox.menu-user \
	     	--with-windowmenu=$(DEB_CONFIGURE_SYSCONFDIR)/window.menu \
	     	--with-style=/usr/share/fluxbox/styles/debian_squeeze_dark \
	     	--with-locale=/usr/share/fluxbox/nls \
	     	--enable-shape

CXXFLAGS := -O2 -ffunction-sections

#fix FTBFS with binutils-gold
LDFLAGS=-lfontconfig

$(DEBLOGO_WALLPAPER_PNG): $(DEBLOGO_WALLPAPER_SRC)
	convert $< $@

configure/fluxbox:: $(DEBLOGO_WALLPAPER_PNG)
#         touch aclocal.m4 config.h.in Makefile.in configure
	# replace lucida font to dejavu
	find build-tree/$(DEB_TAR_SRCDIR)/data/styles/ -type f | \
		grep -v 'xpm$$'|grep -v Makefile | xargs \
			perl -pi -e 's#\sbsetroot# fbsetroot#g; \
				s#\slucida# dejavu#g; \
				s#\s-\S+?-lucida-# -*-dejavu-#g; \
				s#\slucidasans# dejavusans#g; \
				s#-lucidatypewriter-#-dejavu-#g'

clean::
	rm -f *.cdbs-config_list $(DEBLOGO_WALLPAPER_PNG)
	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 menu file generated by the 'menu' package.
	rm -f ./debian/fluxbox/usr/bin/fluxbox-generate_menu
	perl debian/debian-fluxbox-config-patch.pl
