blob: d546a5c0285dc88aa6908437abe4335dc8c299cb [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 Williamsf1e5d692016-03-30 15:21:19 -050086 cfgscript="${CONFIGURE_SCRIPT}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050087 if [ -x "$cfgscript" ] ; then
88 bbnote "Running $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} $@"
89 set +e
90 ${CACHED_CONFIGUREVARS} $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"
91 if [ "$?" != "0" ]; then
92 echo "Configure failed. The contents of all config.log files follows to aid debugging"
Patrick Williamsf1e5d692016-03-30 15:21:19 -050093 find ${B} -ignore_readdir_race -name config.log -print -exec cat {} \;
Patrick Williamsc124f4f2015-09-15 14:41:29 -050094 die "oe_runconf failed"
95 fi
96 set -e
97 else
98 bbfatal "no configure script found at $cfgscript"
99 fi
100}
101
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate"
103
104autotools_preconfigure() {
105 if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then
106 if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then
107 if [ "${S}" != "${B}" ]; then
108 echo "Previously configured separate build directory detected, cleaning ${B}"
109 rm -rf ${B}
Patrick Williamsd7e96312015-09-22 08:09:05 -0500110 mkdir -p ${B}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111 else
112 # At least remove the .la files since automake won't automatically
113 # regenerate them even if CFLAGS/LDFLAGS are different
114 cd ${S}
115 if [ "${CLEANBROKEN}" != "1" -a \( -e Makefile -o -e makefile -o -e GNUmakefile \) ]; then
116 echo "Running \"${MAKE} clean\" in ${S}"
117 ${MAKE} clean
118 fi
119 find ${S} -ignore_readdir_race -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 autotools_copy_aclocals ${EXTRACONFFUNCS}"
134do_configure[postfuncs] += "autotools_postconfigure"
135
136ACLOCALDIR = "${B}/aclocal-copy"
137
138python autotools_copy_aclocals () {
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500139 s = d.getVar("AUTOTOOLS_SCRIPT_PATH", True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500140 if not os.path.exists(s + "/configure.in") and not os.path.exists(s + "/configure.ac"):
141 if not d.getVar("AUTOTOOLS_COPYACLOCAL", False):
142 return
143
144 taskdepdata = d.getVar("BB_TASKDEPDATA", False)
145 #bb.warn(str(taskdepdata))
146 pn = d.getVar("PN", True)
147 aclocaldir = d.getVar("ACLOCALDIR", True)
148 oe.path.remove(aclocaldir)
149 bb.utils.mkdirhier(aclocaldir)
150 start = None
151 configuredeps = []
152
153 for dep in taskdepdata:
154 data = taskdepdata[dep]
155 if data[1] == "do_configure" and data[0] == pn:
156 start = dep
157 break
158 if start is None:
159 bb.fatal("Couldn't find ourself in BB_TASKDEPDATA?")
160
161 # We need to find configure tasks which are either from <target> -> <target>
162 # or <native> -> <native> but not <target> -> <native> unless they're direct
163 # dependencies. This mirrors what would get restored from sstate.
164 done = [dep]
165 next = [dep]
166 while next:
167 new = []
168 for dep in next:
169 data = taskdepdata[dep]
170 for datadep in data[3]:
171 if datadep in done:
172 continue
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500173 if (not data[0].endswith("-native")) and taskdepdata[datadep][0].endswith("-native") and dep != start:
174 continue
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500175 done.append(datadep)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176 new.append(datadep)
177 if taskdepdata[datadep][1] == "do_configure":
178 configuredeps.append(taskdepdata[datadep][0])
179 next = new
180
181 #configuredeps2 = []
182 #for dep in taskdepdata:
183 # data = taskdepdata[dep]
184 # if data[1] == "do_configure" and data[0] != pn:
185 # configuredeps2.append(data[0])
186 #configuredeps.sort()
187 #configuredeps2.sort()
188 #bb.warn(str(configuredeps))
189 #bb.warn(str(configuredeps2))
190
191 cp = []
192 siteconf = []
193 for c in configuredeps:
194 if c.endswith("-native"):
195 manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${BUILD_ARCH}-%s.populate_sysroot" % c)
196 elif c.startswith("nativesdk-"):
197 manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${SDK_ARCH}_${SDK_OS}-%s.populate_sysroot" % c)
198 elif "-cross-" in c or "-crosssdk" in c:
199 continue
200 else:
201 manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${MACHINE}-%s.populate_sysroot" % c)
202 try:
203 f = open(manifest, "r")
204 for l in f:
205 if "/aclocal/" in l and l.strip().endswith(".m4"):
206 cp.append(l.strip())
207 elif "config_site.d/" in l:
208 cp.append(l.strip())
209 except:
210 bb.warn("%s not found" % manifest)
211
212 for c in cp:
213 t = os.path.join(aclocaldir, os.path.basename(c))
214 if not os.path.exists(t):
215 os.symlink(c, t)
216
217 d.setVar("CONFIG_SITE", siteinfo_get_files(d, False))
218}
219autotools_copy_aclocals[vardepsexclude] += "MACHINE SDK_ARCH BUILD_ARCH SDK_OS BB_TASKDEPDATA"
220
221autotools_do_configure() {
222 # WARNING: gross hack follows:
223 # An autotools built package generally needs these scripts, however only
224 # automake or libtoolize actually install the current versions of them.
225 # This is a problem in builds that do not use libtool or automake, in the case
226 # where we -need- the latest version of these scripts. e.g. running a build
227 # for a package whose autotools are old, on an x86_64 machine, which the old
228 # config.sub does not support. Work around this by installing them manually
229 # regardless.
230 ( for ac in `find ${S} -ignore_readdir_race -name configure.in -o -name configure.ac`; do
231 rm -f `dirname $ac`/configure
232 done )
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500233 if [ -e ${AUTOTOOLS_SCRIPT_PATH}/configure.in -o -e ${AUTOTOOLS_SCRIPT_PATH}/configure.ac ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500234 olddir=`pwd`
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500235 cd ${AUTOTOOLS_SCRIPT_PATH}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500236 ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/"
237 if [ x"${acpaths}" = xdefault ]; then
238 acpaths=
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500239 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 -0500240 grep -v 'acinclude.m4' | grep -v 'aclocal-copy' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
241 acpaths="$acpaths -I $i"
242 done
243 else
244 acpaths="${acpaths}"
245 fi
246 AUTOV=`automake --version | sed -e '1{s/.* //;s/\.[0-9]\+$//};q'`
247 automake --version
248 echo "AUTOV is $AUTOV"
249 if [ -d ${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV ]; then
250 ACLOCAL="$ACLOCAL --automake-acdir=${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV"
251 fi
252 # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
253 # like it was auto-generated. Work around this by blowing it away
254 # by hand, unless the package specifically asked not to run aclocal.
255 if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
256 rm -f aclocal.m4
257 fi
258 if [ -e configure.in ]; then
259 CONFIGURE_AC=configure.in
260 else
261 CONFIGURE_AC=configure.ac
262 fi
263 if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
264 if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
265 : do nothing -- we still have an old unmodified configure.ac
266 else
267 bbnote Executing glib-gettextize --force --copy
268 echo "no" | glib-gettextize --force --copy
269 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500270 elif grep "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500271 # We'd call gettextize here if it wasn't so broken...
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500272 cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/
273 if [ -d ${S}/po/ ]; then
274 cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/
275 if [ ! -e ${S}/po/remove-potcdate.sin ]; then
276 cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sin ${S}/po/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500277 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500278 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500279 for i in gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4; do
280 for j in `find ${S} -ignore_readdir_race -name $i | grep -v aclocal-copy`; do
281 rm $j
282 done
283 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500284 fi
285 mkdir -p m4
286 if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
287 bbnote Executing intltoolize --copy --force --automake
288 intltoolize --copy --force --automake
289 fi
290 bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
291 ACLOCAL="$ACLOCAL" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || die "autoreconf execution failed."
292 cd $olddir
293 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500294 if [ -e ${CONFIGURE_SCRIPT} ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500295 oe_runconf
296 else
297 bbnote "nothing to configure"
298 fi
299}
300
301autotools_do_install() {
302 oe_runmake 'DESTDIR=${D}' install
303 # Info dir listing isn't interesting at this point so remove it if it exists.
304 if [ -e "${D}${infodir}/dir" ]; then
305 rm -f ${D}${infodir}/dir
306 fi
307}
308
309inherit siteconfig
310
311EXPORT_FUNCTIONS do_configure do_install
312
313B = "${WORKDIR}/build"