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