summaryrefslogtreecommitdiffstats
path: root/meta/classes/autotools.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/autotools.bbclass')
-rw-r--r--meta/classes/autotools.bbclass248
1 files changed, 248 insertions, 0 deletions
diff --git a/meta/classes/autotools.bbclass b/meta/classes/autotools.bbclass
new file mode 100644
index 0000000000..883eb06e26
--- /dev/null
+++ b/meta/classes/autotools.bbclass
@@ -0,0 +1,248 @@
1def autotools_dep_prepend(d):
2 if d.getVar('INHIBIT_AUTOTOOLS_DEPS', True):
3 return ''
4
5 pn = d.getVar('PN', True)
6 deps = ''
7
8 if pn in ['autoconf-native', 'automake-native', 'help2man-native']:
9 return deps
10 deps += 'autoconf-native automake-native '
11
12 if not pn in ['libtool', 'libtool-native'] and not pn.endswith("libtool-cross"):
13 deps += 'libtool-native '
14 if not bb.data.inherits_class('native', d) \
15 and not bb.data.inherits_class('nativesdk', d) \
16 and not bb.data.inherits_class('cross', d) \
17 and not d.getVar('INHIBIT_DEFAULT_DEPS', True):
18 deps += 'libtool-cross '
19
20 return deps + 'gnu-config-native '
21
22EXTRA_OEMAKE = ""
23
24DEPENDS_prepend = "${@autotools_dep_prepend(d)}"
25
26inherit siteinfo
27
28# Space separated list of shell scripts with variables defined to supply test
29# results for autoconf tests we cannot run at build time.
30export CONFIG_SITE = "${@siteinfo_get_files(d)}"
31
32acpaths = "default"
33EXTRA_AUTORECONF = "--exclude=autopoint"
34
35export lt_cv_sys_lib_dlsearch_path_spec = "${libdir} ${base_libdir}"
36
37# When building tools for use at build-time it's recommended for the build
38# system to use these variables when cross-compiling.
39# (http://sources.redhat.com/autobook/autobook/autobook_270.html)
40export CPP_FOR_BUILD = "${BUILD_CPP}"
41export CPPFLAGS_FOR_BUILD = "${BUILD_CPPFLAGS}"
42
43export CC_FOR_BUILD = "${BUILD_CC}"
44export CFLAGS_FOR_BUILD = "${BUILD_CFLAGS}"
45
46export CXX_FOR_BUILD = "${BUILD_CXX}"
47export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
48
49export LD_FOR_BUILD = "${BUILD_LD}"
50export LDFLAGS_FOR_BUILD = "${BUILD_LDFLAGS}"
51
52def autotools_set_crosscompiling(d):
53 if not bb.data.inherits_class('native', d):
54 return " cross_compiling=yes"
55 return ""
56
57def append_libtool_sysroot(d):
58 # Only supply libtool sysroot option for non-native packages
59 if not bb.data.inherits_class('native', d):
60 return '--with-libtool-sysroot=${STAGING_DIR_HOST}'
61 return ""
62
63# EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}"
64
65CONFIGUREOPTS = " --build=${BUILD_SYS} \
66 --host=${HOST_SYS} \
67 --target=${TARGET_SYS} \
68 --prefix=${prefix} \
69 --exec_prefix=${exec_prefix} \
70 --bindir=${bindir} \
71 --sbindir=${sbindir} \
72 --libexecdir=${libexecdir} \
73 --datadir=${datadir} \
74 --sysconfdir=${sysconfdir} \
75 --sharedstatedir=${sharedstatedir} \
76 --localstatedir=${localstatedir} \
77 --libdir=${libdir} \
78 --includedir=${includedir} \
79 --oldincludedir=${oldincludedir} \
80 --infodir=${infodir} \
81 --mandir=${mandir} \
82 --disable-silent-rules \
83 ${CONFIGUREOPT_DEPTRACK} \
84 ${@append_libtool_sysroot(d)}"
85CONFIGUREOPT_DEPTRACK = "--disable-dependency-tracking"
86
87
88oe_runconf () {
89 cfgscript="${S}/configure"
90 if [ -x "$cfgscript" ] ; then
91 bbnote "Running $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} $@"
92 set +e
93 ${CACHED_CONFIGUREVARS} $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"
94 if [ "$?" != "0" ]; then
95 echo "Configure failed. The contents of all config.log files follows to aid debugging"
96 find ${S} -name config.log -print -exec cat {} \;
97 bbfatal "oe_runconf failed"
98 fi
99 set -e
100 else
101 bbfatal "no configure script found at $cfgscript"
102 fi
103}
104
105AUTOTOOLS_AUXDIR ?= "${S}"
106
107CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate"
108
109autotools_preconfigure() {
110 if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then
111 if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then
112 if [ "${S}" != "${B}" ]; then
113 echo "Previously configured separate build directory detected, cleaning ${B}"
114 rm -rf ${B}
115 mkdir ${B}
116 else
117 # At least remove the .la files since automake won't automatically
118 # regenerate them even if CFLAGS/LDFLAGS are different
119 cd ${S}; find ${S} -name \*.la -delete
120 fi
121 fi
122 fi
123}
124
125autotools_postconfigure(){
126 if [ -n "${CONFIGURESTAMPFILE}" ]; then
127 echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE}
128 fi
129}
130
131EXTRACONFFUNCS ??= ""
132
133do_configure[prefuncs] += "autotools_preconfigure ${EXTRACONFFUNCS}"
134do_configure[postfuncs] += "autotools_postconfigure"
135
136ACLOCALDIR = "${B}/aclocal-copy"
137
138autotools_copy_aclocal () {
139 # Remove any previous copy of the m4 macros
140 rm -rf ${ACLOCALDIR}/
141
142 # The aclocal directory could get modified by other processes
143 # uninstalling data from the sysroot. See Yocto #861 for details.
144 # We avoid this by taking a copy here and then files cannot disappear.
145 # We copy native first, then target. This avoids certain races since cp-noerror
146 # won't overwrite existing files.
147 mkdir -p ${ACLOCALDIR}/
148 if [ -d ${STAGING_DATADIR_NATIVE}/aclocal ]; then
149 cp-noerror ${STAGING_DATADIR_NATIVE}/aclocal/ ${ACLOCALDIR}/
150 fi
151 if [ -d ${STAGING_DATADIR}/aclocal -a "${STAGING_DATADIR_NATIVE}/aclocal" != "${STAGING_DATADIR}/aclocal" ]; then
152 cp-noerror ${STAGING_DATADIR}/aclocal/ ${ACLOCALDIR}/
153 fi
154}
155
156autotools_do_configure() {
157 # WARNING: gross hack follows:
158 # An autotools built package generally needs these scripts, however only
159 # automake or libtoolize actually install the current versions of them.
160 # This is a problem in builds that do not use libtool or automake, in the case
161 # where we -need- the latest version of these scripts. e.g. running a build
162 # for a package whose autotools are old, on an x86_64 machine, which the old
163 # config.sub does not support. Work around this by installing them manually
164 # regardless.
165 ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do
166 rm -f `dirname $ac`/configure
167 done )
168 if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
169 olddir=`pwd`
170 cd ${S}
171 autotools_copy_aclocal
172 ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/"
173 if [ x"${acpaths}" = xdefault ]; then
174 acpaths=
175 for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
176 grep -v 'acinclude.m4' | grep -v 'aclocal-copy' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
177 acpaths="$acpaths -I $i"
178 done
179 else
180 acpaths="${acpaths}"
181 fi
182 AUTOV=`automake --version |head -n 1 |sed "s/.* //;s/\.[0-9]\+$//"`
183 automake --version
184 echo "AUTOV is $AUTOV"
185 if [ -d ${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV ]; then
186 ACLOCAL="$ACLOCAL --automake-acdir=${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV"
187 fi
188 # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
189 # like it was auto-generated. Work around this by blowing it away
190 # by hand, unless the package specifically asked not to run aclocal.
191 if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
192 rm -f aclocal.m4
193 fi
194 if [ -e configure.in ]; then
195 CONFIGURE_AC=configure.in
196 else
197 CONFIGURE_AC=configure.ac
198 fi
199 if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
200 if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
201 : do nothing -- we still have an old unmodified configure.ac
202 else
203 bbnote Executing glib-gettextize --force --copy
204 echo "no" | glib-gettextize --force --copy
205 fi
206 else if grep "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
207 # We'd call gettextize here if it wasn't so broken...
208 cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/
209 if [ -d ${S}/po/ ]; then
210 cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/
211 if [ ! -e ${S}/po/remove-potcdate.sin ]; then
212 cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sin ${S}/po/
213 fi
214 fi
215 for i in gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4; do
216 for j in `find ${S} -name $i | grep -v aclocal-copy`; do
217 rm $j
218 done
219 done
220 fi
221 fi
222 mkdir -p m4
223 if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
224 bbnote Executing intltoolize --copy --force --automake
225 intltoolize --copy --force --automake
226 fi
227 bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
228 ACLOCAL="$ACLOCAL" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || bbfatal "autoreconf execution failed."
229 cd $olddir
230 fi
231 if [ -e ${S}/configure ]; then
232 oe_runconf
233 else
234 bbnote "nothing to configure"
235 fi
236}
237
238autotools_do_install() {
239 oe_runmake 'DESTDIR=${D}' install
240 # Info dir listing isn't interesting at this point so remove it if it exists.
241 if [ -e "${D}${infodir}/dir" ]; then
242 rm -f ${D}${infodir}/dir
243 fi
244}
245
246inherit siteconfig
247
248EXPORT_FUNCTIONS do_configure do_install