blob: 8b28b4b5a53dcf22c1fad10fd345ba0e15030963 [file] [log] [blame]
Greg Kroah-Hartmande536e32014-08-31 16:17:04 -07001greybus-y := core.o \
Greg Kroah-Hartmande536e32014-08-31 16:17:04 -07002 debugfs.o \
Johan Hovold7bc6faa2015-11-03 18:03:22 +01003 hd.o \
Alex Elderb09c94a2014-10-01 21:54:16 -05004 manifest.o \
Greg Kroah-Hartman0f035ac2015-04-07 20:26:53 +02005 endo.o \
Greg Kroah-Hartmandf671552014-12-21 14:10:26 -08006 module.o \
Greg Kroah-Hartmana93938a2014-12-19 14:56:30 -08007 interface.o \
Greg Kroah-Hartman3bdec692014-12-12 17:10:16 -05008 bundle.o \
Alex Elderc68adb22014-10-01 21:54:14 -05009 connection.o \
Alex Elder4ccb6b72014-10-28 19:36:00 -050010 protocol.o \
Viresh Kumarcdee4f72015-06-22 16:42:26 +053011 control.o \
Viresh Kumarab69c4c2015-07-03 17:00:29 +053012 svc.o \
Viresh Kumar90f1b612015-08-12 09:19:33 +053013 firmware.o \
Greg Kroah-Hartmane1308c12014-12-24 13:01:43 -080014 operation.o
15
Viresh Kumarf5db53b2015-05-20 16:56:46 +053016gb-phy-y := gpbridge.o \
Viresh Kumar5357cf32015-01-21 16:10:40 +053017 sdio.o \
18 uart.o \
19 pwm.o \
20 gpio.o \
21 i2c.o \
Viresh Kumar15d651b2015-01-23 13:07:45 +053022 spi.o \
Mark Greerddc88ef2015-11-04 09:47:21 -070023 usb.o
Greg Kroah-Hartmanc8a797a2014-08-11 15:30:45 +080024
Viresh Kumar98abb412015-01-21 16:10:41 +053025# Prefix all modules with gb-
26gb-vibrator-y := vibrator.o
27gb-battery-y := battery.o
Alexandre Bailon355a7052015-03-31 09:51:59 +020028gb-loopback-y := loopback.o
Rui Miguel Silva2870b522015-08-14 13:58:19 +010029gb-light-y := light.o
Greg Kroah-Hartmane806c7f2015-05-08 15:50:17 +020030gb-raw-y := raw.o
Greg Kroah-Hartmanc9e9de22015-11-04 20:46:14 -080031gb-hid-y := hid.o
Viresh Kumar98abb412015-01-21 16:10:41 +053032gb-es1-y := es1.o
33gb-es2-y := es2.o
Vaibhav Hiremathd517f272015-10-21 16:50:20 +053034gb-db3-y := db3-platform.o
Viresh Kumar98abb412015-01-21 16:10:41 +053035
Greg Kroah-Hartmanc8a797a2014-08-11 15:30:45 +080036obj-m += greybus.o
Greg Kroah-Hartman71479f62015-01-14 17:07:59 -080037obj-m += gb-phy.o
Greg Kroah-Hartman419a8cf2015-01-14 17:08:00 -080038obj-m += gb-vibrator.o
Greg Kroah-Hartman347fedb2015-01-14 17:08:01 -080039obj-m += gb-battery.o
Alexandre Bailon355a7052015-03-31 09:51:59 +020040obj-m += gb-loopback.o
Rui Miguel Silva2870b522015-08-14 13:58:19 +010041obj-m += gb-light.o
Greg Kroah-Hartmanc9e9de22015-11-04 20:46:14 -080042obj-m += gb-hid.o
Greg Kroah-Hartmane806c7f2015-05-08 15:50:17 +020043obj-m += gb-raw.o
Greg Kroah-Hartman60a7ad72015-01-14 17:08:02 -080044obj-m += gb-es1.o
Greg Kroah-Hartmanf5870272015-01-21 10:24:15 +080045obj-m += gb-es2.o
Vaibhav Hiremathd517f272015-10-21 16:50:20 +053046obj-m += gb-db3.o
Greg Kroah-Hartmanc8a797a2014-08-11 15:30:45 +080047
48KERNELVER ?= $(shell uname -r)
49KERNELDIR ?= /lib/modules/$(KERNELVER)/build
Bryan O'Donoghue68fff962015-05-07 17:00:50 -070050INSTALL_MOD_PATH ?= /..
Greg Kroah-Hartmanc8a797a2014-08-11 15:30:45 +080051PWD := $(shell pwd)
52
Rui Miguel Silva65cac602015-05-13 18:59:00 +010053# kernel config option that shall be enable
Johan Hovold650f38e2015-10-13 19:10:30 +020054CONFIG_OPTIONS_ENABLE := PWM SYSFS SPI USB SND_SOC MMC LEDS_CLASS
Rui Miguel Silva65cac602015-05-13 18:59:00 +010055
56# kernel config option that shall be disable
57CONFIG_OPTIONS_DISABLE :=
58
59# this only run in kbuild part of the makefile
60ifneq ($(KERNELRELEASE),)
Rui Miguel Silva13fcfbb62015-08-14 13:58:18 +010061# This function returns the argument version if current kernel version is minor
62# than the passed version, return 1 if equal or the current kernel version if it
63# is greater than argument version.
Rui Miguel Silva1ab2e892015-08-16 00:48:03 +010064kvers_cmp=$(shell [ "$(KERNELVERSION)" = "$(1)" ] && echo 1 || printf "$(1)\n$(KERNELVERSION)" | sort -V | tail -1)
Rui Miguel Silva13fcfbb62015-08-14 13:58:18 +010065
66ifneq ($(call kvers_cmp,"3.19.0"),3.19.0)
67 CONFIG_OPTIONS_ENABLE += LEDS_CLASS_FLASH
68endif
69
70ifneq ($(call kvers_cmp,"4.2.0"),4.2.0)
71 CONFIG_OPTIONS_ENABLE += V4L2_FLASH_LED_CLASS
72endif
73
Rui Miguel Silva65cac602015-05-13 18:59:00 +010074$(foreach opt,$(CONFIG_OPTIONS_ENABLE),$(if $(CONFIG_$(opt)),, \
75 $(error CONFIG_$(opt) is disabled in the kernel configuration and must be enable \
76 to continue compilation)))
77$(foreach opt,$(CONFIG_OPTIONS_DISABLE),$(if $(filter m y, $(CONFIG_$(opt))), \
78 $(error CONFIG_$(opt) is enabled in the kernel configuration and must be disable \
79 to continue compilation),))
80endif
81
Greg Kroah-Hartman7486dfd2014-11-19 19:09:53 -080082# add -Wall to try to catch everything we can.
Perry Hung3a97cdd2015-07-03 00:27:12 -040083ccflags-y := -Wall
Greg Kroah-Hartman7486dfd2014-11-19 19:09:53 -080084
Bryan O'Donoghue5c8ad592015-09-18 16:38:45 +010085# needed for trace events
86ccflags-y += -I$(src)
87
Greg Kroah-Hartmanc8a797a2014-08-11 15:30:45 +080088all: module
89
90module:
91 $(MAKE) -C $(KERNELDIR) M=$(PWD)
92
Greg Kroah-Hartmanac7171e2014-09-13 12:39:23 -070093check:
94 $(MAKE) -C $(KERNELDIR) M=$(PWD) C=2 CF="-D__CHECK_ENDIAN__"
95
Greg Kroah-Hartmanc8a797a2014-08-11 15:30:45 +080096clean:
97 rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
98 rm -f Module.markers Module.symvers modules.order
99 rm -rf .tmp_versions Modules.symvers
100
101coccicheck:
102 $(MAKE) -C $(KERNELDIR) M=$(PWD) coccicheck
103
Greg Kroah-Hartman025677d2015-01-14 14:55:24 -0800104install: module
Bryan O'Donoghue68fff962015-05-07 17:00:50 -0700105 mkdir -p $(INSTALL_MOD_PATH)/lib/modules/$(KERNELVER)/kernel/drivers/greybus/
106 cp -f *.ko $(INSTALL_MOD_PATH)/lib/modules/$(KERNELVER)/kernel/drivers/greybus/
107 depmod -b $(INSTALL_MOD_PATH) -a $(KERNELVER)