1 DESCRIPTION
= "Meta package for building a installable toolchain"
3 DEPENDS
= "opkg-native opkg-utils-native fakeroot-native sed-native zip-native"
6 # NOTE
: We need
to save
and restore PACKAGE_ARCHS
, because sdk.bbclass
7 # will change HOST_ARCH
, which can result in SITEINFO_ENDIANNESS
(which
8 # is computed in siteinfo.bbclass
) in changing
if the original HOST_ARCH
9 # endianess differs from the
new HOST_ARCH endianess. SITEINFO_ENDIANNESS
10 # is used in a number of places
, including the construction of the
11 # PACKAGE_EXTRA_ARCHS list
for machines that are capable of running in
12 # either endianess. There may be better ways
to fix this.
14 # Save value of PACKAGE_ARCHS
(note the
":=" syntax
to force immediate eval
)
15 REAL_PACKAGE_ARCHS
:= "${PACKAGE_ARCHS}"
17 inherit canadian
-sdk meta
19 #
Restore PACKAGE_ARCHS
(sdk.bbclass may have caused it
to change
)
20 PACKAGE_ARCHS
:= "${REAL_PACKAGE_ARCHS}"
22 SDK_DIR
= "${WORKDIR}/sdk"
23 SDK_OUTPUT
= "${SDK_DIR}/image"
24 SDK_DEPLOY
= "${DEPLOY_DIR}/sdk"
26 IPKG_HOST
= "opkg-cl -f ${IPKGCONF_CANSDK} -o ${SDK_OUTPUT}"
27 IPKG_TARGET
= "opkg-cl -f ${IPKGCONF_TARGET} -o ${SDK_OUTPUT}/${SDK_PATH}/${TARGET_SYS}"
29 TOOLCHAIN_CANADIAN_HOST_TASK ?
= "task-sdk-canadian-host"
30 TOOLCHAIN_TARGET_TASK ?
= "task-sdk-bare"
31 FEED_ARCH ?
= "${TARGET_ARCH}"
32 SDK_SUFFIX
= "toolchain"
33 TOOLCHAIN_OUTPUTNAME ?
= "${SDK_SYS}-${DISTRO}-${DISTRO_VERSION}-${FEED_ARCH}-${TARGET_OS}-${SDK_SUFFIX}"
35 RDEPENDS_$
{PN
} = "${TOOLCHAIN_TARGET_TASK} ${TOOLCHAIN_CANADIAN_HOST_TASK}"
37 TOOLCHAIN_FEED_URI ?
= "${DISTRO_FEED_URI}"
40 OUTPUT_OPKGCONF_TARGET
="${SDK_OUTPUT}/${prefix}/${TARGET_SYS}/${layout_sysconfdir}/opkg.conf"
41 OUTPUT_OPKGCONF_HOST
="${SDK_OUTPUT}/${prefix}/${TARGET_SYS}/${layout_sysconfdir}/opkg-canadian-sdk.conf"
42 OUTPUT_OPKGCONF_SDK
="${SDK_OUTPUT}/${sysconfdir}/opkg-canadian-sdk.conf"
43 rm $
{OUTPUT_OPKGCONF_TARGET
}
44 rm $
{OUTPUT_OPKGCONF_HOST
}
45 rm $
{OUTPUT_OPKGCONF_SDK
}
46 opkgarchs
="${PACKAGE_ARCHS}"
48 for arch in $
{opkgarchs
}; do
49 echo
"arch ${arch} ${priority}" >> $
{OUTPUT_OPKGCONF_TARGET
};
50 echo
"src/gz ${arch} ${TOOLCHAIN_FEED_URI}/${arch}" >> $
{OUTPUT_OPKGCONF_TARGET
};
51 priority
=$
(expr $
{priority
} + 5);
57 mkdir
-p $
{SDK_OUTPUT
}
59 package_generate_ipkg_conf
61 for arch in $
{PACKAGE_ARCHS
}; do
62 revipkgarchs
="$arch $revipkgarchs"
65 mkdir
-p $
{SDK_OUTPUT
}/usr
/lib
/opkg
67 $
{IPKG_HOST
} -force
-depends install $
{TOOLCHAIN_CANADIAN_HOST_TASK
}
69 mkdir
-p $
{SDK_OUTPUT
}/$
{SDK_PATH
}/$
{TARGET_SYS
}/usr
/lib
/opkg
71 $
{IPKG_TARGET
} install $
{TOOLCHAIN_TARGET_TASK
}
73 install
-d $
{SDK_OUTPUT
}/$
{prefix
}/usr
/lib
/opkg
74 mv $
{SDK_OUTPUT
}/usr
/lib
/opkg
/* $
{SDK_OUTPUT
}/$
{prefix
}/usr
/lib
/opkg
/
75 rm
-Rf $
{SDK_OUTPUT
}/usr
/lib
77 install
-d $
{SDK_OUTPUT
}/$
{prefix
}/$
{TARGET_SYS
}/$
{layout_sysconfdir
}
78 install
-m
0644 $
{IPKGCONF_TARGET
} $
{IPKGCONF_CANSDK
} $
{SDK_OUTPUT
}/$
{prefix
}/$
{TARGET_SYS
}/$
{layout_sysconfdir
}/
80 install
-d $
{SDK_OUTPUT
}/$
{sysconfdir
}
81 install
-m
0644 $
{IPKGCONF_CANSDK
} $
{SDK_OUTPUT
}/$
{sysconfdir
}/
83 # extract
and store ipks
, pkgdata
and shlibs
data
84 target_pkgs
=`cat $
{SDK_OUTPUT
}/$
{prefix
}/package
-status | grep Package
: | cut
-f
2 -d ' '`
85 mkdir
-p $
{SDK_OUTPUT
}/$
{prefix
}/ipk
/
86 mkdir
-p $
{SDK_OUTPUT
}/$
{prefix
}/pkgdata
/runtime
/
87 mkdir
-p $
{SDK_OUTPUT
}/$
{prefix
}/$
{TARGET_SYS
}/shlibs
/
88 for pkg in $target_pkgs
; do
89 for arch in $revipkgarchs
; do
90 pkgnames
=$
{DEPLOY_DIR_IPK
}/$arch
/$
{pkg
}_
*_$arch.ipk
91 if [ -e $pkgnames
]; then
92 oenote
"Found $pkgnames"
93 cp $pkgnames $
{SDK_OUTPUT
}/$
{prefix
}/ipk
/
94 orig_pkg
=`opkg
-list
-fields $pkgnames | grep OE
: | cut
-d ' '
-f2`
95 pkg_subdir
=$arch$
{TARGET_VENDOR
}$
{@
['
-'
+ bb.
data.getVar
('TARGET_OS'
, d
, 1), ''
][bb.
data.getVar
('TARGET_OS'
, d
, 1) == (''
or 'custom'
)]}
96 mkdir
-p $
{SDK_OUTPUT
}/$
{prefix
}/pkgdata
/$pkg_subdir
/runtime
97 cp $
{STAGING_DIR
}/pkgdata
/$pkg_subdir
/$orig_pkg $
{SDK_OUTPUT
}/$
{prefix
}/pkgdata
/$pkg_subdir
/
98 subpkgs
=`cat $
{STAGING_DIR
}/pkgdata
/$pkg_subdir
/$orig_pkg | grep PACKAGES
: | cut
-b
10-`
99 for subpkg in $subpkgs
; do
100 cp $
{STAGING_DIR
}/pkgdata
/$pkg_subdir
/runtime
/$subpkg $
{SDK_OUTPUT
}/$
{prefix
}/pkgdata
/$pkg_subdir
/runtime
/
101 if [ -e $
{STAGING_DIR
}/pkgdata
/$pkg_subdir
/runtime
/$subpkg.packaged
];then
102 cp $
{STAGING_DIR
}/pkgdata
/$pkg_subdir
/runtime
/$subpkg.packaged $
{SDK_OUTPUT
}/$
{prefix
}/pkgdata
/$pkg_subdir
/runtime
/
104 if [ -e $
{STAGING_DIR_TARGET
}/shlibs
/$subpkg.list
]; then
105 cp $
{STAGING_DIR_TARGET
}/shlibs
/$subpkg.
* $
{SDK_OUTPUT
}/$
{prefix
}/$
{TARGET_SYS
}/shlibs
/
113 # add missing link
to libgcc_s.so
.1
114 # libgcc
-dev should be responsible
for that
, but it's
not getting built
115 # RP
: it gets smashed up depending on the order that gcc
, gcc
-cross
and
116 # gcc
-cross
-sdk get built
:( (30/11/07)
117 ln
-sf libgcc_s.so
.1 $
{SDK_OUTPUT
}/$
{prefix
}/$
{TARGET_SYS
}/lib
/libgcc_s.so
119 # With sysroot support
, gcc expects the
default C
++ headers
to be
120 # in a specific place.
121 install
-d $
{SDK_OUTPUT
}/$
{prefix
}/$
{TARGET_SYS
}/include
122 mv $
{SDK_OUTPUT
}/$
{prefix
}/$
{TARGET_SYS
}/usr
/include/c
++ \
123 $
{SDK_OUTPUT
}/$
{prefix
}/$
{TARGET_SYS
}/include/
125 # Fix
or remove broken .la files
126 for i in `find $
{SDK_OUTPUT
}/$
{prefix
}/$
{TARGET_SYS
} -name \
*.la`
; do
127 sed
-i
-e
"/^dependency_libs=/s,\([[:space:]']\)${layout_base_libdir},\1${prefix}/${TARGET_SYS}${layout_base_libdir},g" \
128 -e
"/^dependency_libs=/s,\([[:space:]']\)${layout_libdir},\1${prefix}/${TARGET_SYS}${layout_libdir},g" \
129 -e
"/^dependency_libs=/s,\-\([LR]\)${layout_base_libdir},-\1${prefix}/${TARGET_SYS}${layout_base_libdir},g" \
130 -e
"/^dependency_libs=/s,\-\([LR]\)${layout_libdir},-\1${prefix}/${TARGET_SYS}${layout_libdir},g" \
131 -e 's
/^installed
=yes$
/installed
=no
/' $i
133 rm
-f $
{SDK_OUTPUT
}/$
{prefix
}/lib
/*.la
135 # Setup site file
for external use
136 siteconfig
=$
{SDK_OUTPUT
}/$
{prefix
}/site
-config
138 for sitefile in $
{CONFIG_SITE
} ; do
139 cat $sitefile
>> $siteconfig
142 # Create environment setup script
143 script
=$
{SDK_OUTPUT
}/$
{prefix
}/environment
-setup
145 echo 'export PATH
=$
{prefix
}/bin:$PATH'
>> $script
146 echo 'export LIBTOOL_SYSROOT_PATH
=$
{prefix
}/$
{TARGET_SYS
}'
>> $script
147 echo 'export PKG_CONFIG_SYSROOT_DIR
=$
{prefix
}/$
{TARGET_SYS
}'
>> $script
148 echo 'export PKG_CONFIG_PATH
=$
{prefix
}/$
{TARGET_SYS
}$
{layout_libdir
}/pkgconfig'
>> $script
149 echo 'export CONFIG_SITE
=$
{prefix
}/site
-config'
>> $script
150 echo
"alias opkg='LD_LIBRARY_PATH=${prefix}/lib ${prefix}/bin/opkg-cl -f ${sysconfdir}/opkg-canadian-sdk.conf -o ${prefix}'" >> $script
151 echo
"alias opkg-target='LD_LIBRARY_PATH=${prefix}/lib ${prefix}/bin/opkg-cl -f ${prefix}/${TARGET_SYS}${layout_sysconfdir}/opkg.conf -o ${prefix}/${TARGET_SYS}'" >> $script
153 # Add version information
154 versionfile
=$
{SDK_OUTPUT
}/$
{prefix
}/version
156 echo 'Distro
: $
{DISTRO
}'
>> $versionfile
157 echo 'Distro Version
: $
{DISTRO_VERSION
}'
>> $versionfile
158 echo 'Metadata Revision
: $
{METADATA_REVISION
}'
>> $versionfile
159 echo 'Timestamp
: $
{DATETIME
}'
>> $versionfile
164 mkdir
-p $
{SDK_DEPLOY
}
166 fakeroot tar cfj $
{SDK_DEPLOY
}/$
{TOOLCHAIN_OUTPUTNAME
}.tar.bz2 .
167 rm
-f $
{SDK_DEPLOY
}/$
{TOOLCHAIN_OUTPUTNAME
}.zip
168 zip
-r
-D $
{SDK_DEPLOY
}/$
{TOOLCHAIN_OUTPUTNAME
}.zip .
171 do_populate_sdk
[nostamp
] = "1"
172 do_populate_sdk
[lockfiles
] = "${DEPLOY_DIR_IPK}.lock"
173 addtask package_update_index_ipk
before do_populate_sdk
174 addtask populate_sdk
before do_build
after do_install