diff mbox

[v3] greybus: Changes required for integrating into the Android build

Message ID 1412963603-7334-1-git-send-email-john.stultz@linaro.org
State New
Headers show

Commit Message

John Stultz Oct. 10, 2014, 5:53 p.m. UTC
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
diff mbox

Patch

diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..189ca0c
--- /dev/null
+++ b/Android.mk
@@ -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
diff --git a/Makefile b/Makefile
index 42a3944..375a4c5 100644
--- a/Makefile
+++ b/Makefile
@@ -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