#!/bin/bash -ex
# Highly opinionated wrapper for Arch Linux packaging

CARCH=$(. /etc/makepkg.conf; echo $CARCH)

if [ "${CARCH}" =  "i486" ]; then
  LTO="b_lto=false"
else
  LTO="b_lto=true"
fi

exec meson setup \
  --prefix        /usr \
  --libexecdir    lib \
  --sbindir       bin \
  --buildtype     plain \
  --auto-features enabled \
  --wrap-mode     nodownload \
  -D              "${LTO}" \
  -D              b_pie=true \
  "$@"