initscripts-shr: remove devtmpfs initscript for palmpre machine
[openembedded.git] / classes / autotools.bbclass
blob3850ae9e4824535e28f504ff715cf7cdadb47d6e
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 def distro_imposed_configure_flags(d):
69         distro_features = bb.data.getVar('DISTRO_FEATURES', d, True) or ""
70         distro_features = distro_features.split()
71         flags = set()
72         features = (('largefile', 'largefile'),
73                 ('ipv6'     , 'ipv6'),
74                 ('nls'      , 'nls'))
76         for knob, cfgargs in features:
77                 if isinstance(cfgargs, basestring):
78                         cfgargs = [cfgargs]
79                 en_or_dis = knob in distro_features and "enable" or "disable"
80                 for flg in cfgargs:
81                         flags.add("--%s-%s" % (en_or_dis, flg))
82         return " ".join(flags)
84 # EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}"
86 CONFIGUREOPTS = " --build=${BUILD_SYS} \
87                   --host=${HOST_SYS} \
88                   --target=${TARGET_SYS} \
89                   --prefix=${prefix} \
90                   --exec_prefix=${exec_prefix} \
91                   --bindir=${bindir} \
92                   --sbindir=${sbindir} \
93                   --libexecdir=${libexecdir} \
94                   --datadir=${datadir} \
95                   --sysconfdir=${sysconfdir} \
96                   --sharedstatedir=${sharedstatedir} \
97                   --localstatedir=${localstatedir} \
98                   --libdir=${libdir} \
99                   --includedir=${includedir} \
100                   --oldincludedir=${oldincludedir} \
101                   --infodir=${infodir} \
102                   --mandir=${mandir} \
103                   ${@append_libtool_sysroot(d)} \
104                   ${@distro_imposed_configure_flags(d)} \
105                 "
107 oe_runconf () {
108         if [ -x ${S}/configure ] ; then
109                 ${S}/configure \
110                 ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"
111         else
112                 oefatal "no configure script found"
113         fi
116 autotools_do_configure() {
117         case ${PN} in
118         autoconf*)
119         ;;
120         automake*)
121         ;;
122         *)
123                 # WARNING: gross hack follows:
124                 # An autotools built package generally needs these scripts, however only
125                 # automake or libtoolize actually install the current versions of them.
126                 # This is a problem in builds that do not use libtool or automake, in the case
127                 # where we -need- the latest version of these scripts.  e.g. running a build
128                 # for a package whose autotools are old, on an x86_64 machine, which the old
129                 # config.sub does not support.  Work around this by installing them manually
130                 # regardless.
131                 ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do
132                         rm -f `dirname $ac`/configure
133                         done )
134                 if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
135                         olddir=`pwd`
136                         cd ${S}
137                         if [ x"${acpaths}" = xdefault ]; then
138                                 acpaths=
139                                 for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
140                                         grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
141                                         acpaths="$acpaths -I $i"
142                                 done
143                         else
144                                 acpaths="${acpaths}"
145                         fi
146                         AUTOV=`automake --version |head -n 1 |sed "s/.* //;s/\.[0-9]\+$//"`
147                         automake --version
148                         echo "AUTOV is $AUTOV"
149                         install -d ${STAGING_DATADIR}/aclocal
150                         install -d ${STAGING_DATADIR}/aclocal-$AUTOV
151                         acpaths="$acpaths -I${STAGING_DATADIR}/aclocal-$AUTOV -I ${STAGING_DATADIR}/aclocal"
152                         # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
153                         # like it was auto-generated.  Work around this by blowing it away
154                         # by hand, unless the package specifically asked not to run aclocal.
155                         if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
156                                 rm -f aclocal.m4
157                         fi
158                         if [ -e configure.in ]; then
159                           CONFIGURE_AC=configure.in
160                         else
161                           CONFIGURE_AC=configure.ac
162                         fi
163                         if grep -q "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC; then
164                           if grep -q "sed.*POTFILES" $CONFIGURE_AC; then
165                             : do nothing -- we still have an old unmodified configure.ac
166                           else
167                             oenote Executing glib-gettextize --force --copy
168                             echo "no" | glib-gettextize --force --copy
169                           fi
170                         else if grep -q "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC; then
171                           if [ -e ${STAGING_DATADIR}/gettext/config.rpath ]; then
172                             cp ${STAGING_DATADIR}/gettext/config.rpath ${S}/
173                           else
174                             oenote ${STAGING_DATADIR}/gettext/config.rpath not found. gettext is not installed.
175                           fi
176                         fi
178                         fi
179                         for aux in m4 `sed -n -e '/^[[:space:]]*AC_CONFIG_MACRO_DIR/s|[^(]*([[]*\([^])]*\)[]]*)|\1|p' $CONFIGURE_AC`; do
180                                 mkdir -p ${aux}
181                         done
182                         oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
183                         autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed."
184                         if grep -q "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC; then
185                           oenote Executing intltoolize --copy --force --automake
186                           intltoolize --copy --force --automake
187                         fi
188                         cd $olddir
189                 fi
190         ;;
191         esac
192         if [ -e ${S}/configure ]; then
193                 oe_runconf $@
194         else
195                 oenote "nothing to configure"
196         fi
199 autotools_do_install() {
200         oe_runmake 'DESTDIR=${D}' install
203 PACKAGE_PREPROCESS_FUNCS += "${@['autotools_prepackage_lamangler',''][bb.data.getVar('LIBTOOL_HAS_SYSROOT', d, 1) == "yes"]}"
204 autotools_prepackage_lamangler () {
205         for i in `find ${PKGD} -name "*.la"` ; do \
206             sed -i -e 's:${STAGING_LIBDIR}:${libdir}:g;' \
207                    -e 's:${D}::g;' \
208                    -e 's:-I${WORKDIR}\S*: :g;' \
209                    -e 's:-L${WORKDIR}\S*: :g;' \
210                    $i
211         done
214 # STAGE_TEMP_PREFIX is used for a speedup by packaged-staging
215 STAGE_TEMP="${WORKDIR}/temp-staging"
216 STAGE_TEMP_PREFIX = ""
218 autotools_stage_includes() {
219         if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ]
220         then
221                 rm -rf ${STAGE_TEMP}
222                 mkdir -p ${STAGE_TEMP}
223                 make DESTDIR="${STAGE_TEMP}" install
224                 cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
225                 rm -rf ${STAGE_TEMP}
226         fi
229 autotools_stage_dir() {
230         sysroot_stage_dir $1 ${STAGE_TEMP_PREFIX}$2
233 autotools_stage_libdir() {
234         sysroot_stage_libdir $1 ${STAGE_TEMP_PREFIX}$2
237 autotools_stage_all() {
238         if [ "${INHIBIT_AUTO_STAGE}" = "1" ]
239         then
240                 return
241         fi
242         rm -rf ${STAGE_TEMP}
243         mkdir -p ${STAGE_TEMP}
244         oe_runmake DESTDIR="${STAGE_TEMP}" install
245         rm -rf ${STAGE_TEMP}/${mandir} || true
246         rm -rf ${STAGE_TEMP}/${infodir} || true
247         sysroot_stage_dirs ${STAGE_TEMP} ${STAGE_TEMP_PREFIX}
248         rm -rf ${STAGE_TEMP}
251 EXPORT_FUNCTIONS do_configure do_install