#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
# Modified for ifrit build by Mark Hymers 2004-2006

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

%:
	dh $@ --buildsystem=cmake --sourcedirectory=build

override_dh_autoconfigure:
	cd build && cmake \
		-DDESIRED_QT_VERSION:STRING=4 \
		-DQT_LIBRARY_DIR:STRING=/usr/lib/qt4 \
		-DQT_QMAKE_EXECUTABLE:STRING=/usr/bin/qmake-qt4 \
		-DCMAKE_EXE_LINKER_FLAGS:STRING="${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -lGL" \
		-DCMAKE_COLOR_MAKEFILE:BOOL=FALSE

override_dh_clean:
	# Clean up stuff which make clean leaves behind
	rm -f build/CMakeCache.txt build/cmake_install.cmake build/Makefile
	rm -f configure/iconfiguresettings.ext.h
	rm -fr build/CMakeFiles build/progress.make
	rm -f configure-stamp build-stamp ifrit
	# Clean CVS junk
	find -name "\.#*" -delete
	dh_clean

override_dh_install:
	chrpath --delete ifrit
	dh_install
