Add a configure script to generate the CONFIG file

Add a configure script in the root of the repository
that looks and feels like one that would be generated
by autotools. This script simply generates a CONFIG
file for you, which used to be done by hand.

Now to build SPDK you can do the following:

./configure --with-dpdk=path
make

Change-Id: I44ebb91f0cb1468b86da4c0033ac1406595d4967
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Ben Walker 2017-03-30 12:06:49 -07:00 committed by Daniel Verkamp
parent 86840974dc
commit 9dd998cdc0
9 changed files with 263 additions and 64 deletions

1
.gitignore vendored
View File

@ -17,6 +17,7 @@ cscope.out
dpdk-* dpdk-*
CUnit-Memory-Dump.xml CUnit-Memory-Dump.xml
config.h config.h
CONFIG.local
*VC.db *VC.db
.vscode .vscode
.project .project

View File

@ -38,7 +38,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
DIRS-y += lib test examples app DIRS-y += lib test examples app
.PHONY: all clean $(DIRS-y) config.h .PHONY: all clean $(DIRS-y) config.h CONFIG.local
all: $(DIRS-y) all: $(DIRS-y)
clean: $(DIRS-y) clean: $(DIRS-y)
@ -50,7 +50,7 @@ examples: lib
$(DIRS-y): config.h $(DIRS-y): config.h
config.h: CONFIG scripts/genconfig.py config.h: CONFIG CONFIG.local scripts/genconfig.py
$(Q)python scripts/genconfig.py $(MAKEFLAGS) > $@.tmp; \ $(Q)python scripts/genconfig.py $(MAKEFLAGS) > $@.tmp; \
cmp -s $@.tmp $@ || mv $@.tmp $@ ; \ cmp -s $@.tmp $@ || mv $@.tmp $@ ; \
rm -f $@.tmp rm -f $@.tmp

View File

@ -67,41 +67,55 @@ FreeBSD:
4) (cd dpdk-17.02 && gmake install T=x86_64-native-bsdapp-clang DESTDIR=.) 4) (cd dpdk-17.02 && gmake install T=x86_64-native-bsdapp-clang DESTDIR=.)
Build Configuration
===================
Optional components and other build-time configuration are controlled by the `CONFIG` file
in the root SPDK directory. `CONFIG` is a Makefile fragment that may be edited before building to
control which options are enabled.
Boolean (on/off) options are configured with a 'y' (yes) or 'n' (no). For example, this line of
`CONFIG` controls whether the optional RDMA (libibverbs) support is enabled:
CONFIG_RDMA?=n
To enable RDMA, this line of CONFIG may be modified to contain 'y' instead of 'n'.
Alternatively, `CONFIG` options may also be overrriden on the `make` command line:
make CONFIG_RDMA=y
The options specified on the `make` command line take precedence over the default values in
`CONFIG`.
Building Building
======== ========
Once the prerequisites are installed, run 'make' within the SPDK directory Once the prerequisites are installed, building follows the common configure
to build the SPDK libraries and examples. and make pattern. If you followed the instructions above for building DPDK:
If you followed the instructions above for building DPDK:
Linux: Linux:
make DPDK_DIR=./dpdk-17.02/x86_64-native-linuxapp-gcc ./configure --with-dpdk=./dpdk-17.02/x86_64-native-linuxapp-gcc
make
FreeBSD: FreeBSD:
gmake DPDK_DIR=./dpdk-17.02/x86_64-native-bsdapp-clang ./configure --with-dpdk=./dpdk-17.02/x86_64-native-bsdapp-clang
gmake
Advanced Build Options
======================
Optional components and other build-time configuration are controlled by
settings in two Makefile fragments in the root of the repository. `CONFIG`
contains the base settings. Running the `configure` script generates a new
file, `CONFIG.local`, that contains overrides to the base `CONFIG` file. For
advanced configuration, there are a number of additional options to `configure`
that may be used, or `CONFIG.local` can simply be created and edited by hand. A
description of all possible options is located in `CONFIG`.
Boolean (on/off) options are configured with a 'y' (yes) or 'n' (no). For
example, this line of `CONFIG` controls whether the optional RDMA (libibverbs)
support is enabled:
CONFIG_RDMA?=n
To enable RDMA, this line may be added to `CONFIG.local` with a 'y' instead of
'n'. For the majority of options this can be done using the `configure` script.
For example:
./configure --with-dpdk=./dpdk-17.02/x86_64-native-linuxapp-gcc --with-rdma
Additionally, `CONFIG` options may also be overrriden on the `make` command
line:
make CONFIG_RDMA=y
The options specified on the `make` command line take precedence over the
default values in `CONFIG` and `CONFIG.local`. This can be useful if you, for
example, generate a `CONFIG.local` using the `configure` script and then have
one or two options (i.e. debug builds) that you wish to turn on and off
frequently.
Hugepages and Device Binding Hugepages and Device Binding
============================ ============================

