1# 2# Copyright OpenEmbedded Contributors 3# 4# SPDX-License-Identifier: MIT 5# 6 7def get_autotools_dep(d): 8 if d.getVar('INHIBIT_AUTOTOOLS_DEPS'): 9 return '' 10 11 pn = d.getVar('PN') 12 deps = '' 13 14 if pn in ['autoconf-native', 'automake-native']: 15 return deps 16 deps += 'autoconf-native automake-native ' 17 18 if not pn in ['libtool', 'libtool-native'] and not pn.endswith("libtool-cross"): 19 deps += 'libtool-native ' 20 if not bb.data.inherits_class('native', d) \ 21 and not bb.data.inherits_class('nativesdk', d) \ 22 and not bb.data.inherits_class('cross', d) \ 23 and not d.getVar('INHIBIT_DEFAULT_DEPS'): 24 deps += 'libtool-cross ' 25 26 return deps 27 28 29DEPENDS:prepend = "${@get_autotools_dep(d)} " 30 31inherit siteinfo 32 33# Space separated list of shell scripts with variables defined to supply test 34# results for autoconf tests we cannot run at build time. 35# The value of this variable is filled in in a prefunc because it depends on 36# the contents of the sysroot. 37export CONFIG_SITE 38 39EXTRA_AUTORECONF += "--exclude=autopoint" 40 41export lt_cv_sys_lib_dlsearch_path_spec = "${libdir} ${base_libdir}" 42 43# When building tools for use at build-time it's recommended for the build 44# system to use these variables when cross-compiling. 45# https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html 46# https://stackoverflow.com/questions/24201260/autotools-cross-compilation-and-generated-sources/24208587#24208587 47export CPP_FOR_BUILD = "${BUILD_CPP}" 48export CPPFLAGS_FOR_BUILD = "${BUILD_CPPFLAGS}" 49 50export CC_FOR_BUILD = "${BUILD_CC}" 51export CFLAGS_FOR_BUILD = "${BUILD_CFLAGS}" 52 53export CXX_FOR_BUILD = "${BUILD_CXX}" 54export CXXFLAGS_FOR_BUILD = "${BUILD_CXXFLAGS}" 55 56export LD_FOR_BUILD = "${BUILD_LD}" 57export LDFLAGS_FOR_BUILD = "${BUILD_LDFLAGS}" 58 59CONFIGUREOPTS = " --build=${BUILD_SYS} \ 60 --host=${HOST_SYS} \ 61 --target=${TARGET_SYS} \ 62 --prefix=${prefix} \ 63 --exec_prefix=${exec_prefix} \ 64 --bindir=${bindir} \ 65 --sbindir=${sbindir} \ 66 --libexecdir=${libexecdir} \ 67 --datadir=${datadir} \ 68 --sysconfdir=${sysconfdir} \ 69 --sharedstatedir=${sharedstatedir} \ 70 --localstatedir=${localstatedir} \ 71 --libdir=${libdir} \ 72 --includedir=${includedir} \ 73 --oldincludedir=${includedir} \ 74 --infodir=${infodir} \ 75 --mandir=${mandir} \ 76 --disable-silent-rules \ 77 ${CONFIGUREOPT_DEPTRACK}" 78CONFIGUREOPT_DEPTRACK ?= "--disable-dependency-tracking" 79 80CACHED_CONFIGUREVARS ?= "" 81 82AUTOTOOLS_SCRIPT_PATH ?= "${S}" 83CONFIGURE_SCRIPT ?= "${AUTOTOOLS_SCRIPT_PATH}/configure" 84 85AUTOTOOLS_AUXDIR ?= "${AUTOTOOLS_SCRIPT_PATH}" 86 87oe_runconf () { 88 # Use relative path to avoid buildpaths in files 89 cfgscript_name="`basename ${CONFIGURE_SCRIPT}`" 90 cfgscript=`python3 -c "import os; print(os.path.relpath(os.path.dirname('${CONFIGURE_SCRIPT}'), '.'))"`/$cfgscript_name 91 if [ -x "$cfgscript" ] ; then 92 bbnote "Running $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} $@" 93 if ! CONFIG_SHELL=${CONFIG_SHELL-/bin/bash} ${CACHED_CONFIGUREVARS} $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"; then 94 bbnote "The following config.log files may provide further information." 95 bbnote `find ${B} -ignore_readdir_race -type f -name config.log` 96 bbfatal_log "configure failed" 97 fi 98 else 99 bbfatal "no configure script found at $cfgscript" 100 fi 101} 102 103CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate" 104 105autotools_preconfigure() { 106 if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then 107 if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then 108 if [ "${S}" != "${B}" ]; then 109 echo "Previously configured separate build directory detected, cleaning ${B}" 110 rm -rf ${B} 111 mkdir -p ${B} 112 else 113 # At least remove the .la files since automake won't automatically 114 # regenerate them even if CFLAGS/LDFLAGS are different 115 cd ${S} 116 if [ "${CLEANBROKEN}" != "1" -a \( -e Makefile -o -e makefile -o -e GNUmakefile \) ]; then 117 oe_runmake 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 mkdir -p `dirname ${CONFIGURESTAMPFILE}` 128 echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE} 129 fi 130} 131 132EXTRACONFFUNCS ??= "" 133 134EXTRA_OECONF:append = " ${PACKAGECONFIG_CONFARGS}" 135 136do_configure[prefuncs] += "autotools_preconfigure autotools_sitefiles ${EXTRACONFFUNCS}" 137do_configure[postfuncs] += "autotools_postconfigure" 138 139# Tell autoconf to load the site defaults from siteinfo 140python autotools_sitefiles () { 141 sitefiles, searched = siteinfo_get_files(d, sysrootcache=True) 142 d.setVar("CONFIG_SITE", " ".join(sitefiles)) 143} 144 145do_configure[file-checksums] += "${@' '.join(siteinfo_get_files(d, sysrootcache=False)[1])}" 146 147CONFIGURE_FILES = "${S}/configure.in ${S}/configure.ac ${S}/config.h.in *.m4 Makefile.am" 148 149autotools_do_configure() { 150 # WARNING: gross hack follows: 151 # An autotools built package generally needs these scripts, however only 152 # automake or libtoolize actually install the current versions of them. 153 # This is a problem in builds that do not use libtool or automake, in the case 154 # where we -need- the latest version of these scripts. e.g. running a build 155 # for a package whose autotools are old, on an x86_64 machine, which the old 156 # config.sub does not support. Work around this by installing them manually 157 # regardless. 158 159 PRUNE_M4="" 160 161 for ac in `find ${S} -ignore_readdir_race -name configure.in -o -name configure.ac`; do 162 rm -f `dirname $ac`/configure 163 done 164 if [ -e ${AUTOTOOLS_SCRIPT_PATH}/configure.in -o -e ${AUTOTOOLS_SCRIPT_PATH}/configure.ac ]; then 165 olddir=`pwd` 166 cd ${AUTOTOOLS_SCRIPT_PATH} 167 # aclocal looks in the native sysroot by default, so tell it to also look in the target sysroot. 168 ACLOCAL="aclocal --aclocal-path=${STAGING_DATADIR}/aclocal/" 169 # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look 170 # like it was auto-generated. Work around this by blowing it away 171 # by hand, unless the package specifically asked not to run aclocal. 172 if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then 173 bbnote Removing existing aclocal.m4 174 rm -f aclocal.m4 175 fi 176 if [ -e configure.in ]; then 177 CONFIGURE_AC=configure.in 178 else 179 CONFIGURE_AC=configure.ac 180 fi 181 if grep -q "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC; then 182 if grep -q "sed.*POTFILES" $CONFIGURE_AC; then 183 : do nothing -- we still have an old unmodified configure.ac 184 else 185 bbnote Executing glib-gettextize --force --copy 186 echo "no" | glib-gettextize --force --copy 187 fi 188 elif [ "${BPN}" != "gettext" ] && grep -q "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC; then 189 # We'd call gettextize here if it wasn't so broken... 190 cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/ 191 if [ -d ${S}/po/ ]; then 192 cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/ 193 if [ ! -e ${S}/po/remove-potcdate.sed ]; then 194 cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sed ${S}/po/ 195 fi 196 fi 197 PRUNE_M4="$PRUNE_M4 gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4" 198 fi 199 mkdir -p m4 200 201 for i in $PRUNE_M4; do 202 find ${S} -ignore_readdir_race -name $i -delete 203 done 204 205 bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} 206 ACLOCAL="$ACLOCAL" autoreconf -Wcross -Wno-obsolete --verbose --install --force ${EXTRA_AUTORECONF} || die "autoreconf execution failed." 207 cd $olddir 208 fi 209 210 oe_runconf 211} 212 213autotools_do_compile() { 214 oe_runmake 215} 216 217autotools_do_install() { 218 oe_runmake 'DESTDIR=${D}' install 219 # Info dir listing isn't interesting at this point so remove it if it exists. 220 if [ -e "${D}${infodir}/dir" ]; then 221 rm -f ${D}${infodir}/dir 222 fi 223} 224 225EXPORT_FUNCTIONS do_configure do_compile do_install 226 227B = "${WORKDIR}/build" 228