18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ciall: test mod
38c2ecf20Sopenharmony_citest: virtio_test vringh_test
48c2ecf20Sopenharmony_civirtio_test: virtio_ring.o virtio_test.o
58c2ecf20Sopenharmony_civringh_test: vringh_test.o vringh.o virtio_ring.o
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciCFLAGS += -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
88c2ecf20Sopenharmony_ciCFLAGS += -pthread
98c2ecf20Sopenharmony_ciLDFLAGS += -pthread
108c2ecf20Sopenharmony_civpath %.c ../../drivers/virtio ../../drivers/vhost
118c2ecf20Sopenharmony_cimod:
128c2ecf20Sopenharmony_ci	${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test V=${V}
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#oot: build vhost as an out of tree module for a distro kernel
158c2ecf20Sopenharmony_ci#no effort is taken to make it actually build or work, but tends to mostly work
168c2ecf20Sopenharmony_ci#if the distro kernel is very close to upstream
178c2ecf20Sopenharmony_ci#unsupported! this is a development tool only, don't use the
188c2ecf20Sopenharmony_ci#resulting modules in production!
198c2ecf20Sopenharmony_ciOOT_KSRC=/lib/modules/$$(uname -r)/build
208c2ecf20Sopenharmony_ciOOT_VHOST=`pwd`/../../drivers/vhost
218c2ecf20Sopenharmony_ci#Everyone depends on vhost
228c2ecf20Sopenharmony_ci#Tweak the below to enable more modules
238c2ecf20Sopenharmony_ciOOT_CONFIGS=\
248c2ecf20Sopenharmony_ci	CONFIG_VHOST=m \
258c2ecf20Sopenharmony_ci	CONFIG_VHOST_NET=n \
268c2ecf20Sopenharmony_ci	CONFIG_VHOST_SCSI=n \
278c2ecf20Sopenharmony_ci	CONFIG_VHOST_VSOCK=n \
288c2ecf20Sopenharmony_ci	CONFIG_VHOST_RING=n
298c2ecf20Sopenharmony_ciOOT_BUILD=KCFLAGS="-I "${OOT_VHOST} ${MAKE} -C ${OOT_KSRC} V=${V}
308c2ecf20Sopenharmony_cioot-build:
318c2ecf20Sopenharmony_ci	echo "UNSUPPORTED! Don't use the resulting modules in production!"
328c2ecf20Sopenharmony_ci	${OOT_BUILD} M=`pwd`/vhost_test
338c2ecf20Sopenharmony_ci	${OOT_BUILD} M=${OOT_VHOST} ${OOT_CONFIGS}
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cioot-clean: oot-build
368c2ecf20Sopenharmony_cioot: oot-build
378c2ecf20Sopenharmony_cioot-clean: OOT_BUILD+=clean
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci.PHONY: all test mod clean vhost oot oot-clean oot-build
408c2ecf20Sopenharmony_ciclean:
418c2ecf20Sopenharmony_ci	${RM} *.o vringh_test virtio_test vhost_test/*.o vhost_test/.*.cmd \
428c2ecf20Sopenharmony_ci              vhost_test/Module.symvers vhost_test/modules.order *.d
438c2ecf20Sopenharmony_ci-include *.d
44