[RAMEN9610-8778]AndroidKernel.mk: Modify build system to move output dir
authorYoungwan Kim <y103.kim@samsung.com>
Wed, 21 Nov 2018 01:57:11 +0000 (10:57 +0900)
committerhskang <hs1218.kang@samsung.com>
Mon, 3 Dec 2018 05:48:37 +0000 (14:48 +0900)
Change-Id: I2879748bf2a32657c5189fc6350fb855399946bf
Signed-off-by: Youngwan Kim <y103.kim@samsung.com>
AndroidKernel.mk
Makefile
lib/libdss-build.sh

index 88308bad193ad80427bc780a0d07ef025b1f11ba..a090e4d62b95d72b51f1b179fed1d8df078881da 100644 (file)
@@ -5,6 +5,7 @@ $(error KERNEL_DEFCONFIG must be set as environment variable)
 endif
 
 ifeq ($(INSTALLED_KERNEL_TARGET),)
+KERNEL_OBJECTS := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
 INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
 BOARD_PREBUILT_DTBOIMAGE := $(PRODUCT_OUT)/prebuilt_dtbo.img
@@ -40,15 +41,16 @@ endif
 
 ifeq ($(TARGET_PREBUILT_KERNEL),)
 
-TARGET_KERNEL_SOURCE := kernel/$(TARGET_KERNEL)
-KERNEL_CONFIG := $(TARGET_KERNEL_SOURCE)/.config
-KERNEL_BOOT := $(TARGET_KERNEL_SOURCE)/arch/$(KERNEL_ARCH)/boot
+KERNEL_CONFIG := $(KERNEL_OBJECTS)/.config
+KERNEL_BOOT := $(KERNEL_OBJECTS)/arch/$(KERNEL_ARCH)/boot
 KERNEL_BIN := $(KERNEL_BOOT)/Image
 KERNEL_DTB_DIR := $(KERNEL_BOOT)/dts/exynos
 KERNEL_DTB := $(KERNEL_DTB_DIR)/exynos9610.dtb
-KERNEL_DTBO_CFG := $(KERNEL_DTB_DIR)/exynos9610_dtboimg.cfg
 MKDTIMG := $(HOST_OUT_EXECUTABLES)/mkdtimg
 
+TARGET_KERNEL_SOURCE := kernel/$(TARGET_KERNEL)
+KERNEL_DTB_SOURCE_DIR := $(TARGET_KERNEL_SOURCE)/arch/$(KERNEL_ARCH)/boot/dts/exynos
+KERNEL_DTBO_CFG := $(KERNEL_DTB_SOURCE_DIR)/exynos9610_dtboimg.cfg
 KERNEL_MERGE_CONFIG := $(TARGET_KERNEL_SOURCE)/scripts/kconfig/merge_config.sh
 KERNEL_CONFIG_BASE := $(TARGET_KERNEL_SOURCE)/arch/$(KERNEL_ARCH)/configs
 KERNEL_DEFCONFIG_PATH := $(KERNEL_CONFIG_BASE)/$(KERNEL_DEFCONFIG)
@@ -58,7 +60,7 @@ $(error Kernel configuration not defined, cannot build kernel)
 else
 
 ifeq ($(TARGET_BUILD_VARIANT),eng)
-MAKE_CONFIG_CMD := $(MAKE) -C $(TARGET_KERNEL_SOURCE) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(KERNEL_DEFCONFIG)
+MAKE_CONFIG_CMD := $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(PWD)/$(KERNEL_OBJECTS) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(KERNEL_DEFCONFIG)
 else
 ifeq ($(TARGET_BUILD_VARIANT),userdebug)
 KERNEL_USER_CFG := $(KERNEL_CONFIG_BASE)/$(TARGET_SOC)_userdebug.cfg
@@ -66,7 +68,8 @@ else
 KERNEL_USER_CFG := $(KERNEL_CONFIG_BASE)/$(TARGET_SOC)_user.cfg
 endif
 MAKE_CONFIG_CMD := ARCH=$(KERNEL_ARCH) $(KERNEL_MERGE_CONFIG) -m -O $(TARGET_KERNEL_SOURCE) $(KERNEL_DEFCONFIG_PATH) $(KERNEL_USER_CFG);
