#!/usr/bin/make -f

FLAGS=-g -O2 -pipe -ffast-math -mtune=generic -msse -msse2 -mfpmath=sse -fPIC -DPIC -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2

export CFLAGS=$(FLAGS)
export CXXFLAGS=$(FLAGS)
export LDFLAGS=-Wl,-O1 -Wl,-Bsymbolic-functions -Wl,--strip-all -Wl,-z,relro,-z,now

override_dh_auto_configure:
	./configure --enable-sse --enable-static --disable-shared --disable-thorough-tests --disable-xmms-plugin --prefix=/opt/kxstudio/

override_dh_auto_install:
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp/
	find $(CURDIR)/debian/tmp/ -name \*.la -delete

override_dh_auto_test:
	dh_auto_test --no-act

override_dh_auto_clean:
	if [ -f Makefile ]; then make clean; fi

	rm -f Makefile
	rm -f build/Makefile
	rm -f config.h
	rm -f config.log
	rm -f config.status
	rm -f doc/Makefile
	rm -f doc/html/Makefile
	rm -f doc/html/images/Makefile
	rm -f doc/html/images/hw/Makefile
	rm -f doc/html/ru/Makefile
	rm -f examples/Makefile
	rm -f examples/c/Makefile
	rm -f examples/c/decode/Makefile
	rm -f examples/c/decode/file/Makefile
	rm -f examples/c/encode/Makefile
	rm -f examples/c/encode/file/Makefile
	rm -f examples/cpp/Makefile
	rm -f examples/cpp/decode/Makefile
	rm -f examples/cpp/decode/file/Makefile
	rm -f examples/cpp/encode/Makefile
	rm -f examples/cpp/encode/file/Makefile
	rm -f include/FLAC++/Makefile
	rm -f include/FLAC/Makefile
	rm -f include/Makefile
	rm -f include/share/Makefile
	rm -f include/share/grabbag/Makefile
	rm -f include/test_libs_common/Makefile
	rm -f libtool
	rm -f libtool-disable-static
	rm -f m4/Makefile
	rm -f man/Makefile
	rm -f obj/Makefile
	rm -f obj/debug/Makefile
	rm -f obj/debug/bin/Makefile
	rm -f obj/debug/lib/Makefile
	rm -f obj/release/Makefile
	rm -f obj/release/bin/Makefile
	rm -f obj/release/lib/Makefile
	rm -f src/Makefile
	rm -f src/flac/Makefile
	rm -f src/libFLAC++/Makefile
	rm -f src/libFLAC++/flac++.pc
	rm -f src/libFLAC/Makefile
	rm -f src/libFLAC/flac.pc
	rm -f src/libFLAC/ia32/Makefile
	rm -f src/libFLAC/include/Makefile
	rm -f src/libFLAC/include/private/Makefile
	rm -f src/libFLAC/include/protected/Makefile
	rm -f src/libFLAC/ppc/Makefile
	rm -f src/libFLAC/ppc/as/Makefile
	rm -f src/libFLAC/ppc/gas/Makefile
	rm -f src/metaflac/Makefile
	rm -f src/monkeys_audio_utilities/Makefile
	rm -f src/monkeys_audio_utilities/flac_mac/Makefile
	rm -f src/monkeys_audio_utilities/flac_ren/Makefile
	rm -f src/plugin_common/Makefile
	rm -f src/plugin_winamp2/Makefile
	rm -f src/plugin_winamp2/include/Makefile
	rm -f src/plugin_winamp2/include/winamp2/Makefile
	rm -f src/plugin_xmms/Makefile
	rm -f src/share/Makefile
	rm -f src/share/getopt/Makefile
	rm -f src/share/grabbag/Makefile
	rm -f src/share/replaygain_analysis/Makefile
	rm -f src/share/replaygain_synthesis/Makefile
	rm -f src/share/replaygain_synthesis/include/Makefile
	rm -f src/share/replaygain_synthesis/include/private/Makefile
	rm -f src/share/utf8/Makefile
	rm -f src/test_grabbag/Makefile
	rm -f src/test_grabbag/cuesheet/Makefile
	rm -f src/test_grabbag/picture/Makefile
	rm -f src/test_libFLAC++/Makefile
	rm -f src/test_libFLAC/Makefile
	rm -f src/test_libs_common/Makefile
	rm -f src/test_seeking/Makefile
	rm -f src/test_streams/Makefile
	rm -f stamp-h1
	rm -f test/Makefile
	rm -f test/cuesheets/Makefile
	rm -f test/flac-to-flac-metadata-test-files/Makefile
	rm -f test/metaflac-test-files/Makefile
	rm -f test/pictures/Makefile

%:
	dh $@
