merge of 'bed1f45d5c2e76fbd336580d09caef10c613f256'
[vuplus_openembedded] / classes / binconfig.bbclass
1 inherit base
2
3 # The namespaces can clash here hence the two step replace
4 def get_binconfig_mangle(d):
5         import bb.data
6         s = "-e ''"
7         if not bb.data.inherits_class('native', d):
8                 optional_quote = r"\(\"\?\)"
9                 s += " -e 's:=%s${libdir}:=\\1OELIBDIR:;'" % optional_quote
10                 s += " -e 's:=%s${includedir}:=\\1OEINCDIR:;'" % optional_quote
11                 s += " -e 's:=%s${datadir}:=\\1OEDATADIR:'" % optional_quote
12                 s += " -e 's:=%s${prefix}:=\\1OEPREFIX:'" % optional_quote
13                 s += " -e 's:=%s${exec_prefix}:=\\1OEEXECPREFIX:'" % optional_quote
14                 s += " -e 's:-L${libdir}:-LOELIBDIR:;'"
15                 s += " -e 's:-I${includedir}:-IOEINCDIR:;'"
16                 s += " -e 's:OELIBDIR:${STAGING_LIBDIR}:;'"
17                 s += " -e 's:OEINCDIR:${STAGING_INCDIR}:;'"
18                 s += " -e 's:OEDATADIR:${STAGING_DATADIR}:'"
19                 s += " -e 's:OEPREFIX:${STAGING_DIR_HOST}${layout_prefix}:'"
20                 s += " -e 's:OEEXECPREFIX:${STAGING_DIR_HOST}${layout_exec_prefix}:'"
21                 s += " -e 's:-I${WORKDIR}:-I${STAGING_INCDIR}:'"
22                 s += " -e 's:-L${WORKDIR}:-L${STAGING_LIBDIR}:'"
23                 if bb.data.getVar("OE_BINCONFIG_EXTRA_MANGLE", d):
24                     s += bb.data.getVar("OE_BINCONFIG_EXTRA_MANGLE", d)
25         return s
26
27 BINCONFIG_GLOB ?= "*-config"
28
29 do_install_append() {
30
31     #the 'if' protects native packages, since we can't easily check for bb.data.inherits_class('native', d) in shell 
32     if [ -e ${D}${bindir} ] ; then
33         for config in `find ${S} -name '${BINCONFIG_GLOB}'`; do
34                 cat $config | sed \
35                 -e 's:${STAGING_LIBDIR}:${libdir}:g;' \ 
36                 -e 's:${STAGING_INCDIR}:${includedir}:g;' \
37                 -e 's:${STAGING_DATADIR}:${datadir}:' \
38                 -e 's:${STAGING_DIR_HOST}${layout_prefix}:${prefix}:' > ${D}${bindir}/`basename $config`
39         done
40     fi  
41
42         for lafile in `find ${D} -name *.la` ; do
43                 sed -i \
44                     -e 's:${STAGING_LIBDIR}:${libdir}:g;' \
45                     -e 's:${STAGING_INCDIR}:${includedir}:g;' \
46                     -e 's:${STAGING_DATADIR}:${datadir}:' \
47                     -e 's:${STAGING_DIR_HOST}${layout_prefix}:${prefix}:' \
48                     $lafile
49         done        
50 }
51
52 do_stage_append() {
53         for config in `find ${S} -name '${BINCONFIG_GLOB}'`; do
54                 configname=`basename $config`
55                 install -d ${STAGING_BINDIR_CROSS}
56                 cat $config | sed ${@get_binconfig_mangle(d)} > ${STAGING_BINDIR_CROSS}/$configname
57                 chmod u+x ${STAGING_BINDIR_CROSS}/$configname
58         done
59 }