View File

@ -14,16 +14,10 @@ cd $rootdir
date -u date -u
git describe --tags git describe --tags
if [ -d /usr/src/fio ]; then
MAKECONFIG="$MAKECONFIG CONFIG_FIO_PLUGIN=y FIO_SOURCE_DIR=/usr/src/fio"
fi
if [ -d /usr/include/rbd ] && [ -d /usr/include/rados ]; then
MAKECONFIG="$MAKECONFIG CONFIG_RBD=y"
fi
timing_enter autobuild timing_enter autobuild
./configure $config_params
timing_enter check_format timing_enter check_format
./scripts/check_format.sh ./scripts/check_format.sh
timing_exit check_format timing_exit check_format
@ -41,7 +35,7 @@ $MAKE $MAKEFLAGS clean
timing_enter scanbuild_make timing_enter scanbuild_make
fail=0 fail=0
time $scanbuild $MAKE $MAKEFLAGS DPDK_DIR=$DPDK_DIR $MAKECONFIG || fail=1 time $scanbuild $MAKE $MAKEFLAGS || fail=1
if [ $fail -eq 1 ]; then if [ $fail -eq 1 ]; then
if [ -d $out/scan-build-tmp ]; then if [ -d $out/scan-build-tmp ]; then
scanoutput=$(ls -1 $out/scan-build-tmp/) scanoutput=$(ls -1 $out/scan-build-tmp/)
@ -61,7 +55,7 @@ timing_exit scanbuild_make
STAT1=`stat examples/nvme/identify/identify` STAT1=`stat examples/nvme/identify/identify`
sleep 1 sleep 1
touch lib/nvme/nvme_internal.h touch lib/nvme/nvme_internal.h
$MAKE $MAKEFLAGS DPDK_DIR=$DPDK_DIR $MAKECONFIG $MAKE $MAKEFLAGS
STAT2=`stat examples/nvme/identify/identify` STAT2=`stat examples/nvme/identify/identify`
if [ "$STAT1" == "$STAT2" ]; then if [ "$STAT1" == "$STAT2" ]; then

View File

@ -33,7 +33,8 @@ echo "tmpdir=$tmpdir"
tar -C "$tmpdir" -xf $tarball tar -C "$tmpdir" -xf $tarball
( (
cd "$tmpdir"/spdk-* cd "$tmpdir"/spdk-*
time $MAKE ${MAKEFLAGS} DPDK_DIR=$DPDK_DIR CONFIG_DEBUG=n CONFIG_WERROR=y ./configure $config_params --disable-debug --enable-werror
time $MAKE ${MAKEFLAGS}
) )
rm -rf "$tmpdir" rm -rf "$tmpdir"

167
configure vendored Executable file
View File

