summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure153
1 files changed, 109 insertions, 44 deletions
diff --git a/configure b/configure
index d42dec3..8fb0cc2 100755
--- a/configure
+++ b/configure
@@ -7,23 +7,12 @@
set -eu
-# Default to `make`
-MAKE="${MAKE:-make}"
-
-# Pass -j$(nproc) unless MAKEFLAGS is set
-if [ "${MAKEFLAGS+y}" ]; then
- j=""
-else
- j="-j$({ nproc || sysctl -n hw.ncpu || getconf _NPROCESSORS_ONLN || echo 1; } 2>/dev/null)"
-fi
-
-for arg; do
- case "$arg" in
- -h|--help)
- cat <<EOF
+# Print the help message
+help() {
+ cat <<EOF
Usage:
- \$ $0 [--enable-*|--disable-*] [CC=...] [CFLAGS=...] [...]
+ \$ $0 [--enable-*|--disable-*] [--with-*|--without-*] [CC=...] [...]
\$ $MAKE $j
Variables set in the environment or on the command line will be picked up:
@@ -53,72 +42,148 @@ The default flags result in a plain debug build. Other build profiles include:
--enable-gcov
Enable code coverage instrumentation
-External dependencies are auto-detected by default, but you can --enable or
---disable them manually:
+External dependencies are auto-detected by default, but you can build --with or
+--without them explicitly:
- --enable-libacl --disable-libacl
- --enable-libcap --disable-libcap
- --enable-libselinux --disable-libselinux
- --enable-liburing --disable-liburing
- --enable-oniguruma --disable-oniguruma
+ --with-libacl --without-libacl
+ --with-libcap --without-libcap
+ --with-libselinux --without-libselinux
+ --with-liburing --without-liburing
+ --with-oniguruma --without-oniguruma
Packaging:
--prefix=/path
Set the installation prefix (default: /usr)
+ --mandir=/path
+ Set the man page directory (default: \$PREFIX/share/man)
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
EOF
- exit 0
+}
+
+# Report an argument parsing error
+invalid() {
+ printf 'error: Unrecognized option "%s"\n\n' "$1" >&2
+ printf 'Run %s --help for more information.\n' "$0" >&2
+ exit 1
+}
+
+# Get the number of cores to use
+nproc() {
+ {
+ command nproc \
+ || sysctl -n hw.ncpu \
+ || getconf _NPROCESSORS_ONLN \
+ || echo 1
+ } 2>/dev/null
+}
+
+# Save the ./configure command line for bfs --version
+export CONFFLAGS="$*"
+
+# Default to `make`
+MAKE="${MAKE-make}"
+
+# Parse the command-line arguments
+for arg; do
+ shift
+
+ # --[(enable|disable|with|without)-]$name[=$value]
+ value="${arg#*=}"
+ name="${arg%%=*}"
+ name="${name#--}"
+ case "$arg" in
+ --enable-*|--disable-*|--with-*|--without-*)
+ name="${name#*-}"
;;
+ esac
+ NAME=$(printf '%s' "$name" | tr 'a-z-' 'A-Z_')
- --enable-*|--disable-*)
+ # y/n modality
+ case "$arg" in
+ --enable-*|--with-*)
case "$arg" in
- --enable-*) yn=y ;;
- --disable-*) yn=n ;;
+ *=y|*=yes) yn=y ;;
+ *=n|*=no) yn=n ;;
+ *=*) invalid "$arg" ;;
+ *) yn=y ;;
esac
+ ;;
+ --disable-*|--without-*)
+ case "$arg" in
+ *=*) invalid "arg" ;;
+ *) yn=n ;;
+ esac
+ ;;
+ esac
- name="${arg#--*able-}"
- NAME=$(printf '%s' "$name" | tr 'a-z-' 'A-Z_')
+ # Fix up --enable-lib* to --with-lib*
+ case "$arg" in
+ --enable-*|--disable-*)
case "$name" in
libacl|libcap|libselinux|liburing|oniguruma)
- shift
- set -- "$@" "USE_$NAME=$yn"
+ old="$arg"
+ case "$arg" in
+ --enable-*) arg="--with-${arg#--*-}" ;;
+ --disable-*) arg="--without-${arg#--*-}" ;;
+ esac
+ printf 'warning: Treating "%s" like "%s"\n' "$old" "$arg" >&2
;;
+ esac
+ ;;
+ esac
+
+ case "$arg" in
+ -h|--help)
+ help
+ exit 0
+ ;;
+
+ --enable-*|--disable-*)
+ case "$name" in
release|asan|lsan|msan|tsan|ubsan|lint|gcov)
- shift
set -- "$@" "$NAME=$yn"
;;
*)
- printf 'error: Unrecognized option "%s"\n\n' "$arg" >&2
- printf 'Run %s --help for more information.\n' "$0" >&2
- exit 1
+ invalid "$arg"
;;
esac
;;
- --prefix=*)
- shift
- set -- "$@" "PREFIX=${arg#*=}"
+ --with-*|--without-*)
+ case "$name" in
+ libacl|libcap|libselinux|liburing|oniguruma)
+ set -- "$@" "WITH_$NAME=$yn"
+ ;;
+ *)
+ invalid "$arg"
+ ;;
+ esac
+ ;;
+
+ --prefix=*|--mandir=*)
+ set -- "$@" "$NAME=$value"
+ ;;
+
+ --infodir=*|--build=*|--host=*|--target=*)
+ printf 'warning: Ignoring option "%s"\n' "$arg" >&2
;;
MAKE=*)
- MAKE="${arg#*=}"
- shift
+ MAKE="$value"
;;
# make flag (-j2) or variable (CC=clang)
-*|*=*)
- continue
+ set -- "$@" "$arg"
;;
*)
- printf 'error: Unrecognized option "%s"\n\n' "$arg" >&2
- printf 'Run %s --help for more information.\n' "$0" >&2
- exit 1
+ invalid "$arg"
;;
esac
done
@@ -132,6 +197,6 @@ for f in Makefile build completions docs src tests; do
done
# Set MAKEFLAGS to -j$(nproc) if it's unset
-export MAKEFLAGS="${MAKEFLAGS-$j}"
+export MAKEFLAGS="${MAKEFLAGS--j$(nproc)}"
$MAKE -rf build/config.mk "$@"