llvm-common: use do_install to do the stuff
[openembedded.git] / classes / autotools.bbclass
blob754fb875cb9ccd45b515508d5d94aa66af3581e4
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 # Space separated list of shell scripts with variables defined to supply test
34 # results for autoconf tests we cannot run at build time.
35 export CONFIG_SITE = "${@siteinfo_get_files(d)}"
37 acpaths = "default"
38 EXTRA_AUTORECONF = "--exclude=autopoint"
40 def autotools_set_crosscompiling(d):
41         if not bb.data.inherits_class('native', d):
42                 return " cross_compiling=yes"
43         return ""
45 # EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}"
47 CONFIGUREOPTS = " --build=${BUILD_SYS} \
48                   --host=${HOST_SYS} \
49                   --target=${TARGET_SYS} \
50                   --prefix=${prefix} \
51                   --exec_prefix=${exec_prefix} \
52                   --bindir=${bindir} \
53                   --sbindir=${sbindir} \
54                   --libexecdir=${libexecdir} \
55                   --datadir=${datadir} \
56                   --sysconfdir=${sysconfdir} \
57                   --sharedstatedir=${sharedstatedir} \
58                   --localstatedir=${localstatedir} \
59                   --libdir=${libdir} \
60                   --includedir=${includedir} \
61                   --oldincludedir=${oldincludedir} \
62                   --infodir=${infodir} \
63                   --mandir=${mandir}"
65 oe_runconf () {
66         if [ -x ${S}/configure ] ; then
67                 ${S}/configure ${CONFIGUREOPTS} ${EXTRA_OECONF} "$@"
68         else
69                 oefatal "no configure script found"
70         fi
73 autotools_do_configure() {
74         case ${PN} in
75         autoconf*)
76         ;;
77         automake*)
78         ;;
79         *)
80                 # WARNING: gross hack follows:
81                 # An autotools built package generally needs these scripts, however only
82                 # automake or libtoolize actually install the current versions of them.
83                 # This is a problem in builds that do not use libtool or automake, in the case
84                 # where we -need- the latest version of these scripts.  e.g. running a build
85                 # for a package whose autotools are old, on an x86_64 machine, which the old
86                 # config.sub does not support.  Work around this by installing them manually
87                 # regardless.
88                 ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do
89                         rm -f `dirname $ac`/configure
90                         done )
91                 if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
92                         olddir=`pwd`
93                         cd ${S}
94                         if [ x"${acpaths}" = xdefault ]; then
95                                 acpaths=
96                                 for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
97                                         grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
98                                         acpaths="$acpaths -I $i"
99                                 done
100                         else
101                                 acpaths="${acpaths}"
102                         fi
103                         AUTOV=`automake --version |head -n 1 |sed "s/.* //;s/\.[0-9]\+$//"`
104                         automake --version
105                         echo "AUTOV is $AUTOV"
106                         install -d ${STAGING_DATADIR}/aclocal
107                         install -d ${STAGING_DATADIR}/aclocal-$AUTOV
108                         acpaths="$acpaths -I${STAGING_DATADIR}/aclocal-$AUTOV -I ${STAGING_DATADIR}/aclocal"
109                         # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
110                         # like it was auto-generated.  Work around this by blowing it away
111                         # by hand, unless the package specifically asked not to run aclocal.
112                         if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
113                                 rm -f aclocal.m4
114                         fi
115                         if [ -e configure.in ]; then
116                           CONFIGURE_AC=configure.in
117                         else
118                           CONFIGURE_AC=configure.ac
119                         fi
120                         if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
121                           if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
122                             : do nothing -- we still have an old unmodified configure.ac
123                           else
124                             oenote Executing glib-gettextize --force --copy
125                             echo "no" | glib-gettextize --force --copy
126                           fi
127                         else if grep "^[[:space:]]*AM_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
128                           if [ -e ${STAGING_DATADIR}/gettext/config.rpath ]; then
129                             cp ${STAGING_DATADIR}/gettext/config.rpath ${S}/
130                           else
131                             oenote ${STAGING_DATADIR}/gettext/config.rpath not found. gettext is not installed.
132                           fi
133                         fi
135                         fi
136                         mkdir -p m4
137                         oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
138                         autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed."
139                         if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
140                           oenote Executing intltoolize --copy --force --automake
141                           intltoolize --copy --force --automake
142                         fi
143                         cd $olddir
144                 fi
145         ;;
146         esac
147         if [ -e ${S}/configure ]; then
148                 oe_runconf $@
149         else
150                 oenote "nothing to configure"
151         fi
154 autotools_do_install() {
155         oe_runmake 'DESTDIR=${D}' install
158 PACKAGE_PREPROCESS_FUNCS += "autotools_prepackage_lamangler"
160 autotools_prepackage_lamangler () {
161         for i in `find ${PKGD} -name "*.la"` ; do \
162             sed -i -e 's:${STAGING_LIBDIR}:${libdir}:g;' \
163                    -e 's:${D}::g;' \
164                    -e 's:-I${WORKDIR}\S*: :g;' \
165                    -e 's:-L${WORKDIR}\S*: :g;' \
166                    $i
167         done
170 # STAGE_TEMP_PREFIX is used for a speedup by packaged-staging
171 STAGE_TEMP="${WORKDIR}/temp-staging"
172 STAGE_TEMP_PREFIX = ""
174 autotools_stage_includes() {
175         if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ]
176         then
177                 rm -rf ${STAGE_TEMP}
178                 mkdir -p ${STAGE_TEMP}
179                 make DESTDIR="${STAGE_TEMP}" install
180                 cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
181                 rm -rf ${STAGE_TEMP}
182         fi
185 autotools_stage_dir() {
186         sysroot_stage_dir $1 ${STAGE_TEMP_PREFIX}$2
189 autotools_stage_libdir() {
190         sysroot_stage_libdir $1 ${STAGE_TEMP_PREFIX}$2
193 autotools_stage_all() {
194         if [ "${INHIBIT_AUTO_STAGE}" = "1" ]
195         then
196                 return
197         fi
198         rm -rf ${STAGE_TEMP}
199         mkdir -p ${STAGE_TEMP}
200         oe_runmake DESTDIR="${STAGE_TEMP}" install
201         rm -rf ${STAGE_TEMP}/${mandir} || true
202         rm -rf ${STAGE_TEMP}/${infodir} || true
203         sysroot_stage_dirs ${STAGE_TEMP} ${STAGE_TEMP_PREFIX}
204         rm -rf ${STAGE_TEMP}
207 EXPORT_FUNCTIONS do_configure do_install