#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

include /usr/share/dpkg/architecture.mk

# GCC 15's <omp.h> declares C++ templates/namespaces, but SuiteSparse's
# /usr/include/suitesparse/SuiteSparse_config.h includes <omp.h> inside an
# `extern "C"` block (when _OPENMP is defined), which the compiler rejects with
# "error: template with C linkage" for every translation unit that reaches
# dune/istl/umfpack.hh (directly or via dune/istl/overlappingschwarz.hh) before
# <omp.h> has been included anywhere else.  Force-include <omp.h> first so that
# the nested inclusion is a no-op thanks to its _OMP_H include guard.
OPM_DEBIAN_CMAKE_FLAGS = -DINSTALL_BENCHMARKS=1 -DCMAKE_CXX_FLAGS="-include omp.h"

override_dh_install:
	# Manual delete runpath set by openmpi 5.0.5
	# See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1085509
	find debian/tmp/ \( -name \*.so -o  -name \*.so.\* \) -exec chrpath -d '{}' \; || true
	find debian/tmp/usr/bin -type f -exec chrpath -d '{}' \; || true
	dh_install

%:
	dh $@

OPM_DEBIAN_MK ?= /usr/share/opm/opm-debian.mk
ifneq ("$(wildcard $(OPM_DEBIAN_MK))","")
   include $(OPM_DEBIAN_MK)
endif
OPM_LIB_DEBIAN_MK ?= /usr/share/opm/opm-lib-debian.mk
ifneq ("$(wildcard $(OPM_LIB_DEBIAN_MK))","")
    include $(OPM_LIB_DEBIAN_MK) # for makeshlibs
endif
