xref: /OK3568_Linux_fs/yocto/poky/meta/classes/autotools.bbclass (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyundef get_autotools_dep(d):
2*4882a593Smuzhiyun    if d.getVar('INHIBIT_AUTOTOOLS_DEPS'):
3*4882a593Smuzhiyun        return ''
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun    pn = d.getVar('PN')
6*4882a593Smuzhiyun    deps = ''
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun    if pn in ['autoconf-native', 'automake-native']:
9*4882a593Smuzhiyun        return deps
10*4882a593Smuzhiyun    deps += 'autoconf-native automake-native '
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun    if not pn in ['libtool', 'libtool-native'] and not pn.endswith("libtool-cross"):
13*4882a593Smuzhiyun        deps += 'libtool-native '
14*4882a593Smuzhiyun        if not bb.data.inherits_class('native', d) \
15*4882a593Smuzhiyun                        and not bb.data.inherits_class('nativesdk', d) \
16*4882a593Smuzhiyun                        and not bb.data.inherits_class('cross', d) \
17*4882a593Smuzhiyun                        and not d.getVar('INHIBIT_DEFAULT_DEPS'):
18*4882a593Smuzhiyun            deps += 'libtool-cross '
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun    return deps
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunDEPENDS:prepend = "${@get_autotools_dep(d)} "
24*4882a593Smuzhiyun
25*4882a593Smuzhiyuninherit siteinfo
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun# Space separated list of shell scripts with variables defined to supply test
28*4882a593Smuzhiyun# results for autoconf tests we cannot run at build time.
29*4882a593Smuzhiyun# The value of this variable is filled in in a prefunc because it depends on
30*4882a593Smuzhiyun# the contents of the sysroot.
31*4882a593Smuzhiyunexport CONFIG_SITE
32*4882a593Smuzhiyun
33*4882a593Smuzhiyunacpaths ?= "default"
34*4882a593SmuzhiyunEXTRA_AUTORECONF = "--exclude=autopoint --exclude=gtkdocize"
35*4882a593Smuzhiyun
36*4882a593Smuzhiyunexport lt_cv_sys_lib_dlsearch_path_spec = "${libdir} ${base_libdir}"
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun# When building tools for use at build-time it's recommended for the build
39*4882a593Smuzhiyun# system to use these variables when cross-compiling.
40*4882a593Smuzhiyun# (http://sources.redhat.com/autobook/autobook/autobook_270.html)
41*4882a593Smuzhiyunexport CPP_FOR_BUILD = "${BUILD_CPP}"
42*4882a593Smuzhiyunexport CPPFLAGS_FOR_BUILD = "${BUILD_CPPFLAGS}"
43*4882a593Smuzhiyun
44*4882a593Smuzhiyunexport CC_FOR_BUILD = "${BUILD_CC}"
45*4882a593Smuzhiyunexport CFLAGS_FOR_BUILD = "${BUILD_CFLAGS}"
46*4882a593Smuzhiyun
47*4882a593Smuzhiyunexport CXX_FOR_BUILD = "${BUILD_CXX}"
48*4882a593Smuzhiyunexport CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
49*4882a593Smuzhiyun
50*4882a593Smuzhiyunexport LD_FOR_BUILD = "${BUILD_LD}"
51*4882a593Smuzhiyunexport LDFLAGS_FOR_BUILD = "${BUILD_LDFLAGS}"
52*4882a593Smuzhiyun
53*4882a593Smuzhiyundef append_libtool_sysroot(d):
54*4882a593Smuzhiyun    # Only supply libtool sysroot option for non-native packages
55*4882a593Smuzhiyun    if not bb.data.inherits_class('native', d):
56*4882a593Smuzhiyun        return '--with-libtool-sysroot=${STAGING_DIR_HOST}'
57*4882a593Smuzhiyun    return ""
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunCONFIGUREOPTS = " --build=${BUILD_SYS} \
60*4882a593Smuzhiyun		  --host=${HOST_SYS} \
61*4882a593Smuzhiyun		  --target=${TARGET_SYS} \
62*4882a593Smuzhiyun		  --prefix=${prefix} \
63*4882a593Smuzhiyun		  --exec_prefix=${exec_prefix} \
64*4882a593Smuzhiyun		  --bindir=${bindir} \
65*4882a593Smuzhiyun		  --sbindir=${sbindir} \
66*4882a593Smuzhiyun		  --libexecdir=${libexecdir} \
67*4882a593Smuzhiyun		  --datadir=${datadir} \
68*4882a593Smuzhiyun		  --sysconfdir=${sysconfdir} \
69*4882a593Smuzhiyun		  --sharedstatedir=${sharedstatedir} \
70*4882a593Smuzhiyun		  --localstatedir=${localstatedir} \
71*4882a593Smuzhiyun		  --libdir=${libdir} \
72*4882a593Smuzhiyun		  --includedir=${includedir} \
73*4882a593Smuzhiyun		  --oldincludedir=${oldincludedir} \
74*4882a593Smuzhiyun		  --infodir=${infodir} \
75*4882a593Smuzhiyun		  --mandir=${mandir} \
76*4882a593Smuzhiyun		  --disable-silent-rules \
77*4882a593Smuzhiyun		  ${CONFIGUREOPT_DEPTRACK} \
78*4882a593Smuzhiyun		  ${@append_libtool_sysroot(d)}"
79*4882a593SmuzhiyunCONFIGUREOPT_DEPTRACK ?= "--disable-dependency-tracking"
80*4882a593Smuzhiyun
81*4882a593SmuzhiyunCACHED_CONFIGUREVARS ?= ""
82*4882a593Smuzhiyun
83*4882a593SmuzhiyunAUTOTOOLS_SCRIPT_PATH ?= "${S}"
84*4882a593SmuzhiyunCONFIGURE_SCRIPT ?= "${AUTOTOOLS_SCRIPT_PATH}/configure"
85*4882a593Smuzhiyun
86*4882a593SmuzhiyunAUTOTOOLS_AUXDIR ?= "${AUTOTOOLS_SCRIPT_PATH}"
87*4882a593Smuzhiyun
88*4882a593Smuzhiyunoe_runconf () {
89*4882a593Smuzhiyun	# Use relative path to avoid buildpaths in files
90*4882a593Smuzhiyun	cfgscript_name="`basename ${CONFIGURE_SCRIPT}`"
91*4882a593Smuzhiyun	cfgscript=`python3 -c "import os; print(os.path.relpath(os.path.dirname('${CONFIGURE_SCRIPT}'), '.'))"`/$cfgscript_name
92*4882a593Smuzhiyun	if [ -x "$cfgscript" ] ; then
93*4882a593Smuzhiyun		bbnote "Running $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} $@"
94*4882a593Smuzhiyun		if ! CONFIG_SHELL=${CONFIG_SHELL-/bin/bash} ${CACHED_CONFIGUREVARS} $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"; then
95*4882a593Smuzhiyun			bbnote "The following config.log files may provide further information."
96*4882a593Smuzhiyun			bbnote `find ${B} -ignore_readdir_race -type f -name config.log`
97*4882a593Smuzhiyun			bbfatal_log "configure failed"
98*4882a593Smuzhiyun		fi
99*4882a593Smuzhiyun	else
100*4882a593Smuzhiyun		bbfatal "no configure script found at $cfgscript"
101*4882a593Smuzhiyun	fi
102*4882a593Smuzhiyun}
103*4882a593Smuzhiyun
104*4882a593SmuzhiyunCONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate"
105*4882a593Smuzhiyun
106*4882a593Smuzhiyunautotools_preconfigure() {
107*4882a593Smuzhiyun	if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then
108*4882a593Smuzhiyun		if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then
109*4882a593Smuzhiyun			if [ "${S}" != "${B}" ]; then
110*4882a593Smuzhiyun				echo "Previously configured separate build directory detected, cleaning ${B}"
111*4882a593Smuzhiyun				rm -rf ${B}
112*4882a593Smuzhiyun				mkdir -p ${B}
113*4882a593Smuzhiyun			else
114*4882a593Smuzhiyun				# At least remove the .la files since automake won't automatically
115*4882a593Smuzhiyun				# regenerate them even if CFLAGS/LDFLAGS are different
116*4882a593Smuzhiyun				cd ${S}
117*4882a593Smuzhiyun				if [ "${CLEANBROKEN}" != "1" -a \( -e Makefile -o -e makefile -o -e GNUmakefile \) ]; then
118*4882a593Smuzhiyun					oe_runmake clean
119*4882a593Smuzhiyun				fi
120*4882a593Smuzhiyun				find ${S} -ignore_readdir_race -name \*.la -delete
121*4882a593Smuzhiyun			fi
122*4882a593Smuzhiyun		fi
123*4882a593Smuzhiyun	fi
124*4882a593Smuzhiyun}
125*4882a593Smuzhiyun
126*4882a593Smuzhiyunautotools_postconfigure(){
127*4882a593Smuzhiyun	if [ -n "${CONFIGURESTAMPFILE}" ]; then
128*4882a593Smuzhiyun		mkdir -p `dirname ${CONFIGURESTAMPFILE}`
129*4882a593Smuzhiyun		echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE}
130*4882a593Smuzhiyun	fi
131*4882a593Smuzhiyun}
132*4882a593Smuzhiyun
133*4882a593SmuzhiyunEXTRACONFFUNCS ??= ""
134*4882a593Smuzhiyun
135*4882a593SmuzhiyunEXTRA_OECONF:append = " ${PACKAGECONFIG_CONFARGS}"
136*4882a593Smuzhiyun
137*4882a593Smuzhiyundo_configure[prefuncs] += "autotools_preconfigure autotools_aclocals ${EXTRACONFFUNCS}"
138*4882a593Smuzhiyundo_compile[prefuncs] += "autotools_aclocals"
139*4882a593Smuzhiyundo_install[prefuncs] += "autotools_aclocals"
140*4882a593Smuzhiyundo_configure[postfuncs] += "autotools_postconfigure"
141*4882a593Smuzhiyun
142*4882a593SmuzhiyunACLOCALDIR = "${STAGING_DATADIR}/aclocal"
143*4882a593SmuzhiyunACLOCALEXTRAPATH = ""
144*4882a593SmuzhiyunACLOCALEXTRAPATH:class-target = " -I ${STAGING_DATADIR_NATIVE}/aclocal/"
145*4882a593SmuzhiyunACLOCALEXTRAPATH:class-nativesdk = " -I ${STAGING_DATADIR_NATIVE}/aclocal/"
146*4882a593Smuzhiyun
147*4882a593Smuzhiyunpython autotools_aclocals () {
148*4882a593Smuzhiyun    sitefiles, searched = siteinfo_get_files(d, sysrootcache=True)
149*4882a593Smuzhiyun    d.setVar("CONFIG_SITE", " ".join(sitefiles))
150*4882a593Smuzhiyun}
151*4882a593Smuzhiyun
152*4882a593Smuzhiyundo_configure[file-checksums] += "${@' '.join(siteinfo_get_files(d, sysrootcache=False)[1])}"
153*4882a593Smuzhiyun
154*4882a593SmuzhiyunCONFIGURE_FILES = "${S}/configure.in ${S}/configure.ac ${S}/config.h.in ${S}/acinclude.m4 Makefile.am"
155*4882a593Smuzhiyun
156*4882a593Smuzhiyunautotools_do_configure() {
157*4882a593Smuzhiyun	# WARNING: gross hack follows:
158*4882a593Smuzhiyun	# An autotools built package generally needs these scripts, however only
159*4882a593Smuzhiyun	# automake or libtoolize actually install the current versions of them.
160*4882a593Smuzhiyun	# This is a problem in builds that do not use libtool or automake, in the case
161*4882a593Smuzhiyun	# where we -need- the latest version of these scripts.  e.g. running a build
162*4882a593Smuzhiyun	# for a package whose autotools are old, on an x86_64 machine, which the old
163*4882a593Smuzhiyun	# config.sub does not support.  Work around this by installing them manually
164*4882a593Smuzhiyun	# regardless.
165*4882a593Smuzhiyun
166*4882a593Smuzhiyun	PRUNE_M4=""
167*4882a593Smuzhiyun
168*4882a593Smuzhiyun	for ac in `find ${S} -ignore_readdir_race -name configure.in -o -name configure.ac`; do
169*4882a593Smuzhiyun		rm -f `dirname $ac`/configure
170*4882a593Smuzhiyun	done
171*4882a593Smuzhiyun	if [ -e ${AUTOTOOLS_SCRIPT_PATH}/configure.in -o -e ${AUTOTOOLS_SCRIPT_PATH}/configure.ac ]; then
172*4882a593Smuzhiyun		olddir=`pwd`
173*4882a593Smuzhiyun		cd ${AUTOTOOLS_SCRIPT_PATH}
174*4882a593Smuzhiyun		mkdir -p ${ACLOCALDIR}
175*4882a593Smuzhiyun		ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/"
176*4882a593Smuzhiyun		if [ x"${acpaths}" = xdefault ]; then
177*4882a593Smuzhiyun			acpaths=
178*4882a593Smuzhiyun			for i in `find ${AUTOTOOLS_SCRIPT_PATH} -ignore_readdir_race -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
179*4882a593Smuzhiyun				grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
180*4882a593Smuzhiyun				acpaths="$acpaths -I $i"
181*4882a593Smuzhiyun			done
182*4882a593Smuzhiyun		else
183*4882a593Smuzhiyun			acpaths="${acpaths}"
184*4882a593Smuzhiyun		fi
185*4882a593Smuzhiyun		acpaths="$acpaths ${ACLOCALEXTRAPATH}"
186*4882a593Smuzhiyun		AUTOV=`automake --version | sed -e '1{s/.* //;s/\.[0-9]\+$//};q'`
187*4882a593Smuzhiyun		automake --version
188*4882a593Smuzhiyun		echo "AUTOV is $AUTOV"
189*4882a593Smuzhiyun		if [ -d ${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV ]; then
190*4882a593Smuzhiyun			ACLOCAL="$ACLOCAL --automake-acdir=${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV"
191*4882a593Smuzhiyun		fi
192*4882a593Smuzhiyun		# autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
193*4882a593Smuzhiyun		# like it was auto-generated.  Work around this by blowing it away
194*4882a593Smuzhiyun		# by hand, unless the package specifically asked not to run aclocal.
195*4882a593Smuzhiyun		if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
196*4882a593Smuzhiyun			rm -f aclocal.m4
197*4882a593Smuzhiyun		fi
198*4882a593Smuzhiyun		if [ -e configure.in ]; then
199*4882a593Smuzhiyun			CONFIGURE_AC=configure.in
200*4882a593Smuzhiyun		else
201*4882a593Smuzhiyun			CONFIGURE_AC=configure.ac
202*4882a593Smuzhiyun		fi
203*4882a593Smuzhiyun		if grep -q "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC; then
204*4882a593Smuzhiyun			if grep -q "sed.*POTFILES" $CONFIGURE_AC; then
205*4882a593Smuzhiyun				: do nothing -- we still have an old unmodified configure.ac
206*4882a593Smuzhiyun	    		else
207*4882a593Smuzhiyun				bbnote Executing glib-gettextize --force --copy
208*4882a593Smuzhiyun				echo "no" | glib-gettextize --force --copy
209*4882a593Smuzhiyun			fi
210*4882a593Smuzhiyun		elif [ "${BPN}" != "gettext" ] && grep -q "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC; then
211*4882a593Smuzhiyun			# We'd call gettextize here if it wasn't so broken...
212*4882a593Smuzhiyun			cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/
213*4882a593Smuzhiyun			if [ -d ${S}/po/ ]; then
214*4882a593Smuzhiyun				cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/
215*4882a593Smuzhiyun				if [ ! -e ${S}/po/remove-potcdate.sin ]; then
216*4882a593Smuzhiyun					cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sin ${S}/po/
217*4882a593Smuzhiyun				fi
218*4882a593Smuzhiyun			fi
219*4882a593Smuzhiyun			PRUNE_M4="$PRUNE_M4 gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4"
220*4882a593Smuzhiyun		fi
221*4882a593Smuzhiyun		mkdir -p m4
222*4882a593Smuzhiyun
223*4882a593Smuzhiyun		for i in $PRUNE_M4; do
224*4882a593Smuzhiyun			find ${S} -ignore_readdir_race -name $i -delete
225*4882a593Smuzhiyun		done
226*4882a593Smuzhiyun
227*4882a593Smuzhiyun		bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
228*4882a593Smuzhiyun		ACLOCAL="$ACLOCAL" autoreconf -Wcross -Wno-obsolete --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || die "autoreconf execution failed."
229*4882a593Smuzhiyun		cd $olddir
230*4882a593Smuzhiyun	fi
231*4882a593Smuzhiyun	if [ -e ${CONFIGURE_SCRIPT} ]; then
232*4882a593Smuzhiyun		oe_runconf
233*4882a593Smuzhiyun	else
234*4882a593Smuzhiyun		bbnote "nothing to configure"
235*4882a593Smuzhiyun	fi
236*4882a593Smuzhiyun}
237*4882a593Smuzhiyun
238*4882a593Smuzhiyunautotools_do_compile() {
239*4882a593Smuzhiyun	oe_runmake
240*4882a593Smuzhiyun}
241*4882a593Smuzhiyun
242*4882a593Smuzhiyunautotools_do_install() {
243*4882a593Smuzhiyun	oe_runmake 'DESTDIR=${D}' install
244*4882a593Smuzhiyun	# Info dir listing isn't interesting at this point so remove it if it exists.
245*4882a593Smuzhiyun	if [ -e "${D}${infodir}/dir" ]; then
246*4882a593Smuzhiyun		rm -f ${D}${infodir}/dir
247*4882a593Smuzhiyun	fi
248*4882a593Smuzhiyun}
249*4882a593Smuzhiyun
250*4882a593Smuzhiyuninherit siteconfig
251*4882a593Smuzhiyun
252*4882a593SmuzhiyunEXPORT_FUNCTIONS do_configure do_compile do_install
253*4882a593Smuzhiyun
254*4882a593SmuzhiyunB = "${WORKDIR}/build"
255