Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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, False)}" |
| 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 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 80 | AUTOTOOLS_SCRIPT_PATH ?= "${S}" |
| 81 | CONFIGURE_SCRIPT ?= "${AUTOTOOLS_SCRIPT_PATH}/configure" |
| 82 | |
| 83 | AUTOTOOLS_AUXDIR ?= "${AUTOTOOLS_SCRIPT_PATH}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 84 | |
| 85 | oe_runconf () { |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 86 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 89 | if [ -x "$cfgscript" ] ; then |
| 90 | bbnote "Running $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} $@" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 91 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 96 | else |
| 97 | bbfatal "no configure script found at $cfgscript" |
| 98 | fi |
| 99 | } |
| 100 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 101 | CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate" |
| 102 | |
| 103 | autotools_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 Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame] | 109 | mkdir -p ${B} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 110 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 115 | oe_runmake clean |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 116 | fi |
| 117 | find ${S} -ignore_readdir_race -name \*.la -delete |
| 118 | fi |
| 119 | fi |
| 120 | fi |
| 121 | } |
| 122 | |
| 123 | autotools_postconfigure(){ |
| 124 | if [ -n "${CONFIGURESTAMPFILE}" ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 125 | mkdir -p `dirname ${CONFIGURESTAMPFILE}` |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 126 | echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE} |
| 127 | fi |
| 128 | } |
| 129 | |
| 130 | EXTRACONFFUNCS ??= "" |
| 131 | |
| 132 | do_configure[prefuncs] += "autotools_preconfigure autotools_copy_aclocals ${EXTRACONFFUNCS}" |
| 133 | do_configure[postfuncs] += "autotools_postconfigure" |
| 134 | |
| 135 | ACLOCALDIR = "${B}/aclocal-copy" |
| 136 | |
| 137 | python autotools_copy_aclocals () { |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 138 | s = d.getVar("AUTOTOOLS_SCRIPT_PATH", True) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 139 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 151 | # Detect bitbake -b usage |
| 152 | # Everything but quilt-native would have dependencies |
| 153 | nodeps = (pn != "quilt-native") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 154 | |
| 155 | for dep in taskdepdata: |
| 156 | data = taskdepdata[dep] |
| 157 | if data[1] == "do_configure" and data[0] == pn: |
| 158 | start = dep |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 159 | if not nodeps and start: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 160 | break |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 161 | if nodeps and data[0] != pn: |
| 162 | nodeps = False |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 163 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 169 | done = [start] |
| 170 | next = [start] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 171 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 178 | if (not data[0].endswith("-native")) and taskdepdata[datadep][0].endswith("-native") and dep != start: |
| 179 | continue |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 180 | done.append(datadep) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 181 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 197 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 202 | 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 | } |
| 228 | autotools_copy_aclocals[vardepsexclude] += "MACHINE SDK_ARCH BUILD_ARCH SDK_OS BB_TASKDEPDATA" |
| 229 | |
| 230 | autotools_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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 239 | for ac in `find ${S} -ignore_readdir_race -name configure.in -o -name configure.ac`; do |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 240 | rm -f `dirname $ac`/configure |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 241 | done |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 242 | if [ -e ${AUTOTOOLS_SCRIPT_PATH}/configure.in -o -e ${AUTOTOOLS_SCRIPT_PATH}/configure.ac ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 243 | olddir=`pwd` |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 244 | cd ${AUTOTOOLS_SCRIPT_PATH} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 245 | ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/" |
| 246 | if [ x"${acpaths}" = xdefault ]; then |
| 247 | acpaths= |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 248 | for i in `find ${AUTOTOOLS_SCRIPT_PATH} -ignore_readdir_race -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 249 | 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 279 | elif grep "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 280 | # We'd call gettextize here if it wasn't so broken... |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 281 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 286 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 287 | fi |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 288 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 293 | 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 303 | if [ -e ${CONFIGURE_SCRIPT} ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 304 | oe_runconf |
| 305 | else |
| 306 | bbnote "nothing to configure" |
| 307 | fi |
| 308 | } |
| 309 | |
| 310 | autotools_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 | |
| 318 | inherit siteconfig |
| 319 | |
| 320 | EXPORT_FUNCTIONS do_configure do_install |
| 321 | |
| 322 | B = "${WORKDIR}/build" |