merge of '0b604857bbf871639fdb43ee8380222e8ef64bb7'
[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                                 --enable-mainainer-mode \
62                         ${EXTRA_OECONF} \
63                     $@"
64                 oenote "Running $cfgcmd..."
65                 $cfgcmd || oefatal "oe_runconf failed" 
66         else
67                 oefatal "no configure script found"
68         fi
69 }
70
71 autotools_do_configure() {
72         case ${PN} in
73         autoconf*)
74         ;;
75         automake*)
76         ;;
77         *)
78                 # WARNING: gross hack follows:
79                 # An autotools built package generally needs these scripts, however only
80                 # automake or libtoolize actually install the current versions of them.
81                 # This is a problem in builds that do not use libtool or automake, in the case
82                 # where we -need- the latest version of these scripts.  e.g. running a build
83                 # for a package whose autotools are old, on an x86_64 machine, which the old
84                 # config.sub does not support.  Work around this by installing them manually
85                 # regardless.
86                 ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do
87                         rm -f `dirname $ac`/configure
88                         done )
89                 if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
90                         olddir=`pwd`
91                         cd ${S}
92                         if [ x"${acpaths}" = xdefault ]; then
93                                 acpaths=
94                                 for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
95                                         grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
96                                         acpaths="$acpaths -I $i"
97                                 done
98                         else
99                                 acpaths="${acpaths}"
100                         fi
101                         AUTOV=`automake --version |head -n 1 |sed "s/.* //;s/\.[0-9]\+$//"`
102                         automake --version
103                         echo "AUTOV is $AUTOV"
104                         install -d ${STAGING_DATADIR}/aclocal
105                         install -d ${STAGING_DATADIR}/aclocal-$AUTOV
106                         acpaths="$acpaths -I${STAGING_DATADIR}/aclocal-$AUTOV -I ${STAGING_DATADIR}/aclocal"
107                         # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
108                         # like it was auto-generated.  Work around this by blowing it away
109                         # by hand, unless the package specifically asked not to run aclocal.
110                         if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
111                                 rm -f aclocal.m4
112                         fi
113                         if [ -e configure.in ]; then
114                           CONFIGURE_AC=configure.in
115                         else
116                           CONFIGURE_AC=configure.ac
117                         fi
118                         if grep "^AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
119                           if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
120                             : do nothing -- we still have an old unmodified configure.ac
121                           else
122                             oenote Executing glib-gettextize --force --copy
123                             echo "no" | glib-gettextize --force --copy
124                           fi
125                         fi
126                         if grep "^[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
127                           oenote Executing intltoolize --copy --force --automake
128                           intltoolize --copy --force --automake
129                         fi
130                         oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
131                         mkdir -p m4
132                         autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed."
133                         cd $olddir
134                 fi
135         ;;
136         esac
137         if [ -e ${S}/configure ]; then
138                 oe_runconf
139         else
140                 oenote "nothing to configure"
141         fi
142 }
143
144 autotools_do_install() {
145         oe_runmake 'DESTDIR=${D}' install
146
147         for i in `find ${D} -name "*.la"` ; do \
148             sed -i -e s:${STAGING_LIBDIR}:${libdir}:g $i
149             sed -i -e s:${D}::g $i
150             sed -i -e 's:-I${WORKDIR}\S*: :g' $i
151             sed -i -e 's:-L${WORKDIR}\S*: :g' $i
152         done
153 }
154
155 STAGE_TEMP="${WORKDIR}/temp-staging"
156
157 autotools_stage_includes() {
158         if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ]
159         then
160                 rm -rf ${STAGE_TEMP}
161                 mkdir -p ${STAGE_TEMP}
162                 make DESTDIR="${STAGE_TEMP}" install
163                 cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
164                 rm -rf ${STAGE_TEMP}
165         fi
166 }
167
168 autotools_stage_all() {
169         if [ "${INHIBIT_AUTO_STAGE}" = "1" ]
170         then
171                 return
172         fi
173         rm -rf ${STAGE_TEMP}
174         mkdir -p ${STAGE_TEMP}
175         oe_runmake DESTDIR="${STAGE_TEMP}" install
176         if [ -d ${STAGE_TEMP}/${includedir} ]; then
177                 mkdir -p ${STAGING_INCDIR}
178                 cp -fpPR -t ${STAGING_INCDIR} ${STAGE_TEMP}/${includedir}/*
179         fi
180         if [ -d ${STAGE_TEMP}/${libdir} ]
181         then
182                 olddir=`pwd`
183                 cd ${STAGE_TEMP}/${libdir}
184                 las=$(find . -name \*.la -type f)
185                 cd $olddir
186                 echo "Found la files: $las"              
187                 if [ -n "$las" ]; then
188                         # If there are .la files then libtool was used in the
189                         # build, so install them with magic mangling.
190                         for i in $las
191                         do
192                                 dir=$(dirname $i)
193                                 echo "oe_libinstall -C ${S} -so $(basename $i .la) ${STAGING_LIBDIR}/${dir}"
194                                 oe_libinstall -C ${S} -so $(basename $i .la) ${STAGING_LIBDIR}/${dir}
195                         done
196                 else
197                         # Otherwise libtool wasn't used, and lib/ can be copied
198                         # directly.
199                         echo "cp -fpPR ${STAGE_TEMP}/${libdir}/* ${STAGING_LIBDIR}"
200                         cp -fpPR ${STAGE_TEMP}/${libdir}/* ${STAGING_LIBDIR}
201                 fi
202         fi
203         
204         #This will remove an empty directory so we can ignore it
205         rmdir ${STAGE_TEMP}/${datadir} || true
206         if [ -d ${STAGE_TEMP}/${datadir} ]; then
207                         install -d ${STAGING_DATADIR}/
208                         cp -fpPR ${STAGE_TEMP}/${datadir}/* ${STAGING_DATADIR}/
209         fi
210         
211         if [ "${AUTOTOOLS_NATIVE_STAGE_BINARIES}" = "1" ] ; then
212                 #This will remove an empty directory so we can ignore it
213                 rmdir ${STAGE_TEMP}/${bindir} || true 
214                 if [ -d ${STAGE_TEMP}/${bindir} ]; then
215                         mkdir -p ${STAGING_DIR_HOST}${layout_bindir}
216                         cp -fpPR -t ${STAGING_DIR_HOST}/${layout_bindir} ${STAGE_TEMP}/${bindir}/*
217                 fi
218                 #This will remove an empty directory so we can ignore it
219                 rmdir ${STAGE_TEMP}/${sbindir} || true
220                 if [ -d ${STAGE_TEMP}/${sbindir} ]; then
221                         mkdir -p ${STAGING_DIR_HOST}${layout_sbindir}
222                         cp -fpPR -t ${STAGING_DIR_HOST}/${layout_sbindir} ${STAGE_TEMP}/${sbindir}/*
223                 fi
224                 #This will remove an empty directory so we can ignore it
225                 rmdir ${STAGE_TEMP}/${base_bindir} || true
226                 if [ -d ${STAGE_TEMP}/${base_bindir} ]; then
227                         mkdir -p ${STAGING_DIR_HOST}${layout_base_bindir}
228                         cp -fpPR -t ${STAGING_DIR_HOST}/${layout_base_bindir} ${STAGE_TEMP}/${base_bindir}/*
229                 fi
230                 #This will remove an empty directory so we can ignore it
231                 rmdir ${STAGE_TEMP}/${base_sbindir} || true
232                 if [ -d ${STAGE_TEMP}/${base_sbindir} ]; then
233                         mkdir -p ${STAGING_DIR_HOST}${layout_base_sbindir}
234                         cp -fpPR -t ${STAGING_DIR_HOST}/${layout_nase_sbindir} ${STAGE_TEMP}/${base_sbindir}/*
235                 fi
236
237         fi
238         rm -rf ${STAGE_TEMP}
239 }
240
241 EXPORT_FUNCTIONS do_configure do_install