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