d555d6c2d0
Change-Id: Ibbb53fefad5fa117c9b630301fb50bc04c87c3ea Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/442728 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
508 lines
14 KiB
Bash
Executable File
508 lines
14 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
trap 'echo -e "\n\nConfiguration failed\n\n" >&2' ERR
|
|
|
|
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 ""
|
|
echo " --prefix=path Configure installation prefix (default: /usr/local)"
|
|
echo ""
|
|
echo " --enable-debug Configure for debug builds"
|
|
echo " --enable-log-bt Enable support of backtrace printing in SPDK logs (requires libunwind)."
|
|
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 " --enable-lto Enable link-time optimization"
|
|
echo " --disable-tests Disable building of tests"
|
|
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 " crypto Required to build vbdev crypto module."
|
|
echo " No path required."
|
|
echo " dpdk Optional. Uses dpdk submodule in spdk tree if not specified."
|
|
echo " example: /usr/share/dpdk/x86_64-default-linuxapp-gcc"
|
|
echo " fio Required to build fio_plugin."
|
|
echo " example: /usr/src/fio"
|
|
echo " igb-uio-driver Required on some systems to use qat devices"
|
|
echo " No path required"
|
|
echo " vhost Required to build vhost target."
|
|
echo " No path required."
|
|
echo " virtio Required to build vhost initiator (Virtio) bdev module."
|
|
echo " No path required."
|
|
echo " pmdk Required to build persistent memory bdev."
|
|
echo " example: /usr/share/pmdk"
|
|
echo " reduce Required to build \"reduce\" (SPDK block compression)."
|
|
echo " No path required."
|
|
echo " vpp Required to build VPP net module."
|
|
echo " example: /vpp_repo/build-root/install-vpp-native/vpp"
|
|
echo " rbd [disabled]"
|
|
echo " No path required."
|
|
echo " rdma [disabled]"
|
|
echo " No path required."
|
|
echo " shared Required to build spdk shared libraries."
|
|
echo " No path required."
|
|
echo " iscsi-initiator [disabled]"
|
|
echo " No path required."
|
|
echo " vtune Required to profile I/O under Intel VTune Amplifier XE."
|
|
echo " example: /opt/intel/vtune_amplifier_xe_version"
|
|
echo " ocf Required to build OCF module."
|
|
echo " If argument is directory, interpret it as root of OCF repo"
|
|
echo " If argument is file, interpret it as compiled OCF lib"
|
|
echo " example: /usr/src/ocf/"
|
|
echo " isal Enabled by default on x86 architecture. Can be built without though."
|
|
echo " No path required."
|
|
echo ""
|
|
echo "Environment variables:"
|
|
echo ""
|
|
echo "CFLAGS C compiler flags"
|
|
echo "CXXFLAGS C++ compiler flags"
|
|
echo "LDFLAGS Linker flags"
|
|
echo "DESTDIR Destination for 'make install'"
|
|
echo ""
|
|
}
|
|
|
|
# Load default values
|
|
# Convert config to sourcable configuration file
|
|
sed -r 's/CONFIG_([[:alnum:]_]+)=(.*)/CONFIG[\1]=\2/g' CONFIG > CONFIG.sh
|
|
declare -A CONFIG
|
|
source CONFIG.sh
|
|
rm CONFIG.sh
|
|
|
|
|
|
function check_dir() {
|
|
arg="$1"
|
|
dir="${arg#*=}"
|
|
if [ ! -d "$dir" ]; then
|
|
echo "$arg: directory not found"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
for i in "$@"; do
|
|
case "$i" in
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
--prefix=*)
|
|
CONFIG[PREFIX]="${i#*=}"
|
|
;;
|
|
--enable-debug)
|
|
CONFIG[DEBUG]=y
|
|
;;
|
|
--disable-debug)
|
|
CONFIG[DEBUG]=n
|
|
;;
|
|
--enable-log-bt)
|
|
CONFIG[LOG_BACKTRACE]=y
|
|
;;
|
|
--disable-log-bt)
|
|
CONFIG[LOG_BACKTRACE]=n
|
|
;;
|
|
--enable-asan)
|
|
CONFIG[ASAN]=y
|
|
;;
|
|
--disable-asan)
|
|
CONFIG[ASAN]=n
|
|
;;
|
|
--enable-ubsan)
|
|
CONFIG[UBSAN]=y
|
|
;;
|
|
--disable-ubsan)
|
|
CONFIG[UBSAN]=n
|
|
;;
|
|
--enable-tsan)
|
|
CONFIG[TSAN]=y
|
|
;;
|
|
--disable-tsan)
|
|
CONFIG[TSAN]=n
|
|
;;
|
|
--enable-coverage)
|
|
CONFIG[COVERAGE]=y
|
|
;;
|
|
--disable-coverage)
|
|
CONFIG[COVERAGE]=n
|
|
;;
|
|
--enable-lto)
|
|
CONFIG[LTO]=y
|
|
;;
|
|
--disable-lto)
|
|
CONFIG[LTO]=n
|
|
;;
|
|
--enable-tests)
|
|
CONFIG[TESTS]=y
|
|
;;
|
|
--disable-tests)
|
|
CONFIG[TESTS]=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-shared)
|
|
CONFIG[SHARED]=y
|
|
;;
|
|
--without-shared)
|
|
CONFIG[SHARED]=n
|
|
;;
|
|
--with-iscsi-initiator)
|
|
CONFIG[ISCSI_INITIATOR]=y
|
|
;;
|
|
--without-iscsi-initiator)
|
|
CONFIG[ISCSI_INITIATOR]=n
|
|
;;
|
|
--with-dpdk=*)
|
|
check_dir "$i"
|
|
CONFIG[DPDK_DIR]=$(readlink -f ${i#*=})
|
|
;;
|
|
--without-dpdk)
|
|
CONFIG[DPDK_DIR]=
|
|
;;
|
|
--with-crypto)
|
|
CONFIG[CRYPTO]=y
|
|
;;
|
|
--without-crypto)
|
|
CONFIG[CRYPTO]=n
|
|
;;
|
|
--with-vhost)
|
|
CONFIG[VHOST]=y
|
|
;;
|
|
--without-vhost)
|
|
CONFIG[VHOST]=n
|
|
;;
|
|
--with-virtio)
|
|
CONFIG[VIRTIO]=y
|
|
;;
|
|
--without-virtio)
|
|
CONFIG[VIRTIO]=n
|
|
;;
|
|
--with-pmdk)
|
|
CONFIG[PMDK]=y
|
|
CONFIG[PMDK_DIR]=""
|
|
;;
|
|
--with-pmdk=*)
|
|
CONFIG[PMDK]=y
|
|
check_dir "$i"
|
|
CONFIG[PMDK_DIR]=$(readlink -f ${i#*=})
|
|
;;
|
|
--without-pmdk)
|
|
CONFIG[PMDK]=n
|
|
;;
|
|
--with-reduce)
|
|
CONFIG[REDUCE]=y
|
|
;;
|
|
--without-reduce)
|
|
CONFIG[REDUCE]=n
|
|
;;
|
|
--with-vpp)
|
|
CONFIG[VPP]=y
|
|
;;
|
|
--with-vpp=*)
|
|
CONFIG[VPP]=y
|
|
check_dir "$i"
|
|
CONFIG[VPP_DIR]=$(readlink -f ${i#*=})
|
|
;;
|
|
--without-vpp)
|
|
CONFIG[VPP]=n
|
|
;;
|
|
--with-fio=*)
|
|
check_dir "$i"
|
|
CONFIG[FIO_SOURCE_DIR]="${i#*=}"
|
|
CONFIG[FIO_PLUGIN]=y
|
|
;;
|
|
--without-fio)
|
|
CONFIG[FIO_SOURCE_DIR]=
|
|
CONFIG[FIO_PLUGIN]=n
|
|
;;
|
|
--with-vtune=*)
|
|
check_dir "$i"
|
|
CONFIG[VTUNE_DIR]="${i#*=}"
|
|
CONFIG[VTUNE]=y
|
|
;;
|
|
--without-vtune)
|
|
CONFIG[VTUNE_DIR]=
|
|
CONFIG[VTUNE]=n
|
|
;;
|
|
--with-igb-uio-driver)
|
|
CONFIG[IGB_UIO_DRIVER]=y
|
|
;;
|
|
--without-igb-uio-driver)
|
|
CONFIG[IGB_UIO_DRIVER]=n
|
|
;;
|
|
--with-ftl)
|
|
CONFIG[FTL]=y
|
|
;;
|
|
--without-ftl)
|
|
CONFIG[FTL]=n
|
|
;;
|
|
--with-ocf=*)
|
|
CONFIG[OCF]=y
|
|
CONFIG[OCF_PATH]=$(readlink -f ${i#*=})
|
|
;;
|
|
--without-ocf)
|
|
CONFIG[OCF]=n
|
|
CONFIG[OCF_PATH]=
|
|
;;
|
|
--with-isal)
|
|
CONFIG[ISAL]=y
|
|
;;
|
|
--without-isal)
|
|
CONFIG[ISAL]=n
|
|
;;
|
|
--)
|
|
break
|
|
;;
|
|
*)
|
|
echo "Unrecognized option $i"
|
|
usage
|
|
exit 1
|
|
esac
|
|
done
|
|
|
|
# Detect architecture and force no isal if non x86 archtecture
|
|
arch=$(uname -i)
|
|
if [[ $arch != x86_64* ]]; then
|
|
echo "Notice: ISAL auto-disabled due to CPU incompatiblity."
|
|
CONFIG[ISAL]=n
|
|
fi
|
|
|
|
if [ -z "${CONFIG[ENV]}" ]; then
|
|
rootdir=$(readlink -f $(dirname $0))
|
|
CONFIG[ENV]=$rootdir/lib/env_dpdk
|
|
echo "Using default SPDK env in ${CONFIG[ENV]}"
|
|
if [ -z "${CONFIG[DPDK_DIR]}" ]; then
|
|
if [ ! -f "$rootdir"/dpdk/config/common_base ]; then
|
|
echo "DPDK not found; please specify --with-dpdk=<path> or run:"
|
|
echo
|
|
echo " git submodule update --init"
|
|
exit 1
|
|
else
|
|
CONFIG[DPDK_DIR]="${rootdir}/dpdk/build"
|
|
echo "Using default DPDK in ${CONFIG[DPDK_DIR]}"
|
|
fi
|
|
fi
|
|
else
|
|
if [ "${CONFIG[VHOST]}" = "y" ]; then
|
|
echo "Vhost is only supported when using the default DPDK environment. Disabling it."
|
|
fi
|
|
# Always disable vhost, but only print the error message if the user explicitly turned it on.
|
|
CONFIG[VHOST]="n"
|
|
if [ "${CONFIG[VIRTIO]}" = "y" ]; then
|
|
echo "Virtio is only supported when using the default DPDK environment. Disabling it."
|
|
fi
|
|
# Always disable virtio, but only print the error message if the user explicitly turned it on.
|
|
CONFIG[VIRTIO]="n"
|
|
fi
|
|
|
|
if [ "${CONFIG[FIO_PLUGIN]}" = "y" ]; then
|
|
if [ -z "${CONFIG[FIO_SOURCE_DIR]}" ]; then
|
|
echo "When fio is enabled, you must specify the fio directory using --with-fio=path"
|
|
exit 1
|
|
fi
|
|
else
|
|
CONFIG[FIO_SOURCE_DIR]=
|
|
fi
|
|
|
|
if [ "${CONFIG[VTUNE]}" = "y" ]; then
|
|
if [ -z "${CONFIG[VTUNE_DIR]}" ]; then
|
|
echo "When VTune is enabled, you must specify the VTune directory using --with-vtune=path"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ "${CONFIG[ASAN]}" = "y" -a "${CONFIG[TSAN]}" = "y" ]; then
|
|
echo "ERROR: ASAN and TSAN cannot be enabled at the same time."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$OSTYPE" == "freebsd"* ]]; then
|
|
# FreeBSD doesn't support all configurations
|
|
if [[ "${CONFIG[COVERAGE]}" == "y" ]]; then
|
|
echo "ERROR: CONFIG_COVERAGE not available on FreeBSD"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ "${CONFIG[RDMA]}" = "y" ]; then
|
|
if [ "$OSTYPE" != "FreeBSD"* ]; then
|
|
ibv_lib_file="$(ldconfig -p | grep 'libibverbs.so ' || true)"
|
|
if [ ! -z "$ibv_lib_file" ]; then
|
|
ibv_lib_file="${ibv_lib_file##*=> }"
|
|
ibv_lib_file="$(readlink -f $ibv_lib_file)" || true
|
|
fi
|
|
|
|
if [ -z $ibv_lib_file ]; then
|
|
ibv_lib_file="libibverbs.so.0.0.0"
|
|
fi
|
|
|
|
ibv_ver_str="$(basename $ibv_lib_file)"
|
|
ibv_maj_ver=`echo $ibv_ver_str | cut -d. -f3`
|
|
ibv_min_ver=`echo $ibv_ver_str | cut -d. -f4`
|
|
if [[ "$ibv_maj_var" -gt 1 || ("$ibv_maj_ver" -eq 1 && "$ibv_min_ver" -ge 1) ]]; then
|
|
CONFIG[RDMA_SEND_WITH_INVAL]="y"
|
|
else
|
|
CONFIG[RDMA_SEND_WITH_INVAL]="n"
|
|
echo "
|
|
*******************************************************************************
|
|
WARNING: The Infiniband Verbs opcode Send With Invalidate is either not
|
|
supported or is not functional with the current version of libibverbs installed
|
|
on this system. Please upgrade to at least version 1.1.
|
|
|
|
Beginning with Linux kernel 4.14, the kernel NVMe-oF initiator leverages Send
|
|
With Invalidate RDMA operations to improve performance. Failing to use the
|
|
Send With Invalidate operation on the NVMe-oF target side results in full
|
|
functionality, but greatly reduced performance. The SPDK NVMe-oF target will
|
|
be unable to leverage that operation using the currently installed version
|
|
of libibverbs, so Linux kernel NVMe-oF initiators based on kernels greater
|
|
than or equal to 4.14 will see significantly reduced performance.
|
|
*******************************************************************************"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if [[ "${CONFIG[ISAL]}" = "y" ]] || [[ "${CONFIG[CRYPTO]}" = "y" ]]; then
|
|
if [[ $(nasm -v | sed 's/[^0-9]*//g' | awk '{print substr ($0, 0, 5)}') -lt "21202" ]]; then
|
|
echo "Notice: ISAL, compression & crypto auto-disabled due to nasm dependency."
|
|
echo "These features require NASM version 2.12.02 or newer. Please install"
|
|
echo "or upgrade then re-run this script."
|
|
CONFIG[ISAL]=n
|
|
CONFIG[CRYPTO]=n
|
|
CONFIG[IPSEC_MB]=n
|
|
else
|
|
if [[ "${CONFIG[CRYPTO]}" = "y" ]]; then
|
|
CONFIG[IPSEC_MB]=y
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if [[ "${CONFIG[ISAL]}" = "y" ]]; then
|
|
if [ ! -f "$rootdir"/isa-l/autogen.sh ]; then
|
|
echo "isa-l folder is not found; If you do want to install isa-l, run:"
|
|
echo " git submodule update --init"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "${CONFIG[RBD]}" = "y" ]]; then
|
|
echo "ISAL and RBD cannot co-exist currently so disabling ISAL."
|
|
CONFIG[ISAL]=n
|
|
else
|
|
cd $rootdir/isa-l
|
|
ISAL_LOG=/tmp/spdk-isal.log
|
|
echo -n "Configuring ISA-L (logfile: $ISAL_LOG)..."
|
|
./autogen.sh &> $ISAL_LOG
|
|
./configure CFLAGS="-fPIC -g -O2" --enable-shared=no >> $ISAL_LOG 2>&1
|
|
echo "done."
|
|
cd $rootdir
|
|
fi
|
|
fi
|
|
|
|
if [[ "${CONFIG[REDUCE]}" = "y" ]]; then
|
|
if [ ! -f /usr/include/libpmem.h ]; then
|
|
echo --with-reduce requires libpmem.
|
|
echo Please install then re-run this script.
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [[ "${CONFIG[OCF]}" = "y" ]]; then
|
|
if [ -z "${CONFIG[OCF_PATH]}" ]; then
|
|
echo "When OCF module is enabled, you must specify"
|
|
echo "the OCF directory or path to OCF library using --with-ocf=path"
|
|
exit 1
|
|
fi
|
|
|
|
# If OCF_PATH is a file, assume it is a library and use it to compile with
|
|
if [ -f ${CONFIG[OCF_PATH]} ]; then
|
|
CONFIG[CUSTOMOCF]=y
|
|
else
|
|
CONFIG[CUSTOMOCF]=n
|
|
fi
|
|
|
|
# If OCF_PATH is not a library, we need to do sources export procedure using OCF Makefile
|
|
if [[ ${CONFIG[CUSTOMOCF]} = "n" ]]; then
|
|
echo "configuring OCF..."
|
|
rootdir=$(readlink -f $(dirname $0))
|
|
|
|
if pushd "${CONFIG[OCF_PATH]}" > /dev/null && \
|
|
make inc O="$rootdir/lib/bdev/ocf/env/" && \
|
|
make src O="$rootdir/lib/bdev/ocf/env/" CMD=cp 1>/dev/null && \
|
|
popd > /dev/null
|
|
then
|
|
echo "done configuring OCF"
|
|
else
|
|
echo "Could not configure OCF"
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# We are now ready to generate final configuration. But first do sanity
|
|
# check to see if all keys in CONFIG array have its reflection in CONFIG file.
|
|
if [ $(egrep -c "^\s*CONFIG_[[:alnum:]_]+=" CONFIG) -ne ${#CONFIG[@]} ]; then
|
|
echo ""
|
|
echo "BUG: Some configuration options are not present in CONFIG file. Please update this file."
|
|
echo "Missing options in CONFIG (+) file and in current config (-): "
|
|
diff -u --label "CONFIG file" --label "CONFIG[@]" \
|
|
<(sed -r -e '/^\s*$/d; /^\s*#.*/d; s/(CONFIG_[[:alnum:]_]+)=.*/\1/g' CONFIG | sort) \
|
|
<(printf "CONFIG_%s\n" ${!CONFIG[@]} | sort)
|
|
exit 1
|
|
fi
|
|
|
|
echo -n "Creating mk/config.mk..."
|
|
cp -f CONFIG mk/config.mk
|
|
for key in ${!CONFIG[@]}; do
|
|
sed -i.bak -r "s#^\s*CONFIG_${key}=.*#CONFIG_${key}\?=${CONFIG[$key]}#g" mk/config.mk
|
|
done
|
|
# On FreeBSD sed -i 'SUFFIX' - SUFFIX is mandatory. So no way but to delete the backed file.
|
|
rm -f mk/config.mk.bak
|
|
|
|
# Environment variables
|
|
[ -n "$CFLAGS" ] && echo "CFLAGS?=$CFLAGS" > mk/cc.flags.mk
|
|
[ -n "$CXXFLAGS" ] && echo "CXXFLAGS?=$CXXFLAGS" >> mk/cc.flags.mk
|
|
[ -n "$LDFLAGS" ] && echo "LDFLAGS?=$LDFLAGS" >> mk/cc.flags.mk
|
|
[ -n "$DESTDIR" ] && echo "DESTDIR?=$DESTDIR" >> mk/cc.flags.mk
|
|
|
|
echo "done."
|
|
|
|
if [[ "$OSTYPE" == "freebsd"* ]]; then
|
|
echo "Type 'gmake' to build."
|
|
else
|
|
echo "Type 'make' to build."
|
|
fi
|
|
|
|
exit 0
|