xmms: bump PR
[openembedded.git] / classes / autotools.bbclass
blobb2de2b13f76abfc659b44bf3186b640edaaf0568
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']:
12                 return deps
13         deps += 'autoconf-native automake-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 # EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}"
62 CONFIGUREOPTS = " --build=${BUILD_SYS} \
63                   --host=${HOST_SYS} \
64                   --target=${TARGET_SYS} \
65                   --prefix=${prefix} \
66                   --exec_prefix=${exec_prefix} \
67                   --bindir=${bindir} \
68                   --sbindir=${sbindir} \
69                   --libexecdir=${libexecdir} \
70                   --datadir=${datadir} \
71                   --sysconfdir=${sysconfdir} \
72                   --sharedstatedir=${sharedstatedir} \
73                   --localstatedir=${localstatedir} \
74                   --libdir=${libdir} \
75                   --includedir=${includedir} \
76                   --oldincludedir=${oldincludedir} \
77                   --infodir=${infodir} \
78                   --mandir=${mandir}"
80 oe_runconf () {
81         if [ -x ${S}/configure ] ; then
82                 ${S}/configure ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"
83         else
84                 oefatal "no configure script found"
85         fi
88 autotools_do_configure() {
89         case ${PN} in
90         autoconf*)
91         ;;
92         automake*)
93         ;;
94         *)
95                 # WARNING: gross hack follows:
96                 # An autotools built package generally needs these scripts, however only
97                 # automake or libtoolize actually install the current versions of them.
98                 # This is a problem in builds that do not use libtool or automake, in the case
99                 # where we -need- the latest version of these scripts.  e.g. running a build
100                 # for a package whose autotools are old, on an x86_64 machine, which the old
101                 # config.sub does not support.  Work around this by installing them manually
102                 # regardless.
103                 ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do
104                         rm -f `dirname $ac`/configure
105                         done )
106                 if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
107                         olddir=`pwd`
108                         cd ${S}
109                         if [ x"${acpaths}" = xdefault ]; then
110                                 acpaths=
111                                 for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
112                                         grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
113                                         acpaths="$acpaths -I $i"
114                                 done
115                         else
116                                 acpaths="${acpaths}"
117                         fi
118                         AUTOV=`automake --version |head -n 1 |sed "s/.* //;s/\.[0-9]\+$//"`
119                         automake --version
120                         echo "AUTOV is $AUTOV"
121                         install -d ${STAGING_DATADIR}/aclocal
122                         install -d ${STAGING_DATADIR}/aclocal-$AUTOV
123                         acpaths="$acpaths -I${STAGING_DATADIR}/aclocal-$AUTOV -I ${STAGING_DATADIR}/aclocal"
124                         # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
125                         # like it was auto-generated.  Work around this by blowing it away
126                         # by hand, unless the package specifically asked not to run aclocal.
127                         if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
128                                 rm -f aclocal.m4
129                         fi
130                         if [ -e configure.in ]; then
131                           CONFIGURE_AC=configure.in
132                         else
133                           CONFIGURE_AC=configure.ac
134                         fi
135                         if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
136                           if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
137                             : do nothing -- we still have an old unmodified configure.ac
138                           else
139                             oenote Executing glib-gettextize --force --copy
140                             echo "no" | glib-gettextize --force --copy
141                           fi
142                         else if grep "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
143                           if [ -e ${STAGING_DATADIR}/gettext/config.rpath ]; then
144                             cp ${STAGING_DATADIR}/gettext/config.rpath ${S}/
145                           else
146                             oenote ${STAGING_DATADIR}/gettext/config.rpath not found. gettext is not installed.
147                           fi
148                         fi
150                         fi
151                         mkdir -p m4
152                         oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
153                         autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed."
154                         if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
155                           oenote Executing intltoolize --copy --force --automake
156                           intltoolize --copy --force --automake
157                         fi
158                         cd $olddir
159                 fi
160         ;;
161         esac
162         if [ -e ${S}/configure ]; then
163                 oe_runconf $@
164         else
165                 oenote "nothing to configure"
166         fi
169 autotools_do_install() {
170         oe_runmake 'DESTDIR=${D}' install
173 PACKAGE_PREPROCESS_FUNCS += "autotools_prepackage_lamangler"
175 autotools_prepackage_lamangler () {
176         for i in `find ${PKGD} -name "*.la"` ; do \
177             sed -i -e 's:${STAGING_LIBDIR}:${libdir}:g;' \
178                    -e 's:${D}::g;' \
179                    -e 's:-I${WORKDIR}\S*: :g;' \
180                    -e 's:-L${WORKDIR}\S*: :g;' \
181                    $i
182         done
185 # STAGE_TEMP_PREFIX is used for a speedup by packaged-staging
186 STAGE_TEMP="${WORKDIR}/temp-staging"
187 STAGE_TEMP_PREFIX = ""
189 autotools_stage_includes() {
190         if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ]
191         then
192                 rm -rf ${STAGE_TEMP}
193                 mkdir -p ${STAGE_TEMP}
194                 make DESTDIR="${STAGE_TEMP}" install
195                 cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
196                 rm -rf ${STAGE_TEMP}
197         fi
200 autotools_stage_dir() {
201         sysroot_stage_dir $1 ${STAGE_TEMP_PREFIX}$2
204 autotools_stage_libdir() {
205         sysroot_stage_libdir $1 ${STAGE_TEMP_PREFIX}$2
208 autotools_stage_all() {
209         if [ "${INHIBIT_AUTO_STAGE}" = "1" ]
210         then
211                 return
212         fi
213         rm -rf ${STAGE_TEMP}
214         mkdir -p ${STAGE_TEMP}
215         oe_runmake DESTDIR="${STAGE_TEMP}" install
216         rm -rf ${STAGE_TEMP}/${mandir} || true
217         rm -rf ${STAGE_TEMP}/${infodir} || true
218         sysroot_stage_dirs ${STAGE_TEMP} ${STAGE_TEMP_PREFIX}
219         rm -rf ${STAGE_TEMP}
222 EXPORT_FUNCTIONS do_configure do_install