build: add 'make install' rule
For now, this only installs libraries and headers; we will need to consider which binaries should be installed and what they should be named before we add them to the install rule. Change-Id: I78dc8631f793d0df88cd884b0ac66406df9e4427 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/387637 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
09fec7f014
commit
2e7fe8e888
@ -1,6 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## v18.01
|
||||
## v18.01: (Upcoming Release)
|
||||
|
||||
### Build System
|
||||
|
||||
The build system now includes a `make install` rule, including support for the common
|
||||
`DESTDIR` and `prefix` variables as used in other build systems. Additionally, the prefix
|
||||
may be set via the configure `--prefix` option. Example: `make install prefix=/usr`.
|
||||
|
||||
### RPC
|
||||
|
||||
|
3
CONFIG
3
CONFIG
@ -31,6 +31,9 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
# Installation prefix
|
||||
CONFIG_PREFIX?=/usr/local
|
||||
|
||||
# Build with debug logging. Turn off for performance testing and normal usage
|
||||
CONFIG_DEBUG?=n
|
||||
|
||||
|
5
Makefile
5
Makefile
@ -36,7 +36,7 @@ S :=
|
||||
SPDK_ROOT_DIR := $(CURDIR)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
DIRS-y += lib test examples app
|
||||
DIRS-y += lib test examples app include
|
||||
|
||||
.PHONY: all clean $(DIRS-y) config.h CONFIG.local mk/cc.mk
|
||||
|
||||
@ -50,6 +50,9 @@ clean: $(DIRS-y)
|
||||
$(Q)rm -f mk/cc.mk
|
||||
$(Q)rm -f config.h
|
||||
|
||||
install: all
|
||||
$(Q)echo "Installed to $(DESTDIR)$(CONFIG_PREFIX)"
|
||||
|
||||
lib: $(DPDKBUILD)
|
||||
app: lib
|
||||
test: lib
|
||||
|
@ -74,6 +74,12 @@ if [ "$STAT1" == "$STAT2" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test 'make install'
|
||||
rm -rf /tmp/spdk
|
||||
mkdir /tmp/spdk
|
||||
$MAKE $MAKEFLAGS install DESTDIR=/tmp/spdk prefix=/usr
|
||||
ls -lR /tmp/spdk
|
||||
rm -rf /tmp/spdk
|
||||
|
||||
timing_enter doxygen
|
||||
if [ $SPDK_BUILD_DOC -eq 1 ] && hash doxygen; then
|
||||
|
9
configure
vendored
9
configure
vendored
@ -12,6 +12,9 @@ function usage()
|
||||
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-werror Treat compiler warnings as errors"
|
||||
echo " --enable-asan Enable address sanitizer"
|
||||
@ -50,6 +53,9 @@ for i in "$@"; do
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--prefix=*)
|
||||
CONFIG_PREFIX="${i#*=}"
|
||||
;;
|
||||
--enable-debug)
|
||||
CONFIG_DEBUG=y
|
||||
;;
|
||||
@ -199,6 +205,9 @@ echo -n "Creating CONFIG.local..."
|
||||
|
||||
# Write the configuration file
|
||||
rm -f CONFIG.local
|
||||
if [ -n "$CONFIG_PREFIX" ]; then
|
||||
echo "CONFIG_PREFIX?=$CONFIG_PREFIX" >> CONFIG.local
|
||||
fi
|
||||
if [ -n "$CONFIG_DEBUG" ]; then
|
||||
echo "CONFIG_DEBUG?=$CONFIG_DEBUG" >> CONFIG.local
|
||||
fi
|
||||
|
@ -34,7 +34,7 @@
|
||||
SPDK_ROOT_DIR := $(abspath $(CURDIR)/..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
.PHONY: all clean
|
||||
.PHONY: all clean install
|
||||
|
||||
ifeq ($(TARGET_MACHINE),aarch64)
|
||||
DPDK_CONFIG := arm64-armv8a
|
||||
@ -80,3 +80,5 @@ all: $(SPDK_ROOT_DIR)/dpdk/build
|
||||
|
||||
clean:
|
||||
$(Q)rm -rf $(SPDK_ROOT_DIR)/dpdk/build
|
||||
|
||||
install: all
|
||||
|
49
include/Makefile
Normal file
49
include/Makefile
Normal file
@ -0,0 +1,49 @@
|
||||
#
|
||||
# BSD LICENSE
|
||||
#
|
||||
# Copyright (c) Intel Corporation.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Intel Corporation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
SPDK_ROOT_DIR := $(abspath $(CURDIR)/..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
HEADERS := $(wildcard $(SPDK_ROOT_DIR)/include/spdk/*.h)
|
||||
INSTALLED_HEADERS := $(patsubst $(SPDK_ROOT_DIR)/include%,$(DESTDIR)$(includedir)%,$(HEADERS))
|
||||
|
||||
$(DESTDIR)$(includedir)%.h:
|
||||
$(INSTALL_HEADER)
|
||||
|
||||
all:
|
||||
|
||||
clean:
|
||||
|
||||
install: $(INSTALLED_HEADERS)
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk
|
@ -57,3 +57,5 @@ SPDK_LIB_LINKER_ARGS = \
|
||||
$(SPDK_WHOLE_ARCHIVE_LIB_LIST:%=-lspdk_%) \
|
||||
-Wl,--no-whole-archive \
|
||||
$(SPDK_REMAINING_LIB_LIST:%=-lspdk_%)
|
||||
|
||||
install: all
|
||||
|
@ -43,6 +43,15 @@ Q ?= @
|
||||
endif
|
||||
S ?= $(notdir $(CURDIR))
|
||||
|
||||
DESTDIR?=
|
||||
|
||||
ifneq ($(prefix),)
|
||||
CONFIG_PREFIX=$(prefix)
|
||||
endif
|
||||
|
||||
libdir?=$(CONFIG_PREFIX)/lib
|
||||
includedir?=$(CONFIG_PREFIX)/include
|
||||
|
||||
ifeq ($(MAKECMDGOALS),)
|
||||
MAKECMDGOALS=$(.DEFAULT_GOAL)
|
||||
endif
|
||||
@ -192,6 +201,18 @@ LIB_C=\
|
||||
CLEAN_C=\
|
||||
$(Q)rm -f *.a *.o *.d *.d.tmp *.gcno *.gcda
|
||||
|
||||
# Install a library
|
||||
INSTALL_LIB=\
|
||||
$(Q)echo " INSTALL $(DESTDIR)$(libdir)/$(notdir $(LIB))"; \
|
||||
install -d -m 755 "$(DESTDIR)$(libdir)"; \
|
||||
install -m 644 "$(LIB)" "$(DESTDIR)$(libdir)/"
|
||||
|
||||
# Install a header
|
||||
INSTALL_HEADER=\
|
||||
$(Q)echo " INSTALL $@"; \
|
||||
install -d -m 755 "$(DESTDIR)$(includedir)/$(dir $(patsubst $(DESTDIR)$(includedir)/%,%,$@))"; \
|
||||
install -m 644 "$(patsubst $(DESTDIR)$(includedir)/%,%,$@)" "$(DESTDIR)$(includedir)/$(dir $(patsubst $(DESTDIR)$(includedir)/%,%,$@))/"
|
||||
|
||||
%.o: %.c %.d $(MAKEFILE_LIST)
|
||||
$(COMPILE_C)
|
||||
|
||||
|
@ -45,6 +45,9 @@ clean: $(DIRS-y)
|
||||
$(LIB): $(OBJS)
|
||||
$(LIB_C)
|
||||
|
||||
install: all
|
||||
$(INSTALL_LIB)
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk
|
||||
|
@ -33,3 +33,5 @@
|
||||
|
||||
$(DIRS-y) :
|
||||
$(Q)$(MAKE) -e -C $@ S=$S$(S:%=/)$@ $(MAKECMDGOALS) $(MAKESUBDIRFLAGS)
|
||||
|
||||
install: all $(DIRS-y)
|
||||
|
Loading…
Reference in New Issue
Block a user