#!/usr/bin/make -f

%:
	dh $@ --with quilt

override_dh_auto_clean:
	[ ! -f Mkinclude ] || $(MAKE) distclean
	dh_auto_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/dclconfig533-f77 

override_dh_auto_install:
	dh_auto_install -- prefix=$(CURDIR)/debian/tmp/usr
	( cd $(CURDIR)/debian/tmp/usr/lib && \
		$(CC) --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 )

override_dh_auto_clean:

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