when OpenADK nfsroot is used for Gentoo installation, /dev/fd is required
[openadk.git] / target / Makefile
blob846620d6c54989a1fb243d114d146175adbe0910
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_LINUX_KERNEL_USE_CUSTOMCONFIG),y)
8 KERNEL_MODULES_USED:=$(shell grep -s =m $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH))
9 else
10 KERNEL_MODULES_USED:=$(shell grep ^ADK_$(ADK_TARGET_OS)_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_OS_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)$(ADK_TARGET_OS_WALDUX),y)
35 ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_MINICONFIG)$(ADK_TARGET_WALDUX_KERNEL_USE_MINICONFIG),y)
36 ifeq ($(ADK_TARGET_KERNEL_CUSTOMISING),y)
37 config-prepare: $(ADK_TOPDIR)/.config
38 ifeq ($(ADK_TARGET_OS_LINUX),y)
39 @PATH='$(HOST_PATH)' sed -n '/^ADK_LINUX_KERNEL/s//CONFIG/p' $(ADK_TOPDIR)/.config \
40 >$(BUILD_DIR)/.kernelconfig.kernel
41 endif
42 ifeq ($(ADK_TARGET_OS_WALDUX),y)
43 @PATH='$(HOST_PATH)' sed -n '/^ADK_WALDUX_KERNEL/s//CONFIG/p' $(ADK_TOPDIR)/.config \
44 >$(BUILD_DIR)/.kernelconfig.kernel
45 endif
46 @if [ -f $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) ];then \
47 cat $(ADK_TOPDIR)/target/$(ADK_TARGET_OS)/kernel.config \
48 $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) > $(BUILD_DIR)/.kernelconfig.board; \
49 else \
50 echo "no miniconfig found for target system"; \
51 exit 1; \
53 ifneq ($(ADK_TARGET_NO_CMDLINE),y)
54 ifeq ($(ADK_APPLIANCE_KODI),y)
55 $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 consoleblank=0 vt.global_cursor_default=0"#' \
56 $(BUILD_DIR)/.kernelconfig.board
57 endif
58 ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_VGA_ONLY),y)
59 $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_VGA_DEVICE)"#' \
60 $(BUILD_DIR)/.kernelconfig.board
61 endif
62 ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_SERIAL_ONLY),y)
63 $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE),$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED)"#' \
64 $(BUILD_DIR)/.kernelconfig.board
65 endif
66 ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_VGA_SERIAL),y)
67 $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_VGA_DEVICE) console=$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE),$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED)"#' \
68 $(BUILD_DIR)/.kernelconfig.board
69 endif
70 ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_SERIAL_VGA),y)
71 $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE),$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED) console=$(ADK_RUNTIME_CONSOLE_VGA_DEVICE)"#' \
72 $(BUILD_DIR)/.kernelconfig.board
73 endif
74 ifeq ($(ADK_TARGET_SYSTEM_QEMU_M68K_Q800)$(ADK_TARGET_SYSTEM_QEMU_M68K_MCF5208),y)
75 @$(SED) 's#^\(CONFIG_.*BOOTPARAM_STRING="\)\(.*\)"#\1\2 ro $(FS_CMDLINE)"#' \
76 $(BUILD_DIR)/.kernelconfig.board
77 endif
78 ifneq ($(ADK_RUNTIME_INIT_SYSTEMD),y)
79 ifeq ($(ADK_TARGET_ROOTFS_NFSROOT),)
80 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ro"#' \
81 $(BUILD_DIR)/.kernelconfig.board
82 else
83 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 rw"#' \
84 $(BUILD_DIR)/.kernelconfig.board
85 endif
86 endif
87 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 $(FS_CMDLINE)"#' \
88 $(BUILD_DIR)/.kernelconfig.board
89 ifneq ($(ADK_TARGET_CMDLINE),)
90 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 $(ADK_TARGET_CMDLINE)"#' \
91 $(BUILD_DIR)/.kernelconfig.board
92 endif
93 ifeq ($(ADK_TARGET_QEMU_WITH_GRAPHIC),y)
94 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=tty0"#' \
95 $(BUILD_DIR)/.kernelconfig.board
96 endif
97 ifneq ($(ADK_PACKAGE_CRYPTINIT_ROOT),)
98 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 $(ADK_PACKAGE_CMDLINE)"#' \
99 $(BUILD_DIR)/.kernelconfig.board
100 endif
101 ifeq ($(ADK_RUNTIME_QUIET_INIT),y)
102 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 rcquiet=1"#' \
103 $(BUILD_DIR)/.kernelconfig.board
104 endif
105 ifeq ($(ADK_RUNTIME_QUIET_KERNEL),y)
106 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 quiet loglevel=2 vt.global_cursor_default=0"#' \
107 $(BUILD_DIR)/.kernelconfig.board
108 endif
109 ifeq ($(ADK_LINUX_KERNEL_DEBUG_WITH_KGDB)$(ADK_WALDUX_KERNEL_DEBUG_WITH_KGDB),y)
110 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 kgdbwait kgdboc=ttyS0,115200"#' \
111 $(BUILD_DIR)/.kernelconfig.board
112 endif
113 ifeq ($(ADK_LINUX_KERNEL_NETCONSOLE)$(ADK_WALDUX_KERNEL_NETCONSOLE),y)
114 @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 netconsole=@$(ADK_PARAMETER_NETCONSOLE_SRC_IP)/,@$(ADK_PARAMETER_NETCONSOLE_DST_IP)/"#' \
115 $(BUILD_DIR)/.kernelconfig.board
116 endif
117 endif
118 @cd $(BUILD_DIR) && cat .kernelconfig.board .kernelconfig.kernel \
119 >.kernelconfig.tmp
120 @cd $(BUILD_DIR) && cmp -s .kernelconfig.tmp .kernelconfig || \
121 cp .kernelconfig.tmp .kernelconfig
122 @-rm -f $(BUILD_DIR)/.kernelconfig.tmp
123 else
124 config-prepare: $(ADK_TOPDIR)/.config
125 @if [ -f $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) ];then \
126 cat $(ADK_TOPDIR)/target/$(ADK_TARGET_OS)/kernel.config \
127 $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) > $(BUILD_DIR)/.kernelconfig.board; \
128 else \
129 echo "no miniconfig found for target system"; \
130 exit 1; \
132 @cd $(BUILD_DIR) && cmp -s .kernelconfig.board .kernelconfig || \
133 cp .kernelconfig.board .kernelconfig
134 endif
135 else
136 config-prepare: $(ADK_TOPDIR)/.config
137 @true
138 endif
139 endif
141 ifeq ($(ADK_TARGET_OS_FROSTED),y)
142 config-prepare: $(ADK_TOPDIR)/.config
143 @PATH='$(HOST_PATH)' sed -n '/^ADK_FROSTED_/s///p' $(ADK_TOPDIR)/.config \
144 >$(BUILD_DIR)/.frosted
145 @PATH='$(HOST_PATH)' sed -n '/^ADK_PACKAGE_FROSTED_/s///p' $(ADK_TOPDIR)/.config \
146 >$(BUILD_DIR)/.frostedapps
147 endif
149 ifeq ($(ADK_TARGET_OS_FROSTED),y)
150 prepare: frosted-prepare
151 compile: frosted-compile
152 install: frosted-install
153 targethelp: frosted-targethelp
154 endif
156 ifeq ($(ADK_TARGET_OS_RTEMS),y)
157 prepare: rtems-prepare
158 compile: rtems-compile
159 install: rtems-install
160 targethelp: rtems-targethelp
161 endif
163 ifeq ($(ADK_TARGET_OS_ZEPHYR),y)
164 prepare: zephyr-prepare
165 compile: zephyr-compile
166 install: zephyr-install
167 targethelp: zephyr-targethelp
168 endif
170 ifeq ($(ADK_TARGET_OS_LINUX)$(ADK_TARGET_OS_WALDUX),y)
171 prepare: $(ADK_TARGET_ARCH)-prepare
172 compile: $(ADK_TARGET_ARCH)-compile
173 image: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-imageinstall
174 targethelp: $(ADK_TARGET_ARCH)-targethelp
175 install: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-install $(ADK_TARGET_ARCH)-imageinstall
176 clean: $(ADK_TARGET_ARCH)-clean $(ADK_TARGET_ARCH)-imageclean
177 endif
179 %-clean:
180 $(START_TRACE) "target/$(patsubst %-clean,%,$@)-clean.. "
181 $(MAKE) -C $(patsubst %-clean,%,$@) clean
182 $(CMD_TRACE) " done"
183 $(END_TRACE)
185 %-imageclean:
186 $(START_TRACE) "target/$(patsubst %-imageclean,%,$@)-imageclean.. "
187 $(MAKE) -C $(patsubst %-imageclean,%,$@) imageclean
188 $(CMD_TRACE) " done"
189 $(END_TRACE)
191 %-prepare:
192 $(START_TRACE) "target/$(patsubst %-prepare,%,$@)-prepare.. "
193 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
194 $(CMD_TRACE) " done"
195 $(END_TRACE)
197 %-imageprepare:
198 $(START_TRACE) "target/$(patsubst %-imageprepare,%,$@)-imageprepare.. "
199 ifeq ($(ADK_RUNTIME_DEV_UDEV),y)
200 ifneq ($(KERNEL_MODULES_USED),)
201 # This should be made a package instead
202 $(CP) $(BUILD_DIR)/$(ADK_TARGET_OS)-$(ADK_TARGET_ARCH)/modules/lib $(TARGET_DIR)
203 rm -f "$(TARGET_DIR)"/lib/modules/*/build \
204 "$(TARGET_DIR)"/lib/modules/*/source
205 endif
206 endif
207 @for x in $$(ls $(ADK_TOPDIR)/scripts/preimage/*.sh 2>/dev/null); do \
208 [[ -x "$$x" ]] && $$x; \
209 break; \
210 done
211 $(MAKE) -C $(patsubst %-imageprepare,%,$@) imageprepare
212 $(CMD_TRACE) " done"
213 $(END_TRACE)
215 %-compile: %-prepare
216 $(START_TRACE) "target/$(patsubst %-compile,%,$@)-compile.. "
217 $(MAKE) -C $(patsubst %-compile,%,$@) compile
218 $(CMD_TRACE) " done"
219 $(END_TRACE)
221 %-install:
222 $(START_TRACE) "target/$(patsubst %-install,%,$@)-install.. "
223 $(MAKE) -C $(patsubst %-install,%,$@) install
224 $(CMD_TRACE) " done"
225 $(END_TRACE)
227 %-targethelp:
228 $(MAKE) -C $(patsubst %-targethelp,%,$@) targethelp
230 %-imageinstall: %-imageprepare
231 $(MAKE) -C $(patsubst %-imageinstall,%,$@) imageinstall
232 @for x in $$(ls $(ADK_TOPDIR)/scripts/postimage/*.sh 2>/dev/null); do \
233 [[ -x "$$x" ]] && $$x; \
234 break; \
235 done
236 @echo "Login as user root via ssh or console."