#!/usr/bin/make -f export DH_VERBOSE=1 # The magic debhelper rule: %: dh $@ --buildsystem cmake include /usr/share/mpi-default-dev/debian_defaults MPI:=$(ARCH_DEFAULT_MPI_IMPL) DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) TMPDIR=$(CURDIR)/debian/tmp LIBDIR:=/usr/lib/${DEB_HOST_MULTIARCH} PY3DEST:=debian/python3-xdmf PY3:=$(shell py3versions -d) PY3SUPPORTED:=$(shell py3versions -s) CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) -fPIC AUTOGENERATED:= python3-xdmf.install libxdmf-dev.install libxdmf3.install \ libxdmf3.links libxdmf-dev.links build_types:= mpi serial BUILD_DIRS := $(foreach B,$(build_types),$(foreach P,$(PY3SUPPORTED),debian/build-$B-$P)) CMAKE_FLAGS:= -DXDMF_SYSTEM_ZLIB=ON \ -DXDMF_SYSTEM_LIBXML2=ON \ -DXDMF_USE_BZIP2=ON \ -DXDMF_USE_GZIP=ON \ -DXDMF_BUILD_FORTRAN=ON \ -DXDMF_SWIG_FLAGS=-py3 \ -DXDMF_SYSTEM_HDF5=ON \ -DCMAKE_SKIP_RPATH=ON \ -DXDMF_BUILD_UTILS=ON \ -DCMAKE_INSTALL_PREFIX=/usr \ -DXDMF_WRAP_PYTHON=ON \ -DXDMF_REGENERATE_WRAPPERS=ON \ -DGZSTREAM_LIBRARY=$(LIBDIR)/libgzstream.so \ -DBUILD_SHARED_LIBS=TRUE override_dh_auto_configure: for f in ${AUTOGENERATED} ; do \ cat debian/$$f.in | \ sed -e 's%@PY3@%${PY3}%g' | \ sed -e 's%@MPI@%${MPI}%g' | \ sed -e 's%@MULTIARCH@%${DEB_HOST_MULTIARCH}%g' \ > debian/$$f ; \ done mkdir -p $(BUILD_DIRS) for p in $(PY3SUPPORTED) ; do \ l=`echo $$p | sed -e 's/python3.7/python3.7m/' ` ; \ (cd debian/build-serial-$$p && \ cmake ../.. \ $(CMAKE_FLAGS) \ -DPYTHON_INCLUDE_PATH=/usr/include/$$p \ -DPYTHON_LIBRARY=$(LIBDIR)/lib$$l.so \ -DXDMF_BUILD_MPI=OFF -DXDMF_SYSTEM_HDF5_IS_PARALLEL=OFF \ -DHDF5_ROOT=$(LIBDIR)/hdf5/serial ) ; \ (cd debian/build-mpi-$$p && \ cmake ../.. \ $(CMAKE_FLAGS) \ -DPYTHON_INCLUDE_PATH=/usr/include/$$p \ -DPYTHON_LIBRARY=$(LIBDIR)/lib$$l.so \ -DXDMF_BUILD_MPI=ON -DXDMF_SYSTEM_HDF5_IS_PARALLEL=ON \ -DHDF5_ROOT=$(LIBDIR)/hdf5/$(MPI) ) ; \ done override_dh_auto_build: for p in $(BUILD_DIRS) ; do \ $(MAKE) -C $$p ; done override_dh_auto_test: @echo "Ignore; no tests present" override_dh_auto_install: # Move needed for some reason for p in $(BUILD_DIRS) ; do \ mkdir -p $$p/lib ; \ cp $$p/*.py $$p/lib ; \ done # Assemble something workable from the 4 install dirs. for p in $(PY3SUPPORTED) ; do \ $(MAKE) -C debian/build-mpi-$$p install DESTDIR=$(TMPDIR) ; \ mkdir -p $(PY3DEST)/usr/lib/$$p/dist-packages/xdmf/NoMpi ; \ touch $(PY3DEST)/usr/lib/$$p/dist-packages/xdmf/__init__.py ; \ cp debian/build-serial-$$p/Xdmf.py $(PY3DEST)/usr/lib/$$p/dist-packages/xdmf ; \ cp debian/build-serial-$$p/XdmfUtils.py $(PY3DEST)/usr/lib/$$p/dist-packages/xdmf ; \ cp debian/build-serial-$$p/XdmfCore.py $(PY3DEST)/usr/lib/$$p/dist-packages/xdmf ; \ cp debian/build-serial-$$p/lib/__*.so $(PY3DEST)/usr/lib/$$p/dist-packages/xdmf/NoMpi ; \ cp debian/build-mpi-$$p/lib/__*.so $(PY3DEST)/usr/lib/$$p/dist-packages/xdmf ; \ done # Remove build path and kernel version, adjust path to uname, # and remove sytem processor and number of processors to make # build reproducible sed -i -e "s,$(CURDIR),BUILDDIR,g" \ -e "s,/usr/bin/uname,/bin/uname,g" \ -e "s,$(shell uname -r),,g" \ -e "/XDMF_CMAKE_SYSTEM_PROCESSOR/d" \ -e "/XDMF_CMAKE_HOST_SYSTEM_PROCESSOR/d" \ -e "/XDMF_MPIEXEC_MAX_NUMPROCS/d" \ debian/tmp/$(LIBDIR)/cmake/Xdmf/XdmfConfig.cmake override_dh_auto_fixperms: dh_auto_fixperms find debian/libxdmf-dev -type f -exec chmod 644 {} \; override_dh_auto_clean: dh_auto_clean rm -f $(patsubst %, debian/%, ${AUTOGENERATED}) rm -rf $(BUILD_DIRS)