#!/bin/bash

set -eu
set -o pipefail

# shellcheck disable=SC2154
export PATH=/usr/local/c"$which_python"/bin:$PATH
#echo 'pkg-config is at:'
#which pkg-config

#echo 'modversion of glib-2.0 from path-searched pkg-config is:'
#pkg-config --modversion glib-2.0
#echo

#echo "modversion of glib-2.0 from /usr/local/c$which_python/bin/pkg-config is:"
#/usr/local/c"$which_python"/bin/pkg-config --modversion glib-2.0
#echo

#echo "\$PKG_CONFIG_PATH is $PKG_CONFIG_PATH"
#echo

export LDFLAGS="-L/usr/local/c$which_python/lib -Wl,-rpath -Wl,/usr/local/c$which_python/lib"
# $CFLAGS didn't work, jpeglib.h was still not found.  Let's try $CC.
#export CFLAGS="-I/usr/local/c$which_python/include"
export CC="gcc -I/usr/local/c$which_python/include -fPIC"
export CXX="g++ -I/usr/local/c$which_python/include -fPIC"

# ./configure --prefix=/usr/local/c"$which_python" --enable-introspection
# make

# configure the build
# FIXME: Do we need to enable introspection somehow?
meson _build --prefix /usr/local/c"$which_python"

# build GLib
ninja -C _build