#!/usr/bin/make -f
# -*- makefile -*-

# https://wiki.debian.org/Hardening
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

%:
	dh $@

override_dh_auto_configure:
	cd asedriveiiie-usb ; CFLAGS="$(CFLAGS) $(CPPFLAGS)" ./configure
	cd asedriveiiie-serial ; CFLAGS="$(CFLAGS) $(CPPFLAGS)" ./configure

override_dh_auto_build:
	$(MAKE) -C asedriveiiie-usb
	$(MAKE) -C asedriveiiie-serial

override_dh_auto_clean:
	rm -f build-stamp configure-stamp
	touch asedriveiiie-usb/Makefile.inc
	$(MAKE) -C asedriveiiie-usb clean
	touch asedriveiiie-serial/Makefile.inc
	$(MAKE) -C asedriveiiie-serial clean
	dh_auto_clean


USBDIR = $(CURDIR)/debian/libasedrive-usb/usr/lib/pcsc/drivers/
SERIALDIR = $(CURDIR)/debian/libasedrive-serial/usr/lib/pcsc/drivers/

# note that the Athena source package has no "make install" target; we have
# to kick all the files around ourselves.
override_dh_auto_install:
	dh_auto_install

	$(MAKE) -C asedriveiiie-usb install DESTDIR=`pwd`/debian/libasedrive-usb
	rm debian/libasedrive-usb/usr/lib/pcsc/drivers/ifd-ASEDriveIIIe-USB.bundle/Contents/PkgInfo
	rm -r debian/libasedrive-usb/usr/lib/pcsc/drivers/ifd-ASEDriveIIIe-USB.bundle/Contents/Resources
	$(MAKE) -C asedriveiiie-serial install DESTDIR=`pwd`/debian/libasedrive-serial
