#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

#DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
#DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

#ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
#CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
#else
#CROSS= --build $(DEB_BUILD_GNU_TYPE)
#endif

include /usr/share/hardening-includes/hardening.make
FLAGS=$(shell dpkg-buildflags --get CFLAGS)
LDFLAGS=$(shell dpkg-buildflags --get LDFLAGS)
CFLAGS+=$(HARDENING_CFLAGS)
LDFLAGS+=$(HARDENING_LDFLAGS)


%:
	dh $@  --with autotools-dev

override_dh_auto_configure:
	#
	./configure $(CROSS) \
		--prefix=/usr \
		--mandir=\$${prefix}/share/man \
		--infodir=\$${prefix}/share/info \
		--with-external-libupnp \
		--with-external-talloc \
		CFLAGS="$(CFLAGS)" \
		LDFLAGS="$(LDFLAGS) -Wl,-z,defs,--as-needed" \

override_dh_auto_install:
	$(MAKE) DESTDIR=$(CURDIR)/debian/djmount install
	chrpath -d $(CURDIR)/debian/djmount/usr/bin/djmount
	dh_install

override_dh_auto_test:

override_dh_auto_clean:
	[ ! -f Makefile ] || $(MAKE) clean-generic distclean-am distclean-libtool
	rm -rfv gl/Makefile
	rm -rfv gl/.libs
	rm -rfv gl/*.la
	rm -rfv gl/*.lo
	rm -rfv gl/*.o
