xref: /openbmc/linux/tools/virtio/Makefile (revision 2612e3bbc0386368a850140a6c9b990cd496a5ec)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
24e53f78eSMichael S. Tsirkinall: test mod
31515c5ceSRusty Russelltest: virtio_test vringh_test
44e53f78eSMichael S. Tsirkinvirtio_test: virtio_ring.o virtio_test.o
51515c5ceSRusty Russellvringh_test: vringh_test.o vringh.o virtio_ring.o
61515c5ceSRusty Russell
7*77b894f2SPeng Fantry-run = $(shell set -e;		\
8*77b894f2SPeng Fan	if ($(1)) >/dev/null 2>&1;	\
9*77b894f2SPeng Fan	then echo "$(2)";		\
10*77b894f2SPeng Fan	else echo "$(3)";		\
11*77b894f2SPeng Fan	fi)
12*77b894f2SPeng Fan
13*77b894f2SPeng Fan__cc-option = $(call try-run,\
14*77b894f2SPeng Fan	$(1) -Werror $(2) -c -x c /dev/null -o /dev/null,$(2),)
15*77b894f2SPeng Fancc-option = $(call __cc-option, $(CC),$(1))
16*77b894f2SPeng Fan
17*77b894f2SPeng FanCFLAGS += -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h $(call cc-option,-mfunction-return=thunk) $(call cc-option,-fcf-protection=none) $(call cc-option,-mindirect-branch-register)
18*77b894f2SPeng Fan
19f03560a5SMichael S. TsirkinCFLAGS += -pthread
20f03560a5SMichael S. TsirkinLDFLAGS += -pthread
211515c5ceSRusty Russellvpath %.c ../../drivers/virtio ../../drivers/vhost
224e53f78eSMichael S. Tsirkinmod:
23fd2e8d43SMichael S. Tsirkin	${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test V=${V}
24d5f5ee2aSMichael S. Tsirkin
25d5f5ee2aSMichael S. Tsirkin#oot: build vhost as an out of tree module for a distro kernel
26d5f5ee2aSMichael S. Tsirkin#no effort is taken to make it actually build or work, but tends to mostly work
27d5f5ee2aSMichael S. Tsirkin#if the distro kernel is very close to upstream
28d5f5ee2aSMichael S. Tsirkin#unsupported! this is a development tool only, don't use the
29d5f5ee2aSMichael S. Tsirkin#resulting modules in production!
30d5f5ee2aSMichael S. TsirkinOOT_KSRC=/lib/modules/$$(uname -r)/build
31d5f5ee2aSMichael S. TsirkinOOT_VHOST=`pwd`/../../drivers/vhost
32d5f5ee2aSMichael S. Tsirkin#Everyone depends on vhost
33d5f5ee2aSMichael S. Tsirkin#Tweak the below to enable more modules
34d5f5ee2aSMichael S. TsirkinOOT_CONFIGS=\
35d5f5ee2aSMichael S. Tsirkin	CONFIG_VHOST=m \
36d5f5ee2aSMichael S. Tsirkin	CONFIG_VHOST_NET=n \
37d5f5ee2aSMichael S. Tsirkin	CONFIG_VHOST_SCSI=n \
383302363aSMichael S. Tsirkin	CONFIG_VHOST_VSOCK=n \
393302363aSMichael S. Tsirkin	CONFIG_VHOST_RING=n
40d5f5ee2aSMichael S. TsirkinOOT_BUILD=KCFLAGS="-I "${OOT_VHOST} ${MAKE} -C ${OOT_KSRC} V=${V}
41d5f5ee2aSMichael S. Tsirkinoot-build:
42d5f5ee2aSMichael S. Tsirkin	echo "UNSUPPORTED! Don't use the resulting modules in production!"
43d5f5ee2aSMichael S. Tsirkin	${OOT_BUILD} M=`pwd`/vhost_test
44d5f5ee2aSMichael S. Tsirkin	${OOT_BUILD} M=${OOT_VHOST} ${OOT_CONFIGS}
45d5f5ee2aSMichael S. Tsirkin
46d5f5ee2aSMichael S. Tsirkinoot-clean: oot-build
47d5f5ee2aSMichael S. Tsirkinoot: oot-build
48d5f5ee2aSMichael S. Tsirkinoot-clean: OOT_BUILD+=clean
49d5f5ee2aSMichael S. Tsirkin
50d5f5ee2aSMichael S. Tsirkin.PHONY: all test mod clean vhost oot oot-clean oot-build
514e53f78eSMichael S. Tsirkinclean:
521515c5ceSRusty Russell	${RM} *.o vringh_test virtio_test vhost_test/*.o vhost_test/.*.cmd \
534e53f78eSMichael S. Tsirkin              vhost_test/Module.symvers vhost_test/modules.order *.d
544e53f78eSMichael S. Tsirkin-include *.d
55