blob: 2c7968e6597e54a6215b01cbaefbabfc127628eb [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 () {
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500148 d.setVar("CONFIG_SITE", siteinfo_get_files(d, sysrootcache=True))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500149}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500150
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600151CONFIGURE_FILES = "${S}/configure.in ${S}/configure.ac ${S}/config.h.in ${S}/acinclude.m4 Makefile.am"
152
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500153autotools_do_configure() {
154 # WARNING: gross hack follows:
155 # An autotools built package generally needs these scripts, however only
156 # automake or libtoolize actually install the current versions of them.
157 # This is a problem in builds that do not use libtool or automake, in the case
158 # where we -need- the latest version of these scripts. e.g. running a build
159 # for a package whose autotools are old, on an x86_64 machine, which the old
160 # config.sub does not support. Work around this by installing them manually
161 # regardless.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600162
163 PRUNE_M4=""
164
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500165 for ac in `find ${S} -ignore_readdir_race -name configure.in -o -name configure.ac`; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500166 rm -f `dirname $ac`/configure
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500167 done
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500168 if [ -e ${AUTOTOOLS_SCRIPT_PATH}/configure.in -o -e ${AUTOTOOLS_SCRIPT_PATH}/configure.ac ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500169 olddir=`pwd`
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500170 cd ${AUTOTOOLS_SCRIPT_PATH}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500171 mkdir -p ${ACLOCALDIR}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500172 ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/"
173 if [ x"${acpaths}" = xdefault ]; then
174 acpaths=
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500175 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 -0600176 grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500177 acpaths="$acpaths -I $i"
178 done
179 else
180 acpaths="${acpaths}"
181 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500182 acpaths="$acpaths ${ACLOCALEXTRAPATH}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500183 AUTOV=`automake --version | sed -e '1{s/.* //;s/\.[0-9]\+$//};q'`
184 automake --version
185 echo "AUTOV is $AUTOV"
186 if [ -d ${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV ]; then
187 ACLOCAL="$ACLOCAL --automake-acdir=${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV"
188 fi
189 # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
190 # like it was auto-generated. Work around this by blowing it away
191 # by hand, unless the package specifically asked not to run aclocal.
192 if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
193 rm -f aclocal.m4
194 fi
195 if [ -e configure.in ]; then
196 CONFIGURE_AC=configure.in
197 else
198 CONFIGURE_AC=configure.ac
199 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500200 if grep -q "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC; then
201 if grep -q "sed.*POTFILES" $CONFIGURE_AC; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500202 : do nothing -- we still have an old unmodified configure.ac
203 else
204 bbnote Executing glib-gettextize --force --copy
205 echo "no" | glib-gettextize --force --copy
206 fi
Brad Bishop316dfdd2018-06-25 12:45:53 -0400207 elif [ "${BPN}" != "gettext" ] && grep -q "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500208 # We'd call gettextize here if it wasn't so broken...
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500209 cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/
210 if [ -d ${S}/po/ ]; then
211 cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/
212 if [ ! -e ${S}/po/remove-potcdate.sin ]; then
213 cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sin ${S}/po/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500214 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500215 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600216 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 -0500217 fi
218 mkdir -p m4
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600219
220 for i in $PRUNE_M4; do
221 find ${S} -ignore_readdir_race -name $i -delete
222 done
223
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800224 bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600225 ACLOCAL="$ACLOCAL" autoreconf -Wcross -Wno-obsolete --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || die "autoreconf execution failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500226 cd $olddir
227 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500228 if [ -e ${CONFIGURE_SCRIPT} ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500229 oe_runconf
230 else
231 bbnote "nothing to configure"
232 fi
233}
234
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600235autotools_do_compile() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800236 oe_runmake
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600237}
238
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500239autotools_do_install() {
240 oe_runmake 'DESTDIR=${D}' install
241 # Info dir listing isn't interesting at this point so remove it if it exists.
242 if [ -e "${D}${infodir}/dir" ]; then
243 rm -f ${D}${infodir}/dir
244 fi
245}
246
247inherit siteconfig
248
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600249EXPORT_FUNCTIONS do_configure do_compile do_install
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500250
251B = "${WORKDIR}/build"