uclibc-ng: update to 1.0.49
[openadk.git] / mk / image.mk
blob364b80db38768a857aab7e2aee9d61898b814da6
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 ifeq ($(ADK_RUNTIME_FIX_PERMISSION),y)
5 FAKEROOT:=$(STAGING_HOST_DIR)/usr/bin/fakeroot --
6 else
7 FAKEROOT:=
8 endif
10 ifeq ($(ADK_TARGET_OS_LINUX),y)
11 # relative paths, like 'mksh' or '../usr/bin/foosh'
12 ifeq (${ADK_BINSH_ASH},y)
13 BINSH:=ash
14 else ifeq (${ADK_BINSH_BASH},y)
15 BINSH:=bash
16 else ifeq (${ADK_BINSH_SASH},y)
17 BINSH:=sash
18 else ifeq (${ADK_BINSH_HUSH},y)
19 BINSH:=hush
20 else ifeq (${ADK_BINSH_MKSH},y)
21 BINSH:=mksh
22 else ifeq (${ADK_BINSH_ZSH},y)
23 BINSH:=zsh
24 else
25 $(error No /bin/sh configured!)
26 endif
28 # absolute paths
29 ifeq (${ADK_ROOTSH_ASH},y)
30 ROOTSH:=/bin/ash
31 else ifeq (${ADK_ROOTSH_BASH},y)
32 ROOTSH:=/bin/bash
33 else ifeq (${ADK_ROOTSH_SASH},y)
34 ROOTSH:=/bin/sash
35 else ifeq (${ADK_ROOTSH_HUSH},y)
36 ROOTSH:=/bin/hush
37 else ifeq (${ADK_ROOTSH_MKSH},y)
38 ROOTSH:=/bin/mksh
39 else ifeq (${ADK_ROOTSH_TCSH},y)
40 ROOTSH:=/usr/bin/tcsh
41 else ifeq (${ADK_ROOTSH_ZSH},y)
42 ROOTSH:=/bin/zsh
43 else
44 $(error No login shell configured!)
45 endif
46 endif
48 imageprepare: image-prepare-post extra-install prelink
50 # if an extra directory exist in ADK_TOPDIR, copy all content over the
51 # root directory, do the same if make extra=/dir/to/extra is used
52 extra-install:
53 @-if [ -h ${TARGET_DIR}/etc/resolv.conf -a -f $(ADK_TOPDIR)/extra/etc/resolv.conf ];then \
54 rm ${TARGET_DIR}/etc/resolv.conf;\
56 @if test -d '${ADK_TOPDIR}/extra'; then \
57 (cd '${ADK_TOPDIR}/extra' && tar -cf - .) | \
58 (cd ${TARGET_DIR}; tar -xf -); \
60 ifneq (,$(strip ${extra}))
61 @(cd '${extra}' && tar -cf - .) | (cd ${TARGET_DIR}; tar -xf -)
62 endif
64 image-prepare-post:
65 $(BASH) $(ADK_TOPDIR)/scripts/update-rcconf
66 rng=/dev/arandom; test -e $$rng || rng=/dev/urandom; \
67 dd if=$$rng bs=512 count=1 >>${TARGET_DIR}/etc/.rnd 2>/dev/null; \
68 chmod 600 ${TARGET_DIR}/etc/.rnd
69 -for dir in X11 truetype; do \
70 if [ -d ${TARGET_DIR}/usr/share/fonts/$${dir} ];then \
71 for i in $$(ls ${TARGET_DIR}/usr/share/fonts/$${dir}/);do \
72 mkfontdir ${TARGET_DIR}/usr/share/fonts/$${dir}/$${i}; \
73 mkfontscale ${TARGET_DIR}/usr/share/fonts/$${dir}/$${i}; \
74 done; \
75 fi; \
76 done
77 $(SED) '/^root:/s!:/bin/sh$$!:${ROOTSH}!' ${TARGET_DIR}/etc/passwd
78 -rm -f ${TARGET_DIR}/bin/sh
79 ln -sf ${BINSH} ${TARGET_DIR}/bin/sh
81 test -z $(GIT) || \
82 $(GIT) log -1|head -1|sed -e 's#commit ##' \
83 > $(TARGET_DIR)/etc/.adkgithash
84 echo $(ADK_APPLIANCE_VERSION) > $(TARGET_DIR)/etc/.adkversion
85 echo $(ADK_TARGET_SYSTEM) > $(TARGET_DIR)/etc/.adktarget
86 $(TARGET_CC) -v 2> $(TARGET_DIR)/etc/.adkcompiler
87 $(TARGET_LD) -v > $(TARGET_DIR)/etc/.adklinker
88 ifneq (${ADK_PACKAGE_CONFIG_IN_ETC},)
89 gzip -9c ${ADK_TOPDIR}/.config > $(TARGET_DIR)/etc/adkconfig.gz
90 chmod 600 $(TARGET_DIR)/etc/adkconfig.gz
91 endif
92 ifneq ($(ADK_TARGET_ARCH_AARCH64)$(ADK_TARGET_ARCH_X86_64)$(ADK_TARGET_ARCH_PPC64)$(ADK_TARGET_ARCH_SPARC64)$(ADK_TARGET_ABI_N32)$(ADK_TARGET_ABI_N64),)
93 test ! -d ${TARGET_DIR}/lib || mv ${TARGET_DIR}/lib/* ${TARGET_DIR}/${ADK_TARGET_LIBC_PATH}
94 test ! -d ${TARGET_DIR}/lib || rm -rf ${TARGET_DIR}/lib
95 ln -sf /${ADK_TARGET_LIBC_PATH} ${TARGET_DIR}/lib
96 mkdir -p ${TARGET_DIR}/usr/${ADK_TARGET_LIBC_PATH} 2>/dev/null
97 -test ! -d ${TARGET_DIR}/usr/lib || mv ${TARGET_DIR}/usr/lib/* ${TARGET_DIR}/usr/${ADK_TARGET_LIBC_PATH} 2>/dev/null
98 test ! -d ${TARGET_DIR}/usr/lib || rm -rf ${TARGET_DIR}/usr/lib/
99 (cd ${TARGET_DIR}/usr ; ln -sf ${ADK_TARGET_LIBC_PATH} lib)
100 endif
101 ifeq ($(ADK_TARGET_ARCH_LOONGARCH)$(ADK_TARGET_ARCH_S390),y)
102 (cd ${TARGET_DIR}/; ln -sf lib lib64)
103 endif
105 ifeq (${ADK_PRELINK},)
106 prelink:
107 else
108 ${TARGET_DIR}/etc/prelink.conf:
109 echo '/' > $@
111 prelink: ${TARGET_DIR}/etc/prelink.conf
112 $(TRACE) target/prelink
113 ${TARGET_CROSS}prelink ${ADK_PRELINK_OPTS} \
114 --ld-library-path=${STAGING_TARGET_DIR}/usr/lib:${STAGING_TARGET_DIR}/lib \
115 --root=${TARGET_DIR} -a $(MAKE_TRACE)
116 endif
118 KERNEL_PKGDIR:=$(LINUX_BUILD_DIR)/kernel-pkg
119 KERNEL_PKG:=$(PACKAGE_DIR)/kernel_$(KERNEL_VERSION)_$(ADK_TARGET_CPU_ARCH).$(PKG_SUFFIX)
120 TARGET_KERNEL= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_FS}-kernel
121 INITRAMFS= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}
122 ROOTFSSQUASHFS= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}.img
123 ROOTFSJFFS2= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}-jffs2.img
124 ROOTFSUBIFS= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}-ubifs.img
125 ROOTFSTARBALL= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}+kernel.tar.gz
126 ROOTFSUSERTARBALL= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}.tar.gz
127 ROOTFSISO= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}.iso
129 kernel-package: kernel-strip
130 $(START_TRACE) "target/$(ADK_TARGET_ARCH)-create-kernel-package.. "
131 rm -rf $(KERNEL_PKGDIR)
132 ifeq ($(ADK_TARGET_DUAL_BOOT),y)
133 @mkdir -p $(KERNEL_PKGDIR)
134 cp $(BUILD_DIR)/$(TARGET_KERNEL) $(KERNEL_PKGDIR)/kernel
135 else
136 @mkdir -p $(KERNEL_PKGDIR)/boot
137 cp $(BUILD_DIR)/$(TARGET_KERNEL) $(KERNEL_PKGDIR)/boot/kernel
138 endif
139 @${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh ${KERNEL_PKGDIR} \
140 ../$(ADK_TARGET_OS)/kernel.control ${KERNEL_VERSION} ${ADK_TARGET_CPU_ARCH}
141 PATH='$(HOST_PATH)' $(PKG_BUILD) $(KERNEL_PKGDIR) $(PACKAGE_DIR) $(MAKE_TRACE)
142 $(PKG_INSTALL) $(KERNEL_PKG) $(MAKE_TRACE)
143 $(CMD_TRACE) " done"
144 $(END_TRACE)
146 ${FW_DIR}/${ROOTFSTARBALL}: ${TARGET_DIR}/.adk kernel-package
147 cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | sort | \
148 $(CPIO) --quiet -o -Hustar --owner=0:0 | gzip -c >$@
149 ifeq ($(ADK_TARGET_QEMU),y)
150 @cp $(KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
151 endif
153 ${FW_DIR}/${ROOTFSUSERTARBALL}: ${TARGET_DIR}/.adk
154 cd ${TARGET_DIR}; find . | grep -v ./boot/ | sed -n '/^\.\//s///p' | sort | \
155 $(CPIO) --quiet -o -Hustar --owner=0:0 | gzip -c >$@
157 ${STAGING_TARGET_DIR}/${INITRAMFS}_list: ${TARGET_DIR}/.adk
158 PATH='${HOST_PATH}' $(BASH) ${SCRIPT_DIR}/gen_initramfs_list.sh -u squash -g squash \
159 ${TARGET_DIR}/ >$@
161 echo "nod /dev/console 0644 0 0 c 5 1"; \
162 echo "nod /dev/tty 0644 0 0 c 5 0"; \
163 for i in 0 1 2 3 4; do \
164 echo "nod /dev/tty$$i 0644 0 0 c 4 $$$$i"; \
165 done; \
166 echo "nod /dev/null 0666 0 0 c 1 3"; \
167 echo "nod /dev/zero 0666 0 0 c 1 5"; \
168 echo "nod /dev/kmsg 0644 0 0 c 1 11"; \
169 echo "nod /dev/ram 0655 0 0 b 1 1"; \
170 echo "nod /dev/mem 0665 0 0 c 1 1"; \
171 echo "nod /dev/random 0666 0 0 c 1 8"; \
172 echo "nod /dev/urandom 0666 0 0 c 1 9"; \
173 echo "nod /dev/ttyS0 0660 0 0 c 4 64"; \
174 echo "nod /dev/ttysclp0 0660 0 0 c 4 65"; \
175 echo "nod /dev/ttyB0 0660 0 0 c 11 0"; \
176 echo "nod /dev/ttyB1 0660 0 0 c 11 1"; \
177 echo "nod /dev/ttyAMA0 0660 0 0 c 204 64"; \
178 echo "nod /dev/ttyAMA1 0660 0 0 c 204 65"; \
179 echo "nod /dev/ttySC0 0660 0 0 c 204 8"; \
180 echo "nod /dev/ttySC1 0660 0 0 c 204 9"; \
181 echo "nod /dev/ttySC2 0660 0 0 c 204 10"; \
182 echo "nod /dev/ttyBF0 0660 0 0 c 204 64"; \
183 echo "nod /dev/ttyBF1 0660 0 0 c 204 65"; \
184 echo "nod /dev/ttyUL0 0660 0 0 c 204 187"; \
185 echo "nod /dev/ttyUL1 0660 0 0 c 204 188"; \
186 echo "nod /dev/ttyGF0 0660 0 0 c 254 0"; \
187 echo "slink /init /sbin/init 755 0 0"; \
188 ) >>$@
190 ${FW_DIR}/${INITRAMFS}: ${STAGING_TARGET_DIR}/${INITRAMFS}_list
191 ${LINUX_DIR}/usr/gen_init_cpio ${STAGING_TARGET_DIR}/${INITRAMFS}_list | \
192 ${ADK_COMPRESSION_TOOL} -c >$@
194 ${BUILD_DIR}/root.squashfs: ${TARGET_DIR}/.adk
195 ${STAGING_HOST_DIR}/usr/bin/mksquashfs ${TARGET_DIR} \
196 ${BUILD_DIR}/root.squashfs -comp gzip \
197 -nopad -noappend -root-owned $(MAKE_TRACE)
199 ${FW_DIR}/${ROOTFSJFFS2}: ${TARGET_DIR}
200 PATH='${HOST_PATH}' mkfs.jffs2 $(ADK_JFFS2_OPTS) -q -r ${TARGET_DIR} \
201 --pad=$(ADK_TARGET_MTD_SIZE) -o ${FW_DIR}/${ROOTFSJFFS2} $(MAKE_TRACE)
203 ${FW_DIR}/${ROOTFSUBIFS}: ${TARGET_DIR}
205 PATH='${HOST_PATH}'; \
206 SP_SIZE='${ADK_TARGET_FLASH_SUBPAGE_SIZE}'; \
207 PG_SIZE='${ADK_TARGET_FLASH_PAGE_SIZE}'; \
208 LEB_SIZE=$$(((($$SP_SIZE + $$PG_SIZE) / $$PG_SIZE) * $$PG_SIZE)); \
209 mkfs.ubifs -r ${TARGET_DIR} \
210 -m $$PG_SIZE \
211 -e $$((${ADK_TARGET_FLASH_PEB_SIZE} - $$LEB_SIZE)) \
212 -c $$(((${ADK_TARGET_MTD_SIZE} / $$LEB_SIZE))) \
213 -o ${FW_DIR}/rootfs.ubifs; \
214 cd ${FW_DIR} && ubinize -o $@ \
215 -p ${ADK_TARGET_FLASH_PEB_SIZE} \
216 -m ${ADK_TARGET_FLASH_PAGE_SIZE} \
217 -s ${ADK_TARGET_FLASH_SUBPAGE_SIZE} \
218 "${ADK_TOPDIR}/target/${ADK_TARGET_ARCH}/${ADK_TARGET_SYSTEM}/ubinize.cfg"; \
219 ) $(MAKE_TRACE)
221 createinitramfs: ${STAGING_TARGET_DIR}/${INITRAMFS}_list
222 ${SED} 's/.*CONFIG_\(RD_\|BLK_DEV_INITRD\|INITRAMFS_\).*//' \
223 ${LINUX_DIR}/.config
225 echo "CONFIG_BLK_DEV_INITRD=y"; \
226 echo "CONFIG_ACPI_INITRD_TABLE_OVERRIDE=n"; \
227 echo 'CONFIG_INITRAMFS_SOURCE="${STAGING_TARGET_DIR}/${INITRAMFS}_list"'; \
228 echo '# CONFIG_INITRAMFS_COMPRESSION_NONE is not set'; \
229 echo 'CONFIG_CRC32_BIT=y'; \
230 echo '# CONFIG_CRC32_SELFTEST is not set'; \
231 echo '# CONFIG_CRC32_SLICEBY8 is not set'; \
232 echo '# CONFIG_CRC32_SLICEBY4 is not set'; \
233 echo '# CONFIG_CRC32_SARWATE is not set'; \
234 echo 'CONFIG_INITRAMFS_FORCE=n'; \
235 echo 'CONFIG_INITRAMFS_ROOT_UID=0'; \
236 echo 'CONFIG_INITRAMFS_ROOT_GID=0'; \
237 echo 'CONFIG_INITRAMFS_IS_LARGE=n'; \
238 echo 'CONFIG_INITRAMFS_PRESERVE_MTIME=n'; \
239 ) >> ${LINUX_DIR}/.config
240 ifeq ($(ADK_LINUX_KERNEL_COMP_ZSTD),y)
241 echo "CONFIG_RD_XZ=n" >> ${LINUX_DIR}/.config
242 echo "CONFIG_RD_BZIP2=n" >> ${LINUX_DIR}/.config
243 echo "CONFIG_RD_GZIP=n" >> ${LINUX_DIR}/.config
244 echo "CONFIG_RD_LZO=n" >> ${LINUX_DIR}/.config
245 echo "CONFIG_RD_LZ4=n" >> ${LINUX_DIR}/.config
246 echo "CONFIG_RD_LZMA=n" >> ${LINUX_DIR}/.config
247 echo "CONFIG_RD_ZSTD=y" >> ${LINUX_DIR}/.config
248 echo "CONFIG_INITRAMFS_COMPRESSION_ZSTD=y" >> ${LINUX_DIR}/.config
249 endif
250 ifeq ($(ADK_LINUX_KERNEL_COMP_LZ4),y)
251 echo "CONFIG_RD_XZ=n" >> ${LINUX_DIR}/.config
252 echo "CONFIG_RD_BZIP2=n" >> ${LINUX_DIR}/.config
253 echo "CONFIG_RD_GZIP=n" >> ${LINUX_DIR}/.config
254 echo "CONFIG_RD_LZO=n" >> ${LINUX_DIR}/.config
255 echo "CONFIG_RD_LZ4=y" >> ${LINUX_DIR}/.config
256 echo "CONFIG_RD_LZMA=n" >> ${LINUX_DIR}/.config
257 echo "CONFIG_RD_ZSTD=n" >> ${LINUX_DIR}/.config
258 echo "CONFIG_INITRAMFS_COMPRESSION_LZ4=y" >> ${LINUX_DIR}/.config
259 endif
260 ifeq ($(ADK_LINUX_KERNEL_COMP_LZMA),y)
261 echo "CONFIG_RD_XZ=n" >> ${LINUX_DIR}/.config
262 echo "CONFIG_RD_BZIP2=n" >> ${LINUX_DIR}/.config
263 echo "CONFIG_RD_GZIP=n" >> ${LINUX_DIR}/.config
264 echo "CONFIG_RD_LZO=n" >> ${LINUX_DIR}/.config
265 echo "CONFIG_RD_LZ4=n" >> ${LINUX_DIR}/.config
266 echo "CONFIG_RD_LZMA=y" >> ${LINUX_DIR}/.config
267 echo "CONFIG_RD_ZSTD=n" >> ${LINUX_DIR}/.config
268 echo "CONFIG_INITRAMFS_COMPRESSION_LZMA=y" >> ${LINUX_DIR}/.config
269 endif
270 ifeq ($(ADK_LINUX_KERNEL_COMP_LZO),y)
271 echo "CONFIG_RD_XZ=n" >> ${LINUX_DIR}/.config
272 echo "CONFIG_RD_BZIP2=n" >> ${LINUX_DIR}/.config
273 echo "CONFIG_RD_GZIP=n" >> ${LINUX_DIR}/.config
274 echo "CONFIG_RD_LZMA=n" >> ${LINUX_DIR}/.config
275 echo "CONFIG_RD_LZ4=n" >> ${LINUX_DIR}/.config
276 echo "CONFIG_RD_LZO=y" >> ${LINUX_DIR}/.config
277 echo "CONFIG_RD_ZSTD=n" >> ${LINUX_DIR}/.config
278 echo "CONFIG_INITRAMFS_COMPRESSION_LZO=y" >> ${LINUX_DIR}/.config
279 endif
280 ifeq ($(ADK_LINUX_KERNEL_COMP_GZIP),y)
281 echo "CONFIG_RD_XZ=n" >> ${LINUX_DIR}/.config
282 echo "CONFIG_RD_BZIP2=n" >> ${LINUX_DIR}/.config
283 echo "CONFIG_RD_LZO=n" >> ${LINUX_DIR}/.config
284 echo "CONFIG_RD_LZMA=n" >> ${LINUX_DIR}/.config
285 echo "CONFIG_RD_LZ4=n" >> ${LINUX_DIR}/.config
286 echo "CONFIG_RD_GZIP=y" >> ${LINUX_DIR}/.config
287 echo "CONFIG_RD_ZSTD=n" >> ${LINUX_DIR}/.config
288 echo "CONFIG_INITRAMFS_COMPRESSION_GZIP=y" >> ${LINUX_DIR}/.config
289 endif
290 ifeq ($(ADK_LINUX_KERNEL_COMP_BZIP2),y)
291 echo "CONFIG_RD_XZ=n" >> ${LINUX_DIR}/.config
292 echo "CONFIG_RD_GZIP=n" >> ${LINUX_DIR}/.config
293 echo "CONFIG_RD_LZMA=n" >> ${LINUX_DIR}/.config
294 echo "CONFIG_RD_LZO=n" >> ${LINUX_DIR}/.config
295 echo "CONFIG_RD_LZ4=n" >> ${LINUX_DIR}/.config
296 echo "CONFIG_RD_BZIP2=y" >> ${LINUX_DIR}/.config
297 echo "CONFIG_RD_ZSTD=n" >> ${LINUX_DIR}/.config
298 echo "CONFIG_INITRAMFS_COMPRESSION_BZIP2=y" >> ${LINUX_DIR}/.config
299 endif
300 ifeq ($(ADK_LINUX_KERNEL_COMPRESS_NONE),y)
301 echo "CONFIG_RD_XZ=n" >> ${LINUX_DIR}/.config
302 echo "CONFIG_RD_BZIP2=n" >> ${LINUX_DIR}/.config
303 echo "CONFIG_RD_LZO=n" >> ${LINUX_DIR}/.config
304 echo "CONFIG_RD_LZMA=n" >> ${LINUX_DIR}/.config
305 echo "CONFIG_RD_LZ4=n" >> ${LINUX_DIR}/.config
306 echo "CONFIG_RD_GZIP=n" >> ${LINUX_DIR}/.config
307 echo "CONFIG_RD_ZSTD=n" >> ${LINUX_DIR}/.config
308 endif
309 @-rm $(LINUX_DIR)/usr/initramfs_data.cpio* 2>/dev/null
310 ifneq ($(ADK_TARGET_KERNEL_APPEND_DTB),)
311 ${KERNEL_MAKE} zImage dtbs $(MAKE_TRACE)
312 (cd $(LINUX_DIR)/arch/$(ADK_TARGET_ARCH)/boot && \
313 cat dts/${ADK_TARGET_KERNEL_APPEND_DTB}.dtb >> zImage)
314 endif
315 ${KERNEL_MAKE} $(ADK_TARGET_KERNEL) $(MAKE_TRACE)
316 @cp $(KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
318 ${FW_DIR}/${ROOTFSISO}: ${TARGET_DIR} kernel-package
319 mkdir -p ${TARGET_DIR}/boot/syslinux
320 cp ${STAGING_HOST_DIR}/usr/share/syslinux/{isolinux.bin,ldlinux.c32} \
321 ${TARGET_DIR}/boot/syslinux
322 echo 'DEFAULT /boot/kernel root=/dev/sr0' > \
323 ${TARGET_DIR}/boot/syslinux/isolinux.cfg
324 PATH='${HOST_PATH}' mkisofs -R -uid 0 -gid 0 -o $@ \
325 -b boot/syslinux/isolinux.bin \
326 -c boot/syslinux/boot.cat -no-emul-boot \
327 -boot-load-size 4 -boot-info-table ${TARGET_DIR}
329 ifeq (,$(wildcard $(ADK_TOPDIR)/target/$(ADK_TARGET_ARCH)/$(ADK_TARGET_SYSTEM)/$(ADK_TARGET_GENIMAGE_FILENAME)))
330 GENCFG:=$(ADK_TOPDIR)/adk/genimage/$(ADK_TARGET_GENIMAGE_FILENAME)
331 else
332 GENCFG:=$(ADK_TOPDIR)/target/$(ADK_TARGET_ARCH)/$(ADK_TARGET_SYSTEM)/$(ADK_TARGET_GENIMAGE_FILENAME)
333 endif
334 ifeq (,$(wildcard $(ADK_TOPDIR)/target/$(ADK_TARGET_ARCH)/$(ADK_TARGET_SYSTEM)/$(ADK_TARGET_EXTLINUX_FILENAME)))
335 EXTLINUX:=$(ADK_TOPDIR)/adk/extlinux/$(ADK_TARGET_EXTLINUX_FILENAME)
336 else
337 EXTLINUX:=$(ADK_TOPDIR)/target/$(ADK_TARGET_ARCH)/$(ADK_TARGET_SYSTEM)/$(ADK_TARGET_EXTLINUX_FILENAME)
338 endif
340 ${FW_DIR}/${GENIMAGE}: ${TARGET_DIR} kernel-package
341 @rm -rf ${FW_DIR}/temp
342 @mkdir -p ${FW_DIR}/temp
343 @$(CP) $(KERNEL) $(FW_DIR)/kernel
344 @dd if=/dev/zero of=${FW_DIR}/cfgfs.img bs=16384 count=1024 $(MAKE_TRACE)
345 mkdir -p ${FW_DIR}/extlinux
346 $(CP) $(EXTLINUX) $(FW_DIR)/extlinux
347 mkdir -p $(TARGET_DIR)/boot/extlinux
348 $(CP) $(EXTLINUX) $(TARGET_DIR)/boot/extlinux
349 $(CP) $(FW_DIR)/kernel $(TARGET_DIR)/boot
350 -$(CP) $(FW_DIR)/*.dtb $(TARGET_DIR)/boot
351 ifeq ($(ADK_RUNTIME_FIX_PERMISSION),y)
352 echo '#!/bin/sh' > $(ADK_TOPDIR)/scripts/fakeroot.sh
353 echo "chown -R 0:0 $(TARGET_DIR)" >> $(ADK_TOPDIR)/scripts/fakeroot.sh
354 echo 'cd $(TARGET_DIR)' >> $(ADK_TOPDIR)/scripts/fakeroot.sh
355 -@cat $(STAGING_TARGET_DIR)/scripts/permissions.sh >> $(ADK_TOPDIR)/scripts/fakeroot.sh 2>/dev/null
356 chmod 755 $(ADK_TOPDIR)/scripts/fakeroot.sh
357 PATH='$(HOST_PATH)' $(FAKEROOT) $(ADK_TOPDIR)/scripts/fakeroot.sh
358 rm $(ADK_TOPDIR)/scripts/fakeroot.sh $(STAGING_TARGET_DIR)/scripts/permissions.sh
359 endif
360 ifeq ($(ADK_TARGET_DUAL_BOOT),y)
361 $(CP) $(FW_DIR)/kernel $(TARGET_DIR)
362 -$(CP) $(FW_DIR)/*.dtb $(TARGET_DIR)
363 mkdir $(TARGET_DIR)/extlinux
364 $(CP) $(EXTLINUX) $(TARGET_DIR)/extlinux
365 $(SED) "s#root=.*#root=/dev/$(ADK_TARGET_ROOTDEV)p1#" $(TARGET_DIR)/extlinux/extlinux.conf
366 PATH='${HOST_PATH}' $(FAKEROOT) mkfs.ext2 \
367 -d "$(TARGET_DIR)" \
368 -r 1 -N 0 -m 5 -L "rootfs1" \
369 $(FW_DIR)/rootfs1.ext "64M" $(MAKE_TRACE)
370 $(SED) "s#root=.*#root=/dev/$(ADK_TARGET_ROOTDEV)p2#" $(TARGET_DIR)/extlinux/extlinux.conf
371 PATH='${HOST_PATH}' $(FAKEROOT) mkfs.ext2 \
372 -d "$(TARGET_DIR)" \
373 -r 1 -N 0 -m 5 -L "rootfs2" \
374 $(FW_DIR)/rootfs2.ext "64M" $(MAKE_TRACE)
375 PATH='${HOST_PATH}' genimage \
376 --config "$(GENCFG)" \
377 --tmppath "${FW_DIR}/temp" \
378 --rootpath "$(TARGET_DIR)" \
379 --inputpath "$(FW_DIR)" \
380 --outputpath "$(FW_DIR)" $(MAKE_TRACE)
381 else
382 PATH='${HOST_PATH}' $(FAKEROOT) mkfs.ext2 \
383 -d "$(TARGET_DIR)" \
384 -r 1 -N 0 -m 5 -L "rootfs" \
385 $(FW_DIR)/rootfs.ext "64M" $(MAKE_TRACE)
386 PATH='${HOST_PATH}' genimage \
387 --config "$(GENCFG)" \
388 --tmppath "${FW_DIR}/temp" \
389 --rootpath "$(TARGET_DIR)" \
390 --inputpath "$(FW_DIR)" \
391 --outputpath "$(FW_DIR)" $(MAKE_TRACE)
392 endif
393 ifeq ($(ADK_TARGET_DUAL_BOOT),y)
394 (cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | sort | \
395 PATH='${HOST_PATH}' $(CPIO) -o --quiet -Hustar --owner=0:0 | \
396 ${GZIP} -c > ${FW_DIR}/openadk.tar.gz)
397 (cd ${FW_DIR}; PATH='${HOST_PATH}' sha256sum openadk.tar.gz \
398 | cut -d\ -f1 > sha256.txt)
399 (cd ${FW_DIR}; PATH='${HOST_PATH}' tar -cf ${ADK_TARGET_SYSTEM}-update.tar openadk.tar.gzip sha256.txt)
400 @rm -rf ${FW_DIR}/temp
401 endif
402 ifeq ($(ADK_PACKAGE_GRUB_EFI_X86)$(ADK_PACKAGE_GRUB_EFI_X86_64),y)
403 @if [ ! -f $(ADK_TOPDIR)/bios-$(ADK_TARGET_ARCH).bin ]; then \
404 cd $(ADK_TOPDIR); wget http://distfiles.openadk.org/bios-$(ADK_TARGET_ARCH).bin ;\
406 endif
408 imageclean:
409 rm -f $(FW_DIR)/$(ADK_TARGET_SYSTEM)-* ${BUILD_DIR}/$(ADK_TARGET_SYSTEM)-*