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

%:
	dh $@ 

override_dh_install:
	dh_install
	# Arch Linux 32-bit biarch glibc looks for locales in
	# /usr/lib32/locale. We might need to use the host system glibc when
	# pressure-vessel brings in the host graphics drivers.
	install -d -m755 debian/steamrt-container-host-compat/usr/lib$(DEB_HOST_ARCH_BITS)
	install -d -m755 debian/steamrt-container-host-compat/usr/lib/locale
	ln -s ../lib/locale debian/steamrt-container-host-compat/usr/lib$(DEB_HOST_ARCH_BITS)/locale
	# Ensure mount points so we can bring all these in from the host
	# system too, if necessary.
	install -d -m755 debian/steamrt-container-host-compat/usr/lib/gconv
	install -d -m755 debian/steamrt-container-host-compat/usr/lib/$(DEB_HOST_MULTIARCH)/gconv
	install -d -m755 debian/steamrt-container-host-compat/usr/lib$(DEB_HOST_ARCH_BITS)/gconv
	install -d -m755 debian/steamrt-container-host-compat/usr/share/drirc.d
	install -d -m755 debian/steamrt-container-host-compat/usr/share/i18n
	install -d -m755 debian/steamrt-container-host-compat/usr/share/libdrm
	# Tell fontconfig where to look for host's fonts
	install -m755 -d debian/steamrt-container-host-compat/etc/fonts/conf.avail/
	install -m755 fonts/fontconfig-flatpak.conf debian/steamrt-container-host-compat/etc/fonts/conf.avail/50-flatpak.conf
	install -m755 -d debian/steamrt-container-host-compat/etc/fonts/conf.d/
	ln -s ../conf.avail/50-flatpak.conf debian/steamrt-container-host-compat/etc/fonts/conf.d/50-flatpak.conf
	# Create a steam symlink to the stub executable steam-runtime-steam-remote
	install -d -m755 debian/steamrt-container-host-compat/usr/bin/
	ln -s steam-runtime-steam-remote debian/steamrt-container-host-compat/usr/bin/steam
	# Create a xdg-open symlink to the alternative executable steam-runtime-urlopen
	ln -s steam-runtime-urlopen debian/steamrt-container-host-compat/usr/bin/xdg-open
	# Create symlinks to support the non-standard Exherbo library paths
ifeq ($(DEB_HOST_ARCH),amd64)
	install -d -m755 debian/steamrt-container-host-compat/usr/x86_64-pc-linux-gnu/lib/gconv
	ln -s /usr/lib/locale debian/steamrt-container-host-compat/usr/x86_64-pc-linux-gnu/lib/locale
	ln -s /lib64/ld-linux-x86-64.so.2 debian/steamrt-container-host-compat/usr/x86_64-pc-linux-gnu/lib/ld-linux-x86-64.so.2
endif
ifeq ($(DEB_HOST_ARCH),i386)
	install -d -m755 debian/steamrt-container-host-compat/usr/i686-pc-linux-gnu/lib/gconv
	ln -s /usr/lib/locale debian/steamrt-container-host-compat/usr/i686-pc-linux-gnu/lib/locale
	ln -s /lib/ld-linux.so.2 debian/steamrt-container-host-compat/usr/i686-pc-linux-gnu/lib/ld-linux.so.2
endif
ifeq ($(DEB_HOST_ARCH),amd64)
	install -m755 -d debian/steamrt-dev/usr/share/meson/cross/
	install -m755 meson/cross/*.txt debian/steamrt-dev/usr/share/meson/cross/
endif
ifeq ($(DEB_HOST_ARCH),i386)
	install -m755 -d debian/steamrt-dev/usr/share/meson/cross/
	install -m755 meson/cross/*.txt debian/steamrt-dev/usr/share/meson/cross/
endif

override_dh_gencontrol:
	python3 abi/generate-dependencies.py
	dh_gencontrol \
		-- \
		-Vsteamrt:gcc-major=8 \
		${NULL}
