xref: /linux/tools/virtio/Makefile (revision 8f0cbedc86cfc93ea869bbff420a2d86f6373f57)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
24e53f78eSMichael S. Tsirkinall: test mod
3c5d3705cSYunsheng Lintest: virtio_test vringh_test vhost_net_test
44e53f78eSMichael S. Tsirkinvirtio_test: virtio_ring.o virtio_test.o
51515c5ceSRusty Russellvringh_test: vringh_test.o vringh.o virtio_ring.o
6c5d3705cSYunsheng Linvhost_net_test: virtio_ring.o vhost_net_test.o
71515c5ceSRusty Russell
877b894f2SPeng Fantry-run = $(shell set -e;		\
977b894f2SPeng Fan	if ($(1)) >/dev/null 2>&1;	\
1077b894f2SPeng Fan	then echo "$(2)";		\
1177b894f2SPeng Fan	else echo "$(3)";		\
1277b894f2SPeng Fan	fi)
1377b894f2SPeng Fan
1477b894f2SPeng Fan__cc-option = $(call try-run,\
1577b894f2SPeng Fan	$(1) -Werror $(2) -c -x c /dev/null -o /dev/null,$(2),)
1677b894f2SPeng Fancc-option = $(call __cc-option, $(CC),$(1))
1777b894f2SPeng Fan
1877b894f2SPeng 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)
1977b894f2SPeng Fan
20f03560a5SMichael S. TsirkinCFLAGS += -pthread
21f03560a5SMichael S. TsirkinLDFLAGS += -pthread
221515c5ceSRusty Russellvpath %.c ../../drivers/virtio ../../drivers/vhost
234e949e77SMichael S. TsirkinBUILD=KCFLAGS="-I "`pwd`/../../drivers/vhost ${MAKE} -C `pwd`/../.. V=${V}
244e53f78eSMichael S. Tsirkinmod:
254e949e77SMichael S. Tsirkin	${BUILD} M=`pwd`/vhost_test
26d5f5ee2aSMichael S. Tsirkin
27d5f5ee2aSMichael S. Tsirkin#oot: build vhost as an out of tree module for a distro kernel
28d5f5ee2aSMichael S. Tsirkin#no effort is taken to make it actually build or work, but tends to mostly work
29d5f5ee2aSMichael S. Tsirkin#if the distro kernel is very close to upstream
30d5f5ee2aSMichael S. Tsirkin#unsupported! this is a development tool only, don't use the
31d5f5ee2aSMichael S. Tsirkin#resulting modules in production!
32d5f5ee2aSMichael S. TsirkinOOT_KSRC=/lib/modules/$$(uname -r)/build
33d5f5ee2aSMichael S. TsirkinOOT_VHOST=`pwd`/../../drivers/vhost
34d5f5ee2aSMichael S. Tsirkin#Everyone depends on vhost
35d5f5ee2aSMichael S. Tsirkin#Tweak the below to enable more modules
36d5f5ee2aSMichael S. TsirkinOOT_CONFIGS=\
37d5f5ee2aSMichael S. Tsirkin	CONFIG_VHOST=m \
38d5f5ee2aSMichael S. Tsirkin	CONFIG_VHOST_NET=n \
39d5f5ee2aSMichael S. Tsirkin	CONFIG_VHOST_SCSI=n \
403302363aSMichael S. Tsirkin	CONFIG_VHOST_VSOCK=n \
41*39cfe193SMichael S. Tsirkin	CONFIG_VHOST_RING=n \
42*39cfe193SMichael S. Tsirkin	CONFIG_VHOST_VDPA=n
43*39cfe193SMichael S. TsirkinOOT_BUILD=KCFLAGS="-include "`pwd`"/oot-stubs.h -I "${OOT_VHOST} ${MAKE} -C ${OOT_KSRC} V=${V}
44d5f5ee2aSMichael S. Tsirkinoot-build:
45d5f5ee2aSMichael S. Tsirkin	echo "UNSUPPORTED! Don't use the resulting modules in production!"
46d5f5ee2aSMichael S. Tsirkin	${OOT_BUILD} M=`pwd`/vhost_test
47d5f5ee2aSMichael S. Tsirkin	${OOT_BUILD} M=${OOT_VHOST} ${OOT_CONFIGS}
48d5f5ee2aSMichael S. Tsirkin
49d5f5ee2aSMichael S. Tsirkinoot-clean: oot-build
50d5f5ee2aSMichael S. Tsirkinoot: oot-build
51d5f5ee2aSMichael S. Tsirkinoot-clean: OOT_BUILD+=clean
52d5f5ee2aSMichael S. Tsirkin
53d5f5ee2aSMichael S. Tsirkin.PHONY: all test mod clean vhost oot oot-clean oot-build
544e53f78eSMichael S. Tsirkinclean:
55c5d3705cSYunsheng Lin	${RM} *.o vringh_test virtio_test vhost_net_test vhost_test/*.o \
56c5d3705cSYunsheng Lin              vhost_test/.*.cmd vhost_test/Module.symvers \
57c5d3705cSYunsheng Lin              vhost_test/modules.order *.d
584e53f78eSMichael S. Tsirkin-include *.d
59