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