summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure71
1 files changed, 53 insertions, 18 deletions
diff --git a/configure b/configure
index 8cdb7d8..7f0bd04 100755
--- a/configure
+++ b/configure
@@ -7,13 +7,16 @@
set -eu
-# Print the help message()
+# Get the relative path to the source tree based on how the script was run
+DIR=$(dirname -- "$0")
+
+# Print the help message
help() {
cat <<EOF
Usage:
\$ $0 [--enable-*|--disable-*] [--with-*|--without-*] [CC=...] [...]
- \$ $MAKE $j
+ \$ $MAKE -j$(_nproc)
Variables set in the environment or on the command line will be picked up:
@@ -57,25 +60,34 @@ Packaging:
Set the installation prefix (default: /usr)
--mandir=/path
Set the man page directory (default: \$PREFIX/share/man)
+ --version=X.Y.Z
+ Set the version string (default: $("$DIR/build/version.sh"))
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 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
@@ -83,7 +95,7 @@ nproc() {
}
# Save the ./configure command line for bfs --version
-export CONFFLAGS="$*"
+export CONFFLAGS=""
# Default to `make`
MAKE="${MAKE-make}"
@@ -92,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%%=*}"
@@ -131,10 +150,10 @@ 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
- ;;
+ ;;
esac
case "$arg" in
@@ -145,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"
;;
*)
@@ -165,18 +184,37 @@ for arg; do
esac
;;
- --prefix=*|--mandir=*)
+ --prefix=*|--mandir=*|--version=*)
set -- "$@" "$NAME=$value"
;;
--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"
@@ -188,15 +226,12 @@ for arg; do
esac
done
-# Get the relative path to the source tree based on how the script was run
-DIR=$(dirname -- "$0")
-
# 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 "$@"