xref: /spdk/Makefile (revision f01146ae48b78dc5d62db2e0d8050eeabf369e34)
1#
2#  BSD LICENSE
3#
4#  Copyright (c) Intel Corporation.
5#  Copyright (c) 2020, Mellanox Corporation.
6#  All rights reserved.
7#
8#  Redistribution and use in source and binary forms, with or without
9#  modification, are permitted provided that the following conditions
10#  are met:
11#
12#    * Redistributions of source code must retain the above copyright
13#      notice, this list of conditions and the following disclaimer.
14#    * Redistributions in binary form must reproduce the above copyright
15#      notice, this list of conditions and the following disclaimer in
16#      the documentation and/or other materials provided with the
17#      distribution.
18#    * Neither the name of Intel Corporation nor the names of its
19#      contributors may be used to endorse or promote products derived
20#      from this software without specific prior written permission.
21#
22#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33#
34
35S :=
36
37SPDK_ROOT_DIR := $(CURDIR)
38include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
39
40DIRS-y += lib
41DIRS-y += module
42DIRS-$(CONFIG_SHARED) += shared_lib
43DIRS-y += include
44DIRS-$(CONFIG_EXAMPLES) += examples
45DIRS-$(CONFIG_APPS) += app
46DIRS-y += test
47DIRS-$(CONFIG_IPSEC_MB) += ipsecbuild
48DIRS-$(CONFIG_ISAL) += isalbuild
49DIRS-$(CONFIG_VFIO_USER) += vfiouserbuild
50
51.PHONY: all clean $(DIRS-y) include/spdk/config.h mk/config.mk \
52	cc_version cxx_version .libs_only_other .ldflags ldflags install \
53	uninstall
54
55# Workaround for ninja. See dpdkbuild/Makefile
56export MAKE_PID := $(shell echo $$PPID)
57
58ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV))
59ifeq ($(CURDIR)/dpdk/build,$(CONFIG_DPDK_DIR))
60ifneq ($(SKIP_DPDK_BUILD),1)
61ifneq ($(CONFIG_DPDK_PKG_CONFIG),y)
62DPDKBUILD = dpdkbuild
63DIRS-y += dpdkbuild
64endif
65endif
66endif
67endif
68
69ifeq ($(OS),Windows)
70ifeq ($(CURDIR)/wpdk/build,$(CONFIG_WPDK_DIR))
71WPDK = wpdk
72DIRS-y += wpdk
73endif
74endif
75
76ifeq ($(CONFIG_SHARED),y)
77LIB = shared_lib
78else
79LIB = module
80endif
81
82ifeq ($(CONFIG_IPSEC_MB),y)
83LIB += ipsecbuild
84DPDK_DEPS += ipsecbuild
85endif
86
87ifeq ($(CONFIG_ISAL),y)
88LIB += isalbuild
89DPDK_DEPS += isalbuild
90endif
91
92ifeq ($(CONFIG_VFIO_USER),y)
93VFIOUSERBUILD = vfiouserbuild
94LIB += vfiouserbuild
95endif
96
97all: mk/cc.mk $(DIRS-y)
98clean: $(DIRS-y)
99	$(Q)rm -f include/spdk/config.h
100	$(Q)rm -rf build
101
102install: all
103	$(Q)echo "Installed to $(DESTDIR)$(CONFIG_PREFIX)"
104
105uninstall: $(DIRS-y)
106	$(Q)echo "Uninstalled spdk"
107
108ifneq ($(SKIP_DPDK_BUILD),1)
109dpdkdeps $(DPDK_DEPS): $(WPDK)
110dpdkbuild: $(WPDK) $(DPDK_DEPS)
111endif
112
113lib: $(WPDK) $(DPDKBUILD) $(VFIOUSERBUILD)
114module: lib
115shared_lib: module
116app: $(LIB)
117test: $(LIB)
118examples: $(LIB)
119pkgdep:
120	sh ./scripts/pkgdep.sh
121
122$(DIRS-y): mk/cc.mk build_dir include/spdk/config.h
123
124mk/cc.mk:
125	$(Q)echo "Please run configure prior to make"
126	false
127
128build_dir: mk/cc.mk
129	$(Q)mkdir -p build/lib/pkgconfig/tmp
130	$(Q)mkdir -p build/bin
131	$(Q)mkdir -p build/fio
132	$(Q)mkdir -p build/examples
133	$(Q)mkdir -p build/include/spdk
134
135include/spdk/config.h: mk/config.mk scripts/genconfig.py
136	$(Q)echo "#ifndef SPDK_CONFIG_H" > $@.tmp; \
137	echo "#define SPDK_CONFIG_H" >> $@.tmp; \
138	scripts/genconfig.py $(MAKEFLAGS) >> $@.tmp; \
139	echo "#endif /* SPDK_CONFIG_H */" >> $@.tmp; \
140	cmp -s $@.tmp $@ || mv $@.tmp $@ ; \
141	rm -f $@.tmp
142
143cc_version: mk/cc.mk
144	$(Q)echo "SPDK using CC=$(CC)"; $(CC) -v
145
146cxx_version: mk/cc.mk
147	$(Q)echo "SPDK using CXX=$(CXX)"; $(CXX) -v
148
149.libs_only_other:
150	$(Q)echo -n '$(SYS_LIBS) '
151	$(Q)if [ "$(CONFIG_SHARED)" = "y" ]; then \
152		echo -n '-lspdk '; \
153	fi
154
155.ldflags:
156	$(Q)echo -n '$(LDFLAGS) '
157
158ldflags: .ldflags .libs_only_other
159	$(Q)echo ''
160
161include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk
162