merge of '26501141207c84e31e0f43c5795a15c0f16dbce5'
[vuplus_openembedded] / classes / autotools.bbclass
1 inherit base
2
3 def autotools_dep_prepend(d):
4         import bb;
5
6         if bb.data.getVar('INHIBIT_AUTOTOOLS_DEPS', d, 1):
7                 return ''
8
9         pn = bb.data.getVar('PN', d, 1)
10         deps = ''
11
12         if pn in ['autoconf-native', 'automake-native']:
13                 return deps
14         deps += 'autoconf-native automake-native '
15
16         if not pn in ['libtool', 'libtool-native', 'libtool-cross']:
17                 deps += 'libtool-native '
18                 if not bb.data.inherits_class('native', d) \
19                         and not bb.data.inherits_class('cross', d) \
20                         and not bb.data.inherits_class('sdk', d) \
21                         and not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d, 1):
22                     deps += 'libtool-cross '
23
24         return deps + 'gnu-config-native '
25
26 EXTRA_OEMAKE = ""
27 DEPENDS_prepend = "${@autotools_dep_prepend(d)}"
28 acpaths = "default"
29 EXTRA_AUTORECONF = "--exclude=autopoint"
30
31 def autotools_set_crosscompiling(d):
32         import bb
33         if not bb.data.inherits_class('native', d):
34                 return " cross_compiling=yes"
35         return ""
36
37 # EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}"
38
39 oe_runconf () {
40         if [ -x ${S}/configure ] ; then
41                 cfgcmd="${S}/configure \
42                     --build=${BUILD_SYS} \
43                     --host=${HOST_SYS} \
44                     --target=${TARGET_SYS} \
45                     --prefix=${prefix} \
46                     --exec_prefix=${exec_prefix} \
47                     --bindir=${bindir} \
48                     --sbindir=${sbindir} \
49                     --libexecdir=${libexecdir} \
50                     --datadir=${datadir} \
51                     --sysconfdir=${sysconfdir} \
52                     --sharedstatedir=${sharedstatedir} \
53                     --localstatedir=${localstatedir} \
54                     --libdir=${libdir} \
55                     --includedir=${includedir} \
56                     --oldincludedir=${oldincludedir} \
57                     --infodir=${infodir} \
58                     --mandir=${mandir} \
59                         ${EXTRA_OECONF} \
60                     $@"
61                 oenote "Running $cfgcmd..."
62                 $cfgcmd || oefatal "oe_runconf failed" 
63         else
64                 oefatal "no configure script found"
65         fi
66 }
67
68 autotools_do_configure() {
69         case ${PN} in
70         autoconf*)
71         ;;
72         automake*)
73         ;;
74         *)
75                 # WARNING: gross hack follows:
76                 # An autotools built package generally needs these scripts, however only
77                 # automake or libtoolize actually install the current versions of them.
78                 # This is a problem in builds that do not use libtool or automake, in the case
79                 # where we -need- the latest version of these scripts.  e.g. running a build
80                 # for a package whose autotools are old, on an x86_64 machine, which the old
81                 # config.sub does not support.  Work around this by installing them manually
82                 # regardless.
83                 ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do
84                         rm -f `dirname $ac`/configure
85                         done )
86                 if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
87                         olddir=`pwd`
88                         cd ${S}
89                         if [ x"${acpaths}" = xdefault ]; then
90                                 acpaths=
91                                 for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
92                                         grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
93                                         acpaths="$acpaths -I $i"
94                                 done
95                         else
96                                 acpaths="${acpaths}"
97                         fi
98                         AUTOV=`automake --version |head -n 1 |sed "s/.* //;s/\.[0-9]\+$//"`
99                         automake --version
100                         echo "AUTOV is $AUTOV"
101                         install -d ${STAGING_DATADIR}/aclocal
102                         install -d ${STAGING_DATADIR}/aclocal-$AUTOV
103                         acpaths="$acpaths -I${STAGING_DATADIR}/aclocal-$AUTOV -I ${STAGING_DATADIR}/aclocal"
104                         # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
105                         # like it was auto-generated.  Work around this by blowing it away
106                         # by hand, unless the package specifically asked not to run aclocal.
107                         if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
108                                 rm -f aclocal.m4
109                         fi
110                         if [ -e configure.in ]; then
111                           CONFIGURE_AC=configure.in
112                         else
113                           CONFIGURE_AC=configure.ac
114                         fi
115                         if grep "^AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
116                           if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
117                             : do nothing -- we still have an old unmodified configure.ac
118                           else
119                             oenote Executing glib-gettextize --force --copy
120                             echo "no" | glib-gettextize --force --copy
121                           fi
122                         fi
123                         if grep "^[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
124                           oenote Executing intltoolize --copy --force --automake
125                           intltoolize --copy --force --automake
126                         fi
127                         oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
128                         mkdir -p m4
129                         autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed."
130                         cd $olddir
131                 fi
132         ;;
133         esac
134         if [ -e ${S}/configure ]; then
135                 oe_runconf
136         else
137                 oenote "nothing to configure"
138         fi
139 }
140
141 autotools_do_install() {
142         oe_runmake 'DESTDIR=${D}' install
143
144         for i in `find ${D} -name "*.la"` ; do \
145             sed -i -e s:${STAGING_LIBDIR}:${libdir}:g $i
146             sed -i -e s:${D}::g $i
147             sed -i -e 's:-I${WORKDIR}\S*: :g' $i
148             sed -i -e 's:-L${WORKDIR}\S*: :g' $i
149         done
150 }
151
152 STAGE_TEMP="${WORKDIR}/temp-staging"
153
154 autotools_stage_includes() {
155         if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ]
156         then
157                 rm -rf ${STAGE_TEMP}
158                 mkdir -p ${STAGE_TEMP}
159                 make DESTDIR="${STAGE_TEMP}" install
160                 cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
161                 rm -rf ${STAGE_TEMP}
162         fi
163 }
164
165 autotools_stage_all() {
166         if [ "${INHIBIT_AUTO_STAGE}" = "1" ]
167         then
168                 return
169         fi
170         rm -rf ${STAGE_TEMP}
171         mkdir -p ${STAGE_TEMP}
172         oe_runmake DESTDIR="${STAGE_TEMP}" install
173         if [ -d ${STAGE_TEMP}/${includedir} ]; then
174                 cp -fpPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
175         fi
176         if [ -d ${STAGE_TEMP}/${libdir} ]
177         then
178                 find ${STAGE_TEMP}/${libdir} -name '*.la' -exec sed -i s,installed=yes,installed=no, {} \;
179
180                 for i in ${STAGE_TEMP}/${libdir}/*.la
181                 do
182                         if [ ! -f "$i" ]; then
183                                 cp -fpPR ${STAGE_TEMP}/${libdir}/* ${STAGING_LIBDIR}
184                                 break
185                         fi
186                         oe_libinstall -so $(basename $i .la) ${STAGING_LIBDIR}
187                 done
188         fi
189         if [ -d ${STAGE_TEMP}/${datadir}/aclocal ]; then
190                 install -d ${STAGING_DATADIR}/aclocal
191                 cp -fpPR ${STAGE_TEMP}/${datadir}/aclocal/* ${STAGING_DATADIR}/aclocal
192         fi
193         rm -rf ${STAGE_TEMP}
194 }
195
196 EXPORT_FUNCTIONS do_configure do_install