contrib: configure-for-system: specify meson build dir

Instead of forcing to use ./build directory, let's make the the user
specify what directory he wants to use. This will allow to have multiple
build directories with different configurations as meson is designed to
allow, without having to overwrite the existing build one.
This commit is contained in:
Íñigo Huguet 2024-05-22 12:57:51 +02:00 committed by Íñigo Huguet
parent bd1763ebea
commit a07627fdcc

View file

@ -30,7 +30,7 @@ vars_with_vals() {
}
usage() {
echo "$ $0 [-m|--meson] [-a|--autotools] [-s|--show] [-B|--no-build] [-h|--help]"
echo "$ $0 [-m|--meson <builddir>] [-a|--autotools] [-s|--show] [-B|--no-build] [-h|--help]"
echo ""
echo "Configure NetworkManager in a way that is similar to when building"
echo "RPMs of NetworkManager for Fedora/RHEL. The effect is that \`make install\`"
@ -150,6 +150,7 @@ P_NOBUILD="${NOBUILD-0}"
P_DEBUG="${DEBUG-1}"
P_BUILD_TYPE="${BUILD_TYPE-}"
P_MESON_BUILDDIR="${MESON_BUILDDIR-./build}"
P_CFLAGS="${CFLAGS-}"
P_CC="${CC-$((! command -v gcc && command -v clang) &>/dev/null && echo clang || echo gcc)}"
@ -307,9 +308,9 @@ else
fi
if [ -z "$P_BUILD_TYPE" ] ; then
if [ -d ./build -a ! -f ./configure ] ; then
if [ -d "$P_MESON_BUILDDIR" -a ! -f ./configure ] ; then
P_BUILD_TYPE=meson
elif [ ! -d ./build -a -f ./configure ] ; then
elif [ ! -d "$P_MESON_BUILDDIR" -a -f ./configure ] ; then
P_BUILD_TYPE=autotools
else
P_BUILD_TYPE=autotools
@ -322,6 +323,8 @@ while [[ $# -gt 0 ]] ; do
case "$A" in
--meson|-m)
P_BUILD_TYPE=meson
P_MESON_BUILDDIR="$1"
shift
;;
--autotools|-a)
P_BUILD_TYPE=autotools
@ -347,7 +350,7 @@ vars_with_vals
if [ "$P_BUILD_TYPE" == meson ] ; then
MESON_RECONFIGURE=
if test -d "./build/" ; then
if test -d "$P_MESON_BUILDDIR" ; then
MESON_RECONFIGURE="--reconfigure"
fi
@ -355,7 +358,8 @@ if [ "$P_BUILD_TYPE" == meson ] ; then
env \
CC="$P_CC" \
CFLAGS="$P_CFLAGS" \
meson \
meson setup\
$MESON_RECONFIGURE \
--buildtype=plain \
--prefix="$D_PREFIX" \
--libdir="$D_LIBDIR" \
@ -372,11 +376,6 @@ if [ "$P_BUILD_TYPE" == meson ] ; then
--sharedstatedir="$D_SHAREDSTATEDIR" \
--wrap-mode=nodownload \
--auto-features=enabled \
\
build \
\
$MESON_RECONFIGURE \
\
-Db_ndebug=false \
--warnlevel 2 \
$(args_enable "$P_TEST" --werror) \
@ -429,6 +428,8 @@ if [ "$P_BUILD_TYPE" == meson ] ; then
-Dnetconfig=no \
-Dconfig_dns_rc_manager_default="$P_DNS_RC_MANAGER_DEFAULT" \
-Dconfig_logging_backend_default="$P_LOGGING_BACKEND_DEFAULT" \
\
"$P_MESON_BUILDDIR" \
;
else
if ! test -x ./configure ; then
@ -520,7 +521,7 @@ fi
if ! bool "$P_NOBUILD" ; then
if [ "$P_BUILD_TYPE" == meson ] ; then
$SHOW_CMD ninja -C build
$SHOW_CMD ninja -C "$P_MESON_BUILDDIR"
else
$SHOW_CMD make -j 10
fi