Skip to content

Commit

Permalink
configure: Allow to define custom libdir location
Browse files Browse the repository at this point in the history
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 <[email protected]>
Change-Id: I99d6875c9e26f8202723dd6d73bd865b6478bcf9
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12978
Community-CI: Broadcom CI <[email protected]>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <[email protected]>
Reviewed-by: Jim Harris <[email protected]>
Reviewed-by: Dong Yi <[email protected]>
Reviewed-by: Ben Walker <[email protected]>
  • Loading branch information
mikeBashStuff authored and tomzawadzki committed Jul 4, 2022
1 parent 642f8b3 commit e8863cb
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CONFIG
Original file line number Diff line number Diff line change
Expand Up @@ -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=

Expand Down
4 changes: 4 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -298,6 +299,9 @@ for i in "$@"; do
--target-arch=*)
CONFIG[ARCH]="${i#*=}"
;;
--libdir=*)
CONFIG[LIBDIR]="${i#*=}"
;;
--enable-debug)
CONFIG[DEBUG]=y
;;
Expand Down
4 changes: 4 additions & 0 deletions mk/spdk.common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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),)
Expand Down
6 changes: 3 additions & 3 deletions mk/spdk.lib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions rpmbuild/rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions rpmbuild/spdk.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions scripts/pc.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e8863cb

Please sign in to comment.