new file mode 100644
@@ -0,0 +1,28 @@
+.PHONY: build-greybus
+
+$(PRODUCT_OUT)/ramdisk.img: build-greybus
+
+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)
+
+KDIRARG := KERNELDIR="${ANDROID_PRODUCT_OUT}/obj/kernel"
+ifneq ($(ANDROID_64),)
+ ARCHARG := ARCHLINE="ARCH=arm64"
+else
+ ARCHARG := ARCHLINE="ARCH=arm"
+endif
+ARGS := $(KDIRARG) $(ARCHARG)
+
+build-greybus: android_kernel
+ make clean -C $(GREYBUS_SRC_PATH)
+ cd $(GREYBUS_SRC_PATH) &&\
+ $(MAKE) -j$(MAKE_JOBS) CROSS_COMPILE=$(KERNEL_TOOLS_PREFIX) $(ARGS)
+ mkdir -p $(PRODUCT_OUT)/root/lib/modules
+ cp $(GREYBUS_SRC_PATH)/greybus.ko $(PRODUCT_OUT)/root/lib/modules
@@ -18,17 +18,21 @@ obj-m += greybus.o
obj-m += es1-ap-usb.o
obj-m += test_sink.o
+ifeq ($(KERNELDIR), )
KERNELVER ?= $(shell uname -r)
KERNELDIR ?= /lib/modules/$(KERNELVER)/build
+endif
PWD := $(shell pwd)
+EXTRA_CFLAGS += -fno-pic
+
all: module
module:
- $(MAKE) -C $(KERNELDIR) M=$(PWD)
+ $(MAKE) -C $(KERNELDIR) M=$(PWD) $(ARCHLINE)
check:
- $(MAKE) -C $(KERNELDIR) M=$(PWD) C=2 CF="-D__CHECK_ENDIAN__"
+ $(MAKE) -C $(KERNELDIR) M=$(PWD) C=2 CF="-D__CHECK_ENDIAN__" $(ARCHLINE)
clean:
rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
@@ -36,5 +40,5 @@ clean:
rm -rf .tmp_versions Modules.symvers
coccicheck:
- $(MAKE) -C $(KERNELDIR) M=$(PWD) coccicheck
+ $(MAKE) -C $(KERNELDIR) M=$(PWD) $(ARCHLINE) coccicheck
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. Signed-off-by: John Stultz <john.stultz@linaro.org> --- v3: Sorted out the reallocation issue w/ -fno-pic. This should be ok to merge, if no one objects. Android.mk | 28 ++++++++++++++++++++++++++++ Makefile | 10 +++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 Android.mk