#!/usr/bin/make -f

#export DH_VERBOSE=1

# Cope with lam not providing mpicc.
include /usr/share/mpi-default-dev/debian_defaults 
ifeq ($(ARCH_DEFAULT_MPI_IMPL),lam)
  CC:=mpicc.lam
else
  CC:=mpicc
endif

ARCH:=$(shell dpkg --print-architecture)
WITH_LUSTRE := 

#ifeq ($(ARCH), i386) 
#  WITH_LUSTRE:= --with-lustre=/usr
#endif
#ifeq ($(ARCH), amd64)
#  WITH_LUSTRE:= --with-lustre=/usr
#endif
#ifeq ($(ARCH), powerpc) 
#  WITH_LUSTRE:= --with-lustre=/usr
#endif
#ifeq ($(ARCH), ia64) 
#  WITH_LUSTRE:= --with-lustre=/usr
#endif

BINDIR=debian/libadios-dev/usr/bin
DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# magic debhelper rule
%:
	dh $@ --with python2

override_dh_auto_clean:
	dh_clean
	find . -name '*.pyc' -delete

override_dh_auto_configure:
	dh_auto_configure --  $(WITH_LUSTRE) --enable-shared --prefix=`pwd`/debian/tmp  MPIFC=mpif77 CC=$(CC)

override_dh_auto_install:
	$(MAKE) install prefix=$(shell pwd)/debian/libadios-dev/usr 
	# remove due to it not working in multi-arch;
	rm -f  $(BINDIR)/adios_config.flags
	# renamed as per Adios CCS issue #118716, Debbug #639257
	mv $(BINDIR)/gpp.py $(BINDIR)/adiosxml2h
	cp debian/adios_config $(BINDIR)/adios_config
	mv $(BINDIR)/gpp_types.py $(BINDIR)/gpp_types
	mv $(BINDIR)/xmlparser.py $(BINDIR)/xmlparser
