op_datetime.sh: Fixed screen blanking when changing time
[openpandora.oe.git] / recipes / meta / meta-toolchain.bb
1 DESCRIPTION = "Meta package for building a installable toolchain"
2 LICENSE = "MIT"
3 DEPENDS = "opkg-native ipkg-utils-native fakeroot-native sed-native"
4
5 inherit meta
6
7 SDK_DIR = "${WORKDIR}/sdk"
8 SDK_OUTPUT = "${SDK_DIR}/image"
9 SDK_OUTPUT2 = "${SDK_DIR}/image-extras"
10 SDK_DEPLOY = "${DEPLOY_DIR}/sdk"
11
12 IPKG_HOST = "opkg-cl -f ${IPKGCONF_SDK} -o ${SDK_OUTPUT}"
13 IPKG_TARGET = "opkg-cl -f ${IPKGCONF_TARGET} -o ${SDK_OUTPUT}/${SDKPATH}/${TARGET_SYS}"
14
15 TOOLCHAIN_HOST_TASK ?= "task-sdk-host"
16 TOOLCHAIN_TARGET_TASK ?= "task-sdk-bare"
17 TOOLCHAIN_TARGET_EXCLUDE ?= ""
18 FEED_ARCH ?= "${TARGET_ARCH}"
19 SDK_SUFFIX = "toolchain"
20 TOOLCHAIN_OUTPUTNAME ?= "${DISTRO}-${DISTRO_VERSION}-${SDK_SYS}-${FEED_ARCH}-${TARGET_OS}-${SDK_SUFFIX}"
21
22 RDEPENDS = "${TOOLCHAIN_TARGET_TASK} ${TOOLCHAIN_HOST_TASK}"
23
24 TOOLCHAIN_FEED_URI ?= "${DISTRO_FEED_URI}"
25
26 modify_opkg_conf () {
27         OUTPUT_OPKGCONF_TARGET="${SDK_OUTPUT}/${SDKPATH}/${TARGET_SYS}/${sysconfdir}/opkg.conf"
28         OUTPUT_OPKGCONF_HOST="${SDK_OUTPUT}/${SDKPATH}/${TARGET_SYS}/${sysconfdir}/opkg-sdk.conf"
29         OUTPUT_OPKGCONF_SDK="${SDK_OUTPUT}/${sysconfdir}/opkg-sdk.conf"
30         rm -f ${OUTPUT_OPKGCONF_TARGET}
31         rm -f ${OUTPUT_OPKGCONF_HOST}
32         rm -f ${OUTPUT_OPKGCONF_SDK}
33         opkgarchs="${PACKAGE_ARCHS}"
34         priority=1
35         for arch in ${opkgarchs}; do
36                 echo "arch ${arch} ${priority}" >> ${OUTPUT_OPKGCONF_TARGET};
37                 echo "src/gz ${arch} ${TOOLCHAIN_FEED_URI}/${arch}" >> ${OUTPUT_OPKGCONF_TARGET};
38                 priority=$(expr ${priority} + 5);
39         done
40 }
41
42 do_populate_sdk() {
43         rm -rf ${SDK_OUTPUT}
44         mkdir -p ${SDK_OUTPUT}
45         mkdir -p ${SDK_OUTPUT}${libdir}/opkg/
46         mkdir -p ${SDK_OUTPUT}/${SDKPATH}/${TARGET_SYS}${libdir}/opkg/
47
48         package_generate_ipkg_conf
49
50         for arch in ${PACKAGE_ARCHS}; do
51                 revipkgarchs="$arch $revipkgarchs"
52         done
53
54         ${IPKG_HOST} update
55         ${IPKG_HOST} -force-depends install ${TOOLCHAIN_HOST_TASK}
56
57         ${IPKG_TARGET} update
58         ${IPKG_TARGET} install ${TOOLCHAIN_TARGET_TASK}
59
60         # Remove packages in the exclude list which were installed by dependencies
61         if [ ! -z "${TOOLCHAIN_TARGET_EXCLUDE}" ]; then
62                 ${IPKG_TARGET} remove -force-depends ${TOOLCHAIN_TARGET_EXCLUDE}
63         fi
64
65         install -d ${SDK_OUTPUT}/${SDKPATH}/usr/lib/opkg
66         mv ${SDK_OUTPUT}/usr/lib/opkg/* ${SDK_OUTPUT}/${SDKPATH}/usr/lib/opkg/
67         rm -Rf ${SDK_OUTPUT}/usr/lib
68
69         # Clean up empty directories from excluded packages
70         find ${SDK_OUTPUT} -depth -type d -empty -print0 | xargs -r0 /bin/rmdir
71
72         install -d ${SDK_OUTPUT}/${SDKPATH}/${TARGET_SYS}/${sysconfdir}
73         install -m 0644 ${IPKGCONF_TARGET} ${IPKGCONF_SDK} ${SDK_OUTPUT}/${SDKPATH}/${TARGET_SYS}/${sysconfdir}/
74
75         install -d ${SDK_OUTPUT}/${SDKPATH}/${sysconfdir}
76         install -m 0644 ${IPKGCONF_SDK} ${SDK_OUTPUT}/${SDKPATH}/${sysconfdir}/
77
78         # extract and store ipks, pkgdata and shlibs data
79         target_pkgs=`cat ${SDK_OUTPUT}/${SDKPATH}/${TARGET_SYS}/usr/lib/opkg/status | grep Package: | cut -f 2 -d ' '`
80         mkdir -p ${SDK_OUTPUT2}/${SDKPATH}/ipk/
81         mkdir -p ${SDK_OUTPUT2}/${SDKPATH}/pkgdata/runtime/
82         mkdir -p ${SDK_OUTPUT2}/${SDKPATH}/${TARGET_SYS}/shlibs/
83         for pkg in $target_pkgs ; do
84                 for arch in $revipkgarchs; do
85                         pkgnames=${DEPLOY_DIR_IPK}/$arch/${pkg}_*_$arch.ipk
86                         if [ -e $pkgnames ]; then
87                                 oenote "Found $pkgnames"
88                                 cp $pkgnames ${SDK_OUTPUT2}/${SDKPATH}/ipk/
89                                 orig_pkg=`ipkg-list-fields $pkgnames | grep OE: | cut -d ' ' -f2`
90                                 pkg_subdir=$arch${TARGET_VENDOR}${@['-' + bb.data.getVar('TARGET_OS', d, 1), ''][bb.data.getVar('TARGET_OS', d, 1) == ('' or 'custom')]}
91                                 mkdir -p ${SDK_OUTPUT2}/${SDKPATH}/pkgdata/$pkg_subdir/runtime
92                                 cp ${TMPDIR}/pkgdata/$pkg_subdir/$orig_pkg ${SDK_OUTPUT2}/${SDKPATH}/pkgdata/$pkg_subdir/
93                                 subpkgs=`cat ${TMPDIR}/pkgdata/$pkg_subdir/$orig_pkg | grep PACKAGES: | cut -b 10-`
94                                 for subpkg in $subpkgs; do
95                                         cp ${TMPDIR}/pkgdata/$pkg_subdir/runtime/$subpkg ${SDK_OUTPUT2}/${SDKPATH}/pkgdata/$pkg_subdir/runtime/
96                                         if [ -e ${TMPDIR}/pkgdata/$pkg_subdir/runtime/$subpkg.packaged ];then
97                                                 cp ${TMPDIR}/pkgdata/$pkg_subdir/runtime/$subpkg.packaged ${SDK_OUTPUT2}/${SDKPATH}/pkgdata/$pkg_subdir/runtime/
98                                         fi
99                                         if [ -e ${STAGING_DIR_TARGET}/shlibs/$subpkg.list ]; then
100                                                 cp ${STAGING_DIR_TARGET}/shlibs/$subpkg.* ${SDK_OUTPUT2}/${SDKPATH}/${TARGET_SYS}/shlibs/
101                                         fi
102                                 done
103                                 break
104                         fi
105                 done
106         done
107
108         # add missing link to libgcc_s.so.1
109         # libgcc-dev should be responsible for that, but it's not getting built
110         # RP: it gets smashed up depending on the order that gcc, gcc-cross and 
111         # gcc-cross-sdk get built :( (30/11/07)
112         ln -sf libgcc_s.so.1 ${SDK_OUTPUT}/${SDKPATH}/${TARGET_SYS}/lib/libgcc_s.so
113
114         # With sysroot support, gcc expects the default C++ headers to be
115         # in a specific place.
116         install -d ${SDK_OUTPUT}/${SDKPATH}/${TARGET_SYS}/include
117         mv ${SDK_OUTPUT}/${SDKPATH}/${TARGET_SYS}/usr/include/c++ \
118                 ${SDK_OUTPUT}/${SDKPATH}/${TARGET_SYS}/include/
119
120         # Fix or remove broken .la files
121         for i in `find ${SDK_OUTPUT}/${SDKPATH}/${TARGET_SYS} -name \*.la`; do
122                 sed -i  -e "/^dependency_libs=/s,\([[:space:]']\)${base_libdir},\1\$SDK_PATH/\$TARGET_SYS${base_libdir},g" \
123                         -e "/^dependency_libs=/s,\([[:space:]']\)${libdir},\1\$SDK_PATH/\$TARGET_SYS${libdir},g" \
124                         -e "/^dependency_libs=/s,\-\([LR]\)${base_libdir},-\1\$SDK_PATH/\$TARGET_SYS${base_libdir},g" \
125                         -e "/^dependency_libs=/s,\-\([LR]\)${libdir},-\1\$SDK_PATH/\$TARGET_SYS${libdir},g" \
126                         -e 's/^installed=yes$/installed=no/' $i
127         done
128         rm -f ${SDK_OUTPUT}/${SDKPATH}/lib/*.la
129
130         # Setup site file for external use
131         siteconfig=${SDK_OUTPUT}/${SDKPATH}/site-config
132         touch $siteconfig
133         for sitefile in ${CONFIG_SITE} ; do
134                 cat $sitefile >> $siteconfig
135         done
136
137         # Create environment setup script
138         script=${SDK_OUTPUT}/${SDKPATH}/environment-setup
139         touch $script
140         echo 'export SDK_PATH=${SDKPATH}' >> $script
141         echo 'export TARGET_SYS=${TARGET_SYS}' >> $script
142         echo 'export PATH=$SDK_PATH/bin:$PATH' >> $script
143         echo 'export CPATH=$SDK_PATH/$TARGET_SYS/usr/include:$CPATH' >> $script
144         echo 'export LIBTOOL_SYSROOT_PATH=$SDK_PATH/$TARGET_SYS' >> $script
145         echo 'export PKG_CONFIG_SYSROOT_DIR=$SDK_PATH/$TARGET_SYS' >> $script
146         echo 'export PKG_CONFIG_PATH=$SDK_PATH/$TARGET_SYS${libdir}/pkgconfig' >> $script
147         echo 'export CONFIG_SITE=$SDK_PATH/site-config' >> $script
148         echo 'alias opkg="LD_LIBRARY_PATH=$SDK_PATH/lib $SDK_PATH/bin/opkg-cl -f $SDK_PATH/${sysconfdir}/opkg-sdk.conf -o $SDK_PATH"' >> $script
149         echo 'alias opkg-target="LD_LIBRARY_PATH=$SDK_PATH/lib $SDK_PATH/bin/opkg-cl -f $SDK_PATH/$TARGET_SYS${sysconfdir}/opkg.conf -o $SDK_PATH/$TARGET_SYS"' >> $script
150
151         # Add version information
152         versionfile=${SDK_OUTPUT}/${SDKPATH}/version
153         touch $versionfile
154         echo 'Distro: ${DISTRO}' >> $versionfile
155         echo 'Distro Version: ${DISTRO_VERSION}' >> $versionfile
156         echo 'Metadata Revision: ${METADATA_REVISION}' >> $versionfile
157         echo 'Timestamp: ${DATETIME}' >> $versionfile
158
159         modify_opkg_conf
160
161         # Package it up
162         mkdir -p ${SDK_DEPLOY}
163         cd ${SDK_OUTPUT}
164         fakeroot tar cfj ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.tar.bz2 .
165         cd ${SDK_OUTPUT2}
166         fakeroot tar cfj ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}-extras.tar.bz2 .
167 }
168
169 do_populate_sdk[nostamp] = "1"
170 addtask package_update_index_ipk before do_populate_sdk
171 addtask populate_sdk before do_build after do_install