Merge oe-devel@oe-devel.bkbits.net:packages
[openembedded.git] / classes / autotools.oeclass
1 inherit base
2
3 def autotools_dep_prepend(d):
4         import oe;
5         pn = oe.data.getVar('PN', d, 1)
6         deps = ''
7
8         if pn in ['autoconf-native', 'automake-native']:
9                 return deps
10         deps += 'autoconf-native automake-native '
11
12         if not pn in ['libtool', 'libtool-native', 'libtool-cross']:
13                 deps += 'libtool-native '
14
15         return deps + 'gnu-config-native '
16
17 EXTRA_OEMAKE = ""
18 DEPENDS_prepend = "${@autotools_dep_prepend(d)}"
19 acpaths = "default"
20 EXTRA_AUTORECONF = "--exclude=autopoint"
21
22 def autotools_set_crosscompiling(d):
23         import oe
24         if not oe.data.inherits_class('native', d):
25                 return " cross_compiling=yes"
26         return ""
27
28 # EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}"
29
30 oe_runconf () {
31         if [ -x ${S}/configure ] ; then
32                 cfgcmd="${S}/configure \
33                     --build=${BUILD_SYS} \
34                     --host=${HOST_SYS} \
35                     --target=${TARGET_SYS} \
36                     --prefix=${prefix} \
37                     --exec_prefix=${exec_prefix} \
38                     --bindir=${bindir} \
39                     --sbindir=${sbindir} \
40                     --libexecdir=${libexecdir} \
41                     --datadir=${datadir} \
42                     --sysconfdir=${sysconfdir} \
43                     --sharedstatedir=${sharedstatedir} \
44                     --localstatedir=${localstatedir} \
45                     --libdir=${libdir} \
46                     --includedir=${includedir} \
47                     --oldincludedir=${oldincludedir} \
48                     --infodir=${infodir} \
49                     --mandir=${mandir} \
50                         ${EXTRA_OECONF} \
51                     $@"
52                 oenote "Running $cfgcmd..."
53                 $cfgcmd || oefatal "oe_runconf failed" 
54         else
55                 oefatal "no configure script found"
56         fi
57 }
58
59 autotools_do_configure() {
60         case ${PN} in
61         autoconf*)
62         ;;
63         automake*)
64         ;;
65         *)
66                 # WARNING: gross hack follows:
67                 # An autotools built package generally needs these scripts, however only
68                 # automake or libtoolize actually install the current versions of them.
69                 # This is a problem in builds that do not use libtool or automake, in the case
70                 # where we -need- the latest version of these scripts.  e.g. running a build
71                 # for a package whose autotools are old, on an x86_64 machine, which the old
72                 # config.sub does not support.  Work around this by installing them manually
73                 # regardless.
74                 ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do
75                         rm -f `dirname $ac`/configure
76                         done )
77                 if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
78                         olddir=`pwd`
79                         cd ${S}
80                         if [ x"${acpaths}" = xdefault ]; then
81                                 acpaths=
82                                 for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
83                                         grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
84                                         acpaths="$acpaths -I $i"
85                                 done
86                         else
87                                 acpaths="${acpaths}"
88                         fi
89                         install -d ${STAGING_DIR}/${HOST_SYS}/share/aclocal
90                         acpaths="$acpaths -I ${STAGING_DIR}/${HOST_SYS}/share/aclocal"
91                         # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
92                         # like it was auto-generated.  Work around this by blowing it away
93                         # by hand, unless the package specifically asked not to run aclocal.
94                         if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
95                                 rm -f aclocal.m4
96                         fi
97                         if [ -e configure.in ]; then
98                           CONFIGURE_AC=configure.in
99                         else
100                           CONFIGURE_AC=configure.ac
101                         fi
102                         if grep "^AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
103                           if grep "sed.*POTFILES" configure.ac >/dev/null; then
104                             : do nothing -- we still have an old unmodified configure.ac
105                           else
106                             oenote Executing glib-gettextize --force --copy
107                             echo "no" | glib-gettextize --force --copy
108                           fi
109                         fi
110                         if grep "^AC_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
111                           oenote Executing intltoolize --copy --force --automake
112                           intltoolize --copy --force --automake
113                         fi
114                         oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
115                         mkdir -p m4
116                         autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed."
117                         cd $olddir
118                 fi
119         ;;
120         esac
121         if [ -e ${S}/configure ]; then
122                 oe_runconf
123         else
124                 oenote "nothing to configure"
125         fi
126 }
127
128 autotools_do_install() {
129         oe_runmake 'DESTDIR=${D}' install
130 }
131
132 STAGE_TEMP="${WORKDIR}/temp-staging"
133
134 autotools_stage_includes() {
135         rm -rf ${STAGE_TEMP}
136         mkdir -p ${STAGE_TEMP}
137         make DESTDIR="${STAGE_TEMP}" install
138         cp -a ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
139         rm -rf ${STAGE_TEMP}
140 }
141
142 EXPORT_FUNCTIONS do_configure do_install