#!/usr/bin/make -f
# -*- makefile -*-
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

%:
	dh $@

override_dh_auto_configure:
	FC=gfortran \
	  dh_auto_configure -- --prefix=/usr

override_dh_auto_test:

override_dh_auto_install:
	mkdir -p $(CURDIR)/debian/tmp/usr
	dh_auto_install -- prefix=$(CURDIR)/debian/tmp/usr
	rm debian/tmp/usr/bin/dclconfig
	$(CC) $(LDFLAGS) -shared -Wl,-soname,libf77dcl.so.6 \
	  -o $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libf77dcl.so.6.0.0 \
	  `find $(CURDIR) -name \*.o`
	( cd $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) ; ln -s libf77dcl.so.6.0.0 libf77dcl.so.6 )
	( cd $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) ; ln -s libf77dcl.so.6.0.0 libf77dcl.so )

override_dh_install:
	dh_install --sourcedir=debian/tmp

override_dh_auto_clean:
	[ ! -f Mkinclude ] || $(MAKE) distclean
	dh_auto_clean
	rm -f $(CURDIR)/lib/lib*.so
	rm -f $(CURDIR)/lib/lib*.so.*
	rm -f $(CURDIR)/src/misc1/fiolib/fcpack.f

override_dh_compress:
	dh_compress -X.png -X.f -X.dat

override_dh_installchengelogs:
	dh_installchangelogs --all --keep HISTORY

override_dh_installdocs:
	dh_installdocs -A README CREDITS

.PHONY: override_dh_strip
override_dh_strip:
	dh_strip --dbg-package=libf77dcl6-dbg
