#!/usr/bin/make -f

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

%:
	dh $@

override_dh_auto_clean:
	[ ! -f Mkinclude ] || $(MAKE) clean
	-rm -f Mkinclude SIGEN.htm config.cache config.log config.status
	-rm -f src/f*/charset.* chkfort.cfg
	-rm -rf tmp
	dh_clean
	rm -f src/f77/x
	rm -f src/f90/x

override_dh_auto_configure:
	FC=/usr/bin/gfortran \
		 dh_auto_configure -- \
		 --enable-shared \
		 --bindir=/usr/bin \
		 --includedir=/usr/include/dcl-f90 \
		 --with-dclconfig=/usr/bin/dclconfig

override_dh_auto_install:
	dh_auto_install -- prefix=$(CURDIR)/debian/tmp/usr
	( cd $(CURDIR)/debian/tmp/usr/lib && \
		$(CC) $(CFLAGS) $(LDFLAGS) --shared -Wl,-soname,libf90dcl.so.5 -o libf90dcl.so.5.2 \
		  -Wl,--whole-archive libf90dcl.a -Wl,--no-whole-archive )
	( cd $(CURDIR)/debian/tmp/usr/lib && \
		ln -s libf90dcl.so.5.2 libf90dcl.so.5 )
	( cd $(CURDIR)/debian/tmp/usr/lib && \
		ln -s libf90dcl.so.5.2 libf90dcl.so )

.PHONY: override_dh_strip
override_dh_strip:
	dh_strip --dbg-package=dcl-f90-dbg
