Update drivers
[vuplus_openembedded] / 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 acpaths = "default"
32 EXTRA_AUTORECONF = "--exclude=autopoint"
33
34 def autotools_set_crosscompiling(d):
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 "^[[:space:]]*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                         mkdir -p m4
126                         if grep "^[[:space:]]*[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                         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 PACKAGE_PREPROCESS_FUNCS += "autotools_prepackage_lamangler"
148
149 autotools_prepackage_lamangler () {
150         for i in `find ${PKGD} -name "*.la"` ; do \
151                 sed -i -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${libdir}/\1,g' $i
152                 sed -i -e s:${CROSS_DIR}/${HOST_SYS}::g $i
153                 sed -i -e s:${CROSS_DIR}::g $i
154                 sed -i -e s:${STAGING_LIBDIR}:${libdir}:g $i
155                 sed -i -e s:${STAGING_DIR_HOST}::g $i
156                 sed -i -e s:${STAGING_DIR}::g $i
157                 sed -i -e s:${S}::g $i
158                 sed -i -e s:${T}::g $i
159                 sed -i -e s:${D}::g $i
160         done
161 }
162
163 STAGE_TEMP="${WORKDIR}/temp-staging"
164
165 autotools_stage_includes() {
166         if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ]
167         then
168                 rm -rf ${STAGE_TEMP}
169                 mkdir -p ${STAGE_TEMP}
170                 make DESTDIR="${STAGE_TEMP}" install
171                 cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
172                 rm -rf ${STAGE_TEMP}
173         fi
174 }
175
176 autotools_stage_dir() {
177         sysroot_stage_dir $1 ${STAGE_TEMP_PREFIX}$2
178 }
179
180 autotools_stage_libdir() {
181         sysroot_stage_libdir $1 ${STAGE_TEMP_PREFIX}$2
182 }
183
184 autotools_stage_all() {
185         if [ "${INHIBIT_AUTO_STAGE}" = "1" ]
186         then
187                 return
188         fi
189         rm -rf ${STAGE_TEMP}
190         mkdir -p ${STAGE_TEMP}
191         oe_runmake DESTDIR="${STAGE_TEMP}" install
192         rm -rf ${STAGE_TEMP}/${mandir} || true
193         rm -rf ${STAGE_TEMP}/${infodir} || true
194         sysroot_stage_dirs ${STAGE_TEMP} ${STAGE_TEMP_PREFIX}
195         rm -rf ${STAGE_TEMP}
196 }
197
198 EXPORT_FUNCTIONS do_configure do_install
199