Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

build: Commit

build


Commit MetaInfo

Révision37040a1239d5d69cd90838c38a58a635248ea597 (tree)
l'heure2014-12-27 21:41:42
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Message de Log

android-x86: add kernel building rules

Change Summary

Modification

--- /dev/null
+++ b/core/tasks/kernel.mk
@@ -0,0 +1,111 @@
1+#
2+# Copyright (C) 2014 The Android-x86 Open Source Project
3+#
4+# Licensed under the Apache License, Version 2.0 (the "License");
5+# you may not use this file except in compliance with the License.
6+# You may obtain a copy of the License at
7+#
8+# http://www.apache.org/licenses/LICENSE-2.0
9+#
10+
11+ifeq ($(KBUILD_OUTPUT),)
12+ifeq ($(TARGET_PREBUILT_KERNEL),)
13+
14+KERNEL_DIR ?= kernel
15+
16+ifneq ($(filter x86%,$(TARGET_ARCH)),)
17+TARGET_KERNEL_ARCH ?= $(TARGET_ARCH)
18+KERNEL_TARGET := bzImage
19+TARGET_KERNEL_CONFIG ?= android-$(TARGET_KERNEL_ARCH)_defconfig
20+KERNEL_CONFIG_DIR := arch/x86/configs
21+endif
22+ifeq ($(TARGET_ARCH),arm)
23+KERNEL_TARGET := zImage
24+TARGET_KERNEL_CONFIG ?= goldfish_defconfig
25+KERNEL_CONFIG_DIR := arch/arm/configs
26+endif
27+
28+KBUILD_OUTPUT := $(abspath $(TARGET_OUT_INTERMEDIATES)/kernel)
29+mk_kernel := + $(hide) $(MAKE) -C $(KERNEL_DIR) O=$(KBUILD_OUTPUT) ARCH=$(TARGET_ARCH) $(if $(SHOW_COMMANDS),V=1)
30+
31+KERNEL_CONFIG_FILE := $(if $(wildcard $(TARGET_KERNEL_CONFIG)),$(TARGET_KERNEL_CONFIG),$(KERNEL_DIR)/$(KERNEL_CONFIG_DIR)/$(TARGET_KERNEL_CONFIG))
32+
33+MOD_ENABLED := $(shell grep ^CONFIG_MODULES=y $(KERNEL_CONFIG_FILE))
34+FIRMWARE_ENABLED := $(shell grep ^CONFIG_FIRMWARE_IN_KERNEL=y $(KERNEL_CONFIG_FILE))
35+
36+# I understand Android build system discourage to use submake,
37+# but I don't want to write a complex Android.mk to build kernel.
38+# This is the simplest way I can think.
39+KERNEL_DOTCONFIG_FILE := $(KBUILD_OUTPUT)/.config
40+KERNEL_ARCH_CHANGED := $(if $(filter 0,$(shell grep -s ^$(if $(filter x86,$(TARGET_KERNEL_ARCH)),\#.)CONFIG_64BIT $(KERNEL_DOTCONFIG_FILE) | wc -l)),FORCE)
41+$(KERNEL_DOTCONFIG_FILE): $(KERNEL_CONFIG_FILE) $(KERNEL_ARCH_CHANGED) | $(ACP)
42+ $(copy-file-to-new-target)
43+
44+# bison is needed to build kernel and external modules from source
45+BISON := $(HOST_OUT_EXECUTABLES)/bison$(HOST_EXECUTABLE_SUFFIX)
46+
47+BUILT_KERNEL_TARGET := $(KBUILD_OUTPUT)/arch/$(TARGET_ARCH)/boot/$(KERNEL_TARGET)
48+$(INSTALLED_KERNEL_TARGET): $(KERNEL_DOTCONFIG_FILE) $(BISON)
49+ $(mk_kernel) oldnoconfig
50+ $(mk_kernel) $(KERNEL_TARGET) $(if $(MOD_ENABLED),modules)
51+ $(hide) $(ACP) -fp $(BUILT_KERNEL_TARGET) $@
52+ $(if $(FIRMWARE_ENABLED),$(mk_kernel) INSTALL_MOD_PATH=$(abspath $(TARGET_OUT)) firmware_install)
53+
54+ifneq ($(MOD_ENABLED),)
55+KERNEL_MODULES_DEP := $(firstword $(wildcard $(TARGET_OUT)/lib/modules/*/modules.dep))
56+KERNEL_MODULES_DEP := $(if $(KERNEL_MODULES_DEP),$(KERNEL_MODULES_DEP),$(TARGET_OUT)/lib/modules)
57+
58+$(TARGET_OUT_INTERMEDIATES)/%.kmodule: $(INSTALLED_KERNEL_TARGET)
59+ $(hide) cp -an $(EXTRA_KERNEL_MODULE_PATH_$*) $(TARGET_OUT_INTERMEDIATES)/$*.kmodule
60+ @echo Building additional kernel module $*
61+ $(mk_kernel) M=$(abspath $@) modules
62+
63+$(KERNEL_MODULES_DEP): $(INSTALLED_KERNEL_TARGET) $(patsubst %,$(TARGET_OUT_INTERMEDIATES)/%.kmodule,$(TARGET_EXTRA_KERNEL_MODULES))
64+ $(hide) rm -rf $(TARGET_OUT)/lib/modules
65+ $(mk_kernel) INSTALL_MOD_PATH=$(abspath $(TARGET_OUT)) modules_install
66+ + $(hide) for kmod in $(TARGET_EXTRA_KERNEL_MODULES) ; do \
67+ echo Installing additional kernel module $${kmod} ; \
68+ $(subst +,,$(subst $(hide),,$(mk_kernel))) INSTALL_MOD_PATH=$(abspath $(TARGET_OUT)) M=$(abspath $(TARGET_OUT_INTERMEDIATES))/$${kmod}.kmodule modules_install ; \
69+ done
70+ $(hide) rm -f $(TARGET_OUT)/lib/modules/*/{build,source}
71+endif
72+
73+$(BUILT_SYSTEMIMAGE): $(KERNEL_MODULES_DEP)
74+
75+# rules to get source of Broadcom 802.11a/b/g/n hybrid device driver
76+# based on broadcomsetup.sh of Kyle Evans
77+WL_PATH := $(KERNEL_DIR)/drivers/net/wireless/wl
78+WL_ENABLED := $(if $(wildcard $(WL_PATH)),$(shell grep ^CONFIG_WL=[my] $(KERNEL_CONFIG_FILE)))
79+WL_ARCH_CHANGED := $(if $(shell file $(WL_PATH)/lib/wlc_hybrid.o_shipped | grep -s $(if $(filter x86,$(TARGET_KERNEL_ARCH)),80386,x86-64)),,FORCE)
80+ifeq ($(filter x86,$(TARGET_KERNEL_ARCH)),)
81+WL_SRC := $(WL_PATH)/hybrid-v35_64-nodebug-pcoem-6_30_223_141.tar.gz
82+else
83+WL_SRC := $(WL_PATH)/hybrid-v35-nodebug-pcoem-6_30_223_141.tar.gz
84+endif
85+$(WL_SRC):
86+ @echo Downloading $(@F)...
87+ $(hide) curl http://www.broadcom.com/docs/linux_sta/$(@F) > $@
88+$(WL_PATH)/Makefile : $(WL_SRC) $(wildcard $(WL_PATH)/*.patch) $(WL_ARCH_CHANGED) $(KERNEL_ARCH_CHANGED)
89+ $(hide) tar zxf $< -C $(@D) --overwrite && \
90+ patch -p5 -d $(@D) -i wl.patch && \
91+ patch -p1 -d $(@D) -i linux-recent.patch
92+$(INSTALLED_KERNEL_TARGET): $(if $(WL_ENABLED),$(WL_PATH)/Makefile)
93+
94+installclean: FILES += $(KBUILD_OUTPUT) $(INSTALLED_KERNEL_TARGET)
95+
96+TARGET_PREBUILT_KERNEL := $(INSTALLED_KERNEL_TARGET)
97+
98+.PHONY: kernel
99+kernel: $(TARGET_PREBUILT_KERNEL)
100+
101+else
102+
103+$(INSTALLED_KERNEL_TARGET): $(TARGET_PREBUILT_KERNEL) | $(ACP)
104+ $(copy-file-to-new-target)
105+ifdef TARGET_PREBUILT_MODULES
106+ mkdir -p $(TARGET_OUT)/lib
107+ $(hide) cp -r $(TARGET_PREBUILT_MODULES) $(TARGET_OUT)/lib
108+endif
109+
110+endif # TARGET_PREBUILT_KERNEL
111+endif # KBUILD_OUTPUT
Afficher sur ancien navigateur de dépôt.