qmake2: Define env var for strip. Convert to use INC_PR.
[openembedded.git] / classes / autotools.bbclass
blob974458928a7594d4a8bfa30c6e5ba8b210a6ea3a
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 pn not in ['libtool', 'libtool-native', 'libtool-cross']:
16                 deps += 'libtool-native '
17                 if (not oe.utils.inherits(d, 'native', 'nativesdk', 'cross',
18                                           'sdk') and
19                     not d.getVar('INHIBIT_DEFAULT_DEPS', True)):
20                         deps += 'libtool-cross '
22         return deps + 'gnu-config-native '
24 EXTRA_OEMAKE = ""
26 DEPENDS_prepend = "${@autotools_deps(d)}"
27 DEPENDS_virtclass-native_prepend = "${@autotools_deps(d)}"
28 DEPENDS_virtclass-nativesdk_prepend = "${@autotools_deps(d)}"
30 inherit siteinfo
32 def _autotools_get_sitefiles(d):
33     if oe.utils.inherits(d, 'native', 'nativesdk'):
34         return
36     sitedata = siteinfo_data(d)
37     for path in d.getVar("BBPATH", True).split(":"):
38         for element in sitedata:
39             filename = os.path.join(path, "site", element)
40             if os.path.exists(filename):
41                 yield filename
43 # Space separated list of shell scripts with variables defined to supply test
44 # results for autoconf tests we cannot run at build time.
45 export CONFIG_SITE = "${@' '.join(_autotools_get_sitefiles(d))}"
47 acpaths = "default"
48 EXTRA_AUTORECONF = "--exclude=autopoint"
50 def autotools_set_crosscompiling(d):
51         if not bb.data.inherits_class('native', d):
52                 return " cross_compiling=yes"
53         return ""
55 def append_libtool_sysroot(d):
56         if bb.data.getVar('LIBTOOL_HAS_SYSROOT', d, 1) == "yes":
57                 if bb.data.getVar('BUILD_SYS', d, 1) == bb.data.getVar('HOST_SYS', d, 1):
58                         return '--with-libtool-sysroot'
59                 else:
60                         return '--with-libtool-sysroot=${STAGING_DIR_HOST}'
61         return ''
63 def distro_imposed_configure_flags(d):
64         distro_features = bb.data.getVar('DISTRO_FEATURES', d, True) or ""
65         distro_features = distro_features.split()
66         flags = set()
67         features = (('largefile', 'largefile'),
68                 ('ipv6'     , 'ipv6'),
69                 ('nls'      , 'nls'))
71         for knob, cfgargs in features:
72                 if isinstance(cfgargs, basestring):
73                         cfgargs = [cfgargs]
74                 en_or_dis = knob in distro_features and "enable" or "disable"
75                 for flg in cfgargs:
76                         flags.add("--%s-%s" % (en_or_dis, flg))
77         return " ".join(flags)
79 # EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}"
81 CONFIGUREOPTS = " --build=${BUILD_SYS} \
82                   --host=${HOST_SYS} \
83                   --target=${TARGET_SYS} \
84                   --prefix=${prefix} \
85                   --exec_prefix=${exec_prefix} \
86                   --bindir=${bindir} \
87                   --sbindir=${sbindir} \
88                   --libexecdir=${libexecdir} \
89                   --datadir=${datadir} \
90                   --sysconfdir=${sysconfdir} \
91                   --sharedstatedir=${sharedstatedir} \
92                   --localstatedir=${localstatedir} \
93                   --libdir=${libdir} \
94                   --includedir=${includedir} \
95                   --oldincludedir=${oldincludedir} \
96                   --infodir=${infodir} \
97                   --mandir=${mandir} \
98                   ${@append_libtool_sysroot(d)} \
99                   ${@distro_imposed_configure_flags(d)} \
100                 "
102 oe_runconf () {
103         if [ -x ${S}/configure ] ; then
104                 ${S}/configure \
105                 ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"
106         else
107                 oefatal "no configure script found"
108         fi
111 oe_autoreconf () {
112         if [ x"${acpaths}" = xdefault ]; then
113                 acpaths=
114                 for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
115                         grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
116                         acpaths="$acpaths -I $i"
117                 done
118         else
119                 acpaths="${acpaths}"
120         fi
121         AUTOV=`automake --version | head -n 1 | sed "s/.* //;s/\.[0-9]\+$//"`
122         install -d ${STAGING_DATADIR}/aclocal
123         install -d ${STAGING_DATADIR}/aclocal-$AUTOV
124         acpaths="$acpaths -I${STAGING_DATADIR}/aclocal-$AUTOV -I ${STAGING_DATADIR}/aclocal"
125         # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
126         # like it was auto-generated.  Work around this by blowing it away
127         # by hand, unless the package specifically asked not to run aclocal.
128         if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
129                 rm -f aclocal.m4
130         fi
131         if [ -e configure.in ]; then
132                 CONFIGURE_AC=configure.in
133         else
134                 CONFIGURE_AC=configure.ac
135         fi
136         if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
137                 if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
138                         : do nothing -- we still have an old unmodified configure.ac
139                 else
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         for aux in m4 `sed -n -e '/^[[:space:]]*AC_CONFIG_MACRO_DIR/s|[^(]*([[]*\([^])]*\)[]]*)|\1|p' $CONFIGURE_AC`; do
152                 mkdir -p ${aux}
153         done
154         autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed."
155         if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
156                 intltoolize --copy --force --automake
157         fi
160 autotools_do_configure() {
161         case ${PN} in
162         autoconf*|automake*)
163         ;;
164         *)
165                 find ${S} -name configure.in -o -name configure.ac | \
166                         while read fn; do
167                                 rm -f `dirname $fn`/configure
168                         done
169                 if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
170                         olddir=`pwd`
171                         cd ${S}
172                         oe_autoreconf
173                         cd $olddir
174                 fi
175         ;;
176         esac
177         if [ -e ${S}/configure ]; then
178                 oe_runconf $@
179         else
180                 oenote "nothing to configure"
181         fi
184 autotools_do_install() {
185         oe_runmake 'DESTDIR=${D}' install
188 PACKAGE_PREPROCESS_FUNCS += "${@['autotools_prepackage_lamangler',''][bb.data.getVar('LIBTOOL_HAS_SYSROOT', d, 1) == "yes"]}"
189 autotools_prepackage_lamangler () {
190         for i in `find ${PKGD} -name "*.la"` ; do \
191             sed -i -e 's:${STAGING_LIBDIR}:${libdir}:g;' \
192                    -e 's:${D}::g;' \
193                    -e 's:-I${WORKDIR}\S*: :g;' \
194                    -e 's:-L${WORKDIR}\S*: :g;' \
195                    $i
196         done
199 # STAGE_TEMP_PREFIX is used for a speedup by packaged-staging
200 STAGE_TEMP="${WORKDIR}/temp-staging"
201 STAGE_TEMP_PREFIX = ""
203 autotools_stage_includes() {
204         if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ]
205         then
206                 rm -rf ${STAGE_TEMP}
207                 mkdir -p ${STAGE_TEMP}
208                 make DESTDIR="${STAGE_TEMP}" install
209                 cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
210                 rm -rf ${STAGE_TEMP}
211         fi
214 autotools_stage_dir() {
215         sysroot_stage_dir $1 ${STAGE_TEMP_PREFIX}$2
218 autotools_stage_libdir() {
219         sysroot_stage_libdir $1 ${STAGE_TEMP_PREFIX}$2
222 autotools_stage_all() {
223         if [ "${INHIBIT_AUTO_STAGE}" = "1" ]
224         then
225                 return
226         fi
227         rm -rf ${STAGE_TEMP}
228         mkdir -p ${STAGE_TEMP}
229         oe_runmake DESTDIR="${STAGE_TEMP}" install
230         rm -rf ${STAGE_TEMP}/${mandir} || true
231         rm -rf ${STAGE_TEMP}/${infodir} || true
232         sysroot_stage_dirs ${STAGE_TEMP} ${STAGE_TEMP_PREFIX}
233         rm -rf ${STAGE_TEMP}
236 EXPORT_FUNCTIONS do_configure do_install