openssl: update to 3.0.14
[openadk.git] / mk / kernel-build.mk
blob29458abf06c7d77d514a0a32e17354a06b6628a2
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/$(ADK_TARGET_OS)-ver.mk
6 include $(ADK_TOPDIR)/mk/$(ADK_TARGET_OS).mk
7 include $(ADK_TOPDIR)/mk/kernel-vars.mk
9 ifeq ($(ADK_TARGET_OS_LINUX),y)
10 KERNEL_MODULES_USED:=$(shell grep ^ADK_LINUX_KERNEL $(ADK_TOPDIR)/.config|grep =m)
11 endif
12 ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_CUSTOMCONFIG),y)
13 KERNEL_MODULES_USED:=$(shell grep -s =m $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH))
14 endif
16 KERNEL_FILE:=$(ADK_TARGET_KERNEL)
17 KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
18 ifeq ($(ADK_TARGET_KERNEL_LINUXBIN),y)
19 KERNEL_FILE:=vmlinux
20 endif
21 ifeq ($(ADK_TARGET_KERNEL_ZIMAGE),y)
22 KERNEL_FILE:=vmlinux
23 endif
24 ifeq ($(ADK_TARGET_KERNEL_VMLINUX_EFI),y)
25 KERNEL_FILE:=vmlinux.efi
26 KERNEL_TARGET:=all
27 endif
28 ifeq ($(ADK_TARGET_KERNEL_VMLINUX_GZ),y)
29 KERNEL_FILE:=vmlinux
30 KERNEL_TARGET:=all
31 endif
32 ifeq ($(ADK_TARGET_KERNEL_BZIMAGE),y)
33 KERNEL_FILE:=vmlinux
34 KERNEL_TARGET:=all
35 endif
36 ifeq ($(ADK_TARGET_KERNEL_IMAGE),y)
37 KERNEL_FILE:=vmlinux
38 endif
39 ifeq ($(ADK_TARGET_KERNEL_SIMPLEIMAGE),y)
40 KERNEL_FILE:=vmlinux.bin
41 KERNEL_TARGET:=simpleImage.milkymist_one
42 endif
44 ifneq ($(KERNEL_MODULES_USED),)
45 KERNEL_TARGET+=modules
46 endif
48 ifeq ($(ADK_RUNTIME_DEV_UDEV),y)
49 ADK_DEPMOD:=$(STAGING_HOST_DIR)/usr/bin/depmod
50 else
51 ADK_DEPMOD:=true
52 endif
54 $(LINUX_DIR)/.prepared: $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/$(ADK_TARGET_OS)-$(KERNEL_FILE_VER)/.patched
55 ln -sf $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/$(ADK_TARGET_OS)-$(KERNEL_FILE_VER) $(LINUX_DIR)
56 mkdir -p $(LINUX_BUILD_DIR)/kmod-control
57 touch $@
59 ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_MINICONFIG),y)
60 $(LINUX_DIR)/.config: $(BUILD_DIR)/.kernelconfig
61 endif
63 ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_CUSTOMCONFIG),y)
64 $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH):
65 $(LINUX_DIR)/.config: $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH)
66 endif
68 $(LINUX_DIR)/.config: $(LINUX_DIR)/.prepared
69 $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-configure.. "
70 echo "-${KERNEL_RELEASE}" >${LINUX_DIR}/localversion
71 ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_DEFCONFIG),y)
72 ${KERNEL_MAKE} $(ADK_TARGET_LINUX_KERNEL_DEFCONFIG) $(MAKE_TRACE)
73 else ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_CUSTOMCONFIG),y)
74 @if [ ! -f $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH) ];then \
75 echo "no kernel configuration found in $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH)"; \
76 exit 1; \
78 ${KERNEL_MAKE} KCONFIG_ALLCONFIG=$(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH) allnoconfig $(MAKE_TRACE)
79 else
80 $(CP) $(BUILD_DIR)/.kernelconfig $(LINUX_DIR)/mini.config
81 ${KERNEL_MAKE} KCONFIG_ALLCONFIG=mini.config allnoconfig $(MAKE_TRACE)
82 endif
83 $(CMD_TRACE) " done"
84 $(END_TRACE)
86 $(LINUX_DIR)/$(KERNEL_FILE): $(LINUX_DIR)/.config
87 $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-compile.. "
88 ifneq ($(ADK_TARGET_KERNEL_APPEND_DTB),)
89 ${KERNEL_MAKE} zImage dtbs $(MAKE_TRACE)
90 (cd $(LINUX_DIR)/arch/$(ADK_TARGET_ARCH)/boot && \
91 cat dts/${ADK_TARGET_KERNEL_APPEND_DTB}.dtb >> zImage)
92 endif
93 ${KERNEL_MAKE} $(KERNEL_TARGET) $(MAKE_TRACE)
94 $(CMD_TRACE) " done"
95 $(END_TRACE)
97 prepare:
98 compile: $(LINUX_DIR)/$(KERNEL_FILE)
99 install:
100 ifneq ($(KERNEL_MODULES_USED),)
101 $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-modules-install.. "
102 rm -rf $(LINUX_BUILD_DIR)/modules
103 ${KERNEL_MAKE} DEPMOD=$(ADK_DEPMOD) \
104 INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules \
105 modules_install $(MAKE_TRACE)
106 $(CMD_TRACE) " done"
107 $(END_TRACE)
108 $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-modules-create-packages.. "
109 rm -f ${PACKAGE_DIR}/kmod-*
110 PATH='${HOST_PATH}' ${BASH} ${SCRIPT_DIR}/make-module-ipkgs.sh \
111 "${ADK_TARGET_CPU_ARCH}" \
112 "${KERNEL_VERSION}" \
113 "${LINUX_BUILD_DIR}" \
114 "${PKG_BUILD}" \
115 "${PACKAGE_DIR}"
116 $(CMD_TRACE) " done"
117 $(END_TRACE)
118 $(START_TRACE) "target/${ADK_TARGET_ARCH}-kernel-modules-install-packages.. "
119 -for pkg in $(PACKAGE_DIR)/kmod-*; do \
120 [[ -e "$$pkg" ]] && $(PKG_INSTALL) $$pkg; \
121 done
122 $(CMD_TRACE) " done"
123 $(END_TRACE)
124 $(CP) $(LINUX_BUILD_DIR)/modules/lib/modules/$(KERNEL_VERSION)/modules.{order,builtin} \
125 $(TARGET_DIR)/lib/modules/$(KERNEL_VERSION)/
126 endif
128 clean:
129 rm -rf $(LINUX_BUILD_DIR)
130 rm -f $(wildcard ${PACKAGE_DIR}/kmod-*) $(wildcard ${PACKAGE_DIR}/kernel_*)