blob: cfb3ffc91e577c81c24ae5dfec0c76d2962e8824 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001do_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 | mipsel | 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 ;;
Patrick Williamsf1e5d692016-03-30 15:21:19 -050028 i*86 )
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029 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}