target/linux/config: Allow enabling UBIFS support
[openadk.git] / mk / kernel-build.mk
blob65d3baba959ae86e2bad6c55634799098624e1a0
1 # This file is part of the OpenADK project. OpenADK is copyrighted
2 # material, please see the LICENCE file in the top-level directory.
4 include $(ADK_TOPDIR)/rules.mk
5 include $(ADK_TOPDIR)/mk/kernel-ver.mk
6 include $(ADK_TOPDIR)/mk/linux.mk
7 include $(ADK_TOPDIR)/mk/kernel-vars.mk
9 ifeq ($(ADK_TARGET_KERNEL_USE_CUSTOMCONFIG),y)
10 KERNEL_MODULES_USED:=$(shell grep -s =m $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH))
11 else
12 KERNEL_MODULES_USED:=$(shell grep ^ADK_KERNEL $(ADK_TOPDIR)/.config|grep =m)
13 endif
15 KERNEL_FILE:=$(ADK_TARGET_KERNEL)
16 KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
17 ifeq ($(ADK_TARGET_KERNEL_LINUXBIN),y)
18 KERNEL_FILE:=vmlinux
19 KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
20 endif
21 ifeq ($(ADK_TARGET_KERNEL_ZIMAGE),y)
22 KERNEL_FILE:=vmlinux
23 KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
24 endif
25 ifeq ($(ADK_TARGET_KERNEL_BZIMAGE),y)
26 KERNEL_FILE:=vmlinux
27 KERNEL_TARGET:=all
28 endif
29 ifeq ($(ADK_TARGET_KERNEL_IMAGE),y)
30 KERNEL_FILE:=vmlinux
31 KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
32 endif
34 ifeq ($(ADK_RUNTIME_DEV_UDEV),y)
35 ADK_DEPMOD:=$(STAGING_HOST_DIR)/usr/bin/depmod
36 else
37 ADK_DEPMOD:=true
38 endif
40 $(LINUX_DIR)/.prepared: $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_FILE_VER)/.patched
41 ln -sf $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_FILE_VER) $(LINUX_DIR)
42 mkdir -p $(LINUX_BUILD_DIR)/kmod-control
43 touch $@
45 ifeq ($(ADK_TARGET_KERNEL_USE_MINICONFIG),y)
46 $(LINUX_DIR)/.config: $(BUILD_DIR)/.kernelconfig
47 endif
49 ifeq ($(ADK_TARGET_KERNEL_USE_CUSTOMCONFIG),y)
50 $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH):
51 $(LINUX_DIR)/.config: $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH)
52 endif
54 $(LINUX_DIR)/.config: $(LINUX_DIR)/.prepared
55 $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-configure.. "
56 -for f in $(TARGETS);do if [ -f $$f ];then rm $$f;fi;done
57 echo "-${KERNEL_RELEASE}" >${LINUX_DIR}/localversion
58 ifeq ($(ADK_TARGET_KERNEL_USE_DEFCONFIG),y)
59 ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} $(ADK_TARGET_KERNEL_DEFCONFIG) $(MAKE_TRACE)
60 else ifeq ($(ADK_TARGET_KERNEL_USE_CUSTOMCONFIG),y)
61 @if [ ! -f $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH) ];then \
62 echo "no kernel configuration found in $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH)"; \
63 exit 1; \
65 ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=$(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH) allnoconfig $(MAKE_TRACE)
66 else
67 $(CP) $(BUILD_DIR)/.kernelconfig $(LINUX_DIR)/mini.config
68 ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=mini.config allnoconfig $(MAKE_TRACE)
69 endif
70 touch -c $(LINUX_DIR)/.config
71 $(CMD_TRACE) " done"
72 $(END_TRACE)
74 $(LINUX_DIR)/$(KERNEL_FILE): $(LINUX_DIR)/.config
75 $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-compile.. "
76 ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} $(KERNEL_TARGET) $(MAKE_TRACE)
77 touch -c $(LINUX_DIR)/$(KERNEL_FILE)
78 $(CMD_TRACE) " done"
79 $(END_TRACE)
81 $(LINUX_BUILD_DIR)/modules: $(LINUX_DIR)/$(KERNEL_FILE)
82 $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-modules-compile.. "
83 ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} modules $(MAKE_TRACE)
84 $(CMD_TRACE) " done"
85 $(END_TRACE)
86 $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-modules-install.. "
87 rm -rf $(LINUX_BUILD_DIR)/modules
88 ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} \
89 DEPMOD=$(ADK_DEPMOD) \
90 INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules \
91 modules_install $(MAKE_TRACE)
92 $(CMD_TRACE) " done"
93 $(END_TRACE)
94 ifneq ($(ADK_RUNTIME_DEV_UDEV),y)
95 $(START_TRACE) "target/$(ADK_TARGET_ARCH)-create-packages.. "
96 @mkdir -p ${PACKAGE_DIR}
97 PATH='${HOST_PATH}' ${BASH} ${SCRIPT_DIR}/make-module-ipkgs.sh \
98 "${ADK_TARGET_CPU_ARCH}" \
99 "${KERNEL_VERSION}" \
100 "${LINUX_BUILD_DIR}" \
101 "${PKG_BUILD}" \
102 "${PACKAGE_DIR}"
103 $(CMD_TRACE) " done"
104 $(END_TRACE)
105 endif
107 prepare:
108 ifneq ($(KERNEL_MODULES_USED),)
109 compile: $(LINUX_BUILD_DIR)/modules
110 else
111 compile: $(LINUX_DIR)/$(KERNEL_FILE)
112 endif
113 install: compile
114 ifneq ($(KERNEL_MODULES_USED),)
115 $(START_TRACE) "target/${ADK_TARGET_ARCH}-modules-install.. "
116 ifeq ($(ADK_TARGET_PACKAGE_IPKG)$(ADK_TARGET_PACKAGE_OPKG),y)
117 $(PKG_INSTALL) $(wildcard ${PACKAGE_DIR}/kmod-*) $(MAKE_TRACE)
118 else
119 $(foreach pkg,$(wildcard ${PACKAGE_DIR}/kmod-*),$(shell $(PKG_INSTALL) $(pkg)))
120 endif
121 $(CMD_TRACE) " done"
122 $(END_TRACE)
123 endif
125 clean:
126 rm -rf $(LINUX_BUILD_DIR)
127 rm -f $(wildcard ${PACKAGE_DIR}/kmod-*) $(wildcard ${PACKAGE_DIR}/kernel_*)