@ -0,0 +1,167 @@
#!/usr/bin/env bash
set -e
function usage()
{
echo "'configure' configures SPDK to compile on supported platforms."
echo ""
echo "Usage: ./configure [OPTION]..."
echo ""
echo "Defaults for the options are specified in brackets."
echo ""
echo "General:"
echo " -h, --help Display this help and exit"
echo " --enable-debug Configure for debug builds"
echo " --enable-werror Treat compiler warnings as errors"
echo " --enable-asan Enable address sanitizer"
echo " --enable-ubsan Enable undefined behavior sanitizer"
echo " --enable-coverage Enable code coverage tracking"
echo " --with-env=path Use an alternate environment implementation"
echo ""
echo "Specifying Dependencies:"
echo "--with-DEPENDENCY[=path] Use the given dependency. Optionally, provide the"
echo " path."
echo "--without-DEPENDENCY Do not link to the given dependency. This may"
echo " disable features and components."
echo ""
echo "Valid dependencies are listed below."
echo " dpdk Required unless providing an alternate env implementation."
echo " example: /usr/share/dpdk/x86_64-default-linuxapp-gcc"
echo " fio Required to build fio_plugin."
echo " example: /usr/src/fio"
echo " rbd [disabled]"
echo " No path required."
echo " rdma [disabled]"
echo " No path required."
echo ""
}
for i in "$@"; do
case "$i" in
-h|--help)
usage
exit 0
;;
--enable-debug)
CONFIG_DEBUG=y
;;
--disable-debug)
CONFIG_DEBUG=n
;;
--enable-asan)
CONFIG_ASAN=y
;;
--disable-asan)
CONFIG_ASAN=n
;;
--enable-ubsan)
CONFIG_UBSAN=y
;;
--disable-ubsan)
CONFIG_UBSAN=n
;;
--enable-coverage)
CONFIG_COVERAGE=y
;;
--disable-coverage)
CONFIG_COVERAGE=n
;;
--enable-werror)
CONFIG_WERROR=y
;;
--disable-werror)
CONFIG_WERROR=n
;;
--with-env=*)
CONFIG_ENV="${i#*=}"
;;
--with-rbd)
CONFIG_RBD=y
;;
--without-rbd)
CONFIG_RBD=n
;;
--with-rdma)
CONFIG_RDMA=y
;;
--without-rdma)
CONFIG_RDMA=n
;;
--with-dpdk=*)
CONFIG_DPDK_DIR="${i#*=}"
;;
--without-dpdk)
CONFIG_DPDK_DIR=
;;
--with-fio=*)
FIO_SOURCE_DIR="${i#*=}"
CONFIG_FIO_PLUGIN=y
;;
--without-fio)
FIO_SOURCE_DIR=
CONFIG_FIO_PLUGIN=n
;;
--)
break
;;
*)
echo "Unrecognized option $i"
usage
exit 1
esac
done
if [ -z "$CONFIG_ENV" ]; then
if [ -z "$CONFIG_DPDK_DIR" ]; then
echo "You must specify the path to dpdk using --with-dpdk=path."
exit 1
fi
fi
if [ "$CONFIG_FIO_PLUGIN" = "y" ]; then
if [ -z "$FIO_SOURCE_DIR" ]; then
echo "When fio is enabled, you must specify the fio directory using --with-fio=path"
exit 1
fi
fi
# Write the configuration file
rm -f CONFIG.local
if [ -n "$CONFIG_DEBUG" ]; then
echo "CONFIG_DEBUG?=$CONFIG_DEBUG" >> CONFIG.local
fi
if [ -n "$CONFIG_WERROR" ]; then
echo "CONFIG_WERROR?=$CONFIG_WERROR" >> CONFIG.local
fi
if [ -n "$CONFIG_COVERAGE" ]; then
echo "CONFIG_COVERAGE?=$CONFIG_COVERAGE" >> CONFIG.local
fi
if [ -n "$CONFIG_ASAN" ]; then
echo "CONFIG_ASAN?=$CONFIG_ASAN" >> CONFIG.local
fi
if [ -n "$CONFIG_UBSAN" ]; then
echo "CONFIG_UBSAN?=$CONFIG_UBSAN" >> CONFIG.local
fi
if [ -n "$CONFIG_ENV" ]; then
echo "CONFIG_ENV?=$CONFIG_ENV" >> CONFIG.local
fi
if [ -n "$CONFIG_DPDK_DIR" ]; then
echo "CONFIG_DPDK_DIR?=$CONFIG_DPDK_DIR" >> CONFIG.local
fi
if [ -n "$CONFIG_FIO_PLUGIN" ]; then
echo "CONFIG_FIO_PLUGIN?=$CONFIG_FIO_PLUGIN" >> CONFIG.local
fi
if [ -n "$FIO_SOURCE_DIR" ]; then
echo "FIO_SOURCE_DIR?=$FIO_SOURCE_DIR" >> CONFIG.local
fi
if [ -n "$CONFIG_RDMA" ]; then
echo "CONFIG_RDMA?=$CONFIG_RDMA" >> CONFIG.local
fi
if [ -n "$CONFIG_RBD" ]; then
echo "CONFIG_RBD?=$CONFIG_RBD" >> CONFIG.local
fi
echo "Type make to build."
exit 0

View File

@ -31,6 +31,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# #
-include $(SPDK_ROOT_DIR)/CONFIG.local
include $(SPDK_ROOT_DIR)/CONFIG include $(SPDK_ROOT_DIR)/CONFIG
C_OPT ?= -fno-omit-frame-pointer C_OPT ?= -fno-omit-frame-pointer

View File

