coreutils: update to 8.25
[openadk.git] / target / Makefile
blob9882e4d843b85cd5e53ae0e1139f2b3535f06b8e
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/rootfs.mk
7 ifeq ($(ADK_TARGET_KERNEL_USE_CUSTOMCONFIG),y)
8 KERNEL_MODULES_USED:=$(shell grep -s =m $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH))
9 else
10 KERNEL_MODULES_USED:=$(shell grep ^ADK_KERNEL $(ADK_TOPDIR)/.config|grep =m)
11 endif
13 all: install
15 ### Kernel .config Creation
16 # The following target combines all kernel-related variables and
17 # config files into a single one to be used as the final kernel
18 # configuration when building. This is how it's done:
19 # 1) fetch all enabled ADK_KERNEL_* vars into
20 # .kernelconfig.kernel
21 # 2) get the global and device-specific static kernel config and place it into
22 # .kernelconfig.board
23 # 3) append $(FS_CMDLINE) to the kernel commandline inside .kernelconfig.board
24 # 4) merge both together into .kernelconfig.tmp
25 # 5) check if .kernelconfig.tmp differs from the current one
26 # (.kernelconfig) at all, overwriting the current one
27 # only if it does (so the timestamp stays intact)
28 # 6) remove the temporary .kernelconfig.tmp
29 ###
30 ADK_PACKAGE_CRYPTINIT_ROOT:=$(strip $(subst ",, $(ADK_PACKAGE_CRYPTINIT_ROOT)))
31 ADK_PACKAGE_CRYPTINIT_SWAP:=$(strip $(subst ",, $(ADK_PACKAGE_CRYPTINIT_SWAP)))
32 ADK_PACKAGE_CMDLINE:=root=$(ADK_PACKAGE_CRYPTINIT_ROOT) swap=$(ADK_PACKAGE_CRYPTINIT_SWAP) resume=/dev/mapper/swapcrypt
34 ifeq ($(ADK_TARGET_OS_LINUX),y)
35 ifeq ($(ADK_TARGET_KERNEL_USE_MINICONFIG),y)
36 ifeq ($(ADK_TARGET_KERNEL_CUSTOMISING),y)
37 config-prepare: $(ADK_TOPDIR)/.config
38 @PATH='$(HOST_PATH)' sed -n '/^ADK_KERNEL/s//CONFIG/p' $(ADK_TOPDIR)/.config \
39 >$(BUILD_DIR)/.kernelconfig.kernel
40 @if [ -f $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) ];then \
41 cat $(ADK_TOPDIR)/target/linux/kernel.config \
42 $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) > $(BUILD_DIR)/.kernelconfig.board; \
43 else \
44 echo "no miniconfig found for target system"; \
45 exit 1; \
47 ifneq ($(ADK_TARGET_NO_CMDLINE),y)
48 ifeq ($(ADK_APPLIANCE_KODI),y)
49 $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 consoleblank=0 vt.global_cursor_default=0"#' \
50 $(BUILD_DIR)/.kernelconfig.board
51 endif
52 ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_VGA_ONLY),y)
53 $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_VGA_DEVICE)"#' \
54 $(BUILD_DIR)/.kernelconfig.board
55 endif
56 ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_SERIAL_ONLY),y)
57 $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE),$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED)"#' \
58 $(BUILD_DIR)/.kernelconfig.board
59 endif
60 ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_VGA_SERIAL),y)
61 $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_VGA_DEVICE) console=$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE),$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED)"#' \
62 $(BUILD_DIR)/.kernelconfig.board
63 endif
64 ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_SERIAL_VGA),y)
65 $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE),$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED) console=$(ADK_RUNTIME_CONSOLE_VGA_DEVICE)"#' \
66 $(BUILD_DIR)/.kernelconfig.board
67 endif
68 ifeq ($(ADK_TARGET_SYSTEM_QEMU_M68K_Q800)$(ADK_TARGET_SYSTEM_QEMU_M68K_MCF5208),y)
69 @$(SED) 's#^\(CONFIG_.*BOOTPARAM_STRING="\)\(.*\)"#\1\2 ro $(FS_CMDLINE)"#' \
70 $(BUILD_DIR)/.kernelconfig.board
71 endif
72 ifneq ($(ADK_RUNTIME_INIT_SYSTEMD),y)
73 ifeq ($(ADK_TARGET_ROOTFS_NFSROOT),)
74 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ro"#' \
75 $(BUILD_DIR)/.kernelconfig.board
76 else
77 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 rw"#' \
78 $(BUILD_DIR)/.kernelconfig.board
79 endif
80 endif
81 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 $(FS_CMDLINE)"#' \
82 $(BUILD_DIR)/.kernelconfig.board
83 ifneq ($(ADK_TARGET_CMDLINE),)
84 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 $(ADK_TARGET_CMDLINE)"#' \
85 $(BUILD_DIR)/.kernelconfig.board
86 endif
87 ifeq ($(ADK_TARGET_QEMU_WITH_GRAPHIC),y)
88 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=tty0"#' \
89 $(BUILD_DIR)/.kernelconfig.board
90 endif
91 ifneq ($(ADK_PACKAGE_CRYPTINIT_ROOT),)
92 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 $(ADK_PACKAGE_CMDLINE)"#' \
93 $(BUILD_DIR)/.kernelconfig.board
94 endif
95 ifeq ($(ADK_RUNTIME_QUIET_INIT),y)
96 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 rcquiet=1"#' \
97 $(BUILD_DIR)/.kernelconfig.board
98 endif
99 ifeq ($(ADK_RUNTIME_QUIET_KERNEL),y)
100 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 quiet loglevel=2 vt.global_cursor_default=0"#' \
101 $(BUILD_DIR)/.kernelconfig.board
102 endif
103 ifeq ($(ADK_KERNEL_DEBUG_WITH_KGDB),y)
104 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 kgdbwait kgdboc=ttyS0,115200"#' \
105 $(BUILD_DIR)/.kernelconfig.board
106 endif
107 ifeq ($(ADK_KERNEL_NETCONSOLE),y)
108 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 netconsole=@$(ADK_PARAMETER_NETCONSOLE_SRC_IP)/,@$(ADK_PARAMETER_NETCONSOLE_DST_IP)/"#' \
109 $(BUILD_DIR)/.kernelconfig.board
110 endif
111 endif
112 @cd $(BUILD_DIR) && cat .kernelconfig.board .kernelconfig.kernel \
113 >.kernelconfig.tmp
114 @cd $(BUILD_DIR) && cmp -s .kernelconfig.tmp .kernelconfig || \
115 cp .kernelconfig.tmp .kernelconfig
116 @-rm -f $(BUILD_DIR)/.kernelconfig.tmp
117 else
118 config-prepare: $(ADK_TOPDIR)/.config
119 @if [ -f $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) ];then \
120 cat $(ADK_TOPDIR)/target/linux/kernel.config \
121 $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) > $(BUILD_DIR)/.kernelconfig.board; \
122 else \
123 echo "no miniconfig found for target system"; \
124 exit 1; \
126 @cd $(BUILD_DIR) && cmp -s .kernelconfig.board .kernelconfig || \
127 cp .kernelconfig.board .kernelconfig
128 endif
129 else
130 config-prepare: $(ADK_TOPDIR)/.config
131 @true
132 endif
133 endif
135 ifeq ($(ADK_TARGET_OS_FROSTED),y)
136 config-prepare: $(ADK_TOPDIR)/.config
137 @PATH='$(HOST_PATH)' sed -n '/^ADK_FROSTED_/s///p' $(ADK_TOPDIR)/.config \
138 >$(BUILD_DIR)/.frosted
139 @PATH='$(HOST_PATH)' sed -n '/^ADK_PACKAGE_FROSTED_/s///p' $(ADK_TOPDIR)/.config \
140 >$(BUILD_DIR)/.frostedapps
141 endif
143 ifeq ($(ADK_TARGET_OS_ZEPHYR),y)
144 config-prepare: $(ADK_TOPDIR)/.config
145 echo foo
146 endif
148 ifeq ($(ADK_TARGET_OS_FROSTED),y)
149 prepare: frosted-prepare
150 compile: frosted-compile
151 install: frosted-install
152 targethelp: frosted-targethelp
153 endif
155 ifeq ($(ADK_TARGET_OS_ZEPHYR),y)
156 prepare: zephyr-prepare
157 compile: zephyr-compile
158 install: zephyr-install
159 targethelp: zephyr-targethelp
160 endif
162 ifeq ($(ADK_TARGET_OS_LINUX),y)
163 prepare: $(ADK_TARGET_ARCH)-prepare
164 compile: $(ADK_TARGET_ARCH)-compile
165 image: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-imageinstall
166 targethelp: $(ADK_TARGET_ARCH)-targethelp
167 install: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-install $(ADK_TARGET_ARCH)-imageinstall
168 clean: $(ADK_TARGET_ARCH)-clean $(ADK_TARGET_ARCH)-imageclean
169 endif
171 %-clean:
172 $(START_TRACE) "target/$(patsubst %-clean,%,$@)-clean.. "
173 $(MAKE) -C $(patsubst %-clean,%,$@) clean
174 $(CMD_TRACE) " done"
175 $(END_TRACE)
177 %-imageclean:
178 $(START_TRACE) "target/$(patsubst %-imageclean,%,$@)-imageclean.. "
179 $(MAKE) -C $(patsubst %-imageclean,%,$@) imageclean
180 $(CMD_TRACE) " done"
181 $(END_TRACE)
183 %-prepare:
184 $(START_TRACE) "target/$(patsubst %-prepare,%,$@)-prepare.. "
185 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
186 $(CMD_TRACE) " done"
187 $(END_TRACE)
189 %-imageprepare:
190 $(START_TRACE) "target/$(patsubst %-imageprepare,%,$@)-imageprepare.. "
191 ifeq ($(ADK_RUNTIME_DEV_UDEV),y)
192 ifneq ($(KERNEL_MODULES_USED),)
193 # This should be made a package instead
194 $(CP) $(BUILD_DIR)/linux-$(ADK_TARGET_ARCH)/modules/lib $(TARGET_DIR)
195 rm -f "$(TARGET_DIR)"/lib/modules/*/build \
196 "$(TARGET_DIR)"/lib/modules/*/source
197 endif
198 endif
199 @for x in $$(ls $(ADK_TOPDIR)/scripts/preimage/*.sh 2>/dev/null); do \
200 [[ -x "$$x" ]] && $$x; \
201 break; \
202 done
203 $(MAKE) -C $(patsubst %-imageprepare,%,$@) imageprepare
204 $(CMD_TRACE) " done"
205 $(END_TRACE)
207 %-compile: %-prepare
208 $(START_TRACE) "target/$(patsubst %-compile,%,$@)-compile.. "
209 $(MAKE) -C $(patsubst %-compile,%,$@) compile
210 $(CMD_TRACE) " done"
211 $(END_TRACE)
213 %-install:
214 $(START_TRACE) "target/$(patsubst %-install,%,$@)-install.. "
215 $(MAKE) -C $(patsubst %-install,%,$@) install
216 $(CMD_TRACE) " done"
217 $(END_TRACE)
219 %-targethelp:
220 $(MAKE) -C $(patsubst %-targethelp,%,$@) targethelp
222 %-imageinstall: %-imageprepare
223 $(MAKE) -C $(patsubst %-imageinstall,%,$@) imageinstall
224 @for x in $$(ls $(ADK_TOPDIR)/scripts/postimage/*.sh 2>/dev/null); do \
225 [[ -x "$$x" ]] && $$x; \
226 break; \
227 done
228 @echo "Login as user root via ssh or console."