xref: /linux-6.15/drivers/staging/greybus/Makefile (revision dca8060d)
1greybus-y :=	core.o		\
2		debugfs.o	\
3		hd.o		\
4		manifest.o	\
5		module.o	\
6		interface.o	\
7		bundle.o	\
8		connection.o	\
9		protocol.o	\
10		control.o	\
11		svc.o		\
12		svc_watchdog.o	\
13		bootrom.o	\
14		operation.o	\
15		legacy.o
16
17gb-phy-y :=	gpbridge.o	\
18		sdio.o	\
19		uart.o	\
20		spi.o	\
21		usb.o
22
23# Prefix all modules with gb-
24gb-vibrator-y := vibrator.o
25gb-power-supply-y := power_supply.o
26gb-loopback-y := loopback.o
27gb-light-y := light.o
28gb-raw-y := raw.o
29gb-hid-y := hid.o
30gb-es2-y := es2.o
31gb-arche-y := arche-platform.o arche-apb-ctrl.o
32gb-audio-module-y := audio_module.o audio_topology.o
33gb-audio-codec-y := audio_codec.o
34gb-audio-gb-y := audio_gb.o
35gb-audio-apbridgea-y := audio_apbridgea.o
36gb-audio-manager-y += audio_manager.o
37gb-audio-manager-y += audio_manager_module.o
38gb-camera-y := camera.o
39gb-firmware-y := fw-core.o fw-download.o
40gb-pwm-y := pwm.o
41gb-gpio-y := gpio.o
42gb-i2c-y := i2c.o
43
44obj-m += greybus.o
45obj-m += gb-phy.o
46obj-m += gb-vibrator.o
47obj-m += gb-power-supply.o
48obj-m += gb-loopback.o
49obj-m += gb-light.o
50obj-m += gb-hid.o
51obj-m += gb-raw.o
52obj-m += gb-es2.o
53ifeq ($(CONFIG_USB_HSIC_USB3613),y)
54 obj-m += gb-arche.o
55endif
56ifeq ($(CONFIG_ARCH_MSM8994),y)
57 obj-m += gb-audio-codec.o
58 obj-m += gb-audio-module.o
59 obj-m += gb-camera.o
60endif
61obj-m += gb-audio-gb.o
62obj-m += gb-audio-apbridgea.o
63obj-m += gb-audio-manager.o
64obj-m += gb-firmware.o
65obj-m += gb-pwm.o
66obj-m += gb-gpio.o
67obj-m += gb-i2c.o
68
69KERNELVER		?= $(shell uname -r)
70KERNELDIR 		?= /lib/modules/$(KERNELVER)/build
71INSTALL_MOD_PATH	?= /..
72PWD			:= $(shell pwd)
73
74# kernel config option that shall be enable
75CONFIG_OPTIONS_ENABLE := POWER_SUPPLY PWM SYSFS SPI USB SND_SOC MMC LEDS_CLASS INPUT
76
77# kernel config option that shall be disable
78CONFIG_OPTIONS_DISABLE :=
79
80# this only run in kbuild part of the makefile
81ifneq ($(KERNELRELEASE),)
82# This function returns the argument version if current kernel version is minor
83# than the passed version, return 1 if equal or the current kernel version if it
84# is greater than argument version.
85kvers_cmp=$(shell [ "$(KERNELVERSION)" = "$(1)" ] && echo 1 || printf "$(1)\n$(KERNELVERSION)" | sort -V | tail -1)
86
87ifneq ($(call kvers_cmp,"3.19.0"),3.19.0)
88    CONFIG_OPTIONS_ENABLE += LEDS_CLASS_FLASH
89endif
90
91ifneq ($(call kvers_cmp,"4.2.0"),4.2.0)
92    CONFIG_OPTIONS_ENABLE += V4L2_FLASH_LED_CLASS
93endif
94
95$(foreach opt,$(CONFIG_OPTIONS_ENABLE),$(if $(CONFIG_$(opt)),, \
96     $(error CONFIG_$(opt) is disabled in the kernel configuration and must be enable \
97     to continue compilation)))
98$(foreach opt,$(CONFIG_OPTIONS_DISABLE),$(if $(filter m y, $(CONFIG_$(opt))), \
99     $(error CONFIG_$(opt) is enabled in the kernel configuration and must be disable \
100     to continue compilation),))
101endif
102
103# add -Wall to try to catch everything we can.
104ccflags-y := -Wall
105
106# needed for trace events
107ccflags-y += -I$(src)
108
109GB_AUDIO_MANAGER_SYSFS ?= true
110ifeq ($(GB_AUDIO_MANAGER_SYSFS),true)
111gb-audio-manager-y += audio_manager_sysfs.o
112ccflags-y += -DGB_AUDIO_MANAGER_SYSFS
113endif
114
115all: module
116
117tools::
118	$(MAKE) -C tools KERNELDIR=$(realpath $(KERNELDIR))
119
120module:
121	$(MAKE) -C $(KERNELDIR) M=$(PWD)
122
123check:
124	$(MAKE) -C $(KERNELDIR) M=$(PWD) C=2 CF="-D__CHECK_ENDIAN__"
125
126clean:
127	rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
128	rm -f Module.markers Module.symvers modules.order
129	rm -rf .tmp_versions Modules.symvers
130	$(MAKE) -C tools clean
131
132coccicheck:
133	$(MAKE) -C $(KERNELDIR) M=$(PWD) coccicheck
134
135install: module
136	mkdir -p $(INSTALL_MOD_PATH)/lib/modules/$(KERNELVER)/kernel/drivers/greybus/
137	cp -f *.ko $(INSTALL_MOD_PATH)/lib/modules/$(KERNELVER)/kernel/drivers/greybus/
138	depmod -b $(INSTALL_MOD_PATH) -a $(KERNELVER)
139