@ -3,7 +3,7 @@ ulimit -c unlimited
export RUN_NIGHTLY=0 export RUN_NIGHTLY=0
MAKECONFIG='CONFIG_DEBUG=y CONFIG_WERROR=y' config_params='--enable-debug --enable-werror'
export UBSAN_OPTIONS='halt_on_error=1:print_stacktrace=1:abort_on_error=1' export UBSAN_OPTIONS='halt_on_error=1:print_stacktrace=1:abort_on_error=1'
@ -12,16 +12,16 @@ export NRHUGE=4096
case `uname` in case `uname` in
FreeBSD) FreeBSD)
DPDK_DIR=/usr/local/share/dpdk/x86_64-native-bsdapp-clang config_params+=' --with-dpdk=/usr/local/share/dpdk/x86_64-native-bsdapp-clang'
MAKE=gmake MAKE=gmake
MAKEFLAGS=${MAKEFLAGS:--j$(sysctl -a | egrep -i 'hw.ncpu' | awk '{print $2}')} MAKEFLAGS=${MAKEFLAGS:--j$(sysctl -a | egrep -i 'hw.ncpu' | awk '{print $2}')}
;; ;;
Linux) Linux)
DPDK_DIR=/usr/local/share/dpdk/x86_64-native-linuxapp-gcc config_params+=' --with-dpdk=/usr/local/share/dpdk/x86_64-native-linuxapp-gcc'
MAKE=make MAKE=make
MAKEFLAGS=${MAKEFLAGS:--j$(nproc)} MAKEFLAGS=${MAKEFLAGS:--j$(nproc)}
MAKECONFIG="$MAKECONFIG CONFIG_COVERAGE=y" config_params+=' --enable-coverage'
MAKECONFIG="$MAKECONFIG CONFIG_UBSAN=y" config_params+=' --enable-ubsan'
;; ;;
*) *)
echo "Unknown OS in $0" echo "Unknown OS in $0"
@ -30,9 +30,19 @@ case `uname` in
esac esac
if [ -f /usr/include/infiniband/verbs.h ]; then if [ -f /usr/include/infiniband/verbs.h ]; then
MAKECONFIG="$MAKECONFIG CONFIG_RDMA=y" config_params+=' --with-rdma'
fi fi
if [ -d /usr/src/fio ]; then
config_params+=' --with-fio=/usr/src/fio'
fi
if [ -d /usr/include/rbd ] && [ -d /usr/include/rados ]; then
config_params+=' --with-rbd'
fi
export config_params
if [ -z "$output_dir" ]; then if [ -z "$output_dir" ]; then
if [ -z "$rootdir" ] || [ ! -d "$rootdir/../output" ]; then if [ -z "$rootdir" ] || [ ! -d "$rootdir/../output" ]; then
output_dir=. output_dir=.

View File

@ -19,22 +19,33 @@ for arg in sys.argv:
if 'DPDK_DIR' in args and 'CONFIG_DPDK_DIR' not in args: if 'DPDK_DIR' in args and 'CONFIG_DPDK_DIR' not in args:
args['CONFIG_DPDK_DIR'] = args['DPDK_DIR'] args['CONFIG_DPDK_DIR'] = args['DPDK_DIR']
with open('CONFIG') as f: defs = {}
for line in f: for config in ('CONFIG', 'CONFIG.local'):
line = line.strip() try:
if not comment.match(line): with open(config) as f:
m = assign.match(line) for line in f:
if m: line = line.strip()
var = m.group(1).strip() if not comment.match(line):
default = m.group(3).strip() m = assign.match(line)
val = default if m:
if var in args: var = m.group(1).strip()
val = args[var] default = m.group(3).strip()
if default.lower() == 'y' or default.lower() == 'n': val = default
if val.lower() == 'y': if var in args:
print "#define SPDK_{0} 1".format(var) val = args[var]
else: if default.lower() == 'y' or default.lower() == 'n':
print "#undef SPDK_{0}".format(var) if val.lower() == 'y':
else: defs["SPDK_{}".format(var)] = 1
strval = val.replace('"', '\"') else:
print "#define SPDK_{0} \"{1}\"".format(var, strval) defs["SPDK_{}".format(var)] = 0
else:
strval = val.replace('"', '\"')
defs["SPDK_{}".format(var)] = strval
except IOError:
continue
for key, value in defs.items():
if value == 0:
print "#undef {}".format(key)
else:
print "#define {} {}".format(key, value)