summaryrefslogtreecommitdiffstats
path: root/meta/classes/image-mklibs.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/image-mklibs.bbclass')
-rw-r--r--meta/classes/image-mklibs.bbclass71
1 files changed, 71 insertions, 0 deletions
diff --git a/meta/classes/image-mklibs.bbclass b/meta/classes/image-mklibs.bbclass
new file mode 100644
index 0000000..11f082b
--- /dev/null
+++ b/meta/classes/image-mklibs.bbclass
@@ -0,0 +1,71 @@
1do_rootfs[depends] += "mklibs-native:do_populate_sysroot"
2
3IMAGE_PREPROCESS_COMMAND += "mklibs_optimize_image; "
4
5mklibs_optimize_image_doit() {
6 rm -rf ${WORKDIR}/mklibs
7 mkdir -p ${WORKDIR}/mklibs/dest
8 cd ${IMAGE_ROOTFS}
9 du -bs > ${WORKDIR}/mklibs/du.before.mklibs.txt
10 for i in `find .`; do file $i; done \
11 | grep ELF \
12 | grep "LSB *executable" \
13 | grep "dynamically linked" \
14 | sed "s/:.*//" \
15 | sed "s+^\./++" \
16 > ${WORKDIR}/mklibs/executables.list
17
18 case ${TARGET_ARCH} in
19 powerpc | mips | microblaze )
20 dynamic_loader="${base_libdir}/ld.so.1"
21 ;;
22 powerpc64)
23 dynamic_loader="${base_libdir}/ld64.so.1"
24 ;;
25 x86_64)
26 dynamic_loader="${base_libdir}/ld-linux-x86-64.so.2"
27 ;;
28 i586 )
29 dynamic_loader="${base_libdir}/ld-linux.so.2"
30 ;;
31 arm )
32 dynamic_loader="${base_libdir}/ld-linux.so.3"
33 ;;
34 * )
35 dynamic_loader="/unknown_dynamic_linker"
36 ;;
37 esac
38
39 mklibs -v \
40 --ldlib ${dynamic_loader} \
41 --libdir ${baselib} \
42 --sysroot ${PKG_CONFIG_SYSROOT_DIR} \
43 --gcc-options "--sysroot=${PKG_CONFIG_SYSROOT_DIR}" \
44 --root ${IMAGE_ROOTFS} \
45 --target `echo ${TARGET_PREFIX} | sed 's/-$//' ` \
46 -d ${WORKDIR}/mklibs/dest \
47 `cat ${WORKDIR}/mklibs/executables.list`
48
49 cd ${WORKDIR}/mklibs/dest
50 for i in *
51 do
52 cp $i `find ${IMAGE_ROOTFS} -name $i`
53 done
54
55 cd ${IMAGE_ROOTFS}
56 du -bs > ${WORKDIR}/mklibs/du.after.mklibs.txt
57
58 echo rootfs size before mklibs optimization: `cat ${WORKDIR}/mklibs/du.before.mklibs.txt`
59 echo rootfs size after mklibs optimization: `cat ${WORKDIR}/mklibs/du.after.mklibs.txt`
60}
61
62mklibs_optimize_image() {
63 for img in ${MKLIBS_OPTIMIZED_IMAGES}
64 do
65 if [ "${img}" = "${PN}" ] || [ "${img}" = "all" ]
66 then
67 mklibs_optimize_image_doit
68 break
69 fi
70 done
71}