diff options
author | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
commit | c527fd1f14c27855a37f2e8ac5346ce8d940ced2 (patch) | |
tree | bb002c1fdf011c41dbd2f0927bed23ecb5f83c97 /meta/classes/autotools.bbclass | |
download | poky-c527fd1f14c27855a37f2e8ac5346ce8d940ced2.tar.gz |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'meta/classes/autotools.bbclass')
-rw-r--r-- | meta/classes/autotools.bbclass | 271 |
1 files changed, 271 insertions, 0 deletions
diff --git a/meta/classes/autotools.bbclass b/meta/classes/autotools.bbclass new file mode 100644 index 0000000000..c60ba10929 --- /dev/null +++ b/meta/classes/autotools.bbclass | |||
@@ -0,0 +1,271 @@ | |||
1 | def autotools_dep_prepend(d): | ||
2 | if d.getVar('INHIBIT_AUTOTOOLS_DEPS', True): | ||
3 | return '' | ||
4 | |||
5 | pn = d.getVar('PN', True) | ||
6 | 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) \ | ||
17 | and not d.getVar('INHIBIT_DEFAULT_DEPS', True): | ||
18 | deps += 'libtool-cross ' | ||
19 | |||
20 | return deps + 'gnu-config-native ' | ||
21 | |||
22 | EXTRA_OEMAKE = "" | ||
23 | |||
24 | DEPENDS_prepend = "${@autotools_dep_prepend(d)}" | ||
25 | |||
26 | inherit siteinfo | ||
27 | |||
28 | # Space separated list of shell scripts with variables defined to supply test | ||
29 | # results for autoconf tests we cannot run at build time. | ||
30 | export CONFIG_SITE = "${@siteinfo_get_files(d)}" | ||
31 | |||
32 | acpaths = "default" | ||
33 | EXTRA_AUTORECONF = "--exclude=autopoint" | ||
34 | |||
35 | export lt_cv_sys_lib_dlsearch_path_spec = "${libdir} ${base_libdir}" | ||
36 | |||
37 | # When building tools for use at build-time it's recommended for the build | ||
38 | # system to use these variables when cross-compiling. | ||
39 | # (http://sources.redhat.com/autobook/autobook/autobook_270.html) | ||
40 | export CPP_FOR_BUILD = "${BUILD_CPP}" | ||
41 | export CPPFLAGS_FOR_BUILD = "${BUILD_CPPFLAGS}" | ||
42 | |||
43 | export CC_FOR_BUILD = "${BUILD_CC}" | ||
44 | export CFLAGS_FOR_BUILD = "${BUILD_CFLAGS}" | ||
45 | |||
46 | export CXX_FOR_BUILD = "${BUILD_CXX}" | ||
47 | export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}" | ||
48 | |||
49 | export LD_FOR_BUILD = "${BUILD_LD}" | ||
50 | export LDFLAGS_FOR_BUILD = "${BUILD_LDFLAGS}" | ||
51 | |||
52 | def autotools_set_crosscompiling(d): | ||
53 | if not bb.data.inherits_class('native', d): | ||
54 | return " cross_compiling=yes" | ||
55 | return "" | ||
56 | |||
57 | def append_libtool_sysroot(d): | ||
58 | # Only supply libtool sysroot option for non-native packages | ||
59 | if not bb.data.inherits_class('native', d): | ||
60 | return '--with-libtool-sysroot=${STAGING_DIR_HOST}' | ||
61 | return "" | ||
62 | |||
63 | # EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}" | ||
64 | |||
65 | CONFIGUREOPTS = " --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)}" | ||
85 | CONFIGUREOPT_DEPTRACK = "--disable-dependency-tracking" | ||
86 | |||
87 | |||
88 | oe_runconf () { | ||
89 | cfgscript="${S}/configure" | ||
90 | if [ -x "$cfgscript" ] ; then | ||
91 | bbnote "Running $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} $@" | ||
92 | set +e | ||
93 | ${CACHED_CONFIGUREVARS} $cfgscript ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@" | ||
94 | if [ "$?" != "0" ]; then | ||
95 | echo "Configure failed. The contents of all config.log files follows to aid debugging" | ||
96 | find ${S} -name config.log -print -exec cat {} \; | ||
97 | bbfatal "oe_runconf failed" | ||
98 | fi | ||
99 | set -e | ||
100 | else | ||
101 | bbfatal "no configure script found at $cfgscript" | ||
102 | fi | ||
103 | } | ||
104 | |||
105 | AUTOTOOLS_AUXDIR ?= "${S}" | ||
106 | |||
107 | CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate" | ||
108 | |||
109 | autotools_preconfigure() { | ||
110 | if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then | ||
111 | if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then | ||
112 | if [ "${S}" != "${B}" ]; then | ||
113 | echo "Previously configured separate build directory detected, cleaning ${B}" | ||
114 | rm -rf ${B} | ||
115 | mkdir ${B} | ||
116 | else | ||
117 | # At least remove the .la files since automake won't automatically | ||
118 | # regenerate them even if CFLAGS/LDFLAGS are different | ||
119 | cd ${S}; find ${S} -name \*.la -delete | ||
120 | fi | ||
121 | fi | ||
122 | fi | ||
123 | } | ||
124 | |||
125 | autotools_postconfigure(){ | ||
126 | if [ -n "${CONFIGURESTAMPFILE}" ]; then | ||
127 | echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE} | ||
128 | fi | ||
129 | } | ||
130 | |||
131 | EXTRACONFFUNCS ??= "" | ||
132 | |||
133 | do_configure[prefuncs] += "autotools_preconfigure autotools_copy_aclocals ${EXTRACONFFUNCS}" | ||
134 | do_configure[postfuncs] += "autotools_postconfigure" | ||
135 | |||
136 | ACLOCALDIR = "${B}/aclocal-copy" | ||
137 | |||
138 | python autotools_copy_aclocals () { | ||
139 | s = d.getVar("S", True) | ||
140 | if not os.path.exists(s + "/configure.in") and not os.path.exists(s + "/configure.ac"): | ||
141 | if not d.getVar("AUTOTOOLS_COPYACLOCAL"): | ||
142 | return | ||
143 | |||
144 | taskdepdata = d.getVar("BB_TASKDEPDATA", False) | ||
145 | pn = d.getVar("PN", True) | ||
146 | aclocaldir = d.getVar("ACLOCALDIR", True) | ||
147 | oe.path.remove(aclocaldir) | ||
148 | bb.utils.mkdirhier(aclocaldir) | ||
149 | configuredeps = [] | ||
150 | for dep in taskdepdata: | ||
151 | data = taskdepdata[dep] | ||
152 | if data[1] == "do_configure" and data[0] != pn: | ||
153 | configuredeps.append(data[0]) | ||
154 | |||
155 | cp = [] | ||
156 | for c in configuredeps: | ||
157 | if c.endswith("-native"): | ||
158 | manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${BUILD_ARCH}-%s.populate_sysroot" % c) | ||
159 | elif c.startswith("nativesdk-"): | ||
160 | manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${SDK_ARCH}-%s.populate_sysroot" % c) | ||
161 | elif c.endswith("-cross") or c.endswith("-cross-initial") or c.endswith("-crosssdk") or c.endswith("-crosssdk-initial"): | ||
162 | continue | ||
163 | else: | ||
164 | manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${MACHINE}-%s.populate_sysroot" % c) | ||
165 | try: | ||
166 | f = open(manifest, "r") | ||
167 | for l in f: | ||
168 | if "/aclocal/" in l and l.strip().endswith(".m4"): | ||
169 | cp.append(l.strip()) | ||
170 | except: | ||
171 | bb.warn("%s not found" % manifest) | ||
172 | |||
173 | for c in cp: | ||
174 | t = os.path.join(aclocaldir, os.path.basename(c)) | ||
175 | if not os.path.exists(t): | ||
176 | os.symlink(c, t) | ||
177 | } | ||
178 | autotools_copy_aclocals[vardepsexclude] += "MACHINE SDK_ARCH BUILD_ARCH BB_TASKDEPDATA" | ||
179 | |||
180 | autotools_do_configure() { | ||
181 | # WARNING: gross hack follows: | ||
182 | # An autotools built package generally needs these scripts, however only | ||
183 | # automake or libtoolize actually install the current versions of them. | ||
184 | # This is a problem in builds that do not use libtool or automake, in the case | ||
185 | # where we -need- the latest version of these scripts. e.g. running a build | ||
186 | # for a package whose autotools are old, on an x86_64 machine, which the old | ||
187 | # config.sub does not support. Work around this by installing them manually | ||
188 | # regardless. | ||
189 | ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do | ||
190 | rm -f `dirname $ac`/configure | ||
191 | done ) | ||
192 | if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then | ||
193 | olddir=`pwd` | ||
194 | cd ${S} | ||
195 | ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/" | ||
196 | if [ x"${acpaths}" = xdefault ]; then | ||
197 | acpaths= | ||
198 | for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \ | ||
199 | grep -v 'acinclude.m4' | grep -v 'aclocal-copy' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do | ||
200 | acpaths="$acpaths -I $i" | ||
201 | done | ||
202 | else | ||
203 | acpaths="${acpaths}" | ||
204 | fi | ||
205 | AUTOV=`automake --version |head -n 1 |sed "s/.* //;s/\.[0-9]\+$//"` | ||
206 | automake --version | ||
207 | echo "AUTOV is $AUTOV" | ||
208 | if [ -d ${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV ]; then | ||
209 | ACLOCAL="$ACLOCAL --automake-acdir=${STAGING_DATADIR_NATIVE}/aclocal-$AUTOV" | ||
210 | fi | ||
211 | # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look | ||
212 | # like it was auto-generated. Work around this by blowing it away | ||
213 | # by hand, unless the package specifically asked not to run aclocal. | ||
214 | if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then | ||
215 | rm -f aclocal.m4 | ||
216 | fi | ||
217 | if [ -e configure.in ]; then | ||
218 | CONFIGURE_AC=configure.in | ||
219 | else | ||
220 | CONFIGURE_AC=configure.ac | ||
221 | fi | ||
222 | if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then | ||
223 | if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then | ||
224 | : do nothing -- we still have an old unmodified configure.ac | ||
225 | else | ||
226 | bbnote Executing glib-gettextize --force --copy | ||
227 | echo "no" | glib-gettextize --force --copy | ||
228 | fi | ||
229 | else if grep "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then | ||
230 | # We'd call gettextize here if it wasn't so broken... | ||
231 | cp ${STAGING_DATADIR_NATIVE}/gettext/config.rpath ${AUTOTOOLS_AUXDIR}/ | ||
232 | if [ -d ${S}/po/ ]; then | ||
233 | cp -f ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in ${S}/po/ | ||
234 | if [ ! -e ${S}/po/remove-potcdate.sin ]; then | ||
235 | cp ${STAGING_DATADIR_NATIVE}/gettext/po/remove-potcdate.sin ${S}/po/ | ||
236 | fi | ||
237 | fi | ||
238 | for i in gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 po.m4 progtest.m4; do | ||
239 | for j in `find ${S} -name $i | grep -v aclocal-copy`; do | ||
240 | rm $j | ||
241 | done | ||
242 | done | ||
243 | fi | ||
244 | fi | ||
245 | mkdir -p m4 | ||
246 | if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then | ||
247 | bbnote Executing intltoolize --copy --force --automake | ||
248 | intltoolize --copy --force --automake | ||
249 | fi | ||
250 | bbnote Executing ACLOCAL=\"$ACLOCAL\" autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths | ||
251 | ACLOCAL="$ACLOCAL" autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || bbfatal "autoreconf execution failed." | ||
252 | cd $olddir | ||
253 | fi | ||
254 | if [ -e ${S}/configure ]; then | ||
255 | oe_runconf | ||
256 | else | ||
257 | bbnote "nothing to configure" | ||
258 | fi | ||
259 | } | ||
260 | |||
261 | autotools_do_install() { | ||
262 | oe_runmake 'DESTDIR=${D}' install | ||
263 | # Info dir listing isn't interesting at this point so remove it if it exists. | ||
264 | if [ -e "${D}${infodir}/dir" ]; then | ||
265 | rm -f ${D}${infodir}/dir | ||
266 | fi | ||
267 | } | ||
268 | |||
269 | inherit siteconfig | ||
270 | |||
271 | EXPORT_FUNCTIONS do_configure do_install | ||