diff options
| author | Richard Purdie <richard@openedhand.com> | 2006-07-21 10:10:31 +0000 |
|---|---|---|
| committer | Richard Purdie <richard@openedhand.com> | 2006-07-21 10:10:31 +0000 |
| commit | b2f192faabe412adce79534e22efe9fb69ee40e2 (patch) | |
| tree | 7076c49d4286f8a1733650bd8fbc7161af200d57 /meta/classes | |
| parent | 2cf0eadf9f730027833af802d7e6c90b44248f80 (diff) | |
| download | openembedded-core-b2f192faabe412adce79534e22efe9fb69ee40e2.tar.gz openembedded-core-b2f192faabe412adce79534e22efe9fb69ee40e2.tar.bz2 openembedded-core-b2f192faabe412adce79534e22efe9fb69ee40e2.zip | |
Rename /openembedded/ -> /meta/
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@530 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/classes')
76 files changed, 5791 insertions, 0 deletions
diff --git a/meta/classes/autotools.bbclass b/meta/classes/autotools.bbclass new file mode 100644 index 0000000000..927e3432b7 --- /dev/null +++ b/meta/classes/autotools.bbclass @@ -0,0 +1,182 @@ +inherit base + +def autotools_dep_prepend(d): + import bb; + + if bb.data.getVar('INHIBIT_AUTOTOOLS_DEPS', d, 1): + return '' + + pn = bb.data.getVar('PN', d, 1) + deps = '' + + if pn in ['autoconf-native', 'automake-native']: + return deps + deps += 'autoconf-native automake-native ' + + if not pn in ['libtool', 'libtool-native', 'libtool-cross']: + deps += 'libtool-native ' + + return deps + 'gnu-config-native ' + +EXTRA_OEMAKE = "" +DEPENDS_prepend = "${@autotools_dep_prepend(d)}" +acpaths = "default" +EXTRA_AUTORECONF = "--exclude=autopoint" + +def autotools_set_crosscompiling(d): + import bb + if not bb.data.inherits_class('native', d): + return " cross_compiling=yes" + return "" + +# EXTRA_OECONF_append = "${@autotools_set_crosscompiling(d)}" + +oe_runconf () { + if [ -x ${S}/configure ] ; then + cfgcmd="${S}/configure \ + --build=${BUILD_SYS} \ + --host=${HOST_SYS} \ + --target=${TARGET_SYS} \ + --prefix=${prefix} \ + --exec_prefix=${exec_prefix} \ + --bindir=${bindir} \ + --sbindir=${sbindir} \ + --libexecdir=${libexecdir} \ + --datadir=${datadir} \ + --sysconfdir=${sysconfdir} \ + --sharedstatedir=${sharedstatedir} \ + --localstatedir=${localstatedir} \ + --libdir=${libdir} \ + --includedir=${includedir} \ + --oldincludedir=${oldincludedir} \ + --infodir=${infodir} \ + --mandir=${mandir} \ + ${EXTRA_OECONF} \ + $@" + oenote "Running $cfgcmd..." + $cfgcmd || oefatal "oe_runconf failed" + else + oefatal "no configure script found" + fi +} + +autotools_do_configure() { + case ${PN} in + autoconf*) + ;; + automake*) + ;; + *) + # WARNING: gross hack follows: + # An autotools built package generally needs these scripts, however only + # automake or libtoolize actually install the current versions of them. + # This is a problem in builds that do not use libtool or automake, in the case + # where we -need- the latest version of these scripts. e.g. running a build + # for a package whose autotools are old, on an x86_64 machine, which the old + # config.sub does not support. Work around this by installing them manually + # regardless. + ( for ac in `find ${S} -name configure.in -o -name configure.ac`; do + rm -f `dirname $ac`/configure + done ) + if [ -e ${S}/configure.in -o -e ${S}/configure.ac ]; then + olddir=`pwd` + cd ${S} + if [ x"${acpaths}" = xdefault ]; then + acpaths= + for i in `find ${S} -maxdepth 2 -name \*.m4|grep -v 'aclocal.m4'| \ + grep -v 'acinclude.m4' | sed -e 's,\(.*/\).*$,\1,'|sort -u`; do + acpaths="$acpaths -I $i" + done + else + acpaths="${acpaths}" + fi + AUTOV=`automake --version |head -n 1 |sed "s/.* //;s/\.[0-9]\+$//"` + automake --version + echo "AUTOV is $AUTOV" + install -d ${STAGING_DIR}/${HOST_SYS}/share/aclocal + install -d ${STAGING_DIR}/${HOST_SYS}/share/aclocal-$AUTOV + acpaths="$acpaths -I ${STAGING_DIR}/${HOST_SYS}/share/aclocal-$AUTOV -I ${STAGING_DIR}/${HOST_SYS}/share/aclocal" + # autoreconf is too shy to overwrite aclocal.m4 if it doesn't look + # like it was auto-generated. Work around this by blowing it away + # by hand, unless the package specifically asked not to run aclocal. + if ! echo ${EXTRA_AUTORECONF} | grep -q "aclocal"; then + rm -f aclocal.m4 + fi + if [ -e configure.in ]; then + CONFIGURE_AC=configure.in + else + CONFIGURE_AC=configure.ac + fi + if grep "^AM_GLIB_GNU_GETTEXT" $CONFIGURE_AC >/dev/null; then + if grep "sed.*POTFILES" $CONFIGURE_AC >/dev/null; then + : do nothing -- we still have an old unmodified configure.ac + else + oenote Executing glib-gettextize --force --copy + echo "no" | glib-gettextize --force --copy + fi + fi + if grep "^AC_PROG_INTLTOOL" $CONFIGURE_AC >/dev/null; then + oenote Executing intltoolize --copy --force --automake + intltoolize --copy --force --automake + fi + oenote Executing autoreconf --verbose --install --force ${EXTRA_AUTORECONF} $acpaths + mkdir -p m4 + autoreconf -Wcross --verbose --install --force ${EXTRA_AUTORECONF} $acpaths || oefatal "autoreconf execution failed." + cd $olddir + fi + ;; + esac + if [ -e ${S}/configure ]; then + oe_runconf + else + oenote "nothing to configure" + fi +} + +autotools_do_install() { + oe_runmake 'DESTDIR=${D}' install +} + +STAGE_TEMP="${WORKDIR}/temp-staging" + +autotools_stage_includes() { + if [ "${INHIBIT_AUTO_STAGE_INCLUDES}" != "1" ] + then + rm -rf ${STAGE_TEMP} + mkdir -p ${STAGE_TEMP} + make DESTDIR="${STAGE_TEMP}" install + cp -pPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR} + rm -rf ${STAGE_TEMP} + fi +} + +autotools_stage_all() { + if [ "${INHIBIT_AUTO_STAGE}" = "1" ] + then + return + fi + rm -rf ${STAGE_TEMP} + mkdir -p ${STAGE_TEMP} + oe_runmake DESTDIR="${STAGE_TEMP}" install + if [ -d ${STAGE_TEMP}/${includedir} ]; then + cp -fpPR ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR} + fi + if [ -d ${STAGE_TEMP}/${libdir} ] + then + for i in ${STAGE_TEMP}/${libdir}/*.la + do + if [ ! -f "$i" ]; then + cp -fpPR ${STAGE_TEMP}/${libdir}/* ${STAGING_LIBDIR} + break + fi + oe_libinstall -so $(basename $i .la) ${STAGING_LIBDIR} + done + fi + if [ -d ${STAGE_TEMP}/${datadir}/aclocal ]; then + install -d ${STAGING_DATADIR}/aclocal + cp -fpPR ${STAGE_TEMP}/${datadir}/aclocal/* ${STAGING_DATADIR}/aclocal + fi + rm -rf ${STAGE_TEMP} +} + +EXPORT_FUNCTIONS do_configure do_install diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass new file mode 100644 index 0000000000..8467ebddc2 --- /dev/null +++ b/meta/classes/base.bbclass @@ -0,0 +1,793 @@ +PATCHES_DIR="${S}" + +def base_dep_prepend(d): + import bb; + # + # Ideally this will check a flag so we will operate properly in + # the case where host == build == target, for now we don't work in + # that case though. + # + deps = "" + + # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not + # we need that built is the responsibility of the patch function / class, not + # the application. + patchdeps = bb.data.getVar("PATCH_DEPENDS", d, 1) + if patchdeps and not patchdeps in bb.data.getVar("PROVIDES", d, 1): + deps = patchdeps + + if not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d): + if (bb.data.getVar('HOST_SYS', d, 1) != + bb.data.getVar('BUILD_SYS', d, 1)): + deps += " virtual/${TARGET_PREFIX}gcc virtual/libc " + return deps + +def base_read_file(filename): + import bb + try: + f = file( filename, "r" ) + except IOError, reason: + return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M: + else: + return f.read().strip() + return None + +def base_conditional(variable, checkvalue, truevalue, falsevalue, d): + import bb + if bb.data.getVar(variable,d,1) == checkvalue: + return truevalue + else: + return falsevalue + +DEPENDS_prepend="${@base_dep_prepend(d)} " + +def base_set_filespath(path, d): + import os, bb + filespath = [] + for p in path: + overrides = bb.data.getVar("OVERRIDES", d, 1) or "" + overrides = overrides + ":" + for o in overrides.split(":"): + filespath.append(os.path.join(p, o)) + bb.data.setVar("FILESPATH", ":".join(filespath), d) + +FILESPATH = "${@base_set_filespath([ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ], d)}" + +def oe_filter(f, str, d): + from re import match + return " ".join(filter(lambda x: match(f, x, 0), str.split())) + +def oe_filter_out(f, str, d): + from re import match + return " ".join(filter(lambda x: not match(f, x, 0), str.split())) + +die() { + oefatal "$*" +} + +oenote() { + echo "NOTE:" "$*" +} + +oewarn() { + echo "WARNING:" "$*" +} + +oefatal() { + echo "FATAL:" "$*" + exit 1 +} + +oedebug() { + test $# -ge 2 || { + echo "Usage: oedebug level \"message\"" + exit 1 + } + + test ${OEDEBUG:-0} -ge $1 && { + shift + echo "DEBUG:" $* + } +} + +oe_runmake() { + if [ x"$MAKE" = x ]; then MAKE=make; fi + oenote ${MAKE} ${EXTRA_OEMAKE} "$@" + ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oe_runmake failed" +} + +oe_soinstall() { + # Purpose: Install shared library file and + # create the necessary links + # Example: + # + # oe_ + # + #oenote installing shared library $1 to $2 + # + libname=`basename $1` + install -m 755 $1 $2/$libname + sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'` + solink=`echo $libname | sed -e 's/\.so\..*/.so/'` + ln -sf $libname $2/$sonamelink + ln -sf $libname $2/$solink +} + +oe_libinstall() { + # Purpose: Install a library, in all its forms + # Example + # + # oe_libinstall libltdl ${STAGING_LIBDIR}/ + # oe_libinstall -C src/libblah libblah ${D}/${libdir}/ + dir="" + libtool="" + silent="" + require_static="" + require_shared="" + staging_install="" + while [ "$#" -gt 0 ]; do + case "$1" in + -C) + shift + dir="$1" + ;; + -s) + silent=1 + ;; + -a) + require_static=1 + ;; + -so) + require_shared=1 + ;; + -*) + oefatal "oe_libinstall: unknown option: $1" + ;; + *) + break; + ;; + esac + shift + done + + libname="$1" + shift + destpath="$1" + if [ -z "$destpath" ]; then + oefatal "oe_libinstall: no destination path specified" + fi + if echo "$destpath/" | egrep '^${STAGING_LIBDIR}/' >/dev/null + then + staging_install=1 + fi + + __runcmd () { + if [ -z "$silent" ]; then + echo >&2 "oe_libinstall: $*" + fi + $* + } + + if [ -z "$dir" ]; then + dir=`pwd` + fi + dotlai=$libname.lai + dir=$dir`(cd $dir; find -name "$dotlai") | sed "s/^\.//;s/\/$dotlai\$//;q"` + olddir=`pwd` + __runcmd cd $dir + + lafile=$libname.la + if [ -f "$lafile" ]; then + # libtool archive + eval `cat $lafile|grep "^library_names="` + libtool=1 + else + library_names="$libname.so* $libname.dll.a" + fi + + __runcmd install -d $destpath/ + dota=$libname.a + if [ -f "$dota" -o -n "$require_static" ]; then + __runcmd install -m 0644 $dota $destpath/ + fi + if [ -f "$dotlai" -a -n "$libtool" ]; then + if test -n "$staging_install" + then + # stop libtool using the final directory name for libraries + # in staging: + __runcmd rm -f $destpath/$libname.la + __runcmd sed -e 's/^installed=yes$/installed=no/' -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${STAGING_LIBDIR}/\1,g' $dotlai >$destpath/$libname.la + else + __runcmd install -m 0644 $dotlai $destpath/$libname.la + fi + fi + + for name in $library_names; do + files=`eval echo $name` + for f in $files; do + if [ ! -e "$f" ]; then + if [ -n "$libtool" ]; then + oefatal "oe_libinstall: $dir/$f not found." + fi + elif [ -L "$f" ]; then + __runcmd cp -P "$f" $destpath/ + elif [ ! -L "$f" ]; then + libfile="$f" + __runcmd install -m 0755 $libfile $destpath/ + fi + done + done + + if [ -z "$libfile" ]; then + if [ -n "$require_shared" ]; then + oefatal "oe_libinstall: unable to locate shared library" + fi + elif [ -z "$libtool" ]; then + # special case hack for non-libtool .so.#.#.# links + baselibfile=`basename "$libfile"` + if (echo $baselibfile | grep -qE '^lib.*\.so\.[0-9.]*$'); then + sonamelink=`${HOST_PREFIX}readelf -d $libfile |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'` + solink=`echo $baselibfile | sed -e 's/\.so\..*/.so/'` + if [ -n "$sonamelink" -a x"$baselibfile" != x"$sonamelink" ]; then + __runcmd ln -sf $baselibfile $destpath/$sonamelink + fi + __runcmd ln -sf $baselibfile $destpath/$solink + fi + fi + + __runcmd cd "$olddir" +} + +oe_machinstall() { + # Purpose: Install machine dependent files, if available + # If not available, check if there is a default + # If no default, just touch the destination + # Example: + # $1 $2 $3 $4 + # oe_machinstall -m 0644 fstab ${D}/etc/fstab + # + # TODO: Check argument number? + # + filename=`basename $3` + dirname=`dirname $3` + + for o in `echo ${OVERRIDES} | tr ':' ' '`; do + if [ -e $dirname/$o/$filename ]; then + oenote $dirname/$o/$filename present, installing to $4 + install $1 $2 $dirname/$o/$filename $4 + return + fi + done +# oenote overrides specific file NOT present, trying default=$3... + if [ -e $3 ]; then + oenote $3 present, installing to $4 + install $1 $2 $3 $4 + else + oenote $3 NOT present, touching empty $4 + touch $4 + fi +} + +addtask showdata +do_showdata[nostamp] = "1" +python do_showdata() { + import sys + # emit variables and shell functions + bb.data.emit_env(sys.__stdout__, d, True) + # emit the metadata which isnt valid shell + for e in d.keys(): + if bb.data.getVarFlag(e, 'python', d): + sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, bb.data.getVar(e, d, 1))) +} + +addtask listtasks +do_listtasks[nostamp] = "1" +python do_listtasks() { + import sys + # emit variables and shell functions + #bb.data.emit_env(sys.__stdout__, d) + # emit the metadata which isnt valid shell + for e in d.keys(): + if bb.data.getVarFlag(e, 'task', d): + sys.__stdout__.write("%s\n" % e) +} + +addtask clean +do_clean[dirs] = "${TOPDIR}" +do_clean[nostamp] = "1" +do_clean[bbdepcmd] = "" +python base_do_clean() { + """clear the build and temp directories""" + dir = bb.data.expand("${WORKDIR}", d) + if dir == '//': raise bb.build.FuncFailed("wrong DATADIR") + bb.note("removing " + dir) + os.system('rm -rf ' + dir) + + dir = "%s.*" % bb.data.expand(bb.data.getVar('STAMP', d), d) + bb.note("removing " + dir) |
