summaryrefslogtreecommitdiff
path: root/meta/classes/image-mklibs.bbclass
blob: 0e72b018c0fb56d768018287fd6ff8d3462c44cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
do_rootfs[depends] += "mklibs-native:do_populate_sysroot"

IMAGE_PREPROCESS_COMMAND += "mklibs_optimize_image; "

mklibs_optimize_image_doit() {
	rm -rf ${WORKDIR}/mklibs
	mkdir -p ${WORKDIR}/mklibs/dest
	cd ${IMAGE_ROOTFS}
	du -bs > ${WORKDIR}/mklibs/du.before.mklibs.txt
	for i in `find .`; do file $i; done \
		| grep ELF \
		| grep "LSB executable" \
		| grep "dynamically linked" \
		| sed "s/:.*//" \
		| sed "s+^\./++" \
		> ${WORKDIR}/mklibs/executables.list

	case ${TARGET_ARCH} in
		powerpc | mips )
			dynamic_loader="/lib/ld.so.1"
			;;
		x86_64)
			dynamic_loader="/lib/ld-linux-x86-64.so.2"
			;;
		i586 )
			dynamic_loader="/lib/ld-linux.so.2"
			;;
		arm )
			dynamic_loader="/lib/ld-linux.so.3"
			;;
		* )
			dynamic_loader="/unknown_dynamic_linker"
			;;
	esac

	mklibs -v \
		--ldlib ${dynamic_loader} \
		--sysroot ${PKG_CONFIG_SYSROOT_DIR} \
		--root ${IMAGE_ROOTFS} \
		--target `echo ${TARGET_PREFIX} | sed 's/-$//' ` \
		-d ${WORKDIR}/mklibs/dest \
		`cat ${WORKDIR}/mklibs/executables.list`

	cd ${WORKDIR}/mklibs/dest
	for i in *
	do
		cp $i `find ${IMAGE_ROOTFS} -name $i`
	done

	cd ${IMAGE_ROOTFS}
	du -bs > ${WORKDIR}/mklibs/du.after.mklibs.txt

	echo rootfs size before mklibs optimization: `cat ${WORKDIR}/mklibs/du.before.mklibs.txt`
	echo rootfs size after mklibs optimization: `cat ${WORKDIR}/mklibs/du.after.mklibs.txt`
}

mklibs_optimize_image() {
	for img in ${MKLIBS_OPTIMIZED_IMAGES}
	do
		if [ "${img}" == "${PN}" ] || [ "${img}" == "all" ]
		then
			mklibs_optimize_image_doit
			break
		fi
	done
}


EXPORT_FUNCTIONS mklibs_optimize_image