#!/bin/bash

set -eux

PATH="/usr/local/cpython-3.8/bin:$PATH"
CFLAGS=
LDFLAGS='-Wl,-rpath,/tmp/notthere-a -Wl,-rpath,/tmp/notthere-b'
PKG_CONFIG_PATH='/usr/local/cpython-3.8/lib/pkgconfig:/usr/lib/pkgconfig'
export PATH CFLAGS LDFLAGS PKG_CONFIG_PATH

# which pkg-config
pkg-config --cflags cairo-gobject

if ! [ -d builddir ]
then
    meson setup builddir
fi

if ! cd builddir
then
    echo "$0: cd failed" 1>&2
    exit 1
fi
meson compile
./demo
objdump -x demo | grep -A 3 -i RUNPATH || true