-MAKE_CONFIG_CMD += $(MAKE) -C $(TARGET_KERNEL_SOURCE) ARCH=$(KERNEL_ARCH) KCONFIG_ALLCONFIG=.config alldefconfig
+MAKE_CONFIG_CMD += $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(PWD)/$(KERNEL_OBJECTS) ARCH=$(KERNEL_ARCH) KCONFIG_ALLCONFIG=.config alldefconfig;
+MAKE_CONFIG_CMD += $(MAKE) -C $(TARGET_KERNEL_SOURCE) distclean
 endif
 
 ifeq ($(N_KERNEL_BUILD_THREAD),)
@@ -90,7 +93,7 @@ $(KERNEL_CONFIG): phony-rebuild
 
 $(KERNEL_BIN): $(KERNEL_CONFIG)
        $(hide) echo "Building kernel..."
-       $(MAKE) -C $(TARGET_KERNEL_SOURCE) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) CLANG_TRIPLE=$(CLANG_TRIPLE) CC=$(CC) -j$(N_KERNEL_BUILD_THREAD)
+       $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(PWD)/$(KERNEL_OBJECTS) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) CLANG_TRIPLE=$(CLANG_TRIPLE) CC=$(CC) -j$(N_KERNEL_BUILD_THREAD)
 
 $(INSTALLED_KERNEL_TARGET): $(INSTALLED_DTBOIMAGE_TARGET)
        cp $(KERNEL_BIN) $(INSTALLED_KERNEL_TARGET)
@@ -98,9 +101,7 @@ $(INSTALLED_KERNEL_TARGET): $(INSTALLED_DTBOIMAGE_TARGET)
 
 $(BOARD_PREBUILT_DTBOIMAGE): $(MKDTIMG) $(KERNEL_DTBO_CFG) $(KERNEL_BIN)
        $(hide) echo "Building DTBOIMAGE..."
-       ln -sf $(TARGET_KERNEL_SOURCE)/arch
-       $(MKDTIMG) cfg_create $@ $(KERNEL_DTBO_CFG)
-       rm -f arch
+       $(MKDTIMG) cfg_create $@ $(KERNEL_DTBO_CFG) -d $(KERNEL_OBJECTS)
 
 endif #TARGET_PREBUILT_KERNEL
 endif #KERNEL_DEFCONFIG
index bf8ce4a095fe10b49db0b92d372303e80ebe1b8f..c19cc94e00f1bb6c57adbcf85f7709b72a85d677 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,6 @@ NAME = Petit Gorille
 # That's our default target when none is given on the command line
 PHONY := _all
 _all:
-       @lib/libdss-build.sh
 
 # o Do not use make's built-in rules and variables
 #   (this increases performance and avoids hard-to-debug behaviour);
@@ -146,6 +145,7 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
 sub-make:
        $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \
        -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
+       @lib/libdss-build.sh $(KBUILD_OUTPUT)/
 
 # Leave processing to above invocation of make
 skip-makefile := 1
@@ -631,7 +631,12 @@ endif
 # command line.
 # This allow a user to issue only 'make' to build a kernel including modules
 # Defaults to vmlinux, but the arch makefile usually adds further targets
+ifneq ($(O),)
+all: vmlinux
+else
 all: vmlinux
+       @lib/libdss-build.sh
+endif
 
 KBUILD_CFLAGS  += $(call cc-option,-fno-PIE)
 KBUILD_AFLAGS  += $(call cc-option,-fno-PIE)
index 321f7383850388e9317e8bd0e94584bfc70388be..e0bbfbf39174e3fde2c4090bd19e268643b7b135 100755 (executable)
@@ -4,6 +4,7 @@ ${CC} \
   --target=aarch64-linux-gnu \
   -Ilib/libdss-include \
   -Iinclude \
+  -I$1/include \
   -mlittle-endian \
   -Qunused-arguments \
   -fno-strict-aliasing \
@@ -27,7 +28,7 @@ ${CC} \
   -fno-strict-overflow \
   -fno-merge-all-constants \
   -fno-stack-check \
-  -g lib/libdss.c -o lib/libdss.o
+  -g lib/libdss.c -o ${1}lib/libdss.o
 
-${CROSS_COMPILE}ar -rc libdss.a lib/libdss.o
+${CROSS_COMPILE}ar -rc ${1}libdss.a ${1}lib/libdss.o
 fi