blob: efa4098d63086fe0606bc6032009491734e238a2 [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
8 if pn in ['autoconf-native', 'automake-native', 'help2man-native']:
9 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.
Patrick Williamsc0f7c042017-02-23 20:41:17 -060028export CONFIG_SITE = "${@siteinfo_get_files(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030acpaths ?= "default"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031EXTRA_AUTORECONF = "--exclude=autopoint"
32
33export lt_cv_sys_lib_dlsearch_path_spec = "${libdir} ${base_libdir}"
34
35# When building tools for use at build-time it's recommended for the build
36# system to use these variables when cross-compiling.
37# (http://sources.redhat.com/autobook/autobook/autobook_270.html)
38export CPP_FOR_BUILD = "${BUILD_CPP}"
39export CPPFLAGS_FOR_BUILD = "${BUILD_CPPFLAGS}"
40
41export CC_FOR_BUILD = "${BUILD_CC}"
42export CFLAGS_FOR_BUILD = "${BUILD_CFLAGS}"
43
44export CXX_FOR_BUILD = "${BUILD_CXX}"
45export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
46
47export LD_FOR_BUILD = "${BUILD_LD}"
48export LDFLAGS_FOR_BUILD = "${BUILD_LDFLAGS}"
49
50def append_libtool_sysroot(d):
51 # Only supply libtool sysroot option for non-native packages
52 if not bb.data.inherits_class('native', d):
53 return '--with-libtool-sysroot=${STAGING_DIR_HOST}'
54 return ""
55
56CONFIGUREOPTS = " --build=${BUILD_SYS} \
57 --host=${HOST_SYS} \
58 --target=${TARGET_SYS} \
59 --prefix=${prefix} \
60 --exec_prefix=${exec_prefix} \
61 --bindir=${bindir} \
62 --sbindir=${sbindir} \
63 --libexecdir=${libexecdir} \
64 --datadir=${datadir} \
65 --sysconfdir=${sysconfdir} \
66 --sharedstatedir=${sharedstatedir} \
67 --localstatedir=${localstatedir} \
68 --libdir=${libdir} \
69 --includedir=${includedir} \
70 --oldincludedir=${oldincludedir} \
71 --infodir=${infodir} \
72 --mandir=${mandir} \
73 --disable-silent-rules \
74 ${CONFIGUREOPT_DEPTRACK} \
75 ${@append_libtool_sysroot(d)}"
76CONFIGUREOPT_DEPTRACK ?= "--disable-dependency-tracking"
77
Patrick Williamsc0f7c042017-02-23 20:41:17 -060078CACHED_CONFIGUREVARS ?= ""
79
Patrick Williamsf1e5d692016-03-30 15:21:19 -050080AUTOTOOLS_SCRIPT_PATH ?= "${S}"
81CONFIGURE_SCRIPT ?= "${AUTOTOOLS_SCRIPT_PATH}/configure"
82
83AUTOTOOLS_AUXDIR ?= "${AUTOTOOLS_SCRIPT_PATH}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084
85oe_runconf () {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050086 # Use relative path to avoid buildpaths in files
87 cfgscript_name="`basename ${CONFIGURE_SCRIPT}`"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060088 cfgscript=`python3 -c "import os; print(os.path.relpath(os.path.dirname('${CONFIGURE_SCRIPT}'), '.'))"`/$cfgscript_name
Patrick Williamsc124f4f2015-09-15 14:41:29 -050089 if [ -x "$cfgscript" ] ; then
90 bbnote "Running $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} $@"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050091 if ! ${CACHED_CONFIGUREVARS} $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"; then
92 bbnote "The following config.log files may provide further information."
93 bbnote `find ${B} -ignore_readdir_race -type f -name config.log`
94 bbfatal_log "configure failed"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050096 else
97 bbfatal "no configure script found at $cfgscript"
98 fi
99}
100
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500101CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate"
102
103autotools_preconfigure() {
104 if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then
105 if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then
106 if [ "${S}" != "${B}" ]; then
107 echo "Previously configured separate build directory detected, cleaning ${B}"
108 rm -rf ${B}
Patrick Williamsd7e96312015-09-22 08:09:05 -0500109 mkdir -p ${B}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500110 else
111 # At least remove the .la files since automake won't automatically
112 # regenerate them even if CFLAGS/LDFLAGS are different
113 cd ${S}
114 if [ "${CLEANBROKEN}" != "1" -a \( -e Makefile -o -e makefile -o -e GNUmakefile \) ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500115 oe_runmake clean
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500116 fi
117 find ${S} -ignore_readdir_race -name \*.la -delete
118 fi
119 fi
120 fi
121}
122
123autotools_postconfigure(){
124 if [ -n "${CONFIGURESTAMPFILE}" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500125 mkdir -p `dirname ${CONFIGURESTAMPFILE}`
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500126 echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE}
127 fi
128}
129
130EXTRACONFFUNCS ??= ""
131
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600132EXTRA_OECONF_append = " ${PACKAGECONFIG_CONFARGS}"
133
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500134do_configure[prefuncs] += "autotools_preconfigure autotools_aclocals ${EXTRACONFFUNCS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500135do_configure[postfuncs] += "autotools_postconfigure"
136
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500137ACLOCALDIR = "${STAGING_DATADIR}/aclocal"
138ACLOCALEXTRAPATH = ""
139ACLOCALEXTRAPATH_class-target = " -I ${STAGING_DATADIR_NATIVE}/aclocal/"
140ACLOCALEXTRAPATH_class-nativesdk = " -I ${STAGING_DATADIR_NATIVE}/aclocal/"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500141
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500142python autotools_aclocals () {
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600143 # Refresh variable with cache files
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500144 d.setVar("CONFIG_SITE", siteinfo_get_files(d, sysrootcache=True))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500145}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500146
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600147CONFIGURE_FILES = "${S}/configure.in ${S}/configure.ac ${S}/config.h.in ${S}/acinclude.m4 Makefile.am"
148
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500149autotools_do_configure() {
150 # WARNING: gross hack follows:
151 # An autotools built package generally needs these scripts, however only
152 # automake or libtoolize actually install the current versions of them.
153 # This is a problem in builds that do not use libtool or automake, in the case
154 # where we -need- the latest version of these scripts. e.g. running a build
155 # for a package whose autotools are old, on an x86_64 machine, which the old
156 # config.sub does not support. Work around this by installing them manually
157 # regardless.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600158
159 PRUNE_M4=""
160
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500161 for ac in `find ${S} -ignore_readdir_race -name configure.in -o -name configure.ac`; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500162 rm -f `dirname $ac`/configure
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500163 done
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500164 if [ -e ${AUTOTOOLS_SCRIPT_PATH}/configure.in -o -e ${AUTOTOOLS_SCRIPT_PATH}/configure.ac ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500165 olddir=`pwd`
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500166 cd ${AUTOTOOLS_SCRIPT_PATH}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500167 mkdir -p ${ACLOCALDIR}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168 ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/"
169 if [ x"${acpaths}" = xdefault ]; then
170 acpaths=
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500171 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 -0600172 grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500173 acpaths="$acpaths -I $i"
174 done
175 else
176 acpaths="${acpaths}"
177 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500178 acpaths="$acpaths ${ACLOCALEXTRAPATH}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500179 AUTOV=`automake --version | sed -e '1{s/.* //;s/\.[0-9]\+$//};q'`
180 automake --version
181 echo "AUTOV is $AUTOV"
182 if [ -d ${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV ]; then
183 ACLOCAL="$ACLOCAL --automake-acdir=${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV"
184 fi
185 # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
186 # like it was auto-generated. Work around this by blowing it away
187 # by hand, unless the package specifically asked not to run aclocal.
188 if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
189 rm -f aclocal.m4
190 fi
191 if [ -e configure.in ]; then
192 CONFIGURE_AC=configure.in
193 else
194 CONFIGURE_AC=configure.ac
195 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500196 if grep -q "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC; then
197 if grep -q "sed.*POTFILES" $CONFIGURE_AC; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500198 : do nothing -- we still have an old unmodified configure.ac
199 else
200 bbnote Executing glib-gettextize --force --copy
201 echo "no" | glib-gettextize --force --copy
202 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500203 elif grep -q "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500204 # We'd call gettextize here if it wasn't so broken...
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500205 cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/
206 if [ -d ${S}/po/ ]; then
207 cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/
208 if [ ! -e ${S}/po/remove-potcdate.sin ]; then
209 cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sin ${S}/po/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500210 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500211 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600212 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 -0500213 fi
214 mkdir -p m4
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500215 if grep -q "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600216 if ! echo "${DEPENDS}" | grep -q intltool-native; then
217 bbwarn "Missing DEPENDS on intltool-native"
218 fi
219 PRUNE_M4="$PRUNE_M4 intltool.m4"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500220 bbnote Executing intltoolize --copy --force --automake
221 intltoolize --copy --force --automake
222 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600223
224 for i in $PRUNE_M4; do
225 find ${S} -ignore_readdir_race -name $i -delete
226 done
227
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500228 bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
229 ACLOCAL="$ACLOCAL" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || die "autoreconf execution failed."
230 cd $olddir
231 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500232 if [ -e ${CONFIGURE_SCRIPT} ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500233 oe_runconf
234 else
235 bbnote "nothing to configure"
236 fi
237}
238
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600239autotools_do_compile() {
240 oe_runmake
241}
242
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500243autotools_do_install() {
244 oe_runmake 'DESTDIR=${D}' install
245 # Info dir listing isn't interesting at this point so remove it if it exists.
246 if [ -e "${D}${infodir}/dir" ]; then
247 rm -f ${D}${infodir}/dir
248 fi
249}
250
251inherit siteconfig
252
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600253EXPORT_FUNCTIONS do_configure do_compile do_install
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500254
255B = "${WORKDIR}/build"