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 | |
| 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 | die "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} |
Patrick Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame^] | 108 | mkdir -p ${B} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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} |
| 113 | if [ "${CLEANBROKEN}" != "1" -a \( -e Makefile -o -e makefile -o -e GNUmakefile \) ]; then |
| 114 | echo "Running \"${MAKE} clean\" in ${S}" |
| 115 | ${MAKE} clean |
| 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 |
| 125 | echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE} |
| 126 | fi |
| 127 | } |
| 128 | |
| 129 | EXTRACONFFUNCS ??= "" |
| 130 | |
| 131 | do_configure[prefuncs] += "autotools_preconfigure autotools_copy_aclocals ${EXTRACONFFUNCS}" |
| 132 | do_configure[postfuncs] += "autotools_postconfigure" |
| 133 | |
| 134 | ACLOCALDIR = "${B}/aclocal-copy" |
| 135 | |
| 136 | python autotools_copy_aclocals () { |
| 137 | s = d.getVar("S", True) |
| 138 | if not os.path.exists(s + "/configure.in") and not os.path.exists(s + "/configure.ac"): |
| 139 | if not d.getVar("AUTOTOOLS_COPYACLOCAL", False): |
| 140 | return |
| 141 | |
| 142 | taskdepdata = d.getVar("BB_TASKDEPDATA", False) |
| 143 | #bb.warn(str(taskdepdata)) |
| 144 | pn = d.getVar("PN", True) |
| 145 | aclocaldir = d.getVar("ACLOCALDIR", True) |
| 146 | oe.path.remove(aclocaldir) |
| 147 | bb.utils.mkdirhier(aclocaldir) |
| 148 | start = None |
| 149 | configuredeps = [] |
| 150 | |
| 151 | for dep in taskdepdata: |
| 152 | data = taskdepdata[dep] |
| 153 | if data[1] == "do_configure" and data[0] == pn: |
| 154 | start = dep |
| 155 | break |
| 156 | if start is None: |
| 157 | bb.fatal("Couldn't find ourself in BB_TASKDEPDATA?") |
| 158 | |
| 159 | # We need to find configure tasks which are either from <target> -> <target> |
| 160 | # or <native> -> <native> but not <target> -> <native> unless they're direct |
| 161 | # dependencies. This mirrors what would get restored from sstate. |
| 162 | done = [dep] |
| 163 | next = [dep] |
| 164 | while next: |
| 165 | new = [] |
| 166 | for dep in next: |
| 167 | data = taskdepdata[dep] |
| 168 | for datadep in data[3]: |
| 169 | if datadep in done: |
| 170 | continue |
| 171 | done.append(datadep) |
| 172 | if (not data[0].endswith("-native")) and taskdepdata[datadep][0].endswith("-native") and dep != start: |
| 173 | continue |
| 174 | new.append(datadep) |
| 175 | if taskdepdata[datadep][1] == "do_configure": |
| 176 | configuredeps.append(taskdepdata[datadep][0]) |
| 177 | next = new |
| 178 | |
| 179 | #configuredeps2 = [] |
| 180 | #for dep in taskdepdata: |
| 181 | # data = taskdepdata[dep] |
| 182 | # if data[1] == "do_configure" and data[0] != pn: |
| 183 | # configuredeps2.append(data[0]) |
| 184 | #configuredeps.sort() |
| 185 | #configuredeps2.sort() |
| 186 | #bb.warn(str(configuredeps)) |
| 187 | #bb.warn(str(configuredeps2)) |
| 188 | |
| 189 | cp = [] |
| 190 | siteconf = [] |
| 191 | for c in configuredeps: |
| 192 | if c.endswith("-native"): |
| 193 | manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${BUILD_ARCH}-%s.populate_sysroot" % c) |
| 194 | elif c.startswith("nativesdk-"): |
| 195 | manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${SDK_ARCH}_${SDK_OS}-%s.populate_sysroot" % c) |
| 196 | elif "-cross-" in c or "-crosssdk" in c: |
| 197 | continue |
| 198 | else: |
| 199 | manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${MACHINE}-%s.populate_sysroot" % c) |
| 200 | try: |
| 201 | f = open(manifest, "r") |
| 202 | for l in f: |
| 203 | if "/aclocal/" in l and l.strip().endswith(".m4"): |
| 204 | cp.append(l.strip()) |
| 205 | elif "config_site.d/" in l: |
| 206 | cp.append(l.strip()) |
| 207 | except: |
| 208 | bb.warn("%s not found" % manifest) |
| 209 | |
| 210 | for c in cp: |
| 211 | t = os.path.join(aclocaldir, os.path.basename(c)) |
| 212 | if not os.path.exists(t): |
| 213 | os.symlink(c, t) |
| 214 | |
| 215 | d.setVar("CONFIG_SITE", siteinfo_get_files(d, False)) |
| 216 | } |
| 217 | autotools_copy_aclocals[vardepsexclude] += "MACHINE SDK_ARCH BUILD_ARCH SDK_OS BB_TASKDEPDATA" |
| 218 | |
| 219 | autotools_do_configure() { |
| 220 | # WARNING: gross hack follows: |
| 221 | # An autotools built package generally needs these scripts, however only |
| 222 | # automake or libtoolize actually install the current versions of them. |
| 223 | # This is a problem in builds that do not use libtool or automake, in the case |
| 224 | # where we -need- the latest version of these scripts. e.g. running a build |
| 225 | # for a package whose autotools are old, on an x86_64 machine, which the old |
| 226 | # config.sub does not support. Work around this by installing them manually |
| 227 | # regardless. |
| 228 | ( for ac in `find ${S} -ignore_readdir_race -name configure.in -o -name configure.ac`; do |
| 229 | rm -f `dirname $ac`/configure |
| 230 | done ) |
| 231 | if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then |
| 232 | olddir=`pwd` |
| 233 | cd ${S} |
| 234 | ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/" |
| 235 | if [ x"${acpaths}" = xdefault ]; then |
| 236 | acpaths= |
| 237 | for i in `find ${S} -ignore_readdir_race -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \ |
| 238 | grep -v 'acinclude.m4' | grep -v 'aclocal-copy' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do |
| 239 | acpaths="$acpaths -I $i" |
| 240 | done |
| 241 | else |
| 242 | acpaths="${acpaths}" |
| 243 | fi |
| 244 | AUTOV=`automake --version | sed -e '1{s/.* //;s/\.[0-9]\+$//};q'` |
| 245 | automake --version |
| 246 | echo "AUTOV is $AUTOV" |
| 247 | if [ -d ${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV ]; then |
| 248 | ACLOCAL="$ACLOCAL --automake-acdir=${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV" |
| 249 | fi |
| 250 | # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look |
| 251 | # like it was auto-generated. Work around this by blowing it away |
| 252 | # by hand, unless the package specifically asked not to run aclocal. |
| 253 | if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then |
| 254 | rm -f aclocal.m4 |
| 255 | fi |
| 256 | if [ -e configure.in ]; then |
| 257 | CONFIGURE_AC=configure.in |
| 258 | else |
| 259 | CONFIGURE_AC=configure.ac |
| 260 | fi |
| 261 | if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then |
| 262 | if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then |
| 263 | : do nothing -- we still have an old unmodified configure.ac |
| 264 | else |
| 265 | bbnote Executing glib-gettextize --force --copy |
| 266 | echo "no" | glib-gettextize --force --copy |
| 267 | fi |
| 268 | else if grep "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then |
| 269 | # We'd call gettextize here if it wasn't so broken... |
| 270 | cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/ |
| 271 | if [ -d ${S}/po/ ]; then |
| 272 | cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/ |
| 273 | if [ ! -e ${S}/po/remove-potcdate.sin ]; then |
| 274 | cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sin ${S}/po/ |
| 275 | fi |
| 276 | fi |
| 277 | for i in gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4; do |
| 278 | for j in `find ${S} -ignore_readdir_race -name $i | grep -v aclocal-copy`; do |
| 279 | rm $j |
| 280 | done |
| 281 | done |
| 282 | fi |
| 283 | fi |
| 284 | mkdir -p m4 |
| 285 | if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then |
| 286 | bbnote Executing intltoolize --copy --force --automake |
| 287 | intltoolize --copy --force --automake |
| 288 | fi |
| 289 | bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths |
| 290 | ACLOCAL="$ACLOCAL" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || die "autoreconf execution failed." |
| 291 | cd $olddir |
| 292 | fi |
| 293 | if [ -e ${S}/configure ]; then |
| 294 | oe_runconf |
| 295 | else |
| 296 | bbnote "nothing to configure" |
| 297 | fi |
| 298 | } |
| 299 | |
| 300 | autotools_do_install() { |
| 301 | oe_runmake 'DESTDIR=${D}' install |
| 302 | # Info dir listing isn't interesting at this point so remove it if it exists. |
| 303 | if [ -e "${D}${infodir}/dir" ]; then |
| 304 | rm -f ${D}${infodir}/dir |
| 305 | fi |
| 306 | } |
| 307 | |
| 308 | inherit siteconfig |
| 309 | |
| 310 | EXPORT_FUNCTIONS do_configure do_install |
| 311 | |
| 312 | B = "${WORKDIR}/build" |