xref: /spdk/vfiouserbuild/Makefile (revision 18c8b52afa69f39481ebb75711b2f30b11693f9d)
1#  SPDX-License-Identifier: BSD-3-Clause
2#  Copyright (c) Intel Corporation.
3#  All rights reserved.
4#
5
6SPDK_ROOT_DIR := $(abspath $(CURDIR)/..)
7include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
8
9.PHONY: all clean install uninstall
10
11# Force-disable scan-build: we support it below, but meson has its own special
12# target instead of allowing CC=scan-build like everyone else.
13SUB_CC = $(patsubst %ccc-analyzer,$(DEFAULT_CC),$(CC))
14
15VFIO_USER_CFG_OPTS = --buildtype $(VFIO_USER_BUILD_TYPE) -Ddefault_library=$(VFIO_USER_BUILD_SHARED) -Dlibdir=$(VFIO_USER_LIB_PREFIX)
16
17all: scan-build
18
19build:
20	$(Q)test -d $(VFIO_USER_BUILD_DIR) || \
21	     CC=$(SUB_CC) meson setup $(VFIO_USER_BUILD_DIR) $(VFIO_USER_SRC_DIR)
22	# Work around pre-v1.9 versions of ninja ignoring new configuration.
23	$(Q)[ $$( (ninja --version; echo 1.9) | sort --version-sort | head -n 1) \
24	     = 1.9 ] || sleep 0.5
25	$(Q)meson configure $(VFIO_USER_BUILD_DIR) $(VFIO_USER_CFG_OPTS)
26	$(Q)meson compile $(MESON_COMPILE_OPTS) -C $(VFIO_USER_BUILD_DIR)
27	DESTDIR=$(VFIO_USER_INSTALL_DIR) meson install --quiet -C $(VFIO_USER_BUILD_DIR)
28
29scan-build: build
30	$(Q)if [ $(CC) = "scan-build" ]; then \
31		ninja -C $(VFIO_USER_BUILD_DIR) scan-build; \
32	fi
33
34install: all
35
36uninstall:
37	@:
38
39clean:
40	$(Q)rm -rf $(VFIO_USER_BUILD_DIR)
41