bitbake.conf: use rootfs/${PN} for IMAGE_ROOTFS
[vuplus_openembedded] / classes / autotools.bbclass
1 inherit base
2
3 # use autotools_stage_all for native packages
4 AUTOTOOLS_NATIVE_STAGE_INSTALL = "1"
5
6 def autotools_dep_prepend(d):
7         import bb;
8
9         if bb.data.getVar('INHIBIT_AUTOTOOLS_DEPS', d, 1):
10                 return ''
11
12         pn = bb.data.getVar('PN', d, 1)
13         deps = ''
14
15         if pn in ['autoconf-native', 'automake-native']:
16                 return deps
17         deps += 'autoconf-native automake-native '
18
19         if not pn in ['libtool', 'libtool-native', 'libtool-cross']:
20                 deps += 'libtool-native '
21                 if not bb.data.inherits_class('native', d) \
22                         and not bb.data.inherits_class('cross', d) \
23                         and not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d, 1):
24                     deps += 'libtool-cross '
25
26         return deps + 'gnu-config-native '
27
28 EXTRA_OEMAKE = ""
29 DEPENDS_prepend = "${@autotools_dep_prepend(d)}"
30 acpaths = "default"
31 EXTRA_AUTORECONF = "--exclude=autopoint"
32
33 def autotools_set_crosscompiling(d):
34         import bb
35         if not bb.data.inherits_class('native', d):
36                 return " cross_compiling=yes"
37         return ""
38
39 # EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}"
40
41 oe_runconf () {
42         if [ -x ${S}/configure ] ; then
43                 cfgcmd="${S}/configure \
44                     --build=${BUILD_SYS} \
45                     --host=${HOST_SYS} \
46                     --target=${TARGET_SYS} \
47                     --prefix=${prefix} \
48                     --exec_prefix=${exec_prefix} \
49                     --bindir=${bindir} \
50                     --sbindir=${sbindir} \
51                     --libexecdir=${libexecdir} \
52                     --datadir=${datadir} \
53                     --sysconfdir=${sysconfdir} \
54                     --sharedstatedir=${sharedstatedir} \
55                     --localstatedir=${localstatedir} \
56                     --libdir=${libdir} \
57                     --includedir=${includedir} \
58                     --oldincludedir=${oldincludedir} \
59                     --infodir=${infodir} \
60                     --mandir=${mandir} \
61                         ${EXTRA_OECONF} \
62                     $@"
63                 oenote "Running $cfgcmd..."
64                 $cfgcmd || oefatal "oe_runconf failed" 
65         else
66                 oefatal "no configure script found"
67         fi
68 }
69
70 autotools_do_configure() {
71         case ${PN} in
72         autoconf*)
73         ;;
74         automake*)
75         ;;
76         *)
77                 # WARNING: gross hack follows:
78                 # An autotools built package generally needs these scripts, however only
79                 # automake or libtoolize actually install the current versions of them.
80                 # This is a problem in builds that do not use libtool or automake, in the case
81                 # where we -need- the latest version of these scripts.  e.g. running a build
82                 # for a package whose autotools are old, on an x86_64 machine, which the old
83                 # config.sub does not support.  Work around this by installing them manually
84                 # regardless.
85                 ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do
86                         rm -f `dirname $ac`/configure
87                         done )
88                 if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
89                         olddir=`pwd`
90                         cd ${S}
91                         if [ x"${acpaths}" = xdefault ]; then
92                                 acpaths=
93                                 for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
94                                         grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
95                                         acpaths="$acpaths -I $i"
96                                 done
97                         else
98                                 acpaths="${acpaths}"
99                         fi
100                         AUTOV=`automake --version |head -n 1 |sed "s/.* //;s/\.[0-9]\+$//"`
101                         automake --version
102                         echo "AUTOV is $AUTOV"
103                         install -d ${STAGING_DATADIR}/aclocal
104                         install -d ${STAGING_DATADIR}/aclocal-$AUTOV
105                         acpaths="$acpaths -I${STAGING_DATADIR}/aclocal-$AUTOV -I ${STAGING_DATADIR}/aclocal"
106                         # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
107                         # like it was auto-generated.  Work around this by blowing it away
108                         # by hand, unless the package specifically asked not to run aclocal.
109                         if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
110                                 rm -f aclocal.m4
111                         fi
112                         if [ -e configure.in ]; then
113                           CONFIGURE_AC=configure.in
114                         else
115                           CONFIGURE_AC=configure.ac
116                         fi
117                         if grep "^AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
118                           if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
119                             : do nothing -- we still have an old unmodified configure.ac
120                           else
121                             oenote Executing glib-gettextize --force --copy
122                             echo "no" | glib-gettextize --force --copy
123                           fi
124                         fi
125                         if grep "^[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
126                           oenote Executing intltoolize --copy --force --automake
127                           intltoolize --copy --force --automake
128                         fi
129                         oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
130                         mkdir -p m4
131                         autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed."
132                         cd $olddir
133                 fi
134         ;;
135         esac
136         if [ -e ${S}/configure ]; then
137                 oe_runconf $@
138         else
139                 oenote "nothing to configure"
140         fi
141 }
142
143 autotools_do_install() {
144         oe_runmake 'DESTDIR=${D}' install
145 }
146
147 do_install_append() {
148         for i in `find ${D} -name "*.la"` ; do \
149                 sed -i -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${libdir}/\1,g' $i
150                 sed -i -e s:${CROSS_DIR}/${HOST_SYS}::g $i
151                 sed -i -e s:${CROSS_DIR}::g $i
152                 sed -i -e s:${STAGING_LIBDIR}:${libdir}:g $i
153                 sed -i -e s:${STAGING_DIR_HOST}::g $i
154                 sed -i -e s:${STAGING_DIR}::g $i
155                 sed -i -e s:${S}::g $i
156                 sed -i -e s:${T}::g $i
157                 sed -i -e s:${D}::g $i
158         done
159 }
160
161 STAGE_TEMP="${WORKDIR}/temp-staging"
162
163 autotools_stage_includes() {
164         if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ]
165         then
166                 rm -rf ${STAGE_TEMP}
167                 mkdir -p ${STAGE_TEMP}
168                 make DESTDIR="${STAGE_TEMP}" install
169                 cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
170                 rm -rf ${STAGE_TEMP}
171         fi
172 }
173
174 autotools_stage_dir() {
175         from="$1"
176         to="$2"
177         # This will remove empty directories so we can ignore them
178         rmdir "$from" 2> /dev/null || true
179         if [ -d "$from" ]; then
180                 mkdir -p "$to"
181                 cp -fpPR "$from"/* "$to"
182         fi
183 }
184
185 autotools_stage_all() {
186         if [ "${INHIBIT_AUTO_STAGE}" = "1" ]
187         then
188                 return
189         fi
190         rm -rf ${STAGE_TEMP}
191         mkdir -p ${STAGE_TEMP}
192         oe_runmake DESTDIR="${STAGE_TEMP}" install
193         autotools_stage_dir ${STAGE_TEMP}/${includedir} ${STAGING_INCDIR}
194         if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then
195                 autotools_stage_dir ${STAGE_TEMP}/${bindir} ${STAGING_DIR_HOST}${layout_bindir}
196                 autotools_stage_dir ${STAGE_TEMP}/${sbindir} ${STAGING_DIR_HOST}${layout_sbindir}
197                 autotools_stage_dir ${STAGE_TEMP}/${base_bindir} ${STAGING_DIR_HOST}${layout_base_bindir}
198                 autotools_stage_dir ${STAGE_TEMP}/${base_sbindir} ${STAGING_DIR_HOST}${layout_base_sbindir}
199                 autotools_stage_dir ${STAGE_TEMP}/${libexecdir} ${STAGING_DIR_HOST}${layout_libexecdir}
200                 if [ "${prefix}/lib" != "${libdir}" ]; then
201                         # python puts its files in here, make sure they are staged as well
202                         autotools_stage_dir ${STAGE_TEMP}/${prefix}/lib ${STAGING_DIR_HOST}${layout_prefix}/lib
203                 fi
204         fi
205         if [ -d ${STAGE_TEMP}/${libdir} ]
206         then
207                 olddir=`pwd`
208                 cd ${STAGE_TEMP}/${libdir}
209                 las=$(find . -name \*.la -type f)
210                 cd $olddir
211                 echo "Found la files: $las"              
212                 for i in $las
213                 do
214                         sed -e 's/^installed=yes$/installed=no/' \
215                             -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*.la\),${STAGING_LIBDIR}/\1,g' \
216                             -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${STAGING_LIBDIR},g' \
217                             -e "/^dependency_libs=/s,\([[:space:]']\)${libdir},\1${STAGING_LIBDIR},g" \
218                             -i ${STAGE_TEMP}/${libdir}/$i
219                 done
220                 autotools_stage_dir ${STAGE_TEMP}/${libdir} ${STAGING_LIBDIR}
221         fi
222         # Ok, this is nasty. pkgconfig.bbclass is usually used to install .pc files,
223         # however some packages rely on the presence of .pc files to enable/disable
224         # their configurataions in which case we better should not install everything
225         # unconditionally, but rather depend on the actual results of make install.
226         # The good news though: a) there are not many packages doing this and
227         # b) packaged staging will fix that anyways. :M:
228         if [ "${AUTOTOOLS_STAGE_PKGCONFIG}" = "1" ]
229         then
230                 if [ -e ${STAGE_TEMP}/${libdir}/pkgconfig/ ] ; then
231                         echo "cp -f ${STAGE_TEMP}/${libdir}/pkgconfig/*.pc ${STAGING_LIBDIR}/pkgconfig/"
232                         cp -f ${STAGE_TEMP}/${libdir}/pkgconfig/*.pc ${STAGING_LIBDIR}/pkgconfig/
233                 fi
234                 if [ -e ${STAGE_TEMP}/${datadir}/pkgconfig/ ] ; then
235                         echo "cp -f ${STAGE_TEMP}/${datadir}/pkgconfig/*.pc ${STAGING_DATADIR}/pkgconfig/"
236                         cp -f ${STAGE_TEMP}/${datadir}/pkgconfig/*.pc ${STAGING_DATADIR}/pkgconfig/
237                 fi
238         fi
239         rm -rf ${STAGE_TEMP}/${mandir} || true
240         rm -rf ${STAGE_TEMP}/${infodir} || true
241         autotools_stage_dir ${STAGE_TEMP}/${datadir} ${STAGING_DATADIR}
242         rm -rf ${STAGE_TEMP}
243 }
244
245 EXPORT_FUNCTIONS do_configure do_install
246