Skip to content

Commit 85bc2bb

Browse files
Pawel Wodkowskijimharris
Pawel Wodkowski
authored andcommittedOct 16, 2018
configure: use mk/config.mk instead of CONFIG.local
We have hairy configuration method. First configure script uses CONFIG, environment and arguments to produce CONFIG.local and config.h then makefile uses CONFIG, environment and CONFIG.local to produce config.h again. First time config.h can't be generated reliably as config.h target in Makefile is passing MAKEFLAGS and they are unknown at configuration phase. Lets remove this mess by producing final mk/config.mk file and get rid of CONFIG.local. This will also generate full build configuration in one file instead scattering them in CONFIG and CONFIG.local. In next patch scripts/genconfig.py can be removed. Change-Id: I5696813312edff7e493207f7aa8569234a365ec0 Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/426364 Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
1 parent 34387cc commit 85bc2bb

File tree

7 files changed

+64
-62
lines changed

7 files changed

+64
-62
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ CONFIG.local
2626
.cproject
2727
.settings
2828
mk/cc.mk
29+
mk/config.mk
2930
PYTHON_COMMAND

‎CONFIG

+28-27
Original file line numberDiff line numberDiff line change
@@ -32,82 +32,83 @@
3232
#
3333

3434
# Installation prefix
35-
CONFIG_PREFIX?=/usr/local
35+
CONFIG_PREFIX="/usr/local"
3636

3737
# Build with debug logging. Turn off for performance testing and normal usage
38-
CONFIG_DEBUG?=n
38+
CONFIG_DEBUG=n
3939

4040
# Build with support of backtrace printing in log messages. Requires libunwind.
41-
CONFIG_LOG_BACKTRACE?=n
41+
CONFIG_LOG_BACKTRACE=n
4242

4343
# Treat warnings as errors (fail the build on any warning).
44-
CONFIG_WERROR?=n
44+
CONFIG_WERROR=n
4545

4646
# Build with link-time optimization.
47-
CONFIG_LTO?=n
47+
CONFIG_LTO=n
4848

4949
# Build with code coverage instrumentation.
50-
CONFIG_COVERAGE?=n
50+
CONFIG_COVERAGE=n
5151

5252
# Build with Address Sanitizer enabled
53-
CONFIG_ASAN?=n
53+
CONFIG_ASAN=n
5454

5555
# Build with Undefined Behavior Sanitizer enabled
56-
CONFIG_UBSAN?=n
56+
CONFIG_UBSAN=n
5757

5858
# Build with Thread Sanitizer enabled
59-
CONFIG_TSAN?=n
59+
CONFIG_TSAN=n
6060

6161
# Build tests
62-
CONFIG_TESTS?=y
62+
CONFIG_TESTS=y
6363

6464
# Directory that contains the desired SPDK environment library.
6565
# By default, this is implemented using DPDK.
66-
CONFIG_ENV?=
66+
CONFIG_ENV=
6767

6868
# This directory should contain 'include' and 'lib' directories for your DPDK
6969
# installation.
70-
CONFIG_DPDK_DIR?=
70+
CONFIG_DPDK_DIR=
7171

7272
# Build SPDK FIO plugin. Requires CONFIG_FIO_SOURCE_DIR set to a valid
7373
# fio source code directory.
74-
CONFIG_FIO_PLUGIN?=n
74+
CONFIG_FIO_PLUGIN=n
7575

7676
# This directory should contain the source code directory for fio
7777
# which is required for building the SPDK FIO plugin.
78-
CONFIG_FIO_SOURCE_DIR?=/usr/src/fio
78+
CONFIG_FIO_SOURCE_DIR=/usr/src/fio
7979

8080
# Enable RDMA support for the NVMf target.
8181
# Requires ibverbs development libraries.
82-
CONFIG_RDMA?=n
83-
CONFIG_RDMA_SEND_WITH_INVAL?=n
82+
CONFIG_RDMA=n
83+
CONFIG_RDMA_SEND_WITH_INVAL=n
8484

8585
# Build Ceph RBD support in bdev modules
8686
# Requires librbd development libraries
87-
CONFIG_RBD?=n
87+
CONFIG_RBD=n
8888

8989
# Build vhost library.
90-
CONFIG_VHOST?=y
90+
CONFIG_VHOST=y
9191

9292
# Build vhost initiator (Virtio) driver.
93-
CONFIG_VIRTIO?=y
93+
CONFIG_VIRTIO=y
9494

9595
# Build with PMDK backends
96-
CONFIG_PMDK?=n
97-
CONFIG_PMDK_DIR?=
96+
CONFIG_PMDK=n
97+
CONFIG_PMDK_DIR=
9898

9999
# Build with VPP
100-
CONFIG_VPP?=n
100+
CONFIG_VPP=n
101+
CONFIG_VPP_DIR=
101102

