#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1


# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


%:
	if [ ! -r CMakeLists.txt ]; then ln -s CMakeLists.txt.ci CMakeLists.txt; fi
	#if [ ! -d htslib ]; then mkdir -p htslib; ln -s /usr/lib/`dpkg-architecture -qDEB_BUILD_MULTIARCH`/libhts.a htslib/; fi
	#if [ ! -d libBigWig ]; then mkdir -p libBigWig; ln -s /usr/lib/`dpkg-architecture -qDEB_BUILD_MULTIARCH`/libBigWig.a libBigWig/; fi
	#if [ ! -d libdeflate ]; then mkdir -p libdeflate; ln -s /usr/lib/`dpkg-architecture -qDEB_BUILD_MULTIARCH`/libdeflate.a libdeflate/; fi
	#if [ ! -d zlib ]; then mkdir -p zlib; ln -s /usr/lib/`dpkg-architecture -qDEB_BUILD_MULTIARCH`/libz.a zlib/; fi
	dh $@


override_dh_auto_install:
	dh_auto_install
	mkdir -p debian/megadepth/usr/bin
	cp obj-*/megadepth_dynamic debian/megadepth/usr/bin/megadepth

override_dh_installman:
	dh_installman

override_dh_auto_clean:
	dh_auto_clean
	if [ -d zlib_ci ]; then rmdir zlib_ci; fi
	if [ -d libBigWig_ci ]; then rmdir libBigWig_ci; fi
	if [ -d libdeflate_ci ]; then rmdir libdeflate_ci; fi
	if [ -d htslib_ci ]; then rmdir htslib_ci; fi
	rm -rf htslib libbigwig libBigWig libdeflate libz zlib
	rm CMakeLists.txt
