blob: 4ab24609904c080c486fdef2bc4b0967c2e5ebe4 [file] [log] [blame]
Patrick Williams213cb262021-08-07 19:21:33 -05001def get_autotools_dep(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
Andrew Geisslerd1e89492021-02-12 15:35:20 -060020 return deps
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021
Patrick Williams213cb262021-08-07 19:21:33 -050022
23DEPENDS:prepend = "${@get_autotools_dep(d)} "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024
25inherit siteinfo
26
27# Space separated list of shell scripts with variables defined to supply test
28# results for autoconf tests we cannot run at build time.
Brad Bishop79641f22019-09-10 07:20:22 -040029# The value of this variable is filled in in a prefunc because it depends on
30# the contents of the sysroot.
31export CONFIG_SITE
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032
Brad Bishop6e60e8b2018-02-01 10:27:11 -050033acpaths ?= "default"
Andrew Geisslerd1e89492021-02-12 15:35:20 -060034EXTRA_AUTORECONF = "--exclude=autopoint --exclude=gtkdocize"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050035
36export lt_cv_sys_lib_dlsearch_path_spec = "${libdir} ${base_libdir}"
37
38# When building tools for use at build-time it's recommended for the build
39# system to use these variables when cross-compiling.
40# (http://sources.redhat.com/autobook/autobook/autobook_270.html)
41export CPP_FOR_BUILD = "${BUILD_CPP}"
42export CPPFLAGS_FOR_BUILD = "${BUILD_CPPFLAGS}"
43
44export CC_FOR_BUILD = "${BUILD_CC}"
45export CFLAGS_FOR_BUILD = "${BUILD_CFLAGS}"
46
47export CXX_FOR_BUILD = "${BUILD_CXX}"
48export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
49
50export LD_FOR_BUILD = "${BUILD_LD}"
51export LDFLAGS_FOR_BUILD = "${BUILD_LDFLAGS}"
52
53def append_libtool_sysroot(d):
54 # Only supply libtool sysroot option for non-native packages
55 if not bb.data.inherits_class('native', d):
56 return '--with-libtool-sysroot=${STAGING_DIR_HOST}'
57 return ""
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=${oldincludedir} \
74 --infodir=${infodir} \
75 --mandir=${mandir} \
76 --disable-silent-rules \
77 ${CONFIGUREOPT_DEPTRACK} \
78 ${@append_libtool_sysroot(d)}"
79CONFIGUREOPT_DEPTRACK ?= "--disable-dependency-tracking"
80
Patrick Williamsc0f7c042017-02-23 20:41:17 -060081CACHED_CONFIGUREVARS ?= ""
82
Patrick Williamsf1e5d692016-03-30 15:21:19 -050083AUTOTOOLS_SCRIPT_PATH ?= "${S}"
84CONFIGURE_SCRIPT ?= "${AUTOTOOLS_SCRIPT_PATH}/configure"
85
86AUTOTOOLS_AUXDIR ?= "${AUTOTOOLS_SCRIPT_PATH}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050087
88oe_runconf () {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050089 # Use relative path to avoid buildpaths in files
90 cfgscript_name="`basename ${CONFIGURE_SCRIPT}`"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060091 cfgscript=`python3 -c "import os; print(os.path.relpath(os.path.dirname('${CONFIGURE_SCRIPT}'), '.'))"`/$cfgscript_name
Patrick Williamsc124f4f2015-09-15 14:41:29 -050092 if [ -x "$cfgscript" ] ; then
93 bbnote "Running $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} $@"
Andrew Geissler6ce62a22020-11-30 19:58:47 -060094 if ! CONFIG_SHELL=${CONFIG_SHELL-/bin/bash} ${CACHED_CONFIGUREVARS} $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050095 bbnote "The following config.log files may provide further information."
96 bbnote `find ${B} -ignore_readdir_race -type f -name config.log`
97 bbfatal_log "configure failed"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050098 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050099 else
100 bbfatal "no configure script found at $cfgscript"
101 fi
102}
103
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate"
105
106autotools_preconfigure() {
107 if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then
108 if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then
109 if [ "${S}" != "${B}" ]; then
110 echo "Previously configured separate build directory detected, cleaning ${B}"
111 rm -rf ${B}
Patrick Williamsd7e96312015-09-22 08:09:05 -0500112 mkdir -p ${B}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113 else
114 # At least remove the .la files since automake won't automatically
115 # regenerate them even if CFLAGS/LDFLAGS are different
116 cd ${S}
117 if [ "${CLEANBROKEN}" != "1" -a \( -e Makefile -o -e makefile -o -e GNUmakefile \) ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500118 oe_runmake clean
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500119 fi
120 find ${S} -ignore_readdir_race -name \*.la -delete
121 fi
122 fi
123 fi
124}
125
126autotools_postconfigure(){
127 if [ -n "${CONFIGURESTAMPFILE}" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500128 mkdir -p `dirname ${CONFIGURESTAMPFILE}`
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500129 echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE}
130 fi
131}
132
133EXTRACONFFUNCS ??= ""
134
Patrick Williams213cb262021-08-07 19:21:33 -0500135EXTRA_OECONF:append = " ${PACKAGECONFIG_CONFARGS}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600136
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500137do_configure[prefuncs] += "autotools_preconfigure autotools_aclocals ${EXTRACONFFUNCS}"
Brad Bishop79641f22019-09-10 07:20:22 -0400138do_compile[prefuncs] += "autotools_aclocals"
139do_install[prefuncs] += "autotools_aclocals"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500140do_configure[postfuncs] += "autotools_postconfigure"
141
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500142ACLOCALDIR = "${STAGING_DATADIR}/aclocal"
143ACLOCALEXTRAPATH = ""
Patrick Williams213cb262021-08-07 19:21:33 -0500144ACLOCALEXTRAPATH:class-target = " -I ${STAGING_DATADIR_NATIVE}/aclocal/"
145ACLOCALEXTRAPATH:class-nativesdk = " -I ${STAGING_DATADIR_NATIVE}/aclocal/"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500146
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500147python autotools_aclocals () {
Andrew Geissler5199d832021-09-24 16:47:35 -0500148 sitefiles, searched = siteinfo_get_files(d, sysrootcache=True)
149 d.setVar("CONFIG_SITE", " ".join(sitefiles))
150}
151
Patrick Williams93c203f2021-10-06 16:15:23 -0500152do_configure[file-checksums] += "${@' '.join(siteinfo_get_files(d, sysrootcache=False)[1])}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500153
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600154CONFIGURE_FILES = "${S}/configure.in ${S}/configure.ac ${S}/config.h.in ${S}/acinclude.m4 Makefile.am"
155
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500156autotools_do_configure() {
157 # WARNING: gross hack follows:
158 # An autotools built package generally needs these scripts, however only
159 # automake or libtoolize actually install the current versions of them.
160 # This is a problem in builds that do not use libtool or automake, in the case
161 # where we -need- the latest version of these scripts. e.g. running a build
162 # for a package whose autotools are old, on an x86_64 machine, which the old
163 # config.sub does not support. Work around this by installing them manually
164 # regardless.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600165
166 PRUNE_M4=""
167
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500168 for ac in `find ${S} -ignore_readdir_race -name configure.in -o -name configure.ac`; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500169 rm -f `dirname $ac`/configure
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500170 done
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500171 if [ -e ${AUTOTOOLS_SCRIPT_PATH}/configure.in -o -e ${AUTOTOOLS_SCRIPT_PATH}/configure.ac ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500172 olddir=`pwd`
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500173 cd ${AUTOTOOLS_SCRIPT_PATH}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500174 mkdir -p ${ACLOCALDIR}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500175 ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/"
176 if [ x"${acpaths}" = xdefault ]; then
177 acpaths=
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500178 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 -0600179 grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500180 acpaths="$acpaths -I $i"
181 done
182 else
183 acpaths="${acpaths}"
184 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500185 acpaths="$acpaths ${ACLOCALEXTRAPATH}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500186 AUTOV=`automake --version | sed -e '1{s/.* //;s/\.[0-9]\+$//};q'`
187 automake --version
188 echo "AUTOV is $AUTOV"
189 if [ -d ${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV ]; then
190 ACLOCAL="$ACLOCAL --automake-acdir=${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV"
191 fi
192 # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
193 # like it was auto-generated. Work around this by blowing it away
194 # by hand, unless the package specifically asked not to run aclocal.
195 if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
196 rm -f aclocal.m4
197 fi
198 if [ -e configure.in ]; then
199 CONFIGURE_AC=configure.in
200 else
201 CONFIGURE_AC=configure.ac
202 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500203 if grep -q "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC; then
204 if grep -q "sed.*POTFILES" $CONFIGURE_AC; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500205 : do nothing -- we still have an old unmodified configure.ac
206 else
207 bbnote Executing glib-gettextize --force --copy
208 echo "no" | glib-gettextize --force --copy
209 fi
Brad Bishop316dfdd2018-06-25 12:45:53 -0400210 elif [ "${BPN}" != "gettext" ] && grep -q "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500211 # We'd call gettextize here if it wasn't so broken...
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500212 cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/
213 if [ -d ${S}/po/ ]; then
214 cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/
215 if [ ! -e ${S}/po/remove-potcdate.sin ]; then
216 cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sin ${S}/po/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500217 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500218 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600219 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 -0500220 fi
221 mkdir -p m4
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600222
223 for i in $PRUNE_M4; do
224 find ${S} -ignore_readdir_race -name $i -delete
225 done
226
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800227 bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600228 ACLOCAL="$ACLOCAL" autoreconf -Wcross -Wno-obsolete --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || die "autoreconf execution failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500229 cd $olddir
230 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500231 if [ -e ${CONFIGURE_SCRIPT} ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500232 oe_runconf
233 else
234 bbnote "nothing to configure"
235 fi
236}
237
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600238autotools_do_compile() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800239 oe_runmake
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600240}
241
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500242autotools_do_install() {
243 oe_runmake 'DESTDIR=${D}' install
244 # Info dir listing isn't interesting at this point so remove it if it exists.
245 if [ -e "${D}${infodir}/dir" ]; then
246 rm -f ${D}${infodir}/dir
247 fi
248}
249
250inherit siteconfig
251
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600252EXPORT_FUNCTIONS do_configure do_compile do_install
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500253
254B = "${WORKDIR}/build"