xref: /spdk/Makefile (revision e4070ee0e012c345f4c059f125f4f9ce3be66690)
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 += app include
44DIRS-$(CONFIG_EXAMPLES) += examples
45DIRS-y += test
46DIRS-$(CONFIG_IPSEC_MB) += ipsecbuild
47DIRS-$(CONFIG_ISAL) += isalbuild
48DIRS-$(CONFIG_VFIO_USER) += vfiouserbuild
49
50.PHONY: all clean $(DIRS-y) include/spdk/config.h mk/config.mk \
51	cc_version cxx_version .libs_only_other .ldflags ldflags install \
52	uninstall
53
54# Workaround for ninja. See dpdkbuild/Makefile
55export MAKE_PID := $(shell echo $$PPID)
56
57ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV))
58ifeq ($(CURDIR)/dpdk/build,$(CONFIG_DPDK_DIR))
59ifneq ($(SKIP_DPDK_BUILD),1)
60DPDKBUILD = dpdkbuild
61DIRS-y += dpdkbuild
62endif
63endif
64endif
65
66ifeq ($(CONFIG_SHARED),y)
67LIB = shared_lib
68else
69LIB = module
70endif
71
72ifeq ($(CONFIG_IPSEC_MB),y)
73LIB += ipsecbuild
74DPDK_DEPS += ipsecbuild
75endif
76
77ifeq ($(CONFIG_ISAL),y)
78LIB += isalbuild
79DPDK_DEPS += isalbuild
80endif
81
82ifeq ($(CONFIG_VFIO_USER),y)
83VFIOUSERBUILD = vfiouserbuild
84LIB += vfiouserbuild
85endif
86
87all: mk/cc.mk $(DIRS-y)
88clean: $(DIRS-y)
89	$(Q)rm -f include/spdk/config.h
90	$(Q)rm -rf build/bin
91	$(Q)rm -rf build/fio
92	$(Q)rm -rf build/examples
93	$(Q)rm -rf build/include
94	$(Q)rm -rf build/lib/pkgconfig
95	$(Q)find build/lib ! -name .gitignore -type f -delete
96
97install: all
98	$(Q)echo "Installed to $(DESTDIR)$(CONFIG_PREFIX)"
99
100uninstall: $(DIRS-y)
101	$(Q)echo "Uninstalled spdk"
102
103ifneq ($(SKIP_DPDK_BUILD),1)
104dpdkbuild: $(DPDK_DEPS)
105endif
106
107lib: $(DPDKBUILD) $(VFIOUSERBUILD)
108module: lib
109shared_lib: module
110app: $(LIB)
111test: $(LIB)
112examples: $(LIB)
113pkgdep:
114	sh ./scripts/pkgdep.sh
115
116$(DIRS-y): mk/cc.mk build_dir include/spdk/config.h
117
118mk/cc.mk:
119	$(Q)echo "Please run configure prior to make"
120	false
121
122build_dir: mk/cc.mk
123	$(Q)mkdir -p build/lib/pkgconfig
124	$(Q)mkdir -p build/bin
125	$(Q)mkdir -p build/fio
126	$(Q)mkdir -p build/examples
127	$(Q)mkdir -p build/include/spdk
128
129include/spdk/config.h: mk/config.mk scripts/genconfig.py
130	$(Q)echo "#ifndef SPDK_CONFIG_H" > $@.tmp; \
131	echo "#define SPDK_CONFIG_H" >> $@.tmp; \
132	scripts/genconfig.py $(MAKEFLAGS) >> $@.tmp; \
133	echo "#endif /* SPDK_CONFIG_H */" >> $@.tmp; \
134	cmp -s $@.tmp $@ || mv $@.tmp $@ ; \
135	rm -f $@.tmp
136
137cc_version: mk/cc.mk
138	$(Q)echo "SPDK using CC=$(CC)"; $(CC) -v
139
140cxx_version: mk/cc.mk
141	$(Q)echo "SPDK using CXX=$(CXX)"; $(CXX) -v
142
143.libs_only_other:
144	$(Q)echo -n '$(SYS_LIBS) '
145	$(Q)if [ "$(CONFIG_SHARED)" = "y" ]; then \
146		echo -n '-lspdk '; \
147	fi
148
149.ldflags:
150	$(Q)echo -n '$(LDFLAGS) '
151
152ldflags: .ldflags .libs_only_other
153	$(Q)echo ''
154
155include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk
156