# SPDX-License-Identifier: GPL-2.0
#
# Rust bindings shim - Common shim code compiled into vmlinux
#
# Shim functions for all Rust drivers (whether built-in or module)


# block_shim.c etc. need to include include/wrapper_*.h
# Use $(srctree)/$(src) to ensure correct path in out-of-tree builds (O=xxx)
ccflags-y += -I$(srctree)/$(src)/include

obj-$(CONFIG_RUST_DRIVERS) += rust_shim.o

rust_shim-y := \
	src/barrier_shim.o \
	src/refcount_shim.o \
	src/bitops_shim.o \
	src/byteorder_shim.o \
	src/of_shim.o \
	src/fwnode_shim.o \
	src/device_shim.o \
	src/debugfs_shim.o \
	src/dmi_shim.o \
	src/gpio_shim.o \
	src/i2c_shim.o \
	src/input_shim.o \
	src/reset_shim.o \
	src/i3c_shim.o \
	src/i3c_missing_stubs.o \
	src/io_shim.o \
	src/macros_shim.o \
	src/machine_t_shim.o \
	src/memory_shim.o \
	src/module_shim.o \
	src/pci_shim.o \
	src/platform_shim.o \
	src/amba_shim.o \
	src/power_shim.o \
	src/rmi_shim.o \
	src/spi_shim.o \
	src/sync_shim.o \
	src/kthread_shim.o \
	src/timer_shim.o \
	src/tty_shim.o \
	src/usb_shim.o \
	src/watchdog_shim.o \
	src/pwm_shim.o \
	src/irq_shim.o \
	src/idr_shim.o \
	src/series_shim.o \
	src/ps2_shim.o \
	src/serio_shim.o \
	src/sysfs_shim.o \
	src/hwmon_shim.o \
	src/iio_shim.o \
	src/err_shim.o \
	src/fs_shim.o \
	src/uaccess_shim.o \
	src/regmap_shim.o \
	src/workqueue_shim.o \
	src/acpi_shim.o \
	src/capability_shim.o \
	src/clk_shim.o \
	src/leds_shim.o \
	src/regulator_shim.o \
	src/matrix_keypad_shim.o \
	src/firmware_shim.o \
	src/pinctrl_shim.o \
	src/mfd_shim.o \
	src/kref_shim.o \
	src/list_shim.o \
	src/fasync_shim.o \
	src/v4l2_shim.o \
	src/i8042_shim.o \
	src/crc8_shim.o \
	src/cros_ec_shim.o \
	src/imx_sc_shim.o \
	src/notifier_shim.o \
	src/nls_shim.o \
	src/net_shim.o \
	src/dma_shim.o \
	src/ethtool_shim.o \
	src/hid_shim.o

# When CONFIG_QLCNIC=m, shim source stays in bindings; build .o here and link into module.
# (Kbuild prepends $(obj)/ to qlcnic-y entries, so cross-dir .o path cannot be used)
ifneq ($(CONFIG_QLCNIC),)
ccflags-y += -I$(srctree)/drivers/net/ethernet/qlogic/qlcnic
ifeq ($(CONFIG_QLCNIC),y)
rust_shim-y += src/qlogic_shim.o
endif
endif

# QLogic qlcnic wrappers (call qlcnic C API from shim)
rust_shim-$(CONFIG_QLCNIC) += src/qlogic_shim.o

ccflags-$(CONFIG_QLCNIC) += -I$(srctree)/drivers/net/ethernet/qlogic/qlcnic

# Block (blk-mq) shim only compiled when CONFIG_BLOCK is enabled
rust_shim-$(CONFIG_BLOCK) += src/block_shim.o

# MCB shim only compiled when CONFIG_MCB is enabled
rust_shim-$(CONFIG_MCB) += src/mcb_shim.o
