diff options
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 57 |
1 files changed, 45 insertions, 12 deletions
@@ -16,7 +16,7 @@ help() { Usage: \$ $0 [--enable-*|--disable-*] [--with-*|--without-*] [CC=...] [...] - \$ $MAKE -j$(nproc) + \$ $MAKE -j$(_nproc) Variables set in the environment or on the command line will be picked up: @@ -66,21 +66,28 @@ Packaging: This script is a thin wrapper around a makefile-based configuration system. Any other arguments will be passed directly to the $MAKE invocation, e.g. - \$ $0 -j$(nproc) V=1 + \$ $0 -j$(_nproc) V=1 EOF } +# Report a warning +warn() { + fmt="$1" + shift + printf "%s: warning: $fmt\\n" "$0" "$@" >&2 +} + # Report an argument parsing error invalid() { - printf 'error: Unrecognized option "%s"\n\n' "$1" >&2 + printf '%s: error: Unrecognized option "%s"\n\n' "$0" "$1" >&2 printf 'Run %s --help for more information.\n' "$0" >&2 exit 1 } # Get the number of cores to use -nproc() { +_nproc() { { - command nproc \ + nproc \ || sysctl -n hw.ncpu \ || getconf _NPROCESSORS_ONLN \ || echo 1 @@ -88,7 +95,7 @@ nproc() { } # Save the ./configure command line for bfs --version -export CONFFLAGS="$*" +export CONFFLAGS="" # Default to `make` MAKE="${MAKE-make}" @@ -97,6 +104,13 @@ MAKE="${MAKE-make}" for arg; do shift + # Only add --options to CONFFLAGS, so we don't print FLAG=values twice in bfs --version + case "$arg" in + -*) + CONFFLAGS="${CONFFLAGS}${CONFFLAGS:+ }${arg}" + ;; + esac + # --[(enable|disable|with|without)-]$name[=$value] value="${arg#*=}" name="${arg%%=*}" @@ -136,7 +150,7 @@ for arg; do --enable-*) arg="--with-${arg#--*-}" ;; --disable-*) arg="--without-${arg#--*-}" ;; esac - printf 'warning: Treating "%s" like "%s"\n' "$old" "$arg" >&2 + warn 'Treating "%s" like "%s"' "$old" "$arg" ;; esac ;; @@ -150,7 +164,7 @@ for arg; do --enable-*|--disable-*) case "$name" in - release|asan|lsan|msan|tsan|ubsan|lint|gcov) + release|lto|asan|lsan|msan|tsan|ubsan|lint|gcov) set -- "$@" "$NAME=$yn" ;; *) @@ -175,13 +189,32 @@ for arg; do ;; --infodir=*|--build=*|--host=*|--target=*) - printf 'warning: Ignoring option "%s"\n' "$arg" >&2 + warn 'Ignoring option "%s"' "$arg" ;; MAKE=*) MAKE="$value" ;; + # Warn about MAKE variables that have documented configure flags + RELEASE=*|LTO=*|ASAN=*|LSAN=*|MSAN=*|TSAN=*|UBSAN=*|LINT=*|GCOV=*) + name=$(printf '%s' "$NAME" | tr 'A-Z_' 'a-z-') + warn '"%s" is deprecated; use --enable-%s' "$arg" "$name" + set -- "$@" "$arg" + ;; + + PREFIX=*|MANDIR=*|VERSION=*) + name=$(printf '%s' "$NAME" | tr 'A-Z_' 'a-z-') + warn '"%s" is deprecated; use --%s=%s' "$arg" "$name" "$value" + set -- "$@" "$arg" + ;; + + WITH_*=*) + name=$(printf '%s' "$NAME" | tr 'A-Z_' 'a-z-') + warn '"%s" is deprecated; use --%s' "$arg" "$name" + set -- "$@" "$arg" + ;; + # make flag (-j2) or variable (CC=clang) -*|*=*) set -- "$@" "$arg" @@ -194,11 +227,11 @@ for arg; do done # Set up symbolic links for out-of-tree builds -for f in Makefile build completions docs src tests; do +for f in Makefile bench build completions docs src tests; do test -e "$f" || ln -s "$DIR/$f" "$f" done -# Set MAKEFLAGS to -j$(nproc) if it's unset -export MAKEFLAGS="${MAKEFLAGS--j$(nproc)}" +# Set MAKEFLAGS to -j$(_nproc) if it's unset +export MAKEFLAGS="${MAKEFLAGS--j$(_nproc)}" $MAKE -rf build/config.mk "$@" |