blob: c43ea9a7efb4913e7dbba2bb58a7dda3e55228a3 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001def 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
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022DEPENDS_prepend = "${@autotools_dep_prepend(d)} "
23
24inherit siteinfo
25
26# Space separated list of shell scripts with variables defined to supply test
27# results for autoconf tests we cannot run at build time.
Patrick Williamsc0f7c042017-02-23 20:41:17 -060028export CONFIG_SITE = "${@siteinfo_get_files(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029
30acpaths = "default"
31EXTRA_AUTORECONF = "--exclude=autopoint"
32
33export lt_cv_sys_lib_dlsearch_path_spec = "${libdir} ${base_libdir}"
34
35# When building tools for use at build-time it's recommended for the build
36# system to use these variables when cross-compiling.
37# (http://sources.redhat.com/autobook/autobook/autobook_270.html)
38export CPP_FOR_BUILD = "${BUILD_CPP}"
39export CPPFLAGS_FOR_BUILD = "${BUILD_CPPFLAGS}"
40
41export CC_FOR_BUILD = "${BUILD_CC}"
42export CFLAGS_FOR_BUILD = "${BUILD_CFLAGS}"
43
44export CXX_FOR_BUILD = "${BUILD_CXX}"
45export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
46
47export LD_FOR_BUILD = "${BUILD_LD}"
48export LDFLAGS_FOR_BUILD = "${BUILD_LDFLAGS}"
49
50def append_libtool_sysroot(d):
51 # Only supply libtool sysroot option for non-native packages
52 if not bb.data.inherits_class('native', d):
53 return '--with-libtool-sysroot=${STAGING_DIR_HOST}'
54 return ""
55
56CONFIGUREOPTS = " --build=${BUILD_SYS} \
57 --host=${HOST_SYS} \
58 --target=${TARGET_SYS} \
59 --prefix=${prefix} \
60 --exec_prefix=${exec_prefix} \
61 --bindir=${bindir} \
62 --sbindir=${sbindir} \
63 --libexecdir=${libexecdir} \
64 --datadir=${datadir} \
65 --sysconfdir=${sysconfdir} \
66 --sharedstatedir=${sharedstatedir} \
67 --localstatedir=${localstatedir} \
68 --libdir=${libdir} \
69 --includedir=${includedir} \
70 --oldincludedir=${oldincludedir} \
71 --infodir=${infodir} \
72 --mandir=${mandir} \
73 --disable-silent-rules \
74 ${CONFIGUREOPT_DEPTRACK} \
75 ${@append_libtool_sysroot(d)}"
76CONFIGUREOPT_DEPTRACK ?= "--disable-dependency-tracking"
77
Patrick Williamsc0f7c042017-02-23 20:41:17 -060078CACHED_CONFIGUREVARS ?= ""
79
Patrick Williamsf1e5d692016-03-30 15:21:19 -050080AUTOTOOLS_SCRIPT_PATH ?= "${S}"
81CONFIGURE_SCRIPT ?= "${AUTOTOOLS_SCRIPT_PATH}/configure"
82
83AUTOTOOLS_AUXDIR ?= "${AUTOTOOLS_SCRIPT_PATH}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084
85oe_runconf () {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050086 # Use relative path to avoid buildpaths in files
87 cfgscript_name="`basename ${CONFIGURE_SCRIPT}`"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060088 cfgscript=`python3 -c "import os; print(os.path.relpath(os.path.dirname('${CONFIGURE_SCRIPT}'), '.'))"`/$cfgscript_name
Patrick Williamsc124f4f2015-09-15 14:41:29 -050089 if [ -x "$cfgscript" ] ; then
90 bbnote "Running $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} $@"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050091 if ! ${CACHED_CONFIGUREVARS} $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"; then
92 bbnote "The following config.log files may provide further information."
93 bbnote `find ${B} -ignore_readdir_race -type f -name config.log`
94 bbfatal_log "configure failed"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050096 else
97 bbfatal "no configure script found at $cfgscript"
98 fi
99}
100
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500101CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate"
102
103autotools_preconfigure() {
104 if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then
105 if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then
106 if [ "${S}" != "${B}" ]; then
107 echo "Previously configured separate build directory detected, cleaning ${B}"
108 rm -rf ${B}
Patrick Williamsd7e96312015-09-22 08:09:05 -0500109 mkdir -p ${B}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500110 else
111 # At least remove the .la files since automake won't automatically
112 # regenerate them even if CFLAGS/LDFLAGS are different
113 cd ${S}
114 if [ "${CLEANBROKEN}" != "1" -a \( -e Makefile -o -e makefile -o -e GNUmakefile \) ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500115 oe_runmake clean
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500116 fi
117 find ${S} -ignore_readdir_race -name \*.la -delete
118 fi
119 fi
120 fi
121}
122
123autotools_postconfigure(){
124 if [ -n "${CONFIGURESTAMPFILE}" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500125 mkdir -p `dirname ${CONFIGURESTAMPFILE}`
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500126 echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE}
127 fi
128}
129
130EXTRACONFFUNCS ??= ""
131
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600132EXTRA_OECONF_append = " ${PACKAGECONFIG_CONFARGS}"
133
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500134do_configure[prefuncs] += "autotools_preconfigure autotools_copy_aclocals ${EXTRACONFFUNCS}"
135do_configure[postfuncs] += "autotools_postconfigure"
136
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600137ACLOCALDIR = "${WORKDIR}/aclocal-copy"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500138
139python autotools_copy_aclocals () {
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600140 import copy
141
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500142 s = d.getVar("AUTOTOOLS_SCRIPT_PATH", True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500143 if not os.path.exists(s + "/configure.in") and not os.path.exists(s + "/configure.ac"):
144 if not d.getVar("AUTOTOOLS_COPYACLOCAL", False):
145 return
146
147 taskdepdata = d.getVar("BB_TASKDEPDATA", False)
148 #bb.warn(str(taskdepdata))
149 pn = d.getVar("PN", True)
150 aclocaldir = d.getVar("ACLOCALDIR", True)
151 oe.path.remove(aclocaldir)
152 bb.utils.mkdirhier(aclocaldir)
153 start = None
154 configuredeps = []
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500155 # Detect bitbake -b usage
156 # Everything but quilt-native would have dependencies
157 nodeps = (pn != "quilt-native")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500158
159 for dep in taskdepdata:
160 data = taskdepdata[dep]
161 if data[1] == "do_configure" and data[0] == pn:
162 start = dep
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500163 if not nodeps and start:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500164 break
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500165 if nodeps and data[0] != pn:
166 nodeps = False
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500167 if start is None:
168 bb.fatal("Couldn't find ourself in BB_TASKDEPDATA?")
169
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600170 # We need to figure out which m4 files we need to expose to this do_configure task.
171 # This needs to match what would get restored from sstate, which is controlled
172 # ultimately by calls from bitbake to setscene_depvalid().
173 # That function expects a setscene dependency tree. We build a dependency tree
174 # condensed to do_populate_sysroot -> do_populate_sysroot dependencies, similar to
175 # that used by setscene tasks. We can then call into setscene_depvalid() and decide
176 # which dependencies we can "see" and should expose the m4 files for.
177 setscenedeps = copy.deepcopy(taskdepdata)
178
179 start = set([start])
180
181 # Create collapsed do_populate_sysroot -> do_populate_sysroot tree
182 for dep in taskdepdata:
183 data = setscenedeps[dep]
184 if data[1] != "do_populate_sysroot":
185 for dep2 in setscenedeps:
186 data2 = setscenedeps[dep2]
187 if dep in data2[3]:
188 data2[3].update(setscenedeps[dep][3])
189 data2[3].remove(dep)
190 if dep in start:
191 start.update(setscenedeps[dep][3])
192 start.remove(dep)
193 del setscenedeps[dep]
194
195 # Remove circular references
196 for dep in setscenedeps:
197 if dep in setscenedeps[dep][3]:
198 setscenedeps[dep][3].remove(dep)
199
200 # Direct dependencies should be present and can be depended upon
201 for dep in start:
202 configuredeps.append(setscenedeps[dep][0])
203
204 # Call into setscene_depvalid for each sub-dependency and only copy m4 files
205 # for ones that would be restored from sstate.
206 done = list(start)
207 next = list(start)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500208 while next:
209 new = []
210 for dep in next:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600211 data = setscenedeps[dep]
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500212 for datadep in data[3]:
213 if datadep in done:
214 continue
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600215 taskdeps = {}
216 taskdeps[dep] = setscenedeps[dep][:2]
217 taskdeps[datadep] = setscenedeps[datadep][:2]
218 retval = setscene_depvalid(datadep, taskdeps, [], d)
219 if retval:
220 bb.note("Skipping setscene dependency %s for m4 macro copying" % datadep)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500221 continue
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500222 done.append(datadep)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500223 new.append(datadep)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600224 configuredeps.append(setscenedeps[datadep][0])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500225 next = new
226
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500227 cp = []
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500228 if nodeps:
229 bb.warn("autotools: Unable to find task dependencies, -b being used? Pulling in all m4 files")
230 for l in [d.expand("${STAGING_DATADIR_NATIVE}/aclocal/"), d.expand("${STAGING_DATADIR}/aclocal/")]:
231 cp.extend(os.path.join(l, f) for f in os.listdir(l))
232
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500233 for c in configuredeps:
234 if c.endswith("-native"):
235 manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${BUILD_ARCH}-%s.populate_sysroot" % c)
236 elif c.startswith("nativesdk-"):
237 manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${SDK_ARCH}_${SDK_OS}-%s.populate_sysroot" % c)
238 elif "-cross-" in c or "-crosssdk" in c:
239 continue
240 else:
241 manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${MACHINE}-%s.populate_sysroot" % c)
242 try:
243 f = open(manifest, "r")
244 for l in f:
245 if "/aclocal/" in l and l.strip().endswith(".m4"):
246 cp.append(l.strip())
247 elif "config_site.d/" in l:
248 cp.append(l.strip())
249 except:
250 bb.warn("%s not found" % manifest)
251
252 for c in cp:
253 t = os.path.join(aclocaldir, os.path.basename(c))
254 if not os.path.exists(t):
255 os.symlink(c, t)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600256
257 # Refresh variable with cache files
258 d.setVar("CONFIG_SITE", siteinfo_get_files(d, aclocalcache=True))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500259}
260autotools_copy_aclocals[vardepsexclude] += "MACHINE SDK_ARCH BUILD_ARCH SDK_OS BB_TASKDEPDATA"
261
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600262CONFIGURE_FILES = "${S}/configure.in ${S}/configure.ac ${S}/config.h.in ${S}/acinclude.m4 Makefile.am"
263
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500264autotools_do_configure() {
265 # WARNING: gross hack follows:
266 # An autotools built package generally needs these scripts, however only
267 # automake or libtoolize actually install the current versions of them.
268 # This is a problem in builds that do not use libtool or automake, in the case
269 # where we -need- the latest version of these scripts. e.g. running a build
270 # for a package whose autotools are old, on an x86_64 machine, which the old
271 # config.sub does not support. Work around this by installing them manually
272 # regardless.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600273
274 PRUNE_M4=""
275
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500276 for ac in `find ${S} -ignore_readdir_race -name configure.in -o -name configure.ac`; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500277 rm -f `dirname $ac`/configure
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500278 done
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500279 if [ -e ${AUTOTOOLS_SCRIPT_PATH}/configure.in -o -e ${AUTOTOOLS_SCRIPT_PATH}/configure.ac ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500280 olddir=`pwd`
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500281 cd ${AUTOTOOLS_SCRIPT_PATH}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500282 ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/"
283 if [ x"${acpaths}" = xdefault ]; then
284 acpaths=
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500285 for i in `find ${AUTOTOOLS_SCRIPT_PATH} -ignore_readdir_race -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600286 grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500287 acpaths="$acpaths -I $i"
288 done
289 else
290 acpaths="${acpaths}"
291 fi
292 AUTOV=`automake --version | sed -e '1{s/.* //;s/\.[0-9]\+$//};q'`
293 automake --version
294 echo "AUTOV is $AUTOV"
295 if [ -d ${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV ]; then
296 ACLOCAL="$ACLOCAL --automake-acdir=${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV"
297 fi
298 # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
299 # like it was auto-generated. Work around this by blowing it away
300 # by hand, unless the package specifically asked not to run aclocal.
301 if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
302 rm -f aclocal.m4
303 fi
304 if [ -e configure.in ]; then
305 CONFIGURE_AC=configure.in
306 else
307 CONFIGURE_AC=configure.ac
308 fi
309 if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
310 if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
311 : do nothing -- we still have an old unmodified configure.ac
312 else
313 bbnote Executing glib-gettextize --force --copy
314 echo "no" | glib-gettextize --force --copy
315 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500316 elif grep "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500317 # We'd call gettextize here if it wasn't so broken...
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500318 cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/
319 if [ -d ${S}/po/ ]; then
320 cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/
321 if [ ! -e ${S}/po/remove-potcdate.sin ]; then
322 cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sin ${S}/po/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500323 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500324 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600325 PRUNE_M4="$PRUNE_M4 gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500326 fi
327 mkdir -p m4
328 if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600329 if ! echo "${DEPENDS}" | grep -q intltool-native; then
330 bbwarn "Missing DEPENDS on intltool-native"
331 fi
332 PRUNE_M4="$PRUNE_M4 intltool.m4"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500333 bbnote Executing intltoolize --copy --force --automake
334 intltoolize --copy --force --automake
335 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600336
337 for i in $PRUNE_M4; do
338 find ${S} -ignore_readdir_race -name $i -delete
339 done
340
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500341 bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
342 ACLOCAL="$ACLOCAL" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || die "autoreconf execution failed."
343 cd $olddir
344 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500345 if [ -e ${CONFIGURE_SCRIPT} ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500346 oe_runconf
347 else
348 bbnote "nothing to configure"
349 fi
350}
351
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600352autotools_do_compile() {
353 oe_runmake
354}
355
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500356autotools_do_install() {
357 oe_runmake 'DESTDIR=${D}' install
358 # Info dir listing isn't interesting at this point so remove it if it exists.
359 if [ -e "${D}${infodir}/dir" ]; then
360 rm -f ${D}${infodir}/dir
361 fi
362}
363
364inherit siteconfig
365
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600366EXPORT_FUNCTIONS do_configure do_compile do_install
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500367
368B = "${WORKDIR}/build"