sync before umount
[openadk.git] / mk / image.mk
blobe6dd06a821d35953ec07244207b592336e0a934a
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 # relative paths, like 'mksh' or '../usr/bin/foosh'
5 ifeq (${ADK_BINSH_ASH},y)
6 BINSH:=ash
7 else ifeq (${ADK_BINSH_BASH},y)
8 BINSH:=bash
9 else ifeq (${ADK_BINSH_MKSH},y)
10 BINSH:=mksh
11 else ifeq (${ADK_BINSH_ZSH},y)
12 BINSH:=zsh
13 else
14 $(error No /bin/sh configured!)
15 endif
17 # absolute paths
18 ifeq (${ADK_ROOTSH_ASH},y)
19 ROOTSH:=/bin/ash
20 else ifeq (${ADK_ROOTSH_BASH},y)
21 ROOTSH:=/bin/bash
22 else ifeq (${ADK_ROOTSH_MKSH},y)
23 ROOTSH:=/bin/mksh
24 else ifeq (${ADK_ROOTSH_TCSH},y)
25 ROOTSH:=/usr/bin/tcsh
26 else ifeq (${ADK_ROOTSH_ZSH},y)
27 ROOTSH:=/bin/zsh
28 else
29 $(error No login shell configured!)
30 endif
32 imageprepare: image-prepare-post extra-install
34 # if an extra directory exist in TOPDIR, copy all content over the
35 # root directory, do the same if make extra=/dir/to/extra is used
36 extra-install:
37 @if [ -d $(TOPDIR)/extra ];then $(CP) $(TOPDIR)/extra/* ${TARGET_DIR};fi
38 @if [ ! -z $(extra) ];then $(CP) $(extra)/* ${TARGET_DIR};fi
40 image-prepare-post:
41 rng=/dev/arandom; test -e $$rng || rng=/dev/urandom; \
42 dd if=$$rng bs=512 count=1 >>${TARGET_DIR}/etc/.rnd 2>/dev/null; \
43 chmod 600 ${TARGET_DIR}/etc/.rnd
44 chmod 4511 ${TARGET_DIR}/bin/busybox
45 @if [ -d ${TARGET_DIR}/usr/share/fonts/X11 ];then \
46 for i in $$(ls ${TARGET_DIR}/usr/share/fonts/X11/);do \
47 mkfontdir ${TARGET_DIR}/usr/share/fonts/X11/$${i}; \
48 done; \
50 sed -i '/^root:/s!:/bin/sh$$!:${ROOTSH}!' ${TARGET_DIR}/etc/passwd
51 -rm -f ${TARGET_DIR}/bin/sh
52 ln -sf ${BINSH} ${TARGET_DIR}/bin/sh
54 KERNEL_PKGDIR:=$(LINUX_BUILD_DIR)/kernel-pkg
55 KERNEL_PKG:=$(PACKAGE_DIR)/kernel_$(KERNEL_VERSION)_$(CPU_ARCH).$(PKG_SUFFIX)
57 kernel-package: $(KERNEL)
58 $(TRACE) target/$(ADK_TARGET_ARCH)-create-kernel-package
59 rm -rf $(KERNEL_PKGDIR)
60 @mkdir -p $(KERNEL_PKGDIR)/boot
61 cp $(KERNEL) $(KERNEL_PKGDIR)/boot/kernel
62 @${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh ${KERNEL_PKGDIR} \
63 ../linux/kernel.control ${KERNEL_VERSION} ${CPU_ARCH}
64 $(PKG_BUILD) $(KERNEL_PKGDIR) $(PACKAGE_DIR) $(MAKE_TRACE)
65 $(TRACE) target/$(ADK_TARGET_ARCH)-install-kernel-package
66 $(PKG_INSTALL) $(KERNEL_PKG) $(MAKE_TRACE)
68 ifeq ($(ADK_HARDWARE_QEMU),y)
69 TARGET_KERNEL= ${ADK_TARGET_SYSTEM}-$(CPU_ARCH)-${ADK_TARGET_FS}-kernel
70 INITRAMFS= ${ADK_TARGET_SYSTEM}-$(CPU_ARCH)-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}
71 ROOTFSSQUASHFS= ${ADK_TARGET_SYSTEM}-$(CPU_ARCH)-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}.img
72 ROOTFSTARBALL= ${ADK_TARGET_SYSTEM}-$(CPU_ARCH)-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}+kernel.tar.gz
73 ROOTFSUSERTARBALL= ${ADK_TARGET_SYSTEM}-$(CPU_ARCH)-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}.tar.gz
74 INITRAMFS_PIGGYBACK= ${ADK_TARGET_SYSTEM}-$(CPU_ARCH)-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}.cpio
75 else
76 TARGET_KERNEL= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_FS}-kernel
77 INITRAMFS= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}
78 ROOTFSSQUASHFS= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}.img
79 ROOTFSTARBALL= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}+kernel.tar.gz
80 ROOTFSUSERTARBALL= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}.tar.gz
81 INITRAMFS_PIGGYBACK= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}.cpio
82 endif
84 ${BIN_DIR}/${ROOTFSTARBALL}: ${TARGET_DIR} kernel-package
85 cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | \
86 sed "s#\(.*\)#:0:0::::::\1#" | sort | \
87 ${TOOLS_DIR}/cpio -o -Hustar -P | gzip -n9 >$@
89 ${BIN_DIR}/${ROOTFSUSERTARBALL}: ${TARGET_DIR}
90 cd ${TARGET_DIR}; find . | grep -v ./boot/ | sed -n '/^\.\//s///p' | \
91 sed "s#\(.*\)#:0:0::::::\1#" | sort | \
92 ${TOOLS_DIR}/cpio -o -Hustar -P | gzip -n9 >$@
94 ${BIN_DIR}/${INITRAMFS}: ${TARGET_DIR}
95 cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | \
96 sed "s#\(.*\)#:0:0::::::\1#" | sort | \
97 ${TOOLS_DIR}/cpio -o -C512 -Hnewc -P | \
98 xz -C crc32 >$@ 2>/dev/null
100 ${BUILD_DIR}/${INITRAMFS_PIGGYBACK}: ${TARGET_DIR}
101 ${SED} 's/.*CONFIG_(BLK_DEV_INITRD|INITRAMFS_SOURCE).*//' \
102 ${LINUX_DIR}/.config
103 echo "CONFIG_BLK_DEV_INITRD=y" >> ${LINUX_DIR}/.config
104 echo 'CONFIG_INITRAMFS_SOURCE="${BUILD_DIR}/${INITRAMFS_PIGGYBACK}"' >> \
105 ${LINUX_DIR}/.config
106 cp $(TOPDIR)/scripts/dev.cpio $@
107 cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | \
108 sed "s#\(.*\)#:0:0::::::\1#" | sort | \
109 ${TOOLS_DIR}/cpio -o -C512 -Hnewc -A -P -O $@ 2>/dev/null
111 ${BUILD_DIR}/root.squashfs: ${TARGET_DIR}
112 ${STAGING_HOST_DIR}/bin/mksquashfs ${TARGET_DIR} \
113 ${BUILD_DIR}/root.squashfs \
114 -nopad -noappend -root-owned $(MAKE_TRACE)
116 createinitramfs:
117 @-rm $(LINUX_DIR)/usr/initramfs_data.cpio* $(MAKE_TRACE)
118 echo N | \
119 $(MAKE) -C $(LINUX_DIR) V=1 CROSS_COMPILE="$(TARGET_CROSS)" \
120 ARCH=$(ARCH) CC="$(TARGET_CC)" -j${ADK_MAKE_JOBS} oldconfig $(MAKE_TRACE)
121 $(MAKE) -C $(LINUX_DIR) V=1 CROSS_COMPILE="$(TARGET_CROSS)" \
122 ARCH=$(ARCH) CC="$(TARGET_CC)" -j${ADK_MAKE_JOBS} $(MAKE_TRACE)
124 imageclean:
125 rm -f $(BIN_DIR)/$(ADK_TARGET_SYSTEM)-* ${BUILD_DIR}/$(ADK_TARGET_SYSTEM)-*