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

DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_MULTIARCH     ?= $(dpkg-architecture -qDEB_HOST_MULTIARCH)

ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel))
LIBOMP_ARCH = mips
endif

ifneq (,$(filter $(DEB_HOST_ARCH), mips64 mips64el))
LIBOMP_ARCH = mips64
endif

%:
	dh $@

override_dh_auto_build:
	cd obj-* && make compiler=gcc
	cd runtime && doxygen doc/doxygen/config
	cd runtime/doc/doxygen/generated/html/ && rm jquery.js && ln -s /usr/share/javascript/jquery/jquery.js

override_dh_clean:
	rm -rf obj-*
	dh_clean

override_dh_install:
	cd debian/tmp/usr/lib && \
		ln -s libomp.so.$(SONAME) libomp.so
	dh_install
	mkdir -p debian/libomp$(SONAME)/usr/lib/$(DEB_HOST_MULTIARCH)/
	mv debian/libomp$(SONAME)/usr/lib/libomp* debian/libomp$(SONAME)/usr/lib/$(DEB_HOST_MULTIARCH)/
	mkdir -p debian/libomp-dev/usr/lib/$(DEB_HOST_MULTIARCH)/
	mv debian/libomp-dev/usr/lib/lib*omp* debian/libomp-dev/usr/lib/$(DEB_HOST_MULTIARCH)/

override_dh_strip:
	dh_strip -plibomp$(SONAME) --dbg-package=libomp$(SONAME)-dbg
