blob: 6649f5df71a411d5bfc48272b57e396baac67caa [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
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, False)}"
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 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
58CONFIGUREOPTS = " --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)}"
78CONFIGUREOPT_DEPTRACK ?= "--disable-dependency-tracking"
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}`"
88 cfgscript=`python -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
132do_configure[prefuncs] += "autotools_preconfigure autotools_copy_aclocals ${EXTRACONFFUNCS}"
133do_configure[postfuncs] += "autotools_postconfigure"
134
135ACLOCALDIR = "${B}/aclocal-copy"
136
137python autotools_copy_aclocals () {
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500138 s = d.getVar("AUTOTOOLS_SCRIPT_PATH", True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500139 if not os.path.exists(s + "/configure.in") and not os.path.exists(s + "/configure.ac"):
140 if not d.getVar("AUTOTOOLS_COPYACLOCAL", False):
141 return
142
143 taskdepdata = d.getVar("BB_TASKDEPDATA", False)
144 #bb.warn(str(taskdepdata))
145 pn = d.getVar("PN", True)
146 aclocaldir = d.getVar("ACLOCALDIR", True)
147 oe.path.remove(aclocaldir)
148 bb.utils.mkdirhier(aclocaldir)
149 start = None
150 configuredeps = []
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500151 # Detect bitbake -b usage
152 # Everything but quilt-native would have dependencies
153 nodeps = (pn != "quilt-native")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500154
155 for dep in taskdepdata:
156 data = taskdepdata[dep]
157 if data[1] == "do_configure" and data[0] == pn:
158 start = dep
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500159 if not nodeps and start:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500160 break
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500161 if nodeps and data[0] != pn:
162 nodeps = False
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500163 if start is None:
164 bb.fatal("Couldn't find ourself in BB_TASKDEPDATA?")
165
166 # We need to find configure tasks which are either from <target> -> <target>
167 # or <native> -> <native> but not <target> -> <native> unless they're direct
168 # dependencies. This mirrors what would get restored from sstate.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500169 done = [start]
170 next = [start]
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171 while next:
172 new = []
173 for dep in next:
174 data = taskdepdata[dep]
175 for datadep in data[3]:
176 if datadep in done:
177 continue
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500178 if (not data[0].endswith("-native")) and taskdepdata[datadep][0].endswith("-native") and dep != start:
179 continue
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500180 done.append(datadep)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500181 new.append(datadep)
182 if taskdepdata[datadep][1] == "do_configure":
183 configuredeps.append(taskdepdata[datadep][0])
184 next = new
185
186 #configuredeps2 = []
187 #for dep in taskdepdata:
188 # data = taskdepdata[dep]
189 # if data[1] == "do_configure" and data[0] != pn:
190 # configuredeps2.append(data[0])
191 #configuredeps.sort()
192 #configuredeps2.sort()
193 #bb.warn(str(configuredeps))
194 #bb.warn(str(configuredeps2))
195
196 cp = []
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500197 if nodeps:
198 bb.warn("autotools: Unable to find task dependencies, -b being used? Pulling in all m4 files")
199 for l in [d.expand("${STAGING_DATADIR_NATIVE}/aclocal/"), d.expand("${STAGING_DATADIR}/aclocal/")]:
200 cp.extend(os.path.join(l, f) for f in os.listdir(l))
201
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500202 for c in configuredeps:
203 if c.endswith("-native"):
204 manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${BUILD_ARCH}-%s.populate_sysroot" % c)
205 elif c.startswith("nativesdk-"):
206 manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${SDK_ARCH}_${SDK_OS}-%s.populate_sysroot" % c)
207 elif "-cross-" in c or "-crosssdk" in c:
208 continue
209 else:
210 manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${MACHINE}-%s.populate_sysroot" % c)
211 try:
212 f = open(manifest, "r")
213 for l in f:
214 if "/aclocal/" in l and l.strip().endswith(".m4"):
215 cp.append(l.strip())
216 elif "config_site.d/" in l:
217 cp.append(l.strip())
218 except:
219 bb.warn("%s not found" % manifest)
220
221 for c in cp:
222 t = os.path.join(aclocaldir, os.path.basename(c))
223 if not os.path.exists(t):
224 os.symlink(c, t)
225
226 d.setVar("CONFIG_SITE", siteinfo_get_files(d, False))
227}
228autotools_copy_aclocals[vardepsexclude] += "MACHINE SDK_ARCH BUILD_ARCH SDK_OS BB_TASKDEPDATA"
229
230autotools_do_configure() {
231 # WARNING: gross hack follows:
232 # An autotools built package generally needs these scripts, however only
233 # automake or libtoolize actually install the current versions of them.
234 # This is a problem in builds that do not use libtool or automake, in the case
235 # where we -need- the latest version of these scripts. e.g. running a build
236 # for a package whose autotools are old, on an x86_64 machine, which the old
237 # config.sub does not support. Work around this by installing them manually
238 # regardless.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500239 for ac in `find ${S} -ignore_readdir_race -name configure.in -o -name configure.ac`; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500240 rm -f `dirname $ac`/configure
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500241 done
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500242 if [ -e ${AUTOTOOLS_SCRIPT_PATH}/configure.in -o -e ${AUTOTOOLS_SCRIPT_PATH}/configure.ac ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500243 olddir=`pwd`
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500244 cd ${AUTOTOOLS_SCRIPT_PATH}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500245 ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/"
246 if [ x"${acpaths}" = xdefault ]; then
247 acpaths=
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500248 for i in `find ${AUTOTOOLS_SCRIPT_PATH} -ignore_readdir_race -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500249 grep -v 'acinclude.m4' | grep -v 'aclocal-copy' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
250 acpaths="$acpaths -I $i"
251 done
252 else
253 acpaths="${acpaths}"
254 fi
255 AUTOV=`automake --version | sed -e '1{s/.* //;s/\.[0-9]\+$//};q'`
256 automake --version
257 echo "AUTOV is $AUTOV"
258 if [ -d ${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV ]; then
259 ACLOCAL="$ACLOCAL --automake-acdir=${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV"
260 fi
261 # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
262 # like it was auto-generated. Work around this by blowing it away
263 # by hand, unless the package specifically asked not to run aclocal.
264 if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
265 rm -f aclocal.m4
266 fi
267 if [ -e configure.in ]; then
268 CONFIGURE_AC=configure.in
269 else
270 CONFIGURE_AC=configure.ac
271 fi
272 if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
273 if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
274 : do nothing -- we still have an old unmodified configure.ac
275 else
276 bbnote Executing glib-gettextize --force --copy
277 echo "no" | glib-gettextize --force --copy
278 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500279 elif grep "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500280 # We'd call gettextize here if it wasn't so broken...
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500281 cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/
282 if [ -d ${S}/po/ ]; then
283 cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/
284 if [ ! -e ${S}/po/remove-potcdate.sin ]; then
285 cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sin ${S}/po/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500286 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500287 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500288 for i in gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4; do
289 for j in `find ${S} -ignore_readdir_race -name $i | grep -v aclocal-copy`; do
290 rm $j
291 done
292 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500293 fi
294 mkdir -p m4
295 if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
296 bbnote Executing intltoolize --copy --force --automake
297 intltoolize --copy --force --automake
298 fi
299 bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
300 ACLOCAL="$ACLOCAL" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || die "autoreconf execution failed."
301 cd $olddir
302 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500303 if [ -e ${CONFIGURE_SCRIPT} ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500304 oe_runconf
305 else
306 bbnote "nothing to configure"
307 fi
308}
309
310autotools_do_install() {
311 oe_runmake 'DESTDIR=${D}' install
312 # Info dir listing isn't interesting at this point so remove it if it exists.
313 if [ -e "${D}${infodir}/dir" ]; then
314 rm -f ${D}${infodir}/dir
315 fi
316}
317
318inherit siteconfig
319
320EXPORT_FUNCTIONS do_configure do_install
321
322B = "${WORKDIR}/build"