Don't inherit siteinfo in base.bbclass
[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 oe_runconf () {
48         if [ -x ${S}/configure ] ; then
49                 cfgcmd="${S}/configure \
50                     --build=${BUILD_SYS} \
51                     --host=${HOST_SYS} \
52                     --target=${TARGET_SYS} \
53                     --prefix=${prefix} \
54                     --exec_prefix=${exec_prefix} \
55                     --bindir=${bindir} \
56                     --sbindir=${sbindir} \
57                     --libexecdir=${libexecdir} \
58                     --datadir=${datadir} \
59                     --sysconfdir=${sysconfdir} \
60                     --sharedstatedir=${sharedstatedir} \
61                     --localstatedir=${localstatedir} \
62                     --libdir=${libdir} \
63                     --includedir=${includedir} \
64                     --oldincludedir=${oldincludedir} \
65                     --infodir=${infodir} \
66                     --mandir=${mandir} \
67                         ${EXTRA_OECONF} \
68                     $@"
69                 oenote "Running $cfgcmd..."
70                 $cfgcmd || oefatal "oe_runconf failed" 
71         else
72                 oefatal "no configure script found"
73         fi
74 }
75
76 autotools_do_configure() {
77         case ${PN} in
78         autoconf*)
79         ;;
80         automake*)
81         ;;
82         *)
83                 # WARNING: gross hack follows:
84                 # An autotools built package generally needs these scripts, however only
85                 # automake or libtoolize actually install the current versions of them.
86                 # This is a problem in builds that do not use libtool or automake, in the case
87                 # where we -need- the latest version of these scripts.  e.g. running a build
88                 # for a package whose autotools are old, on an x86_64 machine, which the old
89                 # config.sub does not support.  Work around this by installing them manually
90                 # regardless.
91                 ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do
92                         rm -f `dirname $ac`/configure
93                         done )
94                 if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then
95                         olddir=`pwd`
96                         cd ${S}
97                         if [ x"${acpaths}" = xdefault ]; then
98                                 acpaths=
99                                 for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \
100                                         grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do
101                                         acpaths="$acpaths -I $i"
102                                 done
103                         else
104                                 acpaths="${acpaths}"
105                         fi
106                         AUTOV=`automake --version |head -n 1 |sed "s/.* //;s/\.[0-9]\+$//"`
107                         automake --version
108                         echo "AUTOV is $AUTOV"
109                         install -d ${STAGING_DATADIR}/aclocal
110                         install -d ${STAGING_DATADIR}/aclocal-$AUTOV
111                         acpaths="$acpaths -I${STAGING_DATADIR}/aclocal-$AUTOV -I ${STAGING_DATADIR}/aclocal"
112                         # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look
113                         # like it was auto-generated.  Work around this by blowing it away
114                         # by hand, unless the package specifically asked not to run aclocal.
115                         if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then
116                                 rm -f aclocal.m4
117                         fi
118                         if [ -e configure.in ]; then
119                           CONFIGURE_AC=configure.in
120                         else
121                           CONFIGURE_AC=configure.ac
122                         fi
123                         if grep "^[[:space:]]*AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then
124                           if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then
125                             : do nothing -- we still have an old unmodified configure.ac
126                           else
127                             oenote Executing glib-gettextize --force --copy
128                             echo "no" | glib-gettextize --force --copy
129                           fi
130                         fi
131                         mkdir -p m4
132                         if grep "^[[:space:]]*[AI][CT]_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then
133                           oenote Executing intltoolize --copy --force --automake
134                           intltoolize --copy --force --automake
135                         fi
136                         oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths
137                         autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed."
138                         cd $olddir
139                 fi
140         ;;
141         esac
142         if [ -e ${S}/configure ]; then
143                 oe_runconf $@
144         else
145                 oenote "nothing to configure"
146         fi
147 }
148
149 autotools_do_install() {
150         oe_runmake 'DESTDIR=${D}' install
151 }
152
153 PACKAGE_PREPROCESS_FUNCS += "autotools_prepackage_lamangler"
154
155 autotools_prepackage_lamangler () {
156         for i in `find ${PKGD} -name "*.la"` ; do \
157                 sed -i -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${libdir}/\1,g' $i
158                 sed -i -e s:${CROSS_DIR}/${HOST_SYS}::g $i
159                 sed -i -e s:${CROSS_DIR}::g $i
160                 sed -i -e s:${STAGING_LIBDIR}:${libdir}:g $i
161                 if [ -n "${STAGING_DIR_HOST}" ]; then
162                         sed -i -e s:${STAGING_DIR_HOST}::g $i
163                 fi
164                 sed -i -e s:${STAGING_DIR}::g $i
165                 sed -i -e s:${S}::g $i
166                 sed -i -e s:${T}::g $i
167                 sed -i -e s:${D}::g $i
168         done
169 }
170
171 STAGE_TEMP="${WORKDIR}/temp-staging"
172
173 autotools_stage_includes() {
174         if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ]
175         then
176                 rm -rf ${STAGE_TEMP}
177                 mkdir -p ${STAGE_TEMP}
178                 make DESTDIR="${STAGE_TEMP}" install
179                 cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}
180                 rm -rf ${STAGE_TEMP}
181         fi
182 }
183
184 autotools_stage_dir() {
185         sysroot_stage_dir $1 ${STAGE_TEMP_PREFIX}$2
186 }
187
188 autotools_stage_libdir() {
189         sysroot_stage_libdir $1 ${STAGE_TEMP_PREFIX}$2
190 }
191
192 autotools_stage_all() {
193         if [ "${INHIBIT_AUTO_STAGE}" = "1" ]
194         then
195                 return
196         fi
197         rm -rf ${STAGE_TEMP}
198         mkdir -p ${STAGE_TEMP}
199         oe_runmake DESTDIR="${STAGE_TEMP}" install
200         rm -rf ${STAGE_TEMP}/${mandir} || true
201         rm -rf ${STAGE_TEMP}/${infodir} || true
202         sysroot_stage_dirs ${STAGE_TEMP} ${STAGE_TEMP_PREFIX}
203         rm -rf ${STAGE_TEMP}
204 }
205
206 EXPORT_FUNCTIONS do_configure do_install
207