102103
# Requires libiscsi development libraries.
103-
CONFIG_ISCSI_INITIATOR?=n
104+
CONFIG_ISCSI_INITIATOR=n
104105

105106
# Enable the dependencies for building the crypto vbdev
106-
CONFIG_CRYPTO?=n
107+
CONFIG_CRYPTO=n
107108

108109
# Build spdk shared libraries in addition to the static ones.
109-
CONFIG_SHARED?=n
110+
CONFIG_SHARED=n
110111

111112
# Build with VTune suport.
112-
CONFIG_VTUNE?=n
113-
CONFIG_VTUNE_DIR?=
113+
CONFIG_VTUNE=n
114+
CONFIG_VTUNE_DIR=

‎Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ DIRS-$(CONFIG_SHARED) += shared_lib
4141
DIRS-y += examples app include
4242
DIRS-$(CONFIG_TESTS) += test
4343

44-
.PHONY: all clean $(DIRS-y) include/spdk/config.h CONFIG.local mk/cc.mk cc_version cxx_version
44+
.PHONY: all clean $(DIRS-y) include/spdk/config.h mk/config.mk mk/cc.mk cc_version cxx_version
4545

4646
ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV))
4747
ifeq ($(CURDIR)/dpdk/build,$(CONFIG_DPDK_DIR))
@@ -81,7 +81,7 @@ mk/cc.mk:
8181
cmp -s $@.tmp $@ || mv $@.tmp $@ ; \
8282
rm -f $@.tmp
8383

84-
include/spdk/config.h: CONFIG CONFIG.local scripts/genconfig.py
84+
include/spdk/config.h: mk/config.mk scripts/genconfig.py
8585
$(Q)PYCMD=$$(cat PYTHON_COMMAND 2>/dev/null) ; \
8686
test -z "$$PYCMD" && PYCMD=python ; \
8787
echo "#ifndef SPDK_CONFIG_H" > $@.tmp; \

‎README.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,20 @@ Details on the Vagrant setup can be found in the
103103
## Advanced Build Options
104104

105105
Optional components and other build-time configuration are controlled by
106-
settings in two Makefile fragments in the root of the repository. `CONFIG`
107-
contains the base settings. Running the `configure` script generates a new
108-
file, `CONFIG.local`, that contains overrides to the base `CONFIG` file. For
109-
advanced configuration, there are a number of additional options to `configure`
110-
that may be used, or `CONFIG.local` can simply be created and edited by hand. A
111-
description of all possible options is located in `CONFIG`.
106+
settings in the Makefile configuration file in the root of the repository. `CONFIG`
107+
contains the base settings for the `configure` script. This script generates a new
108+
file, `mk/config.mk`, that contains final build settings. For advanced configuration,
109+
there are a number of additional options to `configure` that may be used, or
110+
`mk/config.mk` can simply be created and edited by hand. A description of all
111+
possible options is located in `CONFIG`.
112112

113113
Boolean (on/off) options are configured with a 'y' (yes) or 'n' (no). For
114114
example, this line of `CONFIG` controls whether the optional RDMA (libibverbs)
115115
support is enabled:
116116

117117
CONFIG_RDMA?=n
118118

119-
To enable RDMA, this line may be added to `CONFIG.local` with a 'y' instead of
119+
To enable RDMA, this line may be added to `mk/config.mk` with a 'y' instead of
120120
'n'. For the majority of options this can be done using the `configure` script.
121121
For example:
122122

@@ -152,10 +152,9 @@ gmake
152152
~~~
153153

154154
The options specified on the `make` command line take precedence over the
155-
default values in `CONFIG` and `CONFIG.local`. This can be useful if you, for
156-
example, generate a `CONFIG.local` using the `configure` script and then have
157-
one or two options (i.e. debug builds) that you wish to turn on and off
158-
frequently.
155+
values in `mk/config.mk`. This can be useful if you, for example, generate
156+
a `mk/config.mk` using the `configure` script and then have one or two
157+
options (i.e. debug builds) that you wish to turn on and off frequently.
159158

160159
<a id="huge"></a>
161160
## Hugepages and Device Binding

‎configure

+15-19
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function usage()
7070

7171
# Load default values
7272
# Convert config to sourcable configuration file
73-
sed -r 's/CONFIG_([[:alnum:]_]+)\?=(.*)/CONFIG[\1]=\2/g' CONFIG > CONFIG.sh
73+
sed -r 's/CONFIG_([[:alnum:]_]+)=(.*)/CONFIG[\1]=\2/g' CONFIG > CONFIG.sh
7474
declare -A CONFIG
7575
source CONFIG.sh
7676
rm CONFIG.sh
@@ -362,39 +362,35 @@ fi
362362

363363
# We are now ready to generate final configuration. But first do sanity
364364
# check to see if all keys in CONFIG array have its reflection in CONFIG file.
365-
if [ $(egrep -c "^\s*CONFIG_[[:alnum:]_]+\?=" CONFIG) -ne ${#CONFIG[@]} ]; then
365+
if [ $(egrep -c "^\s*CONFIG_[[:alnum:]_]+=" CONFIG) -ne ${#CONFIG[@]} ]; then
366366
echo ""
367367
echo "BUG: Some configuration options are not present in CONFIG file. Please update this file."
368368
echo "Missing options in CONFIG (+) file and in current config (-): "
369369
diff -u --label "CONFIG file" --label "CONFIG[@]" \
370-
<(sed -r -e '/^\s*$/d; /^\s*#.*/d; s/(CONFIG_[[:alnum:]_]+)\?=.*/\1/g' CONFIG | sort) \
370+
<(sed -r -e '/^\s*$/d; /^\s*#.*/d; s/(CONFIG_[[:alnum:]_]+)=.*/\1/g' CONFIG | sort) \
371371
<(printf "CONFIG_%s\n" ${!CONFIG[@]} | sort)
372372
exit 1
373373
fi
374374

375-
echo -n "Creating CONFIG.local..."
376-
cp -f CONFIG CONFIG.local
375+
echo -n "Creating mk/config.mk..."
376+
cp -f CONFIG mk/config.mk
377377
for key in ${!CONFIG[@]}; do
378-
sed -i.bak -r "s#^\s*CONFIG_${key}\?=.*#CONFIG_${key}\?=${CONFIG[$key]}#g" CONFIG.local
378+
sed -i.bak -r "s#^\s*CONFIG_${key}=.*#CONFIG_${key}\?=${CONFIG[$key]}#g" mk/config.mk
379379
done
380380
# On FreeBSD sed -i 'SUFFIX' - SUFFIX is mandatory. So no way but to delete the backed file.
381-
rm -f CONFIG.local.bak
381+
rm -f mk/config.mk.bak
382382

383383
# Environment variables
384-
if [ -n "$CFLAGS" ]; then
385-
echo "CFLAGS?=$CFLAGS" >> CONFIG.local
386-
fi
387-
if [ -n "$CXXFLAGS" ]; then
388-
echo "CXXFLAGS?=$CXXFLAGS" >> CONFIG.local
389-
fi
390-
if [ -n "$LDFLAGS" ]; then
391-
echo "LDFLAGS?=$LDFLAGS" >> CONFIG.local
392-
fi
393-
if [ -n "$DESTDIR" ]; then
394-
echo "DESTDIR?=$DESTDIR" >> CONFIG.local
395-
fi
384+
[ -n "$CFLAGS" ] && echo "CFLAGS?=$CFLAGS" >> mk/config.mk
385+
[ -n "$CXXFLAGS" ] && echo "CXXFLAGS?=$CXXFLAGS" >> mk/config.mk
386+
[ -n "$LDFLAGS" ] && echo "LDFLAGS?=$LDFLAGS" >> mk/config.mk
387+
[ -n "$DESTDIR" ] && echo "DESTDIR?=$DESTDIR" >> mk/config.mk
388+
389+
# When nvme-cli repo will be update this link can be removed
390+
ln -fs mk/config.mk CONFIG.local
396391

397392
echo "done."
393+
398394
if [[ "$OSTYPE" == "freebsd"* ]]; then
399395
echo "Type 'gmake' to build."
400396
else

‎doc/vagrant.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ vagrant@vagrant:~/spdk_repo/spdk$ sudo scripts/pkgdep.sh
137137
<<output trimmed>>
138138
139139
vagrant@vagrant:~/spdk_repo/spdk$ ./configure
140-
Creating CONFIG.local...done.
140+
Creating mk/config.mk...done.
141141
Type 'make' to build.
142142
143143
vagrant@vagrant:~/spdk_repo/spdk$ make

‎mk/spdk.common.mk

+7-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@
3232
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
#
3434

35-
-include $(SPDK_ROOT_DIR)/CONFIG.local
36-
include $(SPDK_ROOT_DIR)/CONFIG
35+
ifneq ($(MAKECMDGOALS),clean)
36+
ifeq ($(wildcard $(SPDK_ROOT_DIR)/mk/config.mk),)
37+
$(error mk/config.mk: file not found. Please run configure before 'make $(filter-out clean,$(MAKECMDGOALS))')
38+
endif
39+
endif
40+
41+
include $(SPDK_ROOT_DIR)/mk/config.mk
3742

3843
-include $(SPDK_ROOT_DIR)/mk/cc.mk
3944

0 commit comments

Comments
 (0)
Please sign in to comment.