xorg-xserver: obsolete old versions
[openembedded.git] / classes / autotools.bbclass
blob247e21d199d91ccbbb96c82f690dec34f35a0adc
1 # use autotools_stage_all for native packages
2 AUTOTOOLS_NATIVE_STAGE_INSTALL = "1"
4 def autotools_deps(d):
5         if bb.data.getVar('INHIBIT_AUTOTOOLS_DEPS', d, 1):
6                 return ''
8         pn = bb.data.getVar('PN', d, 1)
9         deps = ''
11         if pn in ['autoconf-native', 'automake-native', 'help2man-native']:
12                 return deps
13         deps += 'autoconf-native automake-native help2man-native '
15         if not pn in ['libtool', 'libtool-native', 'libtool-cross']:
16                 deps += 'libtool-native '
17                 if not bb.data.inherits_class('native', d) \
18                         and not bb.data.inherits_class('cross', d) \
19                         and not bb.data.inherits_class('sdk', d) \
20                         and not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d, 1):
21                     deps += 'libtool-cross '
23         return deps + 'gnu-config-native '
25 EXTRA_OEMAKE = ""
27 DEPENDS_prepend = "${@autotools_deps(d)}"
28 DEPENDS_virtclass-native_prepend = "${@autotools_deps(d)}"
29 DEPENDS_virtclass-nativesdk_prepend = "${@autotools_deps(d)}"
31 inherit siteinfo
33 def _autotools_get_sitefiles(d):
34     def inherits(d, *classes):
35         if any(bb.data.inherits_class(cls, d) for cls in classes):
36             return True
38     if inherits(d, "native", "nativesdk"):
39         return
41     sitedata = siteinfo_data(d)
42     for path in d.getVar("BBPATH", True).split(":"):
43         for element in sitedata:
44             filename = os.path.join(path, "site", element)
45             if os.path.exists(filename):
46                 yield filename
48 # Space separated list of shell scripts with variables defined to supply test
49 # results for autoconf tests we cannot run at build time.
50 export CONFIG_SITE = "${@' '.join(_autotools_get_sitefiles(d))}"
52 acpaths = "default"
53 EXTRA_AUTORECONF = "--exclude=autopoint"
55 def autotools_set_crosscompiling(d):
56         if not bb.data.inherits_class('native', d):
57                 return " cross_compiling=yes"
58         return ""
60 def append_libtool_sysroot(d):
61         if bb.data.getVar('LIBTOOL_HAS_SYSROOT', d, 1) == "yes":
62                 if bb.data.getVar('BUILD_SYS', d, 1) == bb.data.getVar('HOST_SYS', d, 1):
63                         return '--with-libtool-sysroot'
64                 else:
65                         return '--with-libtool-sysroot=${STAGING_DIR_HOST}'
66         return ''
68 # EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}"
70 CONFIGUREOPTS = " --build=${BUILD_SYS} \
71                   --host=${HOST_SYS} \
72                   --target=${TARGET_SYS} \
73                   --prefix=${prefix} \
74                   --exec_prefix=${exec_prefix} \
75                   --bindir=${bindir} \
76                   --sbindir=${sbindir} \
77                   --libexecdir=${libexecdir} \
78                   --datadir=${datadir} \
79                   --sysconfdir=${sysconfdir} \
80                   --sharedstatedir=${sharedstatedir} \
81                   --localstatedir=${localstatedir} \
82                   --libdir=${libdir} \
83                   --includedir=${includedir} \
84                   --oldincludedir=${oldincludedir} \
85                   --infodir=${infodir} \
86                   --mandir=${mandir} \
87                   ${@append_libtool_sysroot(d)} \
88                 "
90 oe_runconf () {
91         if [ -x ${S}/configure ] ; then
92                 ${S}/configure \
93                 ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"
94         else
95                 oefatal "no configure script found"
96         fi
99 autotools_do_configure() {
100         case ${PN} in
101         autoconf*)
102         ;;
103         automake*)
104         ;;
105         *)
106                 # WARNING: gross hack follows:
107                 # An autotools built package generally needs these scripts, however only
108                 # automake or libtoolize actually install the current versions of them.
109                 # This is a problem in builds that do not use libtool or automake, in the case
110                 # where we -need- the latest version of these scripts.  e.g. running a build
111                 # for a package whose autotools are old, on an x86_64 machine, which the old
112                 # config.sub does not support.  Work around this by installing them manually
113                 # regardless.
114                 ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do
115                         rm -f `dirname $ac`/configure
116                         done )
117                 if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
118                         olddir=`pwd`
119                         cd ${S}
120                         if [ x"${acpaths}" = xdefault ]; then
121                                 acpaths=
122                                 for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
123                                         grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
124                                         acpaths="$acpaths -I $i"
125                                 done
126                         else
127                                 acpaths="${acpaths}"
128                         fi
129                         AUTOV=`automake --version |head -n 1 |sed "s/.* //;s/\.[0-9]\+$//"`
130                         automake --version
131                         echo "AUTOV is $AUTOV"
132                         install -d ${STAGING_DATADIR}/aclocal
133                         install -d ${STAGING_DATADIR}/aclocal-$AUTOV
134                         acpaths="$acpaths -I${STAGING_DATADIR}/aclocal-$AUTOV -I ${STAGING_DATADIR}/aclocal"
135                         # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
136                         # like it was auto-generated.  Work around this by blowing it away
137                         # by hand, unless the package specifically asked not to run aclocal.
138                         if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
139                                 rm -f aclocal.m4
140                         fi
141                         if [ -e configure.in ]; then
142                           CONFIGURE_AC=configure.in
143                         else
144                           CONFIGURE_AC=configure.ac
145                         fi
146                         if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
147                           if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
148                             : do nothing -- we still have an old unmodified configure.ac
149                           else
150                             oenote Executing glib-gettextize --force --copy
151                             echo "no" | glib-gettextize --force --copy
152                           fi
153                         else if grep "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
154                           if [ -e ${STAGING_DATADIR}/gettext/config.rpath ]; then
155                             cp ${STAGING_DATADIR}/gettext/config.rpath ${S}/
156                           else
157                             oenote ${STAGING_DATADIR}/gettext/config.rpath not found. gettext is not installed.
158                           fi
159                         fi
161                         fi
162                         mkdir -p m4
163                         oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
164                         autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed."
165                         if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
166                           oenote Executing intltoolize --copy --force --automake
167                           intltoolize --copy --force --automake
168                         fi
169                         cd $olddir
170                 fi
171         ;;
172         esac
173         if [ -e ${S}/configure ]; then
174                 oe_runconf $@
175         else
176                 oenote "nothing to configure"
177         fi
180 autotools_do_install() {
181         oe_runmake 'DESTDIR=${D}' install
184 PACKAGE_PREPROCESS_FUNCS += "${@['autotools_prepackage_lamangler',''][bb.data.getVar('LIBTOOL_HAS_SYSROOT', d, 1) == "yes"]}"
185 autotools_prepackage_lamangler () {
186         for i in `find ${PKGD} -name "*.la"` ; do \
187             sed -i -e 's:${STAGING_LIBDIR}:${libdir}:g;' \
188                    -e 's:${D}::g;' \
189                    -e 's:-I${WORKDIR}\S*: :g;' \
190                    -e 's:-L${WORKDIR}\S*: :g;' \
191                    $i
192         done
195 # STAGE_TEMP_PREFIX is used for a speedup by packaged-staging
196 STAGE_TEMP="${WORKDIR}/temp-staging"
197 STAGE_TEMP_PREFIX = ""
199 autotools_stage_includes() {
200         if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ]
201         then
202                 rm -rf ${STAGE_TEMP}
203                 mkdir -p ${STAGE_TEMP}
204                 make DESTDIR="${STAGE_TEMP}" install
205                 cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
206                 rm -rf ${STAGE_TEMP}
207         fi
210 autotools_stage_dir() {
211         sysroot_stage_dir $1 ${STAGE_TEMP_PREFIX}$2
214 autotools_stage_libdir() {
215         sysroot_stage_libdir $1 ${STAGE_TEMP_PREFIX}$2
218 autotools_stage_all() {
219         if [ "${INHIBIT_AUTO_STAGE}" = "1" ]
220         then
221                 return
222         fi
223         rm -rf ${STAGE_TEMP}
224         mkdir -p ${STAGE_TEMP}
225         oe_runmake DESTDIR="${STAGE_TEMP}" install
226         rm -rf ${STAGE_TEMP}/${mandir} || true
227         rm -rf ${STAGE_TEMP}/${infodir} || true
228         sysroot_stage_dirs ${STAGE_TEMP} ${STAGE_TEMP_PREFIX}
229         rm -rf ${STAGE_TEMP}
232 EXPORT_FUNCTIONS do_configure do_install