diff options
Diffstat (limited to 'meta/classes/autotools.bbclass')
-rw-r--r-- | meta/classes/autotools.bbclass | 302 |
1 files changed, 302 insertions, 0 deletions
diff --git a/meta/classes/autotools.bbclass b/meta/classes/autotools.bbclass new file mode 100644 index 0000000000..b5f45160ed --- /dev/null +++ b/meta/classes/autotools.bbclass | |||
@@ -0,0 +1,302 @@ | |||
1 | def 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 | |||
22 | EXTRA_OEMAKE = "" | ||
23 | |||
24 | DEPENDS_prepend = "${@autotools_dep_prepend(d)}" | ||
25 | |||
26 | inherit 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. | ||
30 | export CONFIG_SITE = "${@siteinfo_get_files(d)}" | ||
31 | |||
32 | acpaths = "default" | ||
33 | EXTRA_AUTORECONF = "--exclude=autopoint" | ||
34 | |||
35 | export 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) | ||
40 | export CPP_FOR_BUILD = "${BUILD_CPP}" | ||
41 | export CPPFLAGS_FOR_BUILD = "${BUILD_CPPFLAGS}" | ||
42 | |||
43 | export CC_FOR_BUILD = "${BUILD_CC}" | ||
44 | export CFLAGS_FOR_BUILD = "${BUILD_CFLAGS}" | ||
45 | |||
46 | export CXX_FOR_BUILD = "${BUILD_CXX}" | ||
47 | export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}" | ||
48 | |||
49 | export LD_FOR_BUILD = "${BUILD_LD}" | ||
50 | export LDFLAGS_FOR_BUILD = "${BUILD_LDFLAGS}" | ||
51 | |||
52 | def append_libtool_sysroot(d): | ||
53 | # Only supply libtool sysroot option for non-native packages | ||
54 | if not bb.data.inherits_class('native', d): | ||
55 | return '--with-libtool-sysroot=${STAGING_DIR_HOST}' | ||
56 | return "" | ||
57 | |||
58 | CONFIGUREOPTS = " --build=${BUILD_SYS} \ | ||
59 | --host=${HOST_SYS} \ | ||
60 | --target=${TARGET_SYS} \ | ||
61 | --prefix=${prefix} \ | ||
62 | --exec_prefix=${exec_prefix} \ | ||
63 | --bindir=${bindir} \ | ||
64 | --sbindir=${sbindir} \ | ||
65 | --libexecdir=${libexecdir} \ | ||
66 | --datadir=${datadir} \ | ||
67 | --sysconfdir=${sysconfdir} \ | ||
68 | --sharedstatedir=${sharedstatedir} \ | ||
69 | --localstatedir=${localstatedir} \ | ||
70 | --libdir=${libdir} \ | ||
71 | --includedir=${includedir} \ | ||
72 | --oldincludedir=${oldincludedir} \ | ||
73 | --infodir=${infodir} \ | ||
74 | --mandir=${mandir} \ | ||
75 | --disable-silent-rules \ | ||
76 | ${CONFIGUREOPT_DEPTRACK} \ | ||
77 | ${@append_libtool_sysroot(d)}" | ||
78 | CONFIGUREOPT_DEPTRACK = "--disable-dependency-tracking" | ||
79 | |||
80 | |||
81 | oe_runconf () { | ||
82 | cfgscript="${S}/configure" | ||
83 | if [ -x "$cfgscript" ] ; then | ||
84 | bbnote "Running $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} $@" | ||
85 | set +e | ||
86 | ${CACHED_CONFIGUREVARS} $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@" | ||
87 | if [ "$?" != "0" ]; then | ||
88 | echo "Configure failed. The contents of all config.log files follows to aid debugging" | ||
89 | find ${S} -ignore_readdir_race -name config.log -print -exec cat {} \; | ||
90 | bbfatal "oe_runconf failed" | ||
91 | fi | ||
92 | set -e | ||
93 | else | ||
94 | bbfatal "no configure script found at $cfgscript" | ||
95 | fi | ||
96 | } | ||
97 | |||
98 | AUTOTOOLS_AUXDIR ?= "${S}" | ||
99 | |||
100 | CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate" | ||
101 | |||
102 | autotools_preconfigure() { | ||
103 | if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then | ||
104 | if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then | ||
105 | if [ "${S}" != "${B}" ]; then | ||
106 | echo "Previously configured separate build directory detected, cleaning ${B}" | ||
107 | rm -rf ${B} | ||
108 | mkdir ${B} | ||
109 | else | ||
110 | # At least remove the .la files since automake won't automatically | ||
111 | # regenerate them even if CFLAGS/LDFLAGS are different | ||
112 | cd ${S}; find ${S} -name \*.la -delete | ||
113 | fi | ||
114 | fi | ||
115 | fi | ||
116 | } | ||
117 | |||
118 | autotools_postconfigure(){ | ||
119 | if [ -n "${CONFIGURESTAMPFILE}" ]; then | ||
120 | echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE} | ||
121 | fi | ||
122 | } | ||
123 | |||
124 | EXTRACONFFUNCS ??= "" | ||
125 | |||
126 | do_configure[prefuncs] += "autotools_preconfigure autotools_copy_aclocals ${EXTRACONFFUNCS}" | ||
127 | do_configure[postfuncs] += "autotools_postconfigure" | ||
128 | |||
129 | ACLOCALDIR = "${B}/aclocal-copy" | ||
130 | |||
131 | python autotools_copy_aclocals () { | ||
132 | s = d.getVar("S", True) | ||
133 | if not os.path.exists(s + "/configure.in") and not os.path.exists(s + "/configure.ac"): | ||
134 | if not d.getVar("AUTOTOOLS_COPYACLOCAL"): | ||
135 | return | ||
136 | |||
137 | taskdepdata = d.getVar("BB_TASKDEPDATA", False) | ||
138 | #bb.warn(str(taskdepdata)) | ||
139 | pn = d.getVar("PN", True) | ||
140 | aclocaldir = d.getVar("ACLOCALDIR", True) | ||
141 | oe.path.remove(aclocaldir) | ||
142 | bb.utils.mkdirhier(aclocaldir) | ||
143 | start = None | ||
144 | configuredeps = [] | ||
145 | |||
146 | for dep in taskdepdata: | ||
147 | data = taskdepdata[dep] | ||
148 | if data[1] == "do_configure" and data[0] == pn: | ||
149 | start = dep | ||
150 | break | ||
151 | if start is None: | ||
152 | bb.fatal("Couldn't find ourself in BB_TASKDEPDATA?") | ||
153 | |||
154 | # We need to find configure tasks which are either from <target> -> <target> | ||
155 | # or <native> -> <native> but not <target> -> <native> unless they're direct | ||
156 | # dependencies. This mirrors what would get restored from sstate. | ||
157 | done = [dep] | ||
158 | next = [dep] | ||
159 | while next: | ||
160 | new = [] | ||
161 | for dep in next: | ||
162 | data = taskdepdata[dep] | ||
163 | for datadep in data[3]: | ||
164 | if datadep in done: | ||
165 | continue | ||
166 | done.append(datadep) | ||
167 | if (not data[0].endswith("-native")) and taskdepdata[datadep][0].endswith("-native") and dep != start: | ||
168 | continue | ||
169 | new.append(datadep) | ||
170 | if taskdepdata[datadep][1] == "do_configure": | ||
171 | configuredeps.append(taskdepdata[datadep][0]) | ||
172 | next = new | ||
173 | |||
174 | #configuredeps2 = [] | ||
175 | #for dep in taskdepdata: | ||
176 | # data = taskdepdata[dep] | ||
177 | # if data[1] == "do_configure" and data[0] != pn: | ||
178 | # configuredeps2.append(data[0]) | ||
179 | #configuredeps.sort() | ||
180 | #configuredeps2.sort() | ||
181 | #bb.warn(str(configuredeps)) | ||
182 | #bb.warn(str(configuredeps2)) | ||
183 | |||
184 | cp = [] | ||
185 | for c in configuredeps: | ||
186 | if c.endswith("-native"): | ||
187 | manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${BUILD_ARCH}-%s.populate_sysroot" % c) | ||
188 | elif c.startswith("nativesdk-"): | ||
189 | manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${SDK_ARCH}_${SDK_OS}-%s.populate_sysroot" % c) | ||
190 | elif "-cross-" in c or "-crosssdk" in c: | ||
191 | continue | ||
192 | else: | ||
193 | manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${MACHINE}-%s.populate_sysroot" % c) | ||
194 | try: | ||
195 | f = open(manifest, "r") | ||
196 | for l in f: | ||
197 | if "/aclocal/" in l and l.strip().endswith(".m4"): | ||
198 | cp.append(l.strip()) | ||
199 | except: | ||
200 | bb.warn("%s not found" % manifest) | ||
201 | |||
202 | for c in cp: | ||
203 | t = os.path.join(aclocaldir, os.path.basename(c)) | ||
204 | if not os.path.exists(t): | ||
205 | os.symlink(c, t) | ||
206 | } | ||
207 | autotools_copy_aclocals[vardepsexclude] += "MACHINE SDK_ARCH BUILD_ARCH SDK_OS BB_TASKDEPDATA" | ||
208 | |||
209 | autotools_do_configure() { | ||
210 | # WARNING: gross hack follows: | ||
211 | # An autotools built package generally needs these scripts, however only | ||
212 | # automake or libtoolize actually install the current versions of them. | ||
213 | # This is a problem in builds that do not use libtool or automake, in the case | ||
214 | # where we -need- the latest version of these scripts. e.g. running a build | ||
215 | # for a package whose autotools are old, on an x86_64 machine, which the old | ||
216 | # config.sub does not support. Work around this by installing them manually | ||
217 | # regardless. | ||
218 | ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do | ||
219 | rm -f `dirname $ac`/configure | ||
220 | done ) | ||
221 | if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then | ||
222 | olddir=`pwd` | ||
223 | cd ${S} | ||
224 | ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/" | ||
225 | if [ x"${acpaths}" = xdefault ]; then | ||
226 | acpaths= | ||
227 | for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \ | ||
228 | grep -v 'acinclude.m4' | grep -v 'aclocal-copy' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do | ||
229 | acpaths="$acpaths -I $i" | ||
230 | done | ||
231 | else | ||
232 | acpaths="${acpaths}" | ||
233 | fi | ||
234 | AUTOV=`automake --version | sed -e '1{s/.* //;s/\.[0-9]\+$//};q'` | ||
235 | automake --version | ||
236 | echo "AUTOV is $AUTOV" | ||
237 | if [ -d ${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV ]; then | ||
238 | ACLOCAL="$ACLOCAL --automake-acdir=${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV" | ||
239 | fi | ||
240 | # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look | ||
241 | # like it was auto-generated. Work around this by blowing it away | ||
242 | # by hand, unless the package specifically asked not to run aclocal. | ||
243 | if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then | ||
244 | rm -f aclocal.m4 | ||
245 | fi | ||
246 | if [ -e configure.in ]; then | ||
247 | CONFIGURE_AC=configure.in | ||
248 | else | ||
249 | CONFIGURE_AC=configure.ac | ||
250 | fi | ||
251 | if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then | ||
252 | if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then | ||
253 | : do nothing -- we still have an old unmodified configure.ac | ||
254 | else | ||
255 | bbnote Executing glib-gettextize --force --copy | ||
256 | echo "no" | glib-gettextize --force --copy | ||
257 | fi | ||
258 | else if grep "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then | ||
259 | # We'd call gettextize here if it wasn't so broken... | ||
260 | cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/ | ||
261 | if [ -d ${S}/po/ ]; then | ||
262 | cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/ | ||
263 | if [ ! -e ${S}/po/remove-potcdate.sin ]; then | ||
264 | cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sin ${S}/po/ | ||
265 | fi | ||
266 | fi | ||
267 | for i in gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4; do | ||
268 | for j in `find ${S} -name $i | grep -v aclocal-copy`; do | ||
269 | rm $j | ||
270 | done | ||
271 | done | ||
272 | fi | ||
273 | fi | ||
274 | mkdir -p m4 | ||
275 | if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then | ||
276 | bbnote Executing intltoolize --copy --force --automake | ||
277 | intltoolize --copy --force --automake | ||
278 | fi | ||
279 | bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths | ||
280 | ACLOCAL="$ACLOCAL" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || bbfatal "autoreconf execution failed." | ||
281 | cd $olddir | ||
282 | fi | ||
283 | if [ -e ${S}/configure ]; then | ||
284 | oe_runconf | ||
285 | else | ||
286 | bbnote "nothing to configure" | ||
287 | fi | ||
288 | } | ||
289 | |||
290 | autotools_do_install() { | ||
291 | oe_runmake 'DESTDIR=${D}' install | ||
292 | # Info dir listing isn't interesting at this point so remove it if it exists. | ||
293 | if [ -e "${D}${infodir}/dir" ]; then | ||
294 | rm -f ${D}${infodir}/dir | ||
295 | fi | ||
296 | } | ||
297 | |||
298 | inherit siteconfig | ||
299 | |||
300 | EXPORT_FUNCTIONS do_configure do_install | ||
301 | |||
302 | B = "${WORKDIR}/build" | ||