1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-05-22 10:15:16 +02:00

Add configure host detection to set standards flags correctly.

Linux and MacOS were tolerant of having all standards flags set but BSD was not.

Instead detect the host type and set standards flags as appropriate.
This commit is contained in:
Marc Cousin
2020-03-12 10:37:19 -04:00
committed by David Steele
parent fa1f63198d
commit d6ef6c57c3
4 changed files with 125 additions and 1 deletions
+9
View File
@@ -27,6 +27,15 @@
</release-feature-list>
<release-improvement-list>
<release-item>
<release-item-contributor-list>
<release-item-contributor id="marc.cousin"/>
<release-item-reviewer id="david.steele"/>
</release-item-contributor-list>
<p>Add configure host detection to set standards flags correctly.</p>
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-reviewer id="cynthia.shang"/>
+1 -1
View File
@@ -8,7 +8,7 @@
CC = @CC@
# Standards
CSTANDARD = -std=c99 -D_POSIX_C_SOURCE=200809L -D_DARWIN_C_SOURCE
CSTANDARD = @CSTANDARD@
# Optimizations
COPTIMIZE = @COPTIMIZE@
+15
View File
@@ -9,6 +9,21 @@ AC_CONFIG_AUX_DIR(build)
# ----------------------------------------------------------------------------------------------------------------------------------
AC_PROG_CC_C99
# Build C standard based on the host type. C99 is required and other flags are added depending on the host.
# ----------------------------------------------------------------------------------------------------------------------------------
AC_CANONICAL_HOST
CSTANDARD="-std=c99"
case $host_os in
darwin*)
AC_SUBST(CSTANDARD, "${CSTANDARD?} -D_DARWIN_C_SOURCE")
;;
linux*)
AC_SUBST(CSTANDARD, "${CSTANDARD?} -D_POSIX_C_SOURCE=200809L")
;;
esac
# Set warnings and optimizations based on build type (i.e. production or test)
# ----------------------------------------------------------------------------------------------------------------------------------
warning='-Wall -Wextra -Wno-clobbered -Wno-missing-field-initializers'
+100
View File
@@ -630,6 +630,15 @@ CINCLUDE
CWARNING
COPTIMIZE_PAGE_CHECKSUM
COPTIMIZE
CSTANDARD
host_os
host_vendor
host_cpu
host
build_os
build_vendor
build_cpu
build
OBJEXT
EXEEXT
ac_ct_CC
@@ -1299,6 +1308,10 @@ Fine tuning of the installation directories:
_ACEOF
cat <<\_ACEOF
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
_ACEOF
fi
@@ -3039,6 +3052,93 @@ fi
# Build C standard based on the host type. C99 is required and other flags are added depending on the host.
# ----------------------------------------------------------------------------------------------------------------------------------
# Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
$as_echo_n "checking build system type... " >&6; }
if ${ac_cv_build+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_build_alias=$build_alias
test "x$ac_build_alias" = x &&
ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
test "x$ac_build_alias" = x &&
as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
$as_echo "$ac_cv_build" >&6; }
case $ac_cv_build in
*-*-*) ;;
*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
esac
build=$ac_cv_build
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_build
shift
build_cpu=$1
build_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
build_os=$*
IFS=$ac_save_IFS
case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
$as_echo_n "checking host system type... " >&6; }
if ${ac_cv_host+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "x$host_alias" = x; then
ac_cv_host=$ac_cv_build
else
ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
$as_echo "$ac_cv_host" >&6; }
case $ac_cv_host in
*-*-*) ;;
*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
esac
host=$ac_cv_host
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_host
shift
host_cpu=$1
host_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
host_os=$*
IFS=$ac_save_IFS
case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
CSTANDARD="-std=c99"
case $host_os in
darwin*)
CSTANDARD="${CSTANDARD?} -D_DARWIN_C_SOURCE"
;;
linux*)
CSTANDARD="${CSTANDARD?} -D_POSIX_C_SOURCE=200809L"
;;
esac
# Set warnings and optimizations based on build type (i.e. production or test)
# ----------------------------------------------------------------------------------------------------------------------------------
warning='-Wall -Wextra -Wno-clobbered -Wno-missing-field-initializers'