xref: /linux/tools/virtio/Makefile (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
24e53f78eSMichael S. Tsirkinall: test mod
3*c5d3705cSYunsheng 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
6*c5d3705cSYunsheng 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
234e53f78eSMichael S. Tsirkinmod:
24fd2e8d43SMichael S. Tsirkin	${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test V=${V}
25d5f5ee2aSMichael S. Tsirkin
26d5f5ee2aSMichael S. Tsirkin#oot: build vhost as an out of tree module for a distro kernel
27d5f5ee2aSMichael S. Tsirkin#no effort is taken to make it actually build or work, but tends to mostly work
28d5f5ee2aSMichael S. Tsirkin#if the distro kernel is very close to upstream
29d5f5ee2aSMichael S. Tsirkin#unsupported! this is a development tool only, don't use the
30d5f5ee2aSMichael S. Tsirkin#resulting modules in production!
31d5f5ee2aSMichael S. TsirkinOOT_KSRC=/lib/modules/$$(uname -r)/build
32d5f5ee2aSMichael S. TsirkinOOT_VHOST=`pwd`/../../drivers/vhost
33d5f5ee2aSMichael S. Tsirkin#Everyone depends on vhost
34d5f5ee2aSMichael S. Tsirkin#Tweak the below to enable more modules
35d5f5ee2aSMichael S. TsirkinOOT_CONFIGS=\
36d5f5ee2aSMichael S. Tsirkin	CONFIG_VHOST=m \
37d5f5ee2aSMichael S. Tsirkin	CONFIG_VHOST_NET=n \
38d5f5ee2aSMichael S. Tsirkin	CONFIG_VHOST_SCSI=n \
393302363aSMichael S. Tsirkin	CONFIG_VHOST_VSOCK=n \
403302363aSMichael S. Tsirkin	CONFIG_VHOST_RING=n
41d5f5ee2aSMichael S. TsirkinOOT_BUILD=KCFLAGS="-I "${OOT_VHOST} ${MAKE} -C ${OOT_KSRC} V=${V}
42d5f5ee2aSMichael S. Tsirkinoot-build:
43d5f5ee2aSMichael S. Tsirkin	echo "UNSUPPORTED! Don't use the resulting modules in production!"
44d5f5ee2aSMichael S. Tsirkin	${OOT_BUILD} M=`pwd`/vhost_test
45d5f5ee2aSMichael S. Tsirkin	${OOT_BUILD} M=${OOT_VHOST} ${OOT_CONFIGS}
46d5f5ee2aSMichael S. Tsirkin
47d5f5ee2aSMichael S. Tsirkinoot-clean: oot-build
48d5f5ee2aSMichael S. Tsirkinoot: oot-build
49d5f5ee2aSMichael S. Tsirkinoot-clean: OOT_BUILD+=clean
50d5f5ee2aSMichael S. Tsirkin
51d5f5ee2aSMichael S. Tsirkin.PHONY: all test mod clean vhost oot oot-clean oot-build
524e53f78eSMichael S. Tsirkinclean:
53*c5d3705cSYunsheng Lin	${RM} *.o vringh_test virtio_test vhost_net_test vhost_test/*.o \
54*c5d3705cSYunsheng Lin              vhost_test/.*.cmd vhost_test/Module.symvers \
55*c5d3705cSYunsheng Lin              vhost_test/modules.order *.d
564e53f78eSMichael S. Tsirkin-include *.d
57