sg3-utils: add newer buildable version
[openembedded.git] / classes / autotools.bbclass
1 # use autotools_stage_all for native packages
2 AUTOTOOLS_NATIVE_STAGE_INSTALL = "1"
3
4 def autotools_dep_prepend(d):
5         if bb.data.getVar('INHIBIT_AUTOTOOLS_DEPS', d, 1):
6                 return ''
7
8         pn = bb.data.getVar('PN', d, 1)
9         deps = ''
10
11         if pn in ['autoconf-native', 'automake-native']:
12                 return deps
13         deps += 'autoconf-native automake-native '
14
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 '
22
23         return deps + 'gnu-config-native '
24
25 EXTRA_OEMAKE = ""
26
27 DEPENDS_prepend = "${@autotools_dep_prepend(d)}"
28 DEPENDS_virtclass-native_prepend = "${@autotools_dep_prepend(d)}"
29 DEPENDS_virtclass-nativesdk_prepend = "${@autotools_dep_prepend(d)}"
30
31 inherit siteinfo
32
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)}"
36
37 acpaths = "default"
38 EXTRA_AUTORECONF = "--exclude=autopoint"
39
40 def autotools_set_crosscompiling(d):
41         if not bb.data.inherits_class('native', d):
42                 return " cross_compiling=yes"
43         return ""
44
45 # EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}"
46
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}"
64
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
71 }
72
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                         fi
128                         mkdir -p m4
129                         if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
130                           oenote Executing intltoolize --copy --force --automake
131                           intltoolize --copy --force --automake
132                         fi
133                         oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
134                         autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed."
135                         cd $olddir
136                 fi
137         ;;
138         esac
139         if [ -e ${S}/configure ]; then
140                 oe_runconf $@
141         else
142                 oenote "nothing to configure"
143         fi
144 }
145
146 autotools_do_install() {
147         oe_runmake 'DESTDIR=${D}' install
148 }
149
150 PACKAGE_PREPROCESS_FUNCS += "autotools_prepackage_lamangler"
151
152 autotools_prepackage_lamangler () {
153         for i in `find ${PKGD} -name "*.la"` ; do \
154                 sed -i -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${libdir}/\1,g' $i
155                 sed -i -e s:${CROSS_DIR}/${HOST_SYS}::g $i
156                 sed -i -e s:${CROSS_DIR}::g $i
157                 sed -i -e s:${STAGING_LIBDIR}:${libdir}:g $i
158                 if [ -n "${STAGING_DIR_HOST}" ]; then
159                         sed -i -e s:${STAGING_DIR_HOST}::g $i
160                 fi
161                 sed -i -e s:${STAGING_DIR}::g $i
162                 sed -i -e s:${S}::g $i
163                 sed -i -e s:${T}::g $i
164                 sed -i -e s:${D}::g $i
165         done
166 }
167
168 STAGE_TEMP="${WORKDIR}/temp-staging"
169
170 autotools_stage_includes() {
171         if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ]
172         then
173                 rm -rf ${STAGE_TEMP}
174                 mkdir -p ${STAGE_TEMP}
175                 make DESTDIR="${STAGE_TEMP}" install
176                 cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
177                 rm -rf ${STAGE_TEMP}
178         fi
179 }
180
181 autotools_stage_dir() {
182         sysroot_stage_dir $1 ${STAGE_TEMP_PREFIX}$2
183 }
184
185 autotools_stage_libdir() {
186         sysroot_stage_libdir $1 ${STAGE_TEMP_PREFIX}$2
187 }
188
189 autotools_stage_all() {
190         if [ "${INHIBIT_AUTO_STAGE}" = "1" ]
191         then
192                 return
193         fi
194         rm -rf ${STAGE_TEMP}
195         mkdir -p ${STAGE_TEMP}
196         oe_runmake DESTDIR="${STAGE_TEMP}" install
197         rm -rf ${STAGE_TEMP}/${mandir} || true
198         rm -rf ${STAGE_TEMP}/${infodir} || true
199         sysroot_stage_dirs ${STAGE_TEMP} ${STAGE_TEMP_PREFIX}
200         rm -rf ${STAGE_TEMP}
201 }
202
203 EXPORT_FUNCTIONS do_configure do_install
204