new file mode 100644
@@ -0,0 +1,21 @@
+.PHONY: build-greybus
+
+$(PRODUCT_OUT)/ramdisk.img: greybus.ko
+
+include $(CLEAR_VARS)
+GREYBUS_SRC_PATH := $(ANDROID_BUILD_TOP)/external/greybus/
+LOCAL_PATH := $(GREYBUS_SRC_PATH)
+LOCAL_SRC_FILES := greybus.ko
+LOCAL_MODULE := $(LOCAL_SRC_FILES)
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)/root/lib/modules
+$(LOCAL_PATH)/$(LOCAL_SRC_FILES): build-greybus
+include $(BUILD_PREBUILT)
+
+build-greybus: android_kernel
+ cd $(GREYBUS_SRC_PATH) &&\
+ $(MAKE) -j$(MAKE_JOBS) CROSS_COMPILE=$(KERNEL_TOOLS_PREFIX)
+ifeq (,$(wildcard $(PRODUCT_OUT)/root/lib/modules))
+ mkdir -p $(PRODUCT_OUT)/root/lib/modules
+endif
+ cp $(GREYBUS_SRC_PATH)/greybus.ko $(PRODUCT_OUT)/root/lib/modules
@@ -18,17 +18,22 @@ obj-m += greybus.o
obj-m += es1-ap-usb.o
obj-m += test_sink.o
+ifneq (${ANDROID_PRODUCT_OUT}, )
+KERNELDIR := ${ANDROID_PRODUCT_OUT}/obj/kernel
+ARCHLINE := "ARCH=arm64"
+else
KERNELVER ?= $(shell uname -r)
KERNELDIR ?= /lib/modules/$(KERNELVER)/build
+endif
PWD := $(shell pwd)
all: module
module:
- $(MAKE) -C $(KERNELDIR) M=$(PWD)
+ $(MAKE) -C $(KERNELDIR) M=$(PWD) CROSS_COMPILE=$(CROSS_COMPILE) $(ARCHLINE)
check:
- $(MAKE) -C $(KERNELDIR) M=$(PWD) C=2 CF="-D__CHECK_ENDIAN__"
+ $(MAKE) -C $(KERNELDIR) M=$(PWD) C=2 CF="-D__CHECK_ENDIAN__" CROSS_COMPILE=$(CROSS_COMPILE) $(ARCHLINE)
clean:
rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
@@ -36,5 +41,5 @@ clean:
rm -rf .tmp_versions Modules.symvers
coccicheck:
- $(MAKE) -C $(KERNELDIR) M=$(PWD) coccicheck
+ $(MAKE) -C $(KERNELDIR) M=$(PWD) CROSS_COMPILE=$(CROSS_COMPILE) $(ARCHLINE) coccicheck
Just wanted to get some early feedback here. In order to easily integrate into the Android build, include an Android.mk and some extra conditionals in the Makefile to get the proper kerneldir. The ARCHLINE detail is really hackish, but I couldn't seem to find a way to get the ARCH specified properly when crossbuilding without being explicit. Any ideas? Signed-off-by: John Stultz <john.stultz@linaro.org> --- Android.mk | 21 +++++++++++++++++++++ Makefile | 11 ++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 Android.mk