diff options
Diffstat (limited to 'ci/ci_autotools.sh')
-rwxr-xr-x | ci/ci_autotools.sh | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/ci/ci_autotools.sh b/ci/ci_autotools.sh index 4b4d04b87..b141e7fca 100755 --- a/ci/ci_autotools.sh +++ b/ci/ci_autotools.sh @@ -4,18 +4,17 @@ set -e # ci_autotools.sh # Continuously integrate libpng using the GNU Autotools. # -# Copyright (c) 2019-2021 Cosmin Truta. +# Copyright (c) 2019-2022 Cosmin Truta. # # This software is released under the libpng license. # For conditions of distribution and use, see the disclaimer # and license in png.h. -readonly CI_SYSNAME="$(uname -s)" -readonly CI_SCRIPTNAME="$(basename "$0")" -readonly CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" -readonly CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" -readonly CI_BUILDDIR="$CI_SRCDIR/out/autotools.build" -readonly CI_INSTALLDIR="$CI_SRCDIR/out/autotools.install" +CI_SCRIPTNAME="$(basename "$0")" +CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" +CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" +CI_BUILDDIR="$CI_SRCDIR/out/autotools.build" +CI_INSTALLDIR="$CI_SRCDIR/out/autotools.install" function ci_info { printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" @@ -34,12 +33,20 @@ function ci_spawn { } function ci_init_autotools { - # Initialize the CI_ variables with default values, where applicable. + CI_SYSTEM_NAME="$(uname -s)" + CI_MACHINE_NAME="$(uname -m)" CI_MAKE="${CI_MAKE:-make}" - [[ $CI_SYSNAME == Darwin || $CI_SYSNAME == *BSD || $CI_SYSNAME == DragonFly ]] && - CI_CC="${CI_CC:-clang}" - # Print the CI_ variables. - ci_info "system name: $CI_SYSNAME" + # Set CI_CC to cc by default, if the cc command is available. + # The configure script defaults CC to gcc, which is not always a good idea. + [[ -x $(command -v cc) ]] && CI_CC="${CI_CC:-cc}" + # Ensure that the CI_ variables that cannot be customized reliably are not initialized. + [[ ! $CI_CONFIGURE_VARS ]] || ci_err "unexpected: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'" + [[ ! $CI_MAKE_VARS ]] || ci_err "unexpected: \$CI_MAKE_VARS='$CI_MAKE_VARS'" +} + +function ci_trace_autotools { + ci_info "system name: $CI_SYSTEM_NAME" + ci_info "machine hardware name: $CI_MACHINE_NAME" ci_info "source directory: $CI_SRCDIR" ci_info "build directory: $CI_BUILDDIR" ci_info "install directory: $CI_INSTALLDIR" @@ -58,9 +65,6 @@ function ci_init_autotools { ci_info "environment option: \$CI_NO_TEST='$CI_NO_TEST'" ci_info "environment option: \$CI_NO_INSTALL='$CI_NO_INSTALL'" ci_info "environment option: \$CI_NO_CLEAN='$CI_NO_CLEAN'" - # Avoid using the CI_ variables that cannot be customized reliably. - [[ ! $CI_CONFIGURE_VARS ]] || ci_err "unexpected: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'" - [[ ! $CI_MAKE_VARS ]] || ci_err "unexpected: \$CI_MAKE_VARS='$CI_MAKE_VARS'" } function ci_build_autotools { @@ -74,7 +78,7 @@ function ci_build_autotools { [[ $CI_LD ]] && ci_spawn export CPP="$CI_LD" [[ $CI_LD_FLAGS ]] && ci_spawn export LDFLAGS="$CI_LD_FLAGS" [[ $CI_SANITIZERS ]] && { - ci_spawn export CFLAGS="-fsanitize=$CI_SANITIZERS -O2 $CFLAGS" + ci_spawn export CFLAGS="-fsanitize=$CI_SANITIZERS ${CFLAGS:-"-O2"}" ci_spawn export LDFLAGS="-fsanitize=$CI_SANITIZERS $LDFLAGS" } # Build and install. @@ -91,7 +95,8 @@ function ci_build_autotools { } ci_init_autotools -[[ ! $* ]] || { +ci_trace_autotools +[[ $# -eq 0 ]] || { ci_info "note: this program accepts environment options only" ci_err "unexpected command arguments: '$*'" } |