#!/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

VER=may23a
SRCDIR=gildas-src-$(VER)
EXEDIR=gildas-exe-$(VER)
tunecpu:=skylake

GAG_CFLAGS   += -mtune=$(tunecpu)
CXXFLAGS += -mtune=$(tunecpu)
GAG_FFLAGS   += -mtune=$(tunecpu)
CFLAGS  += -mtune=$(tunecpu)
FFLAGS  += -mtune=$(tunecpu)

%:
	dh $@

override_dh_auto_configure:
	tar JxpSf $(SRCDIR).tar.xz

override_dh_clean: 
	if [ -d $(EXEDIR) ]; then \
	   rm -rf $(EXEDIR); \
	fi
	[ ! -f gildas.sh ] || rm gildas.sh
	rm -f build-stamp configure-stamp

	: # Add here commands to clean up after the build process.
	if [ -d $(SRCDIR) ] ; then \
	  rm -rf $(SRCDIR); \
	fi
	dh_clean 

override_dh_install:
	: # Add here commands to install the package into debian/gildas.
	: #$(MAKE) DESTDIR=$(CURDIR)/debian/gildas install
	bash $(CURDIR)/debian/confbuildinst.sh $(CURDIR)/$(SRCDIR) $(EXEDIR)
	cp -a $(CURDIR)/$(EXEDIR) $(CURDIR)/debian/gildas/opt/astro/gildas
	cp $(CURDIR)/gildas.sh $(CURDIR)/debian/gildas/etc/
	cp $(CURDIR)/$(SRCDIR)/admin/bash_profile.src $(CURDIR)/debian/gildas/opt/astro/gildas/$(EXEDIR)/etc/bash_profile
	dh_install

override_dh_shlibdeps:
	dh_shlibdeps -lopt/astro/gildas/$(EXEDIR)/x86_64-ubuntu22.04-gfortran/lib
