configure: Allow to define custom libdir location

This is done mainly to align the final location with the one listed
in the .pc files created for each lib.

Signed-off-by: Michal Berger <michallinuxstuff@gmail.com>
Change-Id: I99d6875c9e26f8202723dd6d73bd865b6478bcf9
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12978
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Michal Berger 2022-06-08 14:43:12 +02:00 committed by Tomasz Zawadzki
parent 642f8b3da5
commit e8863cb76b
7 changed files with 30 additions and 14 deletions

3
CONFIG
View File

@ -10,6 +10,9 @@ CONFIG_PREFIX="/usr/local"
# Target architecture
CONFIG_ARCH=native
# Destination directory for the libraries
CONFIG_LIBDIR=
# Prefix for cross compilation
CONFIG_CROSS_PREFIX=

4
configure vendored
View File

@ -22,6 +22,7 @@ function usage() {
echo ""
echo " --cross-prefix=prefix Prefix for cross compilation (default: none)"
echo " example: aarch64-linux-gnu"
echo " --libdir=path Configure installation path for the libraries (default: \$prefix/lib)"
echo ""
echo " --enable-debug Configure for debug builds"
echo " --enable-werror Treat compiler warnings as errors"
@ -298,6 +299,9 @@ for i in "$@"; do
--target-arch=*)
CONFIG[ARCH]="${i#*=}"
;;
--libdir=*)
CONFIG[LIBDIR]="${i#*=}"
;;
--enable-debug)
CONFIG[DEBUG]=y
;;

View File

@ -26,7 +26,11 @@ CONFIG_PREFIX=$(prefix)
endif
bindir?=$(CONFIG_PREFIX)/bin
ifeq ($(CONFIG_LIBDIR),)
libdir?=$(CONFIG_PREFIX)/lib
else
libdir?=$(CONFIG_LIBDIR)
endif
includedir?=$(CONFIG_PREFIX)/include
ifeq ($(MAKECMDGOALS),)

View File

@ -87,16 +87,16 @@ $(SHARED_REALNAME_LIB): $(LIB)
$(call spdk_build_realname_shared_lib,$(COMPILER),$^,$(SPDK_MAP_FILE),$(LOCAL_SYS_LIBS),$(SPDK_DEP_LIBS))
define pkgconfig_create
$(Q)$(SPDK_ROOT_DIR)/scripts/pc.sh $(1) $(LIBNAME) $(SO_SUFFIX) \
$(Q)$(SPDK_ROOT_DIR)/scripts/pc.sh $(1) $(2) $(LIBNAME) $(SO_SUFFIX) \
"$(DEPDIRS-$(LIBNAME):%=spdk_%) $(MODULES-$(LIBNAME))" \
"" > $@
endef
$(PKGCONFIG): $(LIB)
$(call pkgconfig_create,$(SPDK_ROOT_DIR)/build)
$(call pkgconfig_create,$(SPDK_ROOT_DIR)/build "")
$(PKGCONFIG_INST): $(LIB)
$(call pkgconfig_create,$(CONFIG_PREFIX))
$(call pkgconfig_create,$(CONFIG_PREFIX),$(libdir))
$(LIB): $(OBJS)
$(LIB_C)

View File

@ -105,6 +105,10 @@ build_macros() {
fi
fi
if get_config libdir has-arg; then
macros+=(-D "libdir $(get_config libdir print)")
fi
if [[ $deps == no ]]; then
macros+=(-D "deps 0")
fi

View File

@ -8,6 +8,7 @@
%{!?requirements:%define requirements 0}
%{!?build_requirements:%define build_requirements 0}
%{!?shared:%define shared 0}
%{!?libdir:%define libdir /usr/local/lib}
# Spec metadata
Name: spdk
@ -87,7 +88,7 @@ mkdir -p %{buildroot}/etc/ld.so.conf.d
mkdir -p %{buildroot}%{python3_sitelib}
cat <<-EOF > %{buildroot}/etc/ld.so.conf.d/spdk.conf
/usr/local/lib
%{libdir}
/usr/local/lib/dpdk
EOF
@ -127,7 +128,7 @@ SPDK development libraries and headers
%files devel
/usr/local/include/*
%if %{shared}
/usr/local/lib/lib*.so
%{libdir}/lib*.so
%endif
%package libs
@ -138,10 +139,10 @@ SPDK libraries
%files libs
/etc/ld.so.conf.d/*
/usr/local/lib/lib*.a
/usr/local/lib/pkgconfig/*.pc
%{libdir}/lib*.a
%{libdir}/pkgconfig/*.pc
%if %{shared}
/usr/local/lib/lib*.so.*
%{libdir}/lib*.so.*
%endif
%post libs

View File

@ -1,10 +1,10 @@
#!/usr/bin/env bash
cat << EOF
Description: SPDK $2 library
Name: spdk_$2
Version: $3
Libs: -L$1/lib -lspdk_$2
Requires: $4
Libs.private: $5
Description: SPDK $3 library
Name: spdk_$3
Version: $4
Libs: -L${2:-"$1/lib"} -lspdk_$3
Requires: $5
Libs.private: $6
Cflags: -I$1/include
EOF