blob: 2ceb790b5cfb4e39ac017239a17aac5f52c48c40 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001def autotools_dep_prepend(d):
Brad Bishop6e60e8b2018-02-01 10:27:11 -05002 if d.getVar('INHIBIT_AUTOTOOLS_DEPS'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -05003 return ''
4
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005 pn = d.getVar('PN')
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006 deps = ''
7
Andrew Geisslerb7d28612020-07-24 16:15:54 -05008 if pn in ['autoconf-native', 'automake-native']:
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009 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) \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050017 and not d.getVar('INHIBIT_DEFAULT_DEPS'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018 deps += 'libtool-cross '
19
20 return deps + 'gnu-config-native '
21
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022DEPENDS_prepend = "${@autotools_dep_prepend(d)} "
23
24inherit siteinfo
25
26# Space separated list of shell scripts with variables defined to supply test
27# results for autoconf tests we cannot run at build time.
Brad Bishop79641f22019-09-10 07:20:22 -040028# The value of this variable is filled in in a prefunc because it depends on
29# the contents of the sysroot.
30export CONFIG_SITE
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031
Brad Bishop6e60e8b2018-02-01 10:27:11 -050032acpaths ?= "default"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033EXTRA_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 Williamsc0f7c042017-02-23 20:41:17 -060080CACHED_CONFIGUREVARS ?= ""
81
Patrick Williamsf1e5d692016-03-30 15:21:19 -050082AUTOTOOLS_SCRIPT_PATH ?= "${S}"
83CONFIGURE_SCRIPT ?= "${AUTOTOOLS_SCRIPT_PATH}/configure"
84
85AUTOTOOLS_AUXDIR ?= "${AUTOTOOLS_SCRIPT_PATH}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086
87oe_runconf () {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050088 # Use relative path to avoid buildpaths in files
89 cfgscript_name="`basename ${CONFIGURE_SCRIPT}`"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060090 cfgscript=`python3 -c "import os; print(os.path.relpath(os.path.dirname('${CONFIGURE_SCRIPT}'), '.'))"`/$cfgscript_name
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091 if [ -x "$cfgscript" ] ; then
92 bbnote "Running $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} $@"
Andrew Geissler6ce62a22020-11-30 19:58:47 -060093 if ! CONFIG_SHELL=${CONFIG_SHELL-/bin/bash} ${CACHED_CONFIGUREVARS} $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050094 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"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050098 else
99 bbfatal "no configure script found at $cfgscript"
100 fi
101}
102
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500103CONFIGURESTAMPFILE = "${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}
Patrick Williamsd7e96312015-09-22 08:09:05 -0500111 mkdir -p ${B}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500112 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
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500117 oe_runmake clean
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500118 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
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500127 mkdir -p `dirname ${CONFIGURESTAMPFILE}`
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500128 echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE}
129 fi
130}
131
132EXTRACONFFUNCS ??= ""
133
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600134EXTRA_OECONF_append = " ${PACKAGECONFIG_CONFARGS}"
135
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500136do_configure[prefuncs] += "autotools_preconfigure autotools_aclocals ${EXTRACONFFUNCS}"
Brad Bishop79641f22019-09-10 07:20:22 -0400137do_compile[prefuncs] += "autotools_aclocals"
138do_install[prefuncs] += "autotools_aclocals"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500139do_configure[postfuncs] += "autotools_postconfigure"
140
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500141ACLOCALDIR = "${STAGING_DATADIR}/aclocal"
142ACLOCALEXTRAPATH = ""
143ACLOCALEXTRAPATH_class-target = " -I ${STAGING_DATADIR_NATIVE}/aclocal/"
144ACLOCALEXTRAPATH_class-nativesdk = " -I ${STAGING_DATADIR_NATIVE}/aclocal/"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500145
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500146python autotools_aclocals () {
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500147 d.setVar("CONFIG_SITE", siteinfo_get_files(d, sysrootcache=True))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500148}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500149
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600150CONFIGURE_FILES = "${S}/configure.in ${S}/configure.ac ${S}/config.h.in ${S}/acinclude.m4 Makefile.am"
151
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500152autotools_do_configure() {
153 # WARNING: gross hack follows:
154 # An autotools built package generally needs these scripts, however only
155 # automake or libtoolize actually install the current versions of them.
156 # This is a problem in builds that do not use libtool or automake, in the case
157 # where we -need- the latest version of these scripts. e.g. running a build
158 # for a package whose autotools are old, on an x86_64 machine, which the old
159 # config.sub does not support. Work around this by installing them manually
160 # regardless.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600161
162 PRUNE_M4=""
163
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500164 for ac in `find ${S} -ignore_readdir_race -name configure.in -o -name configure.ac`; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500165 rm -f `dirname $ac`/configure
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500166 done
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500167 if [ -e ${AUTOTOOLS_SCRIPT_PATH}/configure.in -o -e ${AUTOTOOLS_SCRIPT_PATH}/configure.ac ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168 olddir=`pwd`
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500169 cd ${AUTOTOOLS_SCRIPT_PATH}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500170 mkdir -p ${ACLOCALDIR}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171 ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/"
172 if [ x"${acpaths}" = xdefault ]; then
173 acpaths=
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500174 for i in `find ${AUTOTOOLS_SCRIPT_PATH} -ignore_readdir_race -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600175 grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176 acpaths="$acpaths -I $i"
177 done
178 else
179 acpaths="${acpaths}"
180 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500181 acpaths="$acpaths ${ACLOCALEXTRAPATH}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500182 AUTOV=`automake --version | sed -e '1{s/.* //;s/\.[0-9]\+$//};q'`
183 automake --version
184 echo "AUTOV is $AUTOV"
185 if [ -d ${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV ]; then
186 ACLOCAL="$ACLOCAL --automake-acdir=${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV"
187 fi
188 # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
189 # like it was auto-generated. Work around this by blowing it away
190 # by hand, unless the package specifically asked not to run aclocal.
191 if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
192 rm -f aclocal.m4
193 fi
194 if [ -e configure.in ]; then
195 CONFIGURE_AC=configure.in
196 else
197 CONFIGURE_AC=configure.ac
198 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500199 if grep -q "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC; then
200 if grep -q "sed.*POTFILES" $CONFIGURE_AC; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500201 : do nothing -- we still have an old unmodified configure.ac
202 else
203 bbnote Executing glib-gettextize --force --copy
204 echo "no" | glib-gettextize --force --copy
205 fi
Brad Bishop316dfdd2018-06-25 12:45:53 -0400206 elif [ "${BPN}" != "gettext" ] && grep -q "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500207 # We'd call gettextize here if it wasn't so broken...
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500208 cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/
209 if [ -d ${S}/po/ ]; then
210 cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/
211 if [ ! -e ${S}/po/remove-potcdate.sin ]; then
212 cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sin ${S}/po/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500213 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500214 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600215 PRUNE_M4="$PRUNE_M4 gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500216 fi
217 mkdir -p m4
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500218 if grep -q "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600219 if ! echo "${DEPENDS}" | grep -q intltool-native; then
220 bbwarn "Missing DEPENDS on intltool-native"
221 fi
222 PRUNE_M4="$PRUNE_M4 intltool.m4"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500223 bbnote Executing intltoolize --copy --force --automake
224 intltoolize --copy --force --automake
225 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600226
227 for i in $PRUNE_M4; do
228 find ${S} -ignore_readdir_race -name $i -delete
229 done
230
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800231 bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500232 ACLOCAL="$ACLOCAL" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || die "autoreconf execution failed."
233 cd $olddir
234 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500235 if [ -e ${CONFIGURE_SCRIPT} ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500236 oe_runconf
237 else
238 bbnote "nothing to configure"
239 fi
240}
241
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600242autotools_do_compile() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800243 oe_runmake
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600244}
245
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500246autotools_do_install() {
247 oe_runmake 'DESTDIR=${D}' install
248 # Info dir listing isn't interesting at this point so remove it if it exists.
249 if [ -e "${D}${infodir}/dir" ]; then
250 rm -f ${D}${infodir}/dir
251 fi
252}
253
254inherit siteconfig
255
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600256EXPORT_FUNCTIONS do_configure do_compile do_install
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500257
258B = "${WORKDIR}/build"