#!/bin/sh -e
# Highly opinionated wrapper for Alpine Linux packaging

. "${ABUILD_SHAREDIR:-/usr/share/abuild}"/functions.sh

#TODO: set this all up for qnx
# mostly taken from https://github.com/void-linux/void-packages/blob/22bf95cf356bf1a09212733d775d447d011f70b0/common/build-style/meson.sh
#if [ "$CHOST" != "$CBUILD" ]; then
#	_meson_crossfile="abuild-meson.cross"
#	_meson_target_endian=little
#	# just the first part of the hostspec
#	_meson_target_cpu="$CARCH"
#	_meson_cpu_family="$CARCH"
#	case "$CARCH" in
#	arm*)
#		_meson_cpu_family=arm
#		;;
#	ppc64le)
#		_meson_cpu_family=ppc64
#		;;
#	s390x)
#		_meson_target_endian=big
#		;;
#	esac
#	cat > $_meson_crossfile <<-EOF
#	[binaries]
#	strip = '${CROSS_COMPILE}strip'
#	readelf = '${CROSS_COMPILE}readelf'
#	objcopy = '${CROSS_COMPILE}objcopy'
#	pkg-config = 'pkg-config'
#	[properties]
#	needs_exe_wrapper = true
#	sys_root = '$CBUILDROOT'
#	[host_machine]
#	system = 'linux'
#	cpu_family = '$_meson_cpu_family'
#	cpu = '$_meson_target_cpu'
#	endian = '$_meson_target_endian'
#	EOF
#	cat > abuild-meson.native <<-EOF
#	[properties]
#	sys_root = '/'
#	EOF
#	unset _meson_target_cpu _meson_target_endian _meson_cpu_family
#fi

exec meson setup \
		--prefix=/usr \
		--libdir=/usr/lib \
		--libexecdir=/usr/lib \
		--bindir=/usr/bin \
		--sbindir=/usr/bin \
		--includedir=/usr/include \
		--datadir=/usr/share \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localedir=/usr/share/locale \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--sharedstatedir=/var/lib \
		--buildtype=plain \
		--auto-features=auto \
		--wrap-mode=nodownload \
		-Db_lto=false \
		-Db_staticpic=true \
		-Db_pie=true \
		-Dpython.bytecompile=0 \
		-Dwerror=false \
		"$@"

