]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - build-utilities/build-utilities.git/commitdiff
build-utilities: building components for wl18xx
authorVita Preskovsky <vitap@ti.com>
Wed, 31 Oct 2012 09:45:19 +0000 (11:45 +0200)
committerVita Preskovsky <vitap@ti.com>
Wed, 31 Oct 2012 09:45:19 +0000 (11:45 +0200)
 * wilink8 support: bluetooth, nfc and wlan

Signed-off-by: Vita Preskovsky <vitap@ti.com>
15 files changed:
functions/common-functions [new file with mode: 0644]
patches/0001-Python-2.7.3-xcompile.patch [new file with mode: 0644]
patches/0001-bluez-define-_GNU_SOURCE-macro.patch [new file with mode: 0644]
patches/0001-bluez-define-macro-lacking-in-compiler.patch [new file with mode: 0644]
patches/0001-bt-obex-new-dbus-api-for-obexd.patch [new file with mode: 0644]
patches/0001-libnl-add-lnl-genl-to-default-configuration.patch [new file with mode: 0755]
patches/0001-pygobject-python-includes.patch [new file with mode: 0644]
patches/0001-socket-enable-for-bluez-4_98.patch [new file with mode: 0644]
patches/0002-bluez-enable-source-interface.patch [new file with mode: 0644]
setup-env.sample
wl12xx_build.sh
wl18xx_build.sh [new file with mode: 0755]
wl18xx_build_bt.sh [new file with mode: 0755]
wl18xx_build_nfc.sh [new file with mode: 0755]
wlan_enable_config.sh

diff --git a/functions/common-functions b/functions/common-functions
new file mode 100644 (file)
index 0000000..82ce82c
--- /dev/null
@@ -0,0 +1,438 @@
+function check()
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="check-0.9.8.tar.gz"
+       COMPONENT_DIR="check-0.9.8"
+       download_component "http://downloads.sourceforge.net/check/check-0.9.8.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "check built successfully"
+}
+
+function expat()
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="expat-2.1.0.tar.gz"
+       COMPONENT_DIR="expat-2.1.0"
+       
+       download_component "http://downloads.sourceforge.net/project/expat/expat/2.1.0/expat-2.1.0.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               ./configure --host=arm-arago-linux-gnueabi --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "expat built successfully"
+}
+
+function libIConv()
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="libiconv-1.14.tar.gz"
+       COMPONENT_DIR="libiconv-1.14"
+       download_component "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "libIConv built successfully"
+}
+function zlib()
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="zlib-1.2.7.tar.gz"
+       COMPONENT_DIR="zlib-1.2.7"
+       download_component "http://zlib.net/zlib-1.2.7.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               ./configure --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               add_fingerprint 1
+       fi
+       echo "zlib built successfully"
+}
+
+function gettext()
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="gettext-0.18.tar.gz"
+       COMPONENT_DIR="gettext-0.18"
+       download_component "http://ftp.gnu.org/gnu/gettext/gettext-0.18.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               echo "ac_cv_func_unsetenv=no" > arm-linux.cache || exit 1
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --cache-file=arm-linux.cache || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "gettext built successfully"
+}
+
+function glib()
+{
+       if  [ $# -eq 1 ]; then
+               START_MODULE="glib-2.34.0.tar.xz"
+       fi
+       # dependency section, in here we build the dependencies. We do not want to rebuild them each time
+       libIConv
+       zlib
+
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="glib-2.34.0.tar.xz"
+       COMPONENT_DIR="glib-2.34.0"
+       download_component "http://ftp.gnome.org/pub/GNOME/sources/glib/2.34/glib-2.34.0.tar.xz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               echo "glib_cv_stack_grows=no
+               glib_cv_have_qsort_r=no
+               glib_cv_uscore=yes
+               ac_cv_func_posix_getpwuid_r=yes
+               ac_cv_func_posix_getgrgid_r=yes
+               ac_cv_func_pipe2=no" > arm-linux.cache || exit 1
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --cache-file=arm-linux.cache --with-libiconv=gnu || exit 1
+               sed -i 's/\(^Libs: .*\)/\1 -liconv/g' glib-2.0.pc || exit 1
+               sed -i 's/\(^Libs: .*\)/\1 -lgmodule-2.0/g' gio-2.0.pc || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "glib built successfully"
+}
+
+function dbus()
+{
+       if  [ $# -eq 1 ]; then
+               START_MODULE="dbus-1.6.8.tar.gz"
+       fi
+       # dependency section, in here we build the dependencies. We do not want to rebuild them each time
+       expat
+       libffi
+       glib
+
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="dbus-1.6.8.tar.gz"
+       COMPONENT_DIR="dbus-1.6.8"
+       download_component "http://dbus.freedesktop.org/releases/dbus/dbus-1.6.8.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               echo "ac_cv_func_pipe2=no" > arm-linux.cache || exit 1
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --cache-file=arm-linux.cache --disable-inotify --without-x || exit 1
+               make V=1 LIBS="-lffi -lz" || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               echo "messagebus:x:102:105::${MY_LOCALSTATEDIR}/run/dbus:/bin/false" >> ${ROOTFS}${MY_SYSCONFDIR}/passwd || exit 1
+               add_fingerprint 1
+       fi
+       echo "dbus built successfully"
+}
+
+function dbus-glib()
+{
+       if  [ $# -eq 1 ]; then
+               START_MODULE="dbus-glib-0.86.tar.gz"
+       fi
+       # dependency section, in here we build the dependencies. We do not want to rebuild them each time
+       dbus
+       glib
+
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="dbus-glib-0.86.tar.gz"
+       COMPONENT_DIR="dbus-glib-0.86"
+       download_component "http://dbus.freedesktop.org/releases/dbus-glib/dbus-glib-0.86.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               echo "ac_cv_have_abstract_sockets=yes" > arm-linux.cache || exit 1
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --cache-file=arm-linux.cache || exit 1
+               sed -i 's/examples//g' dbus/Makefile || exit 1
+               sed -i 's/tools test/test/g' Makefile || exit 1
+               make LIBS="-lffi -lgthread-2.0" || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "dbus-glib built successfully"
+}
+
+function python()
+{
+       cd ${WORK_SPACE} || exit 1
+       #dependency section
+       glib
+       
+       COMPONENT_NAME="Python-2.7.3.tgz"
+       COMPONENT_DIR="Python-2.7.3"
+       download_component "http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz"
+       echo "CURRENT_OPTION=$CURRENT_OPTION"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               CC=gcc CXX=g++ AR=ar RANLIB=ranlib ./configure || exit 1
+               make python Parser/pgen || exit 1
+               mv python hostpython || exit 1
+               mv Parser/pgen Parser/hostpgen || exit 1
+               make distclean || exit 1
+               patch -p1 < ${old_dir}/patches/0001-Python-2.7.3-xcompile.patch || exit 1
+               ./configure --host=arm-linux --build=x86_64-linux-gnu --prefix=${MY_PREFIX} --with-system-expat --enable-unicode=ucs2 --without-wctype-functions || exit 1
+               make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen BLDSHARED="${CROSS_COMPILE}gcc -shared" CROSS_COMPILE_TARGET=yes HOSTARCH=arm-linux BUILDARCH=x86_64-linux-gnu || exit 1
+               make install DESTDIR=${ROOTFS} HOSTPYTHON=./hostpython BLDSHARED="${CROSS_COMPILE}gcc -shared" CROSS_COMPILE_TARGET=y || exit 1
+               add_fingerprint 1
+       fi
+       echo "python built successfully"
+}
+
+function dbus-python()
+{
+       cd ${WORK_SPACE} || exit 1
+       #dependency section
+       glib
+       dbus
+       python
+
+       COMPONENT_NAME="dbus-python-0.84.0.tar.gz"
+       COMPONENT_DIR="dbus-python-0.84.0"
+       download_component "http://dbus.freedesktop.org/releases/dbus-python/dbus-python-0.84.0.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               echo "am_cv_python_pythondir=${MY_PREFIX}/lib/python2.7/site-packages
+               am_cv_python_pyexecdir=${MY_PREFIX}/lib/python2.7/site-packages" > arm-linux.cache || exit 1
+               PYTHON_INCLUDES="-I${ROOTFS}${MY_PREFIX}/include/python2.7/" PYTHON_LIBS="-L${ROOTFS}/${MY_PREFIX}/lib/python2.7" ./configure --host=arm-linux --build=x86_64-linux-gnu --prefix=${MY_PREFIX} --cache-file=arm-linux.cache || exit 1
+               make PYTHON_INCLUDES="-I${ROOTFS}${MY_PREFIX}/include/python2.7/" || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "dbus-python built successfully"
+}
+
+function pygobject()
+{
+       cd ${WORK_SPACE} || exit 1
+       
+       #dependency section
+       glib
+       python
+
+       COMPONENT_NAME="pygobject-2.21.1.tar.bz2"
+       COMPONENT_DIR="pygobject-2.21.1"
+       download_component "http://ftp.gnome.org/pub/GNOME/sources/pygobject/2.21/pygobject-2.21.1.tar.bz2"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               echo "am_cv_python_pyexecdir=${MY_PREFIX}/lib/python2.7/site-packages" > arm-linux.cache || exit 1
+               CC=gcc CXX=g++ AR=ar RANLIB=ranlib ./configure --disable-glibtest --without-ffi  || exit 1
+               cd ./gobject
+               make generate-constants || exit 1
+               cd ..
+               cp gobject/generate-constants host-generate-constants || exit 1
+               patch -p1 -i ${old_dir}/patches/0001-pygobject-python-includes.patch
+               /usr/bin/libtoolize || exit 1
+               /usr/bin/aclocal -I m4 || exit 1
+               /usr/bin/autoheader || exit 1
+               /usr/bin/automake --add-missing || exit 1
+               /usr/bin/autoconf || exit 1
+               PYTHON_INCLUDES="-I${ROOTFS}${MY_PREFIX}/include/python2.7/" NM=nm ./configure --host=arm-linux --build=x86_64-linux-gnu --prefix=${MY_PREFIX} --cache-file=arm-linux.cache || exit 1
+               cp host-generate-constants gobject/generate-constants || exit 1
+               make PYTHON_INCLUDES="-I${ROOTFS}${MY_PREFIX}/include/python2.7/" || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "pygobject built successfully"
+}
+
+
+function firmware
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="bt-firmware"
+       COMPONENT_REV="c17a13b64e7b1bfb1d44658b2473bcbff763befd"
+       COMPONENT_DIR="bt-firmware"
+       download_component "git://github.com/TI-ECS/bt-firmware.git"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               mkdir -p ${ROOTFS}/lib/firmware || exit 1
+
+               if [ x"$MACHINE_TYPE" = "x" ]; then
+                       get_machine_used
+               fi
+
+               PRINT_STR="Invoking: cp ${MACHINE_TYPE}/TIInit_12.8.32.bts ${ROOTFS}/lib/firmware/"
+               echo ${PRINT_STR}
+               cp ./${MACHINE_TYPE}/TIInit_12.8.32.bts ${ROOTFS}/lib/firmware/ || exit 1
+               add_fingerprint 1
+       fi
+       echo "firmware built successfully"
+}
+
+function uim
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="uim"
+       COMPONENT_REV="c73894456df5def97111cb33d2106b684b8b7959"
+       COMPONENT_DIR="uim"
+       download_component "git://gitorious.org/uim/uim.git"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               if [ x"$MACHINE_TYPE" = "x" ]; then
+                       get_machine_used
+               fi
+               install -d ${ROOTFS}${MY_PREFIX}/sbin ${ROOTFS}/etc/init.d
+               install -d ${ROOTFS}/etc/rcS.d
+               make DESTDIR=${ROOTFS} install
+               install -c -m 755 ${old_dir}/scripts/uim-sysfs.sh ${ROOTFS}/etc/init.d/ || exit 1
+               cd ${ROOTFS}/etc/init.d/ || exit 1
+               ln -s -f ../init.d/uim-sysfs.sh ../rcS.d/S04uim-sysfs || exit 1
+               add_fingerprint 1
+       fi
+       echo "uim built successfully"
+}
+
+function libffi()
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_REV="70084e70ddb13b29dd05c751b1904de206bbe790"
+       COMPONENT_NAME="libffi"
+       COMPONENT_DIR="libffi"
+       
+       download_component "https://github.com/atgreen/libffi.git"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               ./configure --prefix=${MY_PREFIX} CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld RANLIB=${CROSS_COMPILE}ranlib --host=arm-linux || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "libffi built successfully"
+}
+function add_fingerprint()
+{
+       if [ x"$1" = "x" ]; then
+         echo "Function add_fingerprint() called with no parameters!!!"
+         exit 1
+       fi
+       local FILENAME="${FINGURE_PRINT_DIR}/${COMPONENT_NAME##*/}"
+       touch  ${FILENAME} || exit 1
+       echo $1 > ${FILENAME} || exit
+}
+
+function fingerprint()
+{
+       local FILENAME="${FINGURE_PRINT_DIR}/${COMPONENT_NAME##*/}"
+       # if no file exists
+       if [ ! -e ${FILENAME} ]; then
+                       return 0
+       fi
+       read MAX < ${FILENAME}
+       return ${MAX}
+}
+
+function download_component()
+{
+       if [ x"$1" = "x" ]; then
+               echo "Function called with no parameters!!!"
+               exit 1
+       fi
+
+       if [ ! x"${START_MODULE}" = "x" ]; then                         # if the START_MODULE is not empty
+               if [ ${START_MODULE} = ${COMPONENT_NAME} ]; then        # if we are building the start module
+                       CURRENT_OPTION=${USER_OPTION}                   # take the user option as is
+               else
+                       CURRENT_OPTION="1"                              # else, we are building dependency, so we should only build not rebuild
+               fi
+       else
+               CURRENT_OPTION=${USER_OPTION}                           # take the user option as is
+       fi
+       # get the extension of the file
+       local EXT=${1/*./}
+
+       # check the fingerprint value
+       fingerprint
+       case "$?" in
+               0) # 0 - File not compiled nor installed
+                       CURRENT_OPTION="2" # override to "rebuild" option
+               ;;
+               1) # 1 - File was installed properly
+                       # if the option is build and fingerprint OK, nothing to do
+                       if [ ${CURRENT_OPTION} = "1" ]; then 
+                               return
+                       fi
+               ;;
+               *)
+                       echo "Corrupted fingerprint for component ${COMPONENT_NAME}"
+                       exit 1
+               ;;
+       esac
+#      echo "Decided to rebuild for ${COMPONENT_NAME}"
+#      read
+       # I get here in one situation : USER_OPTION = 2
+       case "${EXT}" in
+               git)
+                       # if git directory exist, do not clone it again
+                       if [ ! -d ${COMPONENT_DIR} ]; then
+                         git clone $1 || exit 1
+                       fi
+                       cd ${COMPONENT_DIR} || exit 1
+                       git reset --hard ${COMPONENT_REV} || exit 1
+               ;;
+
+               tgz|gz|bz2|xz|tar)
+                       # delete the working directory if exists
+                       if [ ! x"${COMPONENT_DIR}" = "x" ]; then
+                               rm -rf ${COMPONENT_DIR} || exit 1
+                       fi
+
+                       local TAR_FLAGS="-xavf"
+
+                       # if component doesn't exist, bring it
+                       if [ ! -e ${COMPONENT_NAME} ]; then
+                               wget $1 || exit 1
+                       fi
+                       tar ${TAR_FLAGS} ${COMPONENT_NAME} || exit 1 
+                       # move to the directory if not empty
+                       if [ ! x"${COMPONENT_DIR}" = "x" ]; then                        
+                               cd ${COMPONENT_DIR} || exit 1
+                       fi;
+               ;;
+
+               *)
+                       echo "Unknown extension of remote package"
+                       exit 1
+               ;;
+       esac
+}
+
+function get_machine_used()
+{
+       # check if the machine type is already defined
+       if [ ! x"${MACHINE_TYPE}" = "x" ]; then
+               return;
+       fi
+       echo ""
+       echo "Please select the machine you use:"
+       echo "==================================="
+       echo "3. am335x-evm (am335x)"
+       read choice
+       case $choice in
+               1) MACHINE_TYPE="am335x" ;;
+               *)
+               echo "This is not a valid choice... Exitiing script"
+               exit 1
+               ;;
+       esac
+}
diff --git a/patches/0001-Python-2.7.3-xcompile.patch b/patches/0001-Python-2.7.3-xcompile.patch
new file mode 100644 (file)
index 0000000..3fc4666
--- /dev/null
@@ -0,0 +1,228 @@
+From 846cdf11adb55e88f311bf5ff3ec4173cbe073d9 Mon Sep 17 00:00:00 2001
+From: Eyal Reizer <eyalr@ti.com>
+Date: Mon, 22 Oct 2012 18:57:22 +0300
+Subject: [PATCH] Python-2.7.3-xcompile
+
+Signed-off-by: Eyal Reizer <eyalr@ti.com>
+---
+ Lib/plat-linux3/regen |    8 ++++++++
+ Makefile.pre.in       |   27 ++++++++++++++++-----------
+ configure             |    4 ++--
+ setup.py              |   43 ++++++++++++++++++++++++++++++++-----------
+ 4 files changed, 58 insertions(+), 24 deletions(-)
+ create mode 100644 Lib/plat-linux3/regen
+
+diff --git a/Lib/plat-linux3/regen b/Lib/plat-linux3/regen
+new file mode 100644
+index 0000000..7a78072
+--- /dev/null
++++ b/Lib/plat-linux3/regen
+@@ -0,0 +1,8 @@
++#! /bin/sh
++case `uname` in
++Linux*) ;;
++*) echo Probably not on a Linux system 1>&2
++ exit 1;;
++esac
++set -v
++h2py -i '(u_long)' /usr/include/sys/types.h /usr/include/netinet/in.h /usr/include/dlfcn.h
+diff --git a/Makefile.pre.in b/Makefile.pre.in
+index e2237a9..fc6b2d7 100644
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -182,6 +182,7 @@ UNICODE_OBJS=   @UNICODE_OBJS@
+ PYTHON=               python$(EXE)
+ BUILDPYTHON=  python$(BUILDEXE)
++HOSTPYTHON=     ./$(BUILDPYTHON)
+ # The task to run while instrument when building the profile-opt target
+ PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
+@@ -215,6 +216,8 @@ LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@
+ # Parser
+ PGEN=         Parser/pgen$(EXE)
++HOSTPGEN=   $(PGEN)
++
+ POBJS=                \
+               Parser/acceler.o \
+               Parser/grammar1.o \
+@@ -408,8 +411,8 @@ platform: $(BUILDPYTHON)
+ # Build the shared modules
+ sharedmods: $(BUILDPYTHON)
+       @case $$MAKEFLAGS in \
+-      *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
+-      *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
++      *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' PYTHONXCPREFIX='$(DESTDIR)$(prefix)' $(HOSTPYTHON) -E $(srcdir)/setup.py -q build;; \
++      *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' PYTHONXCPREFIX='$(DESTDIR)$(prefix)' $(HOSTPYTHON) -E $(srcdir)/setup.py build;; \
+       esac
+ # Build static library
+@@ -543,7 +546,7 @@ Modules/python.o: $(srcdir)/Modules/python.c
+ $(GRAMMAR_H) $(GRAMMAR_C): Parser/pgen.stamp
+ Parser/pgen.stamp: $(PGEN) $(GRAMMAR_INPUT)
+               -@$(INSTALL) -d Include
+-              $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
++              -$(HOSTPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
+               -touch Parser/pgen.stamp
+ $(PGEN):      $(PGENOBJS)
+@@ -938,26 +941,26 @@ libinstall:      build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
+               $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
+                       $(DESTDIR)$(LIBDEST)/distutils/tests ; \
+       fi
+-      PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
+-              ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
++      -PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
++              $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
+               -d $(LIBDEST) -f \
+               -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
+               $(DESTDIR)$(LIBDEST)
+-      PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+-              ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
++      -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
++              $(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
+               -d $(LIBDEST) -f \
+               -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
+               $(DESTDIR)$(LIBDEST)
+       -PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
+-              ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
++              $(HOSTPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
+               -d $(LIBDEST)/site-packages -f \
+               -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
+       -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+-              ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
++              $(HOSTPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
+               -d $(LIBDEST)/site-packages -f \
+               -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
+       -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+-              ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
++              $(HOSTPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
+ # Create the PLATDIR source directory, if one wasn't distributed..
+ $(srcdir)/Lib/$(PLATDIR):
+@@ -1062,7 +1065,9 @@ libainstall:     all python-config
+ # Install the dynamically loadable modules
+ # This goes into $(exec_prefix)
+ sharedinstall: sharedmods
+-      $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
++      CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
++      $(RUNSHARED) $(HOSTPYTHON) -E $(srcdir)/setup.py install \
++              --skip-build \
+               --prefix=$(prefix) \
+               --install-scripts=$(BINDIR) \
+               --install-platlib=$(DESTSHARED) \
+diff --git a/configure b/configure
+index 3948080..acf3c8a 100755
+--- a/configure
++++ b/configure
+@@ -13697,7 +13697,7 @@ $as_echo_n "checking for %lld and %llu printf() format support... " >&6; }
+   $as_echo_n "(cached) " >&6
+ else
+   if test "$cross_compiling" = yes; then :
+-  ac_cv_have_long_long_format=no
++  ac_cv_have_long_long_format="cross -- assuming yes"
+ else
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+@@ -13749,7 +13749,7 @@ fi
+ $as_echo "$ac_cv_have_long_long_format" >&6; }
+ fi
+-if test "$ac_cv_have_long_long_format" = yes
++if test "$ac_cv_have_long_long_format" != no
+ then
+ $as_echo "#define PY_FORMAT_LONG_LONG \"ll\"" >>confdefs.h
+diff --git a/setup.py b/setup.py
+index 6b47451..ed56aed 100644
+--- a/setup.py
++++ b/setup.py
+@@ -145,6 +145,7 @@ class PyBuildExt(build_ext):
+     def __init__(self, dist):
+         build_ext.__init__(self, dist)
+         self.failed = []
++        self.cross_compile = os.environ.get('CROSS_COMPILE_TARGET') == 'yes'
+     def build_extensions(self):
+@@ -278,6 +279,14 @@ class PyBuildExt(build_ext):
+                           (ext.name, sys.exc_info()[1]))
+             self.failed.append(ext.name)
+             return
++
++        # Import check will not work when cross-compiling.
++        if os.environ.has_key('PYTHONXCPREFIX'):
++            self.announce(
++                'WARNING: skipping import check for cross-compiled: "%s"' %
++                ext.name)
++            return
++
+         # Workaround for Mac OS X: The Carbon-based modules cannot be
+         # reliably imported into a command-line Python
+         if 'Carbon' in ext.extra_link_args:
+@@ -369,9 +378,10 @@ class PyBuildExt(build_ext):
+     def detect_modules(self):
+         # Ensure that /usr/local is always used
+-        add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
+-        add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+-        self.add_multiarch_paths()
++        if not self.cross_compile:
++            add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
++            add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
++            self.add_multiarch_paths()
+         # Add paths specified in the environment variables LDFLAGS and
+         # CPPFLAGS for header and library files.
+@@ -408,7 +418,8 @@ class PyBuildExt(build_ext):
+                         add_dir_to_list(dir_list, directory)
+         if os.path.normpath(sys.prefix) != '/usr' \
+-                and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
++                and not sysconfig.get_config_var('PYTHONFRAMEWORK') \
++                and not self.cross_compile:
+             # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
+             # (PYTHONFRAMEWORK is set) to avoid # linking problems when
+             # building a framework with different architectures than
+@@ -426,11 +437,14 @@ class PyBuildExt(build_ext):
+         # lib_dirs and inc_dirs are used to search for files;
+         # if a file is found in one of those directories, it can
+         # be assumed that no additional -I,-L directives are needed.
+-        lib_dirs = self.compiler.library_dirs + [
+-            '/lib64', '/usr/lib64',
+-            '/lib', '/usr/lib',
+-            ]
+-        inc_dirs = self.compiler.include_dirs + ['/usr/include']
++        lib_dirs = self.compiler.library_dirs
++        inc_dirs = self.compiler.include_dirs
++        if not self.cross_compile:
++            lib_dirs += [
++                '/lib64', '/usr/lib64',
++                '/lib', '/usr/lib',
++                ]
++            inc_dirs += ['/usr/include']
+         exts = []
+         missing = []
+@@ -1864,8 +1878,15 @@ class PyBuildExt(build_ext):
+                 # Pass empty CFLAGS because we'll just append the resulting
+                 # CFLAGS to Python's; -g or -O2 is to be avoided.
+-                cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
+-                      % (ffi_builddir, ffi_srcdir, " ".join(config_args))
++                if self.cross_compile:
++                    cmd = "cd %s && env CFLAGS='' %s/configure --host=%s --build=%s %s" \
++                          % (ffi_builddir, ffi_srcdir,
++                             os.environ.get('HOSTARCH'),
++                             os.environ.get('BUILDARCH'),
++                             " ".join(config_args))
++                else:
++                    cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
++                          % (ffi_builddir, ffi_srcdir, " ".join(config_args))
+                 res = os.system(cmd)
+                 if res or not os.path.exists(ffi_configfile):
+-- 
+1.7.9.5
+
diff --git a/patches/0001-bluez-define-_GNU_SOURCE-macro.patch b/patches/0001-bluez-define-_GNU_SOURCE-macro.patch
new file mode 100644 (file)
index 0000000..fcf932e
--- /dev/null
@@ -0,0 +1,29 @@
+From 1b09d640c1781e9b28f803c3dc20cea1a1a653a8 Mon Sep 17 00:00:00 2001
+From: Vita Preskovsky <vitap@ti.com>
+Date: Tue, 30 Oct 2012 09:54:58 +0200
+Subject: [PATCH] bluez: define _GNU_SOURCE macro
+
+       * O_CLOEXEC flag used in bluez requires _GNU_SOURCE macro to be defined.
+
+
+Signed-off-by: Vita Preskovsky <vitap@ti.com>
+---
+ profiles/input/hog_device.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/profiles/input/hog_device.c b/profiles/input/hog_device.c
+index f6e945e..576fb3e 100644
+--- a/profiles/input/hog_device.c
++++ b/profiles/input/hog_device.c
+@@ -26,7 +26,7 @@
+ #ifdef HAVE_CONFIG_H
+ #include <config.h>
+ #endif
+-
++#define _GNU_SOURCE
+ #include <stdlib.h>
+ #include <stdbool.h>
+ #include <errno.h>
+-- 
+1.7.9.5
+
diff --git a/patches/0001-bluez-define-macro-lacking-in-compiler.patch b/patches/0001-bluez-define-macro-lacking-in-compiler.patch
new file mode 100644 (file)
index 0000000..797fb67
--- /dev/null
@@ -0,0 +1,34 @@
+From 9c87b79edd1e92ba969eb43e7b8dcc1f3bd7c419 Mon Sep 17 00:00:00 2001
+From: Vita Preskovsky <vitap@ti.com>
+Date: Tue, 30 Oct 2012 10:12:43 +0200
+Subject: [PATCH] bluez: define macro lacking in compiler
+
+       * SO_DOMAIN and SO_PROTOCOL macros are lacking in arago
+         cross compiler.
+
+
+Signed-off-by: Vita Preskovsky <vitap@ti.com>
+---
+ btio/btio.c |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/btio/btio.c b/btio/btio.c
+index 9557503..e3b7088 100644
+--- a/btio/btio.c
++++ b/btio/btio.c
+@@ -38,6 +38,12 @@
+ #include "btio.h"
++#ifndef SO_PROTOCOL
++#define SO_PROTOCOL             38
++#endif
++#ifndef SO_DOMAIN
++#define SO_DOMAIN               39
++#endif
+ #ifndef BT_FLUSHABLE
+ #define BT_FLUSHABLE  8
+ #endif
+-- 
+1.7.9.5
+
diff --git a/patches/0001-bt-obex-new-dbus-api-for-obexd.patch b/patches/0001-bt-obex-new-dbus-api-for-obexd.patch
new file mode 100644 (file)
index 0000000..73ce6ac
--- /dev/null
@@ -0,0 +1,287 @@
+From 0d60f8a9da3f0e77d8703da96d4f9e954f3c7c04 Mon Sep 17 00:00:00 2001
+From: Vita Preskovsky <vitap@ti.com>
+Date: Tue, 30 Oct 2012 18:37:39 +0200
+Subject: [PATCH] bt-obex: new dbus api for obexd
+
+ * obexd's dbus APIs are changed from "org.openobex" to "org.bluez.obex"
+
+
+Signed-off-by: Vita Preskovsky <vitap@ti.com>
+
+diff --git a/src/lib/obexd-api.h b/src/lib/obexd-api.h
+index 09695f6..7716df4 100644
+--- a/src/lib/obexd-api.h
++++ b/src/lib/obexd-api.h
+@@ -33,8 +33,8 @@
+ #include <dbus/dbus-glib.h>
+ #ifdef OBEX_SUPPORT
+-#define OBEXS_DBUS_NAME "org.openobex"
+-#define OBEXC_DBUS_NAME "org.openobex.client"
++#define OBEXS_DBUS_NAME "org.bluez.obex"
++#define OBEXC_DBUS_NAME "org.bluez.obex.client"
+ /* OBEXD DBus API */
+ #include "obexd/obexagent.h"
+diff --git a/src/lib/obexd/obexagent.h b/src/lib/obexd/obexagent.h
+index b94fb2c..5bc5f9c 100644
+--- a/src/lib/obexd/obexagent.h
++++ b/src/lib/obexd/obexagent.h
+@@ -89,7 +89,7 @@ static const DBusGObjectInfo dbus_glib_obexagent_object_info = {
+       0,
+       dbus_glib_obexagent_methods,
+       7,
+-      "org.openobex.Agent\0Authorize\0S\0transfer\0I\0o\0bt_address\0I\0s\0name\0I\0s\0type\0I\0s\0length\0I\0i\0time\0I\0i\0arg6\0O\0F\0N\0s\0\0org.openobex.Agent\0Cancel\0S\0\0org.openobex.Agent\0Release\0S\0\0org.openobex.Agent\0Request\0S\0transfer\0I\0o\0arg1\0O\0F\0N\0s\0\0org.openobex.Agent\0Progress\0S\0transfer\0I\0o\0transferred\0I\0t\0\0org.openobex.Agent\0Complete\0S\0transfer\0I\0o\0\0org.openobex.Agent\0Error\0S\0transfer\0I\0o\0message\0I\0s\0\0\0",
++      "org.bluez.obex.Agent\0Authorize\0S\0transfer\0I\0o\0bt_address\0I\0s\0name\0I\0s\0type\0I\0s\0length\0I\0i\0time\0I\0i\0arg6\0O\0F\0N\0s\0\0org.bluez.obex.Agent\0Cancel\0S\0\0org.bluez.obex.Agent\0Release\0S\0\0org.bluez.obex.Agent\0Request\0S\0transfer\0I\0o\0arg1\0O\0F\0N\0s\0\0org.bluez.obex.Agent\0Progress\0S\0transfer\0I\0o\0transferred\0I\0t\0\0org.bluez.obex.Agent\0Complete\0S\0transfer\0I\0o\0\0org.bluez.obex.Agent\0Error\0S\0transfer\0I\0o\0message\0I\0s\0\0\0",
+       "\0",
+       "\0"
+ };
+diff --git a/src/lib/obexd/obexclient.c b/src/lib/obexd/obexclient.c
+index d8cfa78..b8ac43e 100644
+--- a/src/lib/obexd/obexclient.c
++++ b/src/lib/obexd/obexclient.c
+@@ -83,7 +83,7 @@ static void obexclient_init(OBEXClient *self)
+       GError *error = NULL;
+       /* Getting introspection XML */
+-      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", OBEXCLIENT_DBUS_PATH, "org.freedesktop.DBus.Introspectable");
++      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex.client", OBEXCLIENT_DBUS_PATH, "org.freedesktop.DBus.Introspectable");
+       self->priv->introspection_xml = NULL;
+       if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+               g_critical("%s", error->message);
+@@ -97,7 +97,7 @@ static void obexclient_init(OBEXClient *self)
+       }
+       g_free(check_intf_regex_str);
+-      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", OBEXCLIENT_DBUS_PATH, OBEXCLIENT_DBUS_INTERFACE);
++      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex.client", OBEXCLIENT_DBUS_PATH, OBEXCLIENT_DBUS_INTERFACE);
+ }
+ /* Methods */
+diff --git a/src/lib/obexd/obexclient.h b/src/lib/obexd/obexclient.h
+index d999b76..59799db 100644
+--- a/src/lib/obexd/obexclient.h
++++ b/src/lib/obexd/obexclient.h
+@@ -27,7 +27,7 @@
+ #include <glib-object.h>
+ #define OBEXCLIENT_DBUS_PATH "/"
+-#define OBEXCLIENT_DBUS_INTERFACE "org.openobex.Client"
++#define OBEXCLIENT_DBUS_INTERFACE "org.bluez.obex.Client"
+ /*
+  * Type macros
+diff --git a/src/lib/obexd/obexclient_file_transfer.c b/src/lib/obexd/obexclient_file_transfer.c
+index 05fa36d..683cdfa 100644
+--- a/src/lib/obexd/obexclient_file_transfer.c
++++ b/src/lib/obexd/obexclient_file_transfer.c
+@@ -109,7 +109,7 @@ static void obexclient_file_transfer_post_init(OBEXClientFileTransfer *self, con
+       GError *error = NULL;
+       /* Getting introspection XML */
+-      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", dbus_object_path, "org.freedesktop.DBus.Introspectable");
++      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex.client", dbus_object_path, "org.freedesktop.DBus.Introspectable");
+       self->priv->introspection_xml = NULL;
+       if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+               g_critical("%s", error->message);
+@@ -122,7 +122,7 @@ static void obexclient_file_transfer_post_init(OBEXClientFileTransfer *self, con
+               g_assert(FALSE);
+       }
+       g_free(check_intf_regex_str);
+-      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", dbus_object_path, OBEXCLIENT_FILE_TRANSFER_DBUS_INTERFACE);
++      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex.client", dbus_object_path, OBEXCLIENT_FILE_TRANSFER_DBUS_INTERFACE);
+ }
+ static void _obexclient_file_transfer_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+diff --git a/src/lib/obexd/obexclient_file_transfer.h b/src/lib/obexd/obexclient_file_transfer.h
+index 5e796b2..750d411 100644
+--- a/src/lib/obexd/obexclient_file_transfer.h
++++ b/src/lib/obexd/obexclient_file_transfer.h
+@@ -26,7 +26,7 @@
+ #include <glib-object.h>
+-#define OBEXCLIENT_FILE_TRANSFER_DBUS_INTERFACE "org.openobex.FileTransfer"
++#define OBEXCLIENT_FILE_TRANSFER_DBUS_INTERFACE "org.bluez.obex.FileTransfer"
+ /*
+  * Type macros
+diff --git a/src/lib/obexd/obexclient_session.c b/src/lib/obexd/obexclient_session.c
+index a5b52f8..3b882d1 100644
+--- a/src/lib/obexd/obexclient_session.c
++++ b/src/lib/obexd/obexclient_session.c
+@@ -133,7 +133,7 @@ static void obexclient_session_post_init(OBEXClientSession *self, const gchar *d
+       GError *error = NULL;
+       /* Getting introspection XML */
+-      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", dbus_object_path, "org.freedesktop.DBus.Introspectable");
++      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex.client", dbus_object_path, "org.freedesktop.DBus.Introspectable");
+       self->priv->introspection_xml = NULL;
+       if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+               g_critical("%s", error->message);
+@@ -146,7 +146,7 @@ static void obexclient_session_post_init(OBEXClientSession *self, const gchar *d
+               g_assert(FALSE);
+       }
+       g_free(check_intf_regex_str);
+-      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", dbus_object_path, OBEXCLIENT_SESSION_DBUS_INTERFACE);
++      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex.client", dbus_object_path, OBEXCLIENT_SESSION_DBUS_INTERFACE);
+       /* Properties init */
+       GHashTable *properties = obexclient_session_get_properties(self, &error);
+diff --git a/src/lib/obexd/obexclient_session.h b/src/lib/obexd/obexclient_session.h
+index 87af06d..bffd844 100644
+--- a/src/lib/obexd/obexclient_session.h
++++ b/src/lib/obexd/obexclient_session.h
+@@ -26,7 +26,7 @@
+ #include <glib-object.h>
+-#define OBEXCLIENT_SESSION_DBUS_INTERFACE "org.openobex.Session"
++#define OBEXCLIENT_SESSION_DBUS_INTERFACE "org.bluez.obex.Session"
+ /*
+  * Type macros
+diff --git a/src/lib/obexd/obexclient_transfer.c b/src/lib/obexd/obexclient_transfer.c
+index 68c4bf3..e11e2d4 100644
+--- a/src/lib/obexd/obexclient_transfer.c
++++ b/src/lib/obexd/obexclient_transfer.c
+@@ -133,7 +133,7 @@ static void obexclient_transfer_post_init(OBEXClientTransfer *self, const gchar
+       GError *error = NULL;
+       /* Getting introspection XML */
+-      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", dbus_object_path, "org.freedesktop.DBus.Introspectable");
++      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex.client", dbus_object_path, "org.freedesktop.DBus.Introspectable");
+       self->priv->introspection_xml = NULL;
+       if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+               g_critical("%s", error->message);
+@@ -146,7 +146,7 @@ static void obexclient_transfer_post_init(OBEXClientTransfer *self, const gchar
+               g_assert(FALSE);
+       }
+       g_free(check_intf_regex_str);
+-      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", dbus_object_path, OBEXCLIENT_TRANSFER_DBUS_INTERFACE);
++      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex.client", dbus_object_path, OBEXCLIENT_TRANSFER_DBUS_INTERFACE);
+       /* Properties init */
+       GHashTable *properties = obexclient_transfer_get_properties(self, &error);
+diff --git a/src/lib/obexd/obexclient_transfer.h b/src/lib/obexd/obexclient_transfer.h
+index f84fd69..f92e790 100644
+--- a/src/lib/obexd/obexclient_transfer.h
++++ b/src/lib/obexd/obexclient_transfer.h
+@@ -26,7 +26,7 @@
+ #include <glib-object.h>
+-#define OBEXCLIENT_TRANSFER_DBUS_INTERFACE "org.openobex.Transfer"
++#define OBEXCLIENT_TRANSFER_DBUS_INTERFACE "org.bluez.obex.Transfer"
+ /*
+  * Type macros
+diff --git a/src/lib/obexd/obexmanager.c b/src/lib/obexd/obexmanager.c
+index 1e3e0d4..c77daad 100644
+--- a/src/lib/obexd/obexmanager.c
++++ b/src/lib/obexd/obexmanager.c
+@@ -134,7 +134,7 @@ static void obexmanager_init(OBEXManager *self)
+       GError *error = NULL;
+       /* Getting introspection XML */
+-      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex", OBEXMANAGER_DBUS_PATH, "org.freedesktop.DBus.Introspectable");
++      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex", OBEXMANAGER_DBUS_PATH, "org.freedesktop.DBus.Introspectable");
+       self->priv->introspection_xml = NULL;
+       if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+               g_critical("%s", error->message);
+@@ -148,7 +148,7 @@ static void obexmanager_init(OBEXManager *self)
+       }
+       g_free(check_intf_regex_str);
+-      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex", OBEXMANAGER_DBUS_PATH, OBEXMANAGER_DBUS_INTERFACE);
++      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex", OBEXMANAGER_DBUS_PATH, OBEXMANAGER_DBUS_INTERFACE);
+       /* DBus signals connection */
+diff --git a/src/lib/obexd/obexmanager.h b/src/lib/obexd/obexmanager.h
+index 203fe59..c0fe168 100644
+--- a/src/lib/obexd/obexmanager.h
++++ b/src/lib/obexd/obexmanager.h
+@@ -27,7 +27,7 @@
+ #include <glib-object.h>
+ #define OBEXMANAGER_DBUS_PATH "/"
+-#define OBEXMANAGER_DBUS_INTERFACE "org.openobex.Manager"
++#define OBEXMANAGER_DBUS_INTERFACE "org.bluez.obex.Manager"
+ /*
+  * Type macros
+diff --git a/src/lib/obexd/obexsession.c b/src/lib/obexd/obexsession.c
+index 48380cf..49cbeed 100644
+--- a/src/lib/obexd/obexsession.c
++++ b/src/lib/obexd/obexsession.c
+@@ -120,7 +120,7 @@ static void obexsession_post_init(OBEXSession *self, const gchar *dbus_object_pa
+       GError *error = NULL;
+       /* Getting introspection XML */
+-      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable");
++      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex", dbus_object_path, "org.freedesktop.DBus.Introspectable");
+       self->priv->introspection_xml = NULL;
+       if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+               g_critical("%s", error->message);
+@@ -133,7 +133,7 @@ static void obexsession_post_init(OBEXSession *self, const gchar *dbus_object_pa
+               g_assert(FALSE);
+       }
+       g_free(check_intf_regex_str);
+-      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex", dbus_object_path, OBEXSESSION_DBUS_INTERFACE);
++      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex", dbus_object_path, OBEXSESSION_DBUS_INTERFACE);
+       /* Properties init */
+       GHashTable *properties = obexsession_get_properties(self, &error);
+diff --git a/src/lib/obexd/obexsession.h b/src/lib/obexd/obexsession.h
+index d39e15f..c045859 100644
+--- a/src/lib/obexd/obexsession.h
++++ b/src/lib/obexd/obexsession.h
+@@ -26,7 +26,8 @@
+ #include <glib-object.h>
+-#define OBEXSESSION_DBUS_INTERFACE "org.openobex.Session"
++#define OBEXSESSION_DBUS_INTERFACE "org.bluez.obex.Session"
++
+ /*
+  * Type macros
+diff --git a/src/lib/obexd/obextransfer.c b/src/lib/obexd/obextransfer.c
+index 78dcf52..94c5979 100644
+--- a/src/lib/obexd/obextransfer.c
++++ b/src/lib/obexd/obextransfer.c
+@@ -130,7 +130,7 @@ static void obextransfer_post_init(OBEXTransfer *self, const gchar *dbus_object_
+       GError *error = NULL;
+       /* Getting introspection XML */
+-      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable");
++      self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex", dbus_object_path, "org.freedesktop.DBus.Introspectable");
+       self->priv->introspection_xml = NULL;
+       if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+               g_critical("%s", error->message);
+@@ -143,7 +143,7 @@ static void obextransfer_post_init(OBEXTransfer *self, const gchar *dbus_object_
+               g_assert(FALSE);
+       }
+       g_free(check_intf_regex_str);
+-      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex", dbus_object_path, OBEXTRANSFER_DBUS_INTERFACE);
++      self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.bluez.obex", dbus_object_path, OBEXTRANSFER_DBUS_INTERFACE);
+       /* DBus signals connection */
+diff --git a/src/lib/obexd/obextransfer.h b/src/lib/obexd/obextransfer.h
+index 99f3084..3ccdcbd 100644
+--- a/src/lib/obexd/obextransfer.h
++++ b/src/lib/obexd/obextransfer.h
+@@ -26,7 +26,7 @@
+ #include <glib-object.h>
+-#define OBEXTRANSFER_DBUS_INTERFACE "org.openobex.Transfer"
++#define OBEXTRANSFER_DBUS_INTERFACE "org.bluez.obex.Transfer"
+ /*
+  * Type macros
+-- 
+1.7.9.5
+
diff --git a/patches/0001-libnl-add-lnl-genl-to-default-configuration.patch b/patches/0001-libnl-add-lnl-genl-to-default-configuration.patch
new file mode 100755 (executable)
index 0000000..30f08ee
--- /dev/null
@@ -0,0 +1,24 @@
+From 395c60c2bc00f9f2685d662c006736e2fa562808 Mon Sep 17 00:00:00 2001
+From: Eyal Reizer <eyalr@ti.com>
+Date: Mon, 24 Sep 2012 16:39:19 +0300
+Subject: [PATCH] libnl: add lnl-genl to default configuration
+
+Signed-off-by: Eyal Reizer <eyalr@ti.com>
+---
+ libnl-2.0.pc.in |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libnl-2.0.pc.in b/libnl-2.0.pc.in
+index e44f0fb..0bca566 100644
+--- a/libnl-2.0.pc.in
++++ b/libnl-2.0.pc.in
+@@ -6,5 +6,5 @@ includedir=@includedir@
+ Name: libnl
+ Description: Convenience library for netlink sockets
+ Version: @PACKAGE_VERSION@
+-Libs: -L${libdir} -lnl
++Libs: -L${libdir} -lnl -lnl-genl
+ Cflags: -I${includedir}
+-- 
+1.7.9.5
+
diff --git a/patches/0001-pygobject-python-includes.patch b/patches/0001-pygobject-python-includes.patch
new file mode 100644 (file)
index 0000000..ffc07b3
--- /dev/null
@@ -0,0 +1,53 @@
+--- a/configure.ac     2009-12-25 19:06:22.000000000 +0200
++++ b/configure.ac     2012-10-30 16:59:12.000000000 +0200
+@@ -77,10 +77,12 @@
+ AC_MSG_CHECKING([for PySignal_SetWakeupFd in Python.h])
+ py_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"`
+-if test -x "$PYTHON-config"; then
+-PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
+-else
+-PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
++if test -z $PYTHON_INCLUDES; then
++      if test -x "$PYTHON-config"; then
++              PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
++      else
++              PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
++      fi
+ fi
+ old_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS="-Wall -Werror $PYTHON_INCLUDES"
+--- a/m4/python.m4     2009-12-18 11:03:34.000000000 +0200
++++ b/m4/python.m4     2012-10-30 17:41:19.000000000 +0200
+@@ -45,6 +45,7 @@
+ dnl deduce PYTHON_INCLUDES
+ py_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"`
+ py_exec_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)"`
++if test -z "$PYTHON_INCLUDES"; then
+ if test -x "$PYTHON-config"; then
+ PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
+ else
+@@ -53,6 +54,7 @@
+   PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
+ >fi
+ fi
++fi
+ AC_SUBST(PYTHON_INCLUDES)
+ dnl check if the headers exist:
+ save_CPPFLAGS="$CPPFLAGS"
+@@ -236,6 +238,7 @@
+ dnl deduce PYTHON_INCLUDES
+ py_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"`
+ py_exec_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)"`
++if test -z "$PYTHON_INCLUDES"; then
+ if test -x "$PYTHON-config"; then
+ PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
+ else
+@@ -244,6 +247,7 @@
+   PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
+ fi
+ fi
++fi
+ AC_SUBST(PYTHON_INCLUDES)
+ dnl check if the headers exist:
+ save_CPPFLAGS="$CPPFLAGS"
diff --git a/patches/0001-socket-enable-for-bluez-4_98.patch b/patches/0001-socket-enable-for-bluez-4_98.patch
new file mode 100644 (file)
index 0000000..dc61dcd
--- /dev/null
@@ -0,0 +1,25 @@
+From e142a28897c0b0fe9e61259a96dad6fb9f818ecd Mon Sep 17 00:00:00 2001
+From: Moosa <moosa.baransi@babcomsoftware.com>
+Date: Wed, 22 Feb 2012 10:06:37 +0200
+Subject: [PATCH] socket enable for bluez 0_98
+
+* This is necessary for working with A2DP
+---
+ audio/audio.conf |    1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+diff --git a/audio/audio.conf b/audio/audio.conf
+index 302e046..9533ada 100644
+--- a/audio/audio.conf
++++ b/audio/audio.conf
+@@ -3,6 +3,7 @@
+ # This section contains options which are not specific to any
+ # particular interface
+ [General]
++Enable=Socket
+ # Switch to master role for incoming connections (defaults to true)
+ #Master=true
+-- 
+1.7.1
+
diff --git a/patches/0002-bluez-enable-source-interface.patch b/patches/0002-bluez-enable-source-interface.patch
new file mode 100644 (file)
index 0000000..661f60b
--- /dev/null
@@ -0,0 +1,31 @@
+From 87bcf52a6e9f2ec018bab9dd0da2a2b844b37108 Mon Sep 17 00:00:00 2001
+From: Moosa <moosab@ti.com>
+Date: Wed, 14 Mar 2012 16:43:57 +0200
+Subject: [PATCH] bluez: enable source interface
+
+Enable Source interface on D-Bus that can be used to access
+the Sink functionality
+
+Upstream-Status: Inappropriate [enable feature]
+
+Signed-off-by: Moosa Baransi <moosab@ti.com>
+---
+ audio/audio.conf |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/audio/audio.conf b/audio/audio.conf
+index 9533ada..b554936 100644
+--- a/audio/audio.conf
++++ b/audio/audio.conf
+@@ -3,7 +3,7 @@
+ # This section contains options which are not specific to any
+ # particular interface
+ [General]
+-Enable=Socket
++Enable=Socket,Source
+ # Switch to master role for incoming connections (defaults to true)
+ #Master=true
+-- 
+1.7.1
+
index 032b6d56b55b0aac5ccb8ea325126b2e32911811..141fd023a3ddddcf58af78fbd88fefd0b388b1c3 100644 (file)
@@ -15,6 +15,7 @@ export PATH="$PATH:<toolchain path>"
 export ROOTFS=<path to root filesystem>
 export WORK_SPACE=<working directory>
 export KLIB_BUILD=<linux-kernel>
+export BUILD_VERSION="r8"
 # MACHINE_TYPE - The target machine type. Can have one of the following values: "am1808" , "omap3evm" , "am335x"
 # This is needed to build bluetooth components.
 # This parameter is not relevant for ti814x board.
index 66205939552d95a53b5a13280514f1c05e22581d..39000ced48fd1ad3ca0e9405a5f2559de8a74d4e 100755 (executable)
@@ -1,13 +1,6 @@
 #!/bin/bash
 
 BUILD_VERSION="r5"
-#### R4
-#compat_download_target[r4]="https://gforge.ti.com/gf/download/frsrelease/801/5434/ti-compat-wireless-wl12xx-2012-02-06-r4-12.tgz ti-compat-wireless-wl12xx-2012-02-06-r4-12.tgz http://processors.wiki.ti.com/images/a/aa/Compat-wireless-patches.zip"
-#ti_utils_download_target[r4]="git://github.com/TI-ECS/ti-utils.git"
-#ti_utils_commit_ids[r4]="aaffc13e6c804291ac7dcefdcec181c0207ff67a"
-#hostap_download_target[r4]="git://w1.fi/srv/git/hostap.git"
-#hostap_commit_id[r4]="83fa07226debc2f7082b6ccd62dbb1cd47c30472"
-#hostap_patches[r4]="http://processors.wiki.ti.com/images/8/8a/Hostapd-wpa-supplicant-patches.zip"
 #### R5-SP2
 declare -A compat_download_target["r5"]="https://gforge.ti.com/gf/download/frsrelease/864/5621/ti-compat-wireless-wl12xx-2012-05-17-r5-18.tar.gz http://processors.wiki.ti.com/images/6/6e/Compat-wireless-patches-r5.zip"
 
diff --git a/wl18xx_build.sh b/wl18xx_build.sh
new file mode 100755 (executable)
index 0000000..4f1cd12
--- /dev/null
@@ -0,0 +1,1139 @@
+#!/bin/bash
+
+#### R8-a4.05
+declare -A compat_download_target["r8"]="https://gforge.ti.com/gf/download/frsrelease/973/6259/ti_compat_wireless_wl18xx_R8_A4_05.tar.gz  https://gforge.ti.com/gf/download/frsrelease/974/6260/compat-wireless-patches-r8-a4-05.zip"
+declare -A ti_utils_download_target["r8"]="git://github.com/TI-OpenLink/18xx-ti-utils.git"
+declare -A ti_utils_commit_id["r8"]="ol_r8.a4.05"
+declare -A wl18xx_fw_download_target["r8"]="git://github.com/TI-OpenLink/wl18xx_fw.git"
+declare -A ti_utils_commit_id["r8"]="ol_r8.a4.05"
+declare -A hostap_download_target["r8"]="git://github.com/TI-OpenLink/hostap.git"
+declare -A hostap_commit_id["r8"]="ol_r8.a4.05"
+declare -A hostap_patches["r8"]=""
+declare -A conf_and_scripts["r8"]="https://gforge.ti.com/gf/download/frsrelease/910/5880/ecs-conf-files-and-scripts-2012-08-01.tar.gz"
+
+if [ ! -e setup-env ]
+then
+       echo "No setup-env"
+       exit 1
+fi
+source setup-env
+unset PKG_CONFIG_SYSROOT_DIR
+ME=$0
+components="libnl openssl iw hostap wpa_supplicant crda ti-utils wl18xx-firmware compat-wireless"
+
+function download ()
+{
+       file="$2"
+       [ -e ${WORK_SPACE}/${file} ] && echo "File $file already exists. Skipping download." && return 0
+       wget "$1"
+       if [ $? -ne 0 ]
+       then 
+               echo "Failed to download $file"
+               exit 1
+       fi
+}
+
+function git_clone ()
+{
+       file="$2"
+       [ -e ${WORK_SPACE}/${file} ] && echo "File $file alread exists. Skipping git clone." && return 0
+       git clone "$1"
+       if [ $? -ne 0 ]
+       then
+               echo "Failed to download $2 git repository"
+               exit 1
+       fi
+}
+function compat-wireless()
+{
+       stage=$1
+
+       if [ x"$stage" = "xdownload"  -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}
+               for url in ${compat_download_target["$BUILD_VERSION"]}
+               do
+                       file=`basename $url`
+                       download $url $file
+                       local EXT=${url/*./}
+                       case $EXT in 
+                               "gz")
+                                       [ ! -d ${WORK_SPACE}/compat-wireless ] && tar xzf $file
+                                       ;;
+
+                               "zip")
+                                       if [ ! -e ${WORK_SPACE}/compat-wireless/patches-${BUILD_VERSION}.done ]
+                                       then
+                                               echo "Applying patches"
+                                               cd ${WORK_SPACE}/compat-wireless || exit 1
+                                               mkdir tmp-patches
+                                               cd tmp-patches
+                                               unzip ${WORK_SPACE}/$file
+                                               local -a files=(*.patch)
+                                               cd -
+                                               for(( i=0; i<${#files[@]}; i++ ))
+                                               do
+                                                       patch -p1 -i tmp-patches/${files[$i]} || exit 1;
+                                               done
+                                               res=`./scripts/driver-select wl18xx`
+                                               touch patches-${BUILD_VERSION}.done
+                                       fi
+                                       ;;
+                       esac
+               done
+               
+       fi
+       if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/compat-wireless
+               make KLIB_BUILD=${KLIB_BUILD} KLIB=${ROOTFS} || exit 1
+       fi
+       if [ x"$stage" = "xinstall"  -o x"$stage" = "xall" ]
+       then
+               find ${ROOTFS} -name "wl12xx*.ko" | xargs rm -f
+               find ${ROOTFS} -name "mac80211.ko" | xargs rm -f
+               find ${ROOTFS} -name "cfg80211.ko" | xargs rm -f
+               find ${ROOTFS} -name "compat.ko" | xargs rm -f
+               cd ${WORK_SPACE}/compat-wireless
+               make KLIB_BUILD=${KLIB_BUILD} KLIB=${ROOTFS} install-modules
+       fi
+
+       if [ x"$stage" = "xclean" ]
+       then
+               cd $WORK_SPACE/compat-wireless
+               #make KLIB=${ROOTFS} uninstall
+               cd $WORK_SPACE && rm -rf compat-wireless
+       fi
+
+       cd $WORK_SPACE
+}
+function crda ()
+{
+       stage=$1
+       if [ x"$stage" = "xdownload"  -o x"$stage" = "xall" ]
+       then
+               download "http://wireless.kernel.org/download/crda/crda-1.1.1.tar.bz2" "crda-1.1.1.tar.bz2"
+                download "http://linuxwireless.org/download/wireless-regdb/regulatory.bins/2011.04.28-regulatory.bin" "2011.04.28-regulatory.bin"
+               tar xjf crda-1.1.1.tar.bz2
+               cd ${WORK_SPACE}/crda-1.1.1
+               cp ${WORK_SPACE}/2011.04.28-regulatory.bin .
+       fi
+       if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/crda-1.1.1
+               make USE_OPENSSL=1 all_noverify || exit 1
+       fi
+       if [ x"$stage" = "xinstall"  -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/crda-1.1.1
+               DESTDIR=${ROOTFS} make USE_OPENSSL=1 UDEV_RULE_DIR="etc/udev/rules.d/" install || exit 1
+               mkdir -p ${ROOTFS}/usr/lib/crda
+               cp 2011.04.28-regulatory.bin ${ROOTFS}/usr/lib/crda/regulatory.bin
+       fi
+       if [ x"$stage" = "xclean" ]
+       then
+               cd $WORK_SPACE/crda-1.1.1
+               DESTDIR=${ROOTFS} make clean
+               cd $WORK_SPACE && rm -rf crda-1.1.1
+       fi
+       cd $WORK_SPACE
+}
+
+function iw ()
+{
+       stage=$1
+       if [ x"$stage" = "xdownload"  -o x"$stage" = "xall" ]
+       then
+               git_clone git://git.sipsolutions.net/iw.git iw
+               cd ${WORK_SPACE}/iw
+               git reset --hard 0a236ef5f8e4ba7218aac7d0cdacf45673d5b35c || exit 1
+       fi
+       if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/iw
+               make || exit 1
+       fi
+
+       if [ x"$stage" = "xinstall"  -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/iw
+               DESTDIR=${ROOTFS} make install || exit 1
+       fi
+       if [ x"$stage" = "xclean" ]
+       then
+               cd $WORK_SPACE/iw
+               make clean
+       fi
+       cd $WORK_SPACE
+}
+function libnl ()
+{
+       stage=$1
+       if [ x"$stage" = x"download" -o x"$stage" = "xall" ]
+       then
+               download http://www.infradead.org/~tgr/libnl/files/libnl-2.0.tar.gz libnl-2.0.tar.gz
+               tar xzf libnl-2.0.tar.gz
+               cd ${WORK_SPACE}/libnl-2.0
+               ./configure --prefix=${ROOTFS} CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld RANLIB=${CROSS_COMPILE}ranlib --host=arm-linux
+               if [ $? != 0 ]
+               then
+                       echo "libnl failed to be configured"
+                       exit 1
+               fi
+       fi
+
+       if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/libnl-2.0
+               make || exit 1
+       fi
+       if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/libnl-2.0
+               make install || exit 1
+       fi
+       if [ x"$stage" = "xclean" ]
+       then
+               cd $WORK_SPACE/libnl-2.0
+               make uninstall
+               cd .. && rm -rf libnl-2.0
+       fi
+       cd $WORK_SPACE
+
+}
+function openssl ()
+{
+       stage=$1
+       if [ x"$stage" = x"download" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}
+               download "http://www.openssl.org/source/openssl-1.0.0d.tar.gz" "openssl-1.0.0d.tar.gz"
+               tar xzf openssl-1.0.0d.tar.gz
+               download http://processors.wiki.ti.com/images/e/ee/Openssl-1.0.0d-new-compilation-target-for-configure.zip Openssl-1.0.0d-new-compilation-target-for-configure.zip
+               cd ${WORK_SPACE}/openssl-1.0.0d
+               unzip ${WORK_SPACE}/Openssl-1.0.0d-new-compilation-target-for-configure.zip || exit 1
+               patch -p1 -i 0001-openssl-1.0.0d-new-target-os-for-configure.patch || exit 1
+               CROSS_COMPILE= perl ./Configure  shared --prefix=$ROOTFS/usr --openssldir=$ROOTFS/usr/lib/ssl linux-elf-arm
+       fi || exit 1
+       if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/openssl-1.0.0d
+               make || exit 1
+       fi
+       if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/openssl-1.0.0d
+               make install_sw || exit 1
+       fi
+       if [ x"$stage" = "xclean" ]
+       then
+               cd ${WORK_SPACE}/openssl-1.0.0d
+               rm -f ${ROOTFS}/usr/lib/*ssl* ${ROOTFS}/usr/lib/pkgconfig/*ssl*
+               cd .. && rm -rf openssl-1.0.0d
+       fi
+       cd $WORK_SPACE
+}
+function ti-utils ()
+{
+       stage=$1
+
+       if [ x"$stage" = x"download" -o x"$stage" = "xall" ]
+       then
+               git_clone "${ti_utils_download_target[$BUILD_VERSION]}" 18xx-ti-utils
+               cd ${WORK_SPACE}/18xx-ti-utils
+               git reset --hard "${ti_utils_commit_id[$BUILD_VERSION]}"
+       fi
+
+       if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/18xx-ti-utils
+               NFSROOT=${ROOTFS} make || exit 1
+       fi
+       if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/18xx-ti-utils
+               #NFSROOT=${ROOTFS} make install || exit 1
+               if [ ! -x calibrator ]
+               then
+                       echo "calibrator is not built, run 'make' first"
+                       exit 1
+               fi
+               cp -f ./calibrator ${ROOTFS}/usr/bin
+               chmod 755 ${ROOTFS}/usr/bin/calibrator
+       fi
+       if [ x"$stage" = "xclean" ]
+       then
+               cd ${WORK_SPACE}/18xx-ti-utils
+               NFSROOT=${ROOTFS} make clean
+               rm -f ${ROOTFS}/usr/bin/calibrator
+               cd ${WORK_SPACE}/18xx-ti-utils/wlconf
+               NFSROOT=${ROOTFS} make clean
+               rm -fr ${ROOTFS}/usr/sbin/wlconf
+               rm -fr ${ROOTFS}/home/root/scripts/wlconf/
+       fi
+       cd $WORK_SPACE
+}
+
+function wl18xx-firmware()
+{
+       stage=$1
+        
+       if [ x"$stage" = x"download" -o x"$stage" = "xall" ]
+       then
+               git_clone "${wl18xx_fw_download_target[$BUILD_VERSION]}" wl18xx_fw
+               cd ${WORK_SPACE}/wl18xx_fw
+               git reset --hard "${ti_utils_commit_id[$BUILD_VERSION]}"
+       fi
+
+       if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
+       then
+               mkdir -p $ROOTFS/lib/firmware/ti-connectivity
+               case ${BUILD_VERSION} in
+                       "r8")
+                               cp ${WORK_SPACE}/wl18xx_fw/*.bin $ROOTFS/lib/firmware/ti-connectivity
+                               ;;
+               esac
+
+       fi
+       if [ x"$stage" = "xclean" ]
+       then
+               rm -rf $ROOTFS/lib/firmware/ti-connectivity
+       fi
+       cd $WORK_SPACE
+}
+
+function hostap_patching ()
+{
+       local patch_dir
+       local filename=`basename ${hostap_patches[$BUILD_VERSION]}`
+
+       case ${BUILD_VERSION} in
+               "r8")
+                       return
+                       #patch_dir=patches-r5
+                       ;;
+       esac
+       [ -e ${WORK_SPACE}/hostap/$patch_dir/${patch_dir}.done ] && return
+       download  "${hostap_patches[$BUILD_VERSION]}" "${filename}"
+       mkdir $patch_dir
+       cd $patch_dir && unzip ../$filename && cd -
+       local files=($patch_dir/*.patch)
+       for (( i=0; i<${#files[@]};i++))
+       do 
+               patch -p1 -i "${files[$i]}"
+               if [ $? -ne 0 ]
+               then
+                       echo "Patch $patch_dir/$i failed. Exiting..."
+                       exit 1
+               fi
+       done
+       touch $patch_dir/$patch_dir.done
+}
+function make_hostapd_defconfig ()
+{
+       cat > .config <<"hostapd_defconfig"
+# Example hostapd build time configuration
+#
+# This file lists the configuration options that are used when building the
+# hostapd binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out complete, if they are not to be included, i.e.,
+# just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cass, these lines should use += in order not
+# to override previous values of the variables.
+
+DESTDIR=$(ROOTFS)
+# Driver interface for Host AP driver
+CONFIG_DRIVER_HOSTAP=y
+
+# Driver interface for wired authenticator
+#CONFIG_DRIVER_WIRED=y
+
+# Driver interface for drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+CONFIG_LIBNL20=y
+# driver_nl80211.c requires a rather new libnl (version 1.1) which may not be
+# shipped with your distribution yet. If that is the case, you need to build
+# newer libnl version and point the hostapd build to use it.
+#LIBNL=/usr/src/libnl
+#CFLAGS += -I$(LIBNL)/include
+#LIBS += -L$(LIBNL)/lib
+
+# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
+#CONFIG_DRIVER_BSD=y
+#CFLAGS += -I/usr/local/include
+#LIBS += -L/usr/local/lib
+#LIBS_p += -L/usr/local/lib
+#LIBS_c += -L/usr/local/lib
+
+# Driver interface for no driver (e.g., RADIUS server only)
+#CONFIG_DRIVER_NONE=y
+
+# IEEE 802.11F/IAPP
+CONFIG_IAPP=y
+
+# WPA2/IEEE 802.11i RSN pre-authentication
+CONFIG_RSN_PREAUTH=y
+
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+CONFIG_PEERKEY=y
+
+# IEEE 802.11w (management frame protection)
+# This version is an experimental implementation based on IEEE 802.11w/D1.0
+# draft and is subject to change since the standard has not yet been finalized.
+# Driver support is also needed for IEEE 802.11w.
+#CONFIG_IEEE80211W=y
+
+# Integrated EAP server
+CONFIG_EAP=y
+
+# EAP-MD5 for the integrated EAP server
+CONFIG_EAP_MD5=y
+
+# EAP-TLS for the integrated EAP server
+CONFIG_EAP_TLS=y
+
+# EAP-MSCHAPv2 for the integrated EAP server
+CONFIG_EAP_MSCHAPV2=y
+
+# EAP-PEAP for the integrated EAP server
+CONFIG_EAP_PEAP=y
+
+# EAP-GTC for the integrated EAP server
+CONFIG_EAP_GTC=y
+
+# EAP-TTLS for the integrated EAP server
+CONFIG_EAP_TTLS=y
+
+# EAP-SIM for the integrated EAP server
+#CONFIG_EAP_SIM=y
+
+# EAP-AKA for the integrated EAP server
+#CONFIG_EAP_AKA=y
+
+# EAP-AKA' for the integrated EAP server
+# This requires CONFIG_EAP_AKA to be enabled, too.
+#CONFIG_EAP_AKA_PRIME=y
+
+# EAP-PAX for the integrated EAP server
+#CONFIG_EAP_PAX=y
+
+# EAP-PSK for the integrated EAP server (this is _not_ needed for WPA-PSK)
+#CONFIG_EAP_PSK=y
+
+# EAP-SAKE for the integrated EAP server
+#CONFIG_EAP_SAKE=y
+
+# EAP-GPSK for the integrated EAP server
+#CONFIG_EAP_GPSK=y
+# Include support for optional SHA256 cipher suite in EAP-GPSK
+#CONFIG_EAP_GPSK_SHA256=y
+
+# EAP-FAST for the integrated EAP server
+# Note: Default OpenSSL package does not include support for all the
+# functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
+# the OpenSSL library must be patched (openssl-0.9.9-session-ticket.patch)
+# to add the needed functions.
+#CONFIG_EAP_FAST=y
+
+# Wi-Fi Protected Setup (WPS)
+CONFIG_WPS=y
+# Enable WSC 2.0 support
+CONFIG_WPS2=y
+# Enable UPnP support for external WPS Registrars
+CONFIG_WPS_UPNP=y
+
+# EAP-IKEv2
+#CONFIG_EAP_IKEV2=y
+
+# Trusted Network Connect (EAP-TNC)
+#CONFIG_EAP_TNC=y
+
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+CONFIG_PKCS12=y
+
+# RADIUS authentication server. This provides access to the integrated EAP
+# server from external hosts using RADIUS.
+#CONFIG_RADIUS_SERVER=y
+
+# Build IPv6 support for RADIUS operations
+CONFIG_IPV6=y
+
+# IEEE Std 802.11r-2008 (Fast BSS Transition)
+#CONFIG_IEEE80211R=y
+
+# Use the hostapd's IEEE 802.11 authentication (ACL), but without
+# the IEEE 802.11 Management capability (e.g., madwifi or FreeBSD/net80211)
+#CONFIG_DRIVER_RADIUS_ACL=y
+
+# IEEE 802.11n (High Throughput) support
+CONFIG_IEEE80211N=y
+
+# Remove debugging code that is printing out debug messages to stdout.
+# This can be used to reduce the size of the hostapd considerably if debugging
+# code is not needed.
+#CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove support for RADIUS accounting
+#CONFIG_NO_ACCOUNTING=y
+
+# Remove support for RADIUS
+#CONFIG_NO_RADIUS=y
+
+# Remove support for VLANs
+#CONFIG_NO_VLAN=y
+
+# Remove support for dumping state into a file on SIGUSR1 signal
+# This can be used to reduce binary size at the cost of disabling a debugging
+# option.
+#CONFIG_NO_DUMP_STATE=y
+
+CONFIG_NO_RANDOM_POOL=y
+LIBNL=$(ROOTFS)
+CFLAGS += -I$(LIBNL)/include -I$(ROOTFS)/usr/include/
+LIBS += -L$(LIBNL)/lib -L$(LIBNL)/lib  -L$(ROOTFS)/usr/lib -lssl -lcrypto -ldl
+LIBS_p += -L$(LIBNL)/lib -L$(LIBNL)/lib  -L$(ROOTFS)/usr/lib -lssl -lcrypto -ldl
+hostapd_defconfig
+}
+
+function hostap()
+{
+       stage=$1
+       if [ x"$stage" = x"download" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}
+               git_clone "${hostap_download_target[$BUILD_VERSION]}" hostap
+               cd ${WORK_SPACE}/hostap
+               git reset --hard "${hostap_commit_id[$BUILD_VERSION]}"
+               hostap_patching
+       fi
+       if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/hostap/hostapd
+               make_hostapd_defconfig
+               make clean || exit 1
+               make || exit 1
+       fi
+       if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/hostap/hostapd
+               make install || exit 1
+               for i in hostapd hostapd_cli; do cp -f $i ${ROOTFS}/usr/sbin/$i || exit 1; done
+               cp hostapd.conf ${ROOTFS}/etc/ 
+       fi
+       if [ x"$stage" = "xclean" ]
+       then
+               cd ${WORK_SPACE}/hostap/hostapd
+               make clean
+               cd ../wpa_supplicant
+               make clean
+       fi
+       cd $WORK_SPACE
+
+}
+function make_wpa_sup_defconfig ()
+{
+       cat > .config <<"wpa_sup_defconfig"
+# Example wpa_supplicant build time configuration
+DESTDIR=$(ROOTFS)
+CFLAGS += -I$(ROOTFS)/usr/include/
+LIBS += -L$(ROOTFS)/usr/lib
+LIBS_p += -L$(ROOTFS)/usr/lib
+CONFIG_WAPI=y
+CONFIG_LIBNL20=y
+NEED_BGSCAN=y
+CONFIG_BGSCAN_LEARN=y
+# Driver interface for generic Linux wireless extensions
+CONFIG_DRIVER_WEXT=y
+# Driver interface for Linux drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+# Driver interface for wired Ethernet drivers
+CONFIG_DRIVER_WIRED=y
+# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
+# included)
+CONFIG_IEEE8021X_EAPOL=y
+# EAP-MD5
+CONFIG_EAP_MD5=y
+# EAP-MSCHAPv2
+CONFIG_EAP_MSCHAPV2=y
+# EAP-TLS
+CONFIG_EAP_TLS=y
+# EAL-PEAP
+CONFIG_EAP_PEAP=y
+# EAP-TTLS
+CONFIG_EAP_TTLS=y
+# EAP-GTC
+CONFIG_EAP_GTC=y
+# EAP-OTP
+CONFIG_EAP_OTP=y
+# LEAP
+CONFIG_EAP_LEAP=y
+# Wi-Fi Protected Setup (WPS)
+CONFIG_WPS=y
+# Enable WSC 2.0 support
+CONFIG_WPS2=y
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+CONFIG_PKCS12=y
+# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
+# engine.
+CONFIG_SMARTCARD=y
+# Select control interface backend for external programs, e.g, wpa_cli:
+# unix = UNIX domain sockets (default for Linux/*BSD)
+# udp = UDP sockets using localhost (127.0.0.1)
+# named_pipe = Windows Named Pipe (default for Windows)
+# y = use default (backwards compatibility)
+# If this option is commented out, control interface is not included in the
+# build.
+CONFIG_CTRL_IFACE=y
+# Select configuration backend:
+# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
+#      path is given on command line, not here; this option is just used to
+#      select the backend that allows configuration files to be used)
+# winreg = Windows registry (see win_example.reg for an example)
+CONFIG_BACKEND=file
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+CONFIG_PEERKEY=y
+# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
+CONFIG_DEBUG_FILE=y
+LIBNL=$(ROOTFS)
+CFLAGS += -I$(LIBNL)/include
+LIBS += -L$(LIBNL)/lib  -lssl -lcrypto -ldl
+LIBS_p += -L$(LIBNL)/lib  -lssl -lcrypto -ldl
+# for p2p
+CONFIG_P2P=y
+CONFIG_AP=y
+wpa_sup_defconfig
+}
+function wpa_supplicant ()
+{
+       stage=$1
+       if [ x"$stage" = x"build" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/hostap/wpa_supplicant
+               make clean
+               make_wpa_sup_defconfig
+               make || exit 1
+       fi
+       if [ x"$stage" = x"install" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/hostap/wpa_supplicant
+               make install || exit 1
+               for i in wpa_supplicant wpa_cli wpa_passphrase; do cp $i ${ROOTFS}/usr/sbin//$i || exit 1; done
+               cp wpa_supplicant.conf ${ROOTFS}/etc/ 
+       fi
+       cd $WORK_SPACE
+}
+
+function ecs_tools()
+{
+       stage=$1
+        
+       if [ x"$stage" = x"download" -o x"$stage" = "xall" ]
+       then
+               if [ ! -d ${WORK_SPACE}/conf_and_scripts ]
+               then
+                       echo "Downloading scripts and configuration files"
+                       cd ${WORK_SPACE}
+                       mkdir -p ${WORK_SPACE}/conf_and_scripts
+                       file=`basename ${conf_and_scripts["$BUILD_VERSION"]}`
+                       download ${conf_and_scripts["$BUILD_VERSION"]} $file
+                       cd ${WORK_SPACE}/conf_and_scripts
+                       tar xzf ${WORK_SPACE}/${file}
+                       cd ${WORK_SPACE}
+               fi
+       fi
+       cd $WORK_SPACE
+}
+
+function wlconf ()
+{
+       stage=$1
+       if [ x"$stage" = x"build" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/18xx-ti-utils/wlconf
+               NFSROOT=${ROOTFS} make || exit 1
+       fi
+       if [ x"$stage" = x"install" -o x"$stage" = "xall" ]
+       then
+               cd ${WORK_SPACE}/18xx-ti-utils/wlconf
+               if [ ! -x wlconf ]
+               then
+                       echo "wlconf is not built, run 'make' first"
+                       exit 1
+               fi
+               mkdir -p ${ROOTFS}/usr/sbin/wlconf
+               mkdir -p ${ROOTFS}/usr/sbin/wlconf/official_inis
+               cp -f ./wlconf ${ROOTFS}/usr/sbin/wlconf
+               chmod 755 ${ROOTFS}/usr/sbin/wlconf
+               for i in dictionary.txt struct.bin wl18xx-conf-default.bin README example.conf example.ini; do cp $i ${ROOTFS}/usr/sbin/wlconf/$i || exit 1; done
+               cp official_inis/* ${ROOTFS}/usr/sbin/wlconf/official_inis
+               mkdir -p ${ROOTFS}/home/root/scripts/wlconf
+               ecs_tools "download"
+               cp ${WORK_SPACE}/conf_and_scripts/scripts/wlconf/* ${ROOTFS}/home/root/scripts/wlconf
+               chmod 755 ${ROOTFS}/home/root/scripts/wlconf/*
+       fi
+       cd $WORK_SPACE
+}
+
+function usage ()
+{
+       echo "This script compiles one of following utilities: libnl, openssl, hostapd, wpa_supplicant,wl18xx_modules,firmware,crda,calibrator"
+       echo "by calling specific utility name and action."
+       echo "In case the options is 'all' all utilities will be downloaded and installed on root file system."
+       echo "File setup-env contains all required environment variables, for example:"
+       echo "  ROOTFS=<path to target root file system>."
+       echo "Part of operations requires root access."
+       echo "Usage: `basename $ME` target <libnl"
+       echo "                              openssl"
+       echo "                              hostapd"
+       echo "                              wpa_supplicant"
+       echo "                              wl18xx_modules"
+       echo "                              firmware"
+       echo "                              crda"
+       echo "                              wlconf"
+       echo "                              calibrator>  action <download|build|install>"
+       echo "                      all"
+       echo "                      clean-all"
+}
+
+function check_libs()
+{
+       local openssl=`pkg-config --exists openssl`
+       local libnl=`pkg-config --exists libnl-2.0`
+       package=$1
+
+       if [ $openssl -ne 0 -o $libnl -ne 0 ]
+       then
+               echo "Cannot build $1: openssl and libnl should be installed first."
+               exit 1
+       fi
+}
+function package_dir_exists()
+{
+       if [ -d "$1" ]
+       then
+               echo "Package $2 already downloaded at: $1"
+               return 1
+       fi
+       return 0
+}
+function check_env()
+{
+       [ -e ${WORK_SPACE}/.check_env.stamp ] && return 0
+       which dpkg 2>&1>/dev/null || return 0
+       err=0
+       ret=0
+       packages="python python-m2crypto bash bison flex perl bc corkscrew"
+       for p in ${packages}
+       do
+               echo -n "Checking ${p}..."
+               present=`dpkg --get-selections ${p} 2>/dev/null | awk '{print $1}'`
+               [ x"${present}" != x"${p}" ] && echo "Package ${p} is not found. Please run 'apt-get install ${p}' to install it." && err=1 && ret=1
+               [ ${err} -ne 1 ] && echo "OK"
+               err=0
+       done
+       return ${ret}
+}
+############################# MAIN ##############################################
+# First building environment should be checked
+check_env || exit 1
+if [ -z $CROSS_COMPILE ]
+then
+       #lets find some
+       tool_path=`which arm-none-linux-gnueabi-gcc`
+       if [ $? -ne 0 ]
+       then
+               echo "No tool chain is found"
+               exit 1
+       fi      
+       export CROSS_COMPILE=`dirname $tool_path`/arm-none-linux-gnueabi-
+fi
+
+if [ -z $KLIB_BUILD ]
+then
+       echo "Path to kernel sources has to be defined"
+       exit 1
+fi
+
+if [ -z $ROOTFS ]
+then
+       echo "No path to root file system"
+       exit 1
+fi
+argc=$#
+if [ $argc -lt 1 ]
+then
+       usage
+       exit 1
+elif [ $argc -eq 1 ]
+then
+       if [ x"$1" != x"all" -a x"$1" != x"clean-all" ]
+       then
+               usage
+               exit 1
+       else
+               package="$1"
+       fi
+fi
+
+if [ $argc -eq 2 ]
+then
+       package=$1
+       stage=$2
+fi
+if [ ! -d $WORK_SPACE ]
+then
+       mkdir -p $WORK_SPACE
+       touch ${WORK_SPACE}/.check_env.stamp
+fi
+cd ${WORK_SPACE}
+
+case $package in
+       libnl)
+               case $stage in
+                       download )
+                               package_dir_exists ${WORK_SPACE}/libnl-2.0 libnl-2 && libnl "download"
+                               ;;
+                       build)
+                               package_dir_exists ${WORK_SPACE}/libnl-2.0 libnl-2
+                               if [ ! $? ]
+                               then
+                                       libnl "download"
+                               fi
+                               cd ${WORK_SPACE}/libnl-2.0
+                               libnl "build"
+                               ;;
+                       install)
+                               package_dir_exists ${WORK_SPACE}/libnl-2.0 libnl-2
+                               if [ ! $? ]
+                               then
+                                       libnl "all" && exit
+                               else
+                                       cd ${WORK_SPACE}/libnl-2.0
+                                       libnl "install"
+                               fi
+                               ;;
+                       all)
+                               package_dir_exists ${WORK_SPACE}/libnl-2.0 libnl-2 || rm -rf libnl-2.0
+                               libnl "all"
+                               ;;
+                       *)
+                               echo "Error: illegal action for libnl"
+                               exit 1
+               esac
+               ;;
+       openssl)
+               case $stage in
+                       download )
+                               package_dir_exists ${WORK_SPACE}/openssl-1.0.0d openssl || exit 1
+                               openssl "download"
+                               ;;
+                       build)
+                               package_dir_exists ${WORK_SPACE}/openssl-1.0.0d openssl
+                               if [ ! $? ]
+                               then
+                                       openssl "download"
+                               fi
+                               cd ${WORK_SPACE}/openssl-1.0.0d
+                               openssl "build"
+                               ;;
+                       install)
+                               package_dir_exists ${WORK_SPACE}/openssl-1.0.0d openssl
+                               test [ ! $? ] && openssl "all" && exit 0
+                               cd ${WORK_SPACE}/openssl-1.0.0d
+                               openssl "install"
+                               ;;
+                       all)
+                               package_dir_exists ${WORK_SPACE}/openssl-1.0.0d openssl || rm -rf openssl-1.0.0d
+                               openssl "all"
+                               ;;
+               esac
+               ;;
+       iw)
+               case $stage in
+                       download )
+                               package_dir_exists ${WORK_SPACE}/iw iw || exit 1
+                               iw "download"
+                               ;;
+                       build)
+                               package_dir_exists ${WORK_SPACE}/iw iw
+                               [ ! $? ] && iw "download"
+                               check_libs iw
+                               iw "build"
+                               ;;
+                       install)
+                               package_dir_exists ${WORK_SPACE}/iw iw
+                               [ ! $? ] && iw "donwload"
+                               [ ! -x ${WORK_SPACE}/iw/iw ] && iw "build"
+                               iw "install"
+                               ;;
+                       all)
+
+                               package_dir_exists ${WORK_SPACE}/iw iw || rm -rf ${WORK_SPACE}/iw
+                               iw "all"
+                               ;;
+                       *)
+                               echo "Error: illegal action for iw"
+                               exit 1
+                               ;;
+               esac
+               ;;
+       hostapd)
+               case $stage in
+                       download)
+                               package_dir_exists ${WORK_SPACE}/hostap hostapd || exit 1
+                               hostap "download"
+                               ;;
+                       build)
+                               if [ ! -d ${WORK_SPACE}/hostap ]
+                               then
+                                       hostap "download"
+                               fi
+                               cd ${WORK_SPACE}/hostap
+                               hostap "build"
+                               ;;
+                       install)
+                               if [ ! -d ${WORK_SPACE}/hostap ]
+                               then
+                                       hostap "download"
+                               fi
+                               if [ ! -e ${WORK_SPACE}/hostap/hostapd/hostapd ]
+                               then
+                                       hostap "build"
+                               fi
+                               hostap "install"
+                               ;;
+                       all)
+                               package_dir_exists ${WORK_SPACE}/hostap hostapd || rm -rf ${WORK_SPACE}/hostap
+                               hostap "all"
+                               ;;
+                       *)
+                               echo "Error: illegal action for hostapd"
+                               exit 1
+                               ;;
+               esac
+               
+               ;;
+       wpa_supplicant)
+               case $stage in
+                       download)
+                               package_dir_exists ${WORK_SPACE}/hostap wpa_supplicant || exit 1
+                               hostap "download"
+                               ;;
+                       build)
+                               if [ ! -e ${WORK_SPACE}/hostap ]
+                               then
+                                       hostap "download"
+                               fi
+                               wpa_supplicant "build"
+                               ;;
+                       install)
+                               if [ ! -e ${WORK_SPACE}/hostap ]
+                               then
+                                       hostap "download"
+                               fi
+                               if [ ! -e ${WORK_SPACE}/hostap/wpa_supplicant/wpa_supplicant ]
+                               then
+                                       wpa_supplicant "build"
+                               fi
+                               wpa_supplicant "install"
+                               ;;
+                       *)
+                               echo "Error: illegal action for hostapd"
+                               exit 1
+                               ;;
+               esac
+               ;;
+       wl18xx_modules)
+               case $stage in
+                       download)
+                               package_dir_exists ${WORK_SPACE}/compat-wireless compat-wireless || exit 1
+                               compat-wireless "download"
+                               ;;
+                       build)
+                               if [ ! -d ${WORK_SPACE}/compat-wireless ]
+                               then
+                                       compat-wireless "download"
+                               fi
+                               cd ${WORK_SPACE}/compat-wireless
+                               compat-wireless "build"
+                               ;;
+                       install)
+                               if [ ! -d ${WORK_SPACE}/compat-wireless ]
+                               then
+                                       compat-wireless "all"
+                               else
+                                       cd ${WORK_SPACE}/compat-wireless
+                                       compat-wireless "install"
+                               fi
+                               ;;
+                       all)
+                               package_dir_exists ${WORK_SPACE}/compat-wireless compat-wireless || rm -rf ${WORK_SPACE}/compat-wireless
+                               compat-wireless "all"
+                               ;;
+                       *)
+                               echo "Error: illegal action for wl18xx_modules"
+                               exit 1
+                               ;;
+               esac
+
+               ;;
+       calibrator)
+               case $stage in
+                       download)
+                               if [ -d ${WORK_SPACE}/ti-utils ]
+                               then
+                                       echo "Calibrator is part of ti-utils package that already exists at: ${WORK_SPACE}/18xx-ti-utils"
+                                       exit 0
+                               fi
+                               ti-utils "download"
+                               ;;
+                       build)
+                               if [ ! -d ${WORK_SPACE}/18xx-ti-utils ]
+                               then
+                                       ti-utils "download"
+                               fi
+                               cd ${WORK_SPACE}/ti-utils
+                               ti-utils "build"
+                               ;;
+                       install)
+                               if [ ! -d ${WORK_SPACE}/18xx-ti-utils ]
+                               then
+                                       ti-utils "all"
+                               else
+                                       if [ ! -e ${WORK_SPACE}/18xx-ti-utils/calibrator ]
+                                       then
+                                               ti-utils "build"
+                                       fi
+                                       ti-utils "install"
+                               fi
+                               ;;
+                       all)
+                               ti-utils "all"
+                               ;;
+                       *)
+                               echo "Error: illegal action for calibrator"
+                               exit 1
+                               ;;
+               esac
+               ;;
+       wlconf)
+               case $stage in
+                       download)
+                               if [ ! -d ${WORK_SPACE}/18xx-ti-utils ]
+                               then
+                                       ti-utils "download"
+                               fi
+                               if [ ! -d ${WORK_SPACE}/conf_and_scripts ]
+                               then
+                                       ecs_tools "download"
+                               fi
+                               ;;
+                       build)
+                               if [ ! -d ${WORK_SPACE}/18xx-ti-utils ]
+                               then
+                                       ti-utils "download"
+                               fi
+                               wlconf "build"
+                               ;;
+                       install)
+                               if [ ! -d ${WORK_SPACE}/18xx-ti-utils ]
+                               then
+                                       ti-utils "download"
+                               fi
+                               if [ ! -e ${WORK_SPACE}/18xx-ti-utils/wlconf/wlconf ]
+                               then
+                                       wlconf "build"
+                               fi
+                               if [ ! -d ${WORK_SPACE}/conf_and_scripts ]
+                               then
+                                       ecs_tools "download"
+                               fi
+                               wlconf "install"
+                               ;;
+                       all)
+                               wlconf "all"
+                               ;;
+                       *)
+                               echo "Error: illegal action for wlconf"
+                               exit 1
+                               ;;
+               esac
+               ;;
+       firmware)
+               if [  x$stage = "xclean"  -o  x$stage = "xdownload" -o x$stage = "xinstall"  -o x$stage = "xall" ]
+               then
+
+                       if [ ! -d wl18xx_fw/ ]
+                       then
+                               wl18xx-firmware "download"
+                       fi
+
+                       wl18xx-firmware $2 
+               else
+                       echo "illegal action for firmware"
+                       exit 1
+               fi
+               ;;
+       crda)
+               case $stage in
+                       download)
+                               package_dir_exists ${WORK_SPACE}/crda-1.1.1 crda || exit 1
+                               crda "download"
+                               ;;
+                       build)
+                               if [ ! -d ${WORK_SPACE}/crda-1.1.1 ]
+                               then
+                                       crda "download"
+                               fi
+                               cd ${WORK_SPACE}/crda-1.1.1
+                               crda "build"
+                               ;;
+                       install)
+                               if [ ! -d ${WORK_SPACE}/crda-1.1.1 ]
+                               then
+                                       crda "all"
+                               else
+                                       cd ${WORK_SPACE}/crda-1.1.1
+                                       crda "install"
+                               fi
+                               ;;
+                       all)
+                               package_dir_exists ${WORK_SPACE}/crda-1.1.1 crda || rm -rf ${WORK_SPACE}/crda-1.1.1
+                               crda "all"
+                               ;;
+                       *)
+                               echo "Error: illegal action for crda"
+                               exit 1
+                               ;;
+               esac
+               ;;
+       all)
+               libnl "all"
+               openssl "all"
+               iw "all"
+               hostap "all"
+               wpa_supplicant "all"
+               crda "all"
+               ti-utils "all"
+               wl18xx-firmware "all"
+               compat-wireless "all"
+               wlconf "all"
+               ;;
+       clean-all)
+               compat-wireless "clean"
+               ti-utils "clean"
+               crda "clean"
+               hostap "clean"
+               iw "clean"
+               openssl "clean"
+               libnl "clean"
+               wl18xx-firmware "clean"
+               ;;
+       *)
+               usage
+               exit 1
+esac
diff --git a/wl18xx_build_bt.sh b/wl18xx_build_bt.sh
new file mode 100755 (executable)
index 0000000..fd5cf91
--- /dev/null
@@ -0,0 +1,430 @@
+#!/bin/bash
+
+#                            \\\// 
+#                           -(o o)- 
+#========================oOO==(_)==OOo=======================
+#
+# This file contains the Bluetooth components which should
+# be built and installed on the target filesystem
+#
+
+source ./functions/python-functions
+function usage()
+{
+       echo
+       echo
+       echo "************************************"
+       echo "* Bluetooth Modules Builder Script *"
+       echo "************************************"
+       echo
+       echo "This script compiles the BT modules components"
+       echo "The script can build each component as standalone by invoking: \"./wl12xx_build_bt.sh <module name> <build/rebuild>\""
+       echo "For example: \"./wl12xx_build_bt.sh bt-modules rebuild\""
+       echo
+       echo "Available components are:"
+       echo "bt-modules, expat, libffi, dbus, libIConv, zlib, gettext, glib, dbus-glib,"
+       echo "check, python, pygobject, dbus-python,bluez, hcidump, ncurses"
+       echo "readline, alsa-lib, openobex, libical, obexd, bt-obex, firmware, wl1271-demo, bt-enable"
+       echo
+       echo "You may also build all components by typing: \"./wl12xx_build_bt.sh all build\""
+       echo
+       echo "Prerequisites"
+       echo "============="
+       echo "The following variables should be exported in order to run the script:"
+       echo "1) ROOTFS - should point to the root filesystem where the BT components will be installed"
+       echo "2) WORK_SPACE - should point to the workspace where the components will be downloaded and compiled"
+       echo "3) KLIB_BUILD - should point to the kernel which the compat bluetooth will be compiled against."
+       echo "4) Path to cross compiler in PATH"
+       echo ""
+}
+
+function all()
+{
+       get_machine_used
+       #bt-modules 1
+       uim 1
+       expat 1
+       libffi
+       glib 1
+       dbus 1
+       libIConv 1
+       zlib 1
+       gettext 1
+       dbus-glib 1
+       check 1
+       python 1
+       pygobject 1
+       dbus-python 1
+       bluez 1
+       hcidump 1
+       ncurses 1
+       readline 1
+       alsa-lib 1
+       openobex 1
+       libical 1
+       obexd 1
+       bt-obex 1
+       firmware 1
+       wl1271-demo 1
+       #bt-enable 1
+}
+
+function apply_patches()
+{
+       [ ! -e $LS ] && echo "Please set full path of ls utility in setup-env file." && exit 1
+       files=`$LS *.patch`
+       for f in ${files}; do patch -p1 -i ${f} || exit 1; done
+       return 0
+}
+function bt-modules()
+{
+       if [ x"$KLIB_BUILD" = "x" ]; then
+               echo "Please set KLIB_BUILD variable to point to your Linux kernel"
+               exit 1
+       fi
+
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="ti-compat-bluetooth-2012-02-20.tar.gz"
+       COMPONENT_DIR="compat-bluetooth"
+       download_component "https://gforge.ti.com/gf/download/frsrelease/802/5435/ti-compat-bluetooth-2012-02-20.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               [ ! -e Compat-patch-zip-v1.zip ] && { wget http://processors.wiki.ti.com/images/9/99/Compat-patch-zip-v1.zip || exit 1; }
+               unzip -o Compat-patch-zip-v1.zip || exit 1
+               apply_patches
+
+               ./scripts/driver-select bt || exit 1
+               make KLIB=${ROOTFS} "install-modules" || exit 1
+               add_fingerprint 1
+       fi
+       echo "bt-modules built successfully"
+}
+
+function bluez()
+{
+       if  [ $# -eq 1 ]; then
+               START_MODULE="bluez"
+       fi
+       # dependency section, in here we build the dependencies. We do not want to rebuild them each time
+       check
+       dbus
+       glib
+       uim
+
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="bluez"
+       COMPONENT_REV="70a609bb3a7401b56377de77586e09a56d631468"
+       COMPONENT_DIR="bluez"
+       download_component "git://git.kernel.org/pub/scm/bluetooth/bluez.git"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               #[ ! -e BlueZ_patches-v2.zip ] && { wget http://processors.wiki.ti.com/images/7/7e/BlueZ_patches-v2.zip || exit 1; }
+               #unzip -o BlueZ_patches-v2.zip || exit 1
+               #apply_patches
+               patch -p1 -i ${old_dir}/patches/0001-bluez-define-_GNU_SOURCE-macro.patch
+               patch -p1 -i ${old_dir}/patches/0001-socket-enable-for-bluez-4_98.patch 
+               patch -p1 -i ${old_dir}/patches/0002-bluez-enable-source-interface.patch
+               patch -p1 -i ${old_dir}/patches/0001-bluez-define-macro-lacking-in-compiler.patch
+
+               /usr/bin/libtoolize || exit 1
+               /usr/bin/aclocal || exit 1
+               /usr/bin/autoheader || exit 1
+               /usr/bin/automake --add-missing || exit 1
+               /usr/bin/autoconf || exit 1
+
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --enable-tools --enable-dund --enable-alsa --enable-test --enable-audio --enable-serial --enable-service --enable-hidd --enable-gstreamer --enable-usb --enable-tools --enable-bccmd --enable-hid2hci --enable-dfutool --enable-pand --disable-cups
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               cp audio/audio.conf profiles/input/input.conf ${ROOTFS}${MY_SYSCONFDIR}/bluetooth/ || exit 1
+               cp test/agent ${ROOTFS}${MY_PREFIX}/bin/agent || exit 1
+               add_fingerprint 1
+       fi
+       echo "bluez built successfully"
+}
+
+function hcidump
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="bluez-hcidump-2.2.tar.gz"
+       COMPONENT_DIR="bluez-hcidump-2.2"
+       download_component "http://pkgs.fedoraproject.org/repo/pkgs/bluez-hcidump/bluez-hcidump-2.2.tar.gz/3c298a8be67099fe227f3e4d9de539d5/bluez-hcidump-2.2.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               add_fingerprint 1
+       fi
+       echo "hcidump built successfully"
+}
+
+function ncurses
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="ncurses-5.9.tar.gz"
+       COMPONENT_DIR="ncurses-5.9"
+       download_component "http://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR}  -with-shared --without-debug --without-normal || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               add_fingerprint 1
+       fi
+       echo "ncurses built successfully"
+}
+
+function readline
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="readline-6.2.tar.gz"
+       COMPONENT_DIR="readline-6.2"
+       download_component "ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "readline built successfully"
+}
+
+
+function alsa-lib
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="alsa-lib-1.0.24.1.tar.gz"
+       COMPONENT_DIR="alsa-lib-1.0.25"
+       download_component "http://fossies.org/linux/misc/alsa-lib-1.0.24.1.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               ./configure --prefix=${MY_PREFIX} --host=${BUILD_HOST} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "alsa-lib built successfully"
+}
+
+function openobex
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="openobex-1.5.tar.gz"
+       COMPONENT_DIR="openobex-1.5"
+       download_component "http://ftp.osuosl.org/pub/linux/bluetooth/openobex-1.5.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+       #       wget 'http://mirror.anl.gov/pub/linux/bluetooth/openobex-1.5.tar.gz' || exit 1
+               add_fingerprint 0
+               sed -i '11227 i *)\n;;' configure || exit 1
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --enable-apps --disable-usb || exit 1
+               sed -i 's/^\(libdir=\).*/\1\$\{prefix\}\/lib/g' openobex.pc || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "openobex built successfully"
+}
+
+function libical
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="libical-0.44.tar.gz"
+       COMPONENT_DIR="libical-0.44"
+       download_component "http://downloads.sourceforge.net/project/freeassociation/libical/libical-0.44/libical-0.44.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "libical built successfully"
+}
+
+function obexd
+{
+       if  [ $# -eq 1 ]; then
+               START_MODULE="2281d4fac9fec97993b0a6dc0e2ec42911eac194"
+       fi
+       # dependency section, in here we build the dependencies. We do not want to rebuild them each time
+       bluez
+       openobex
+       libical
+       readline
+       ncurses
+
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="obexd"
+       COMPONENT_REV="2281d4fac9fec97993b0a6dc0e2ec42911eac194"
+       COMPONENT_DIR="obexd"
+       download_component "git://git.kernel.org/pub/scm/bluetooth/obexd.git"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
+               #wget http://processors.wiki.ti.com/images/2/22/Obexd-fix-UTF-conversions-1.tar.gz || exit 1
+               wget http://processors.wiki.ti.com/images/4/43/Obexd-patches_v1.tar.gz || exit 1
+               echo "Openning archive: Obexd-patches_v1.tar.gz" && tar -xzf Obexd-patches_v1.tar.gz || exit 1
+               #apply_patches
+               make || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               add_fingerprint 1
+       fi
+       echo "obexd built successfully"
+}
+
+function bt-obex
+{
+       if  [ $# -eq 1 ]; then
+               START_MODULE="171181b6ef6c94aefc828dc7fd8de136b9f97532"
+       fi
+       # dependency section, in here we build the dependencies. We do not want to rebuild them each time
+       dbus-glib
+       readline
+       ncurses
+
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="bluez-tools"
+       COMPONENT_REV="171181b6ef6c94aefc828dc7fd8de136b9f97532"
+       COMPONENT_DIR="bluez-tools"
+       download_component "git://gitorious.org/bluez-tools/bluez-tools.git"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               [ ! -e Bt-obex-patches.zip ] && { wget 'http://processors.wiki.ti.com/images/f/f5/Bt-obex-patches.zip' || exit 1; }
+               unzip -o Bt-obex-patches.zip || exit 1
+               apply_patches
+               patch -p1 -i ${old_dir}/patches/0001-bt-obex-new-dbus-api-for-obexd.patch
+
+               /usr/bin/libtoolize || exit 1
+               /usr/bin/aclocal || exit 1
+               /usr/bin/autoheader || exit 1
+               /usr/bin/automake --add-missing || exit 1
+               /usr/bin/autoconf || exit 1
+               ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
+               make LIBS="$LIBS -lncurses" || exit 1
+               make install DESTDIR=${ROOTFS} || exit 1
+               add_fingerprint 1
+       fi
+       echo "bt-obex built successfully"
+}
+
+function wl1271-demo
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="wl1271-bluetooth-2012-03-26.tar.gz"
+       COMPONENT_DIR="wl1271-bluetooth"
+       download_component "https://gforge.ti.com/gf/download/frsrelease/827/5494/wl1271-bluetooth-2012-03-26.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               #https://github.com/TI-ECS/wl1271-bluetooth/zipball/master
+               mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
+               mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
+               mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
+
+               if [ x"$MACHINE_TYPE" = "x" ]; then
+                       get_machine_used
+               fi
+
+               cp ./gallery/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
+               cp ./script/common/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
+               cp ./script/${MACHINE_TYPE}/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
+               cp ./ftp_folder/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
+               add_fingerprint 1
+       fi
+       echo "wl1271-demo built successfully"
+}
+
+function bt-enable
+{
+       cd ${WORK_SPACE} || exit 1
+       if [ x"$KLIB_BUILD" = "x" ]; then
+               echo "Please set KLIB_BUILD variable to point to your Linux kernel"
+               exit 1
+       fi
+       COMPONENT_NAME="bt_enable"
+       COMPONENT_REV="dd75971705ada8fb0e88a0fb3f68833086c5bba4"
+       COMPONENT_DIR="bt_enable"
+       download_component "git://github.com/TI-ECS/bt_enable.git"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               [ ! -e Bt-enable-standalone-makefile.zip ] && { wget 'http://processors.wiki.ti.com/images/8/8f/Bt-enable-standalone-makefile.zip' || exit 1; }
+         unzip -o Bt-enable-standalone-makefile.zip || exit 1
+         apply_patches
+
+         if [ x"$MACHINE_TYPE" = "x" ]; then
+                 get_machine_used
+         fi
+         cp ./gpio_en_${MACHINE_TYPE}.c ./gpio_en.c
+         make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} || exit 1
+         make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} install || exit 1
+         add_fingerprint 1
+       fi
+       echo "bt-enable built successfully"
+}
+
+#==================================================================================
+# Main
+#==================================================================================
+old_dir=`pwd`
+MACHINE_TYPE=""
+
+source setup-env || exit 1
+# if there are no sufficient arguments...
+if  [ $# -lt 2 ]; then
+       usage
+       exit 0
+fi
+
+if [ x"$CROSS_COMPILE" = "x" ]; then
+       echo "define CROSS_COMPILE variable"
+       exit 1
+fi
+
+which ${CROSS_COMPILE}gcc > /dev/null
+
+if [ $? -ne 0 ]; then
+       echo "No toolchain in path"
+       exit 1
+fi
+
+BUILD_HOST=`echo $CROSS_COMPILE | sed s/-$//`
+
+if [ x"$ROOTFS" = "x" ]; then
+       echo "Please set ROOTFS variable to point to your root filesystem"
+       exit 1
+fi
+
+if [ x"$WORK_SPACE" = "x" ]; then
+       echo "Please set WORK_SPACE variable to point to your preferred work space"
+       exit 1
+fi
+
+FINGURE_PRINT_DIR="${WORK_SPACE}/.FingurePrint"
+mkdir -p ${FINGURE_PRINT_DIR} || exit 1
+
+USER_OPTION=0
+CURRENT_OPTION=0
+
+case "$2" in
+       build)
+               USER_OPTION=1
+       ;;
+       rebuild)
+               USER_OPTION=2
+       ;;
+       *)
+               echo "Unknown option $2"
+               exit 1
+       ;;
+esac
+
+CURRENT_OPTION=${USER_OPTION}
+
+MODULE_TO_INVOKE=$1
+$MODULE_TO_INVOKE 1
+
+cd ${old_dir}
diff --git a/wl18xx_build_nfc.sh b/wl18xx_build_nfc.sh
new file mode 100755 (executable)
index 0000000..29f8e67
--- /dev/null
@@ -0,0 +1,272 @@
+#!/bin/bash
+
+#                            \\\// 
+#                           -(o o)- 
+#========================oOO==(_)==OOo=======================
+#
+# This file contains the NFC components which should
+# be built and installed on the target filesystem
+#
+BUILD_VERSION="r8"
+declare -A compat_nfc["r8"]="https://gforge.ti.com/gf/download/frsrelease/977/6263/ti-compat-nfc-2012-10-29.tar.gz"
+
+source ./functions/common-functions
+function usage()
+{
+       echo
+       echo
+       echo "************************************"
+       echo "* NFC Modules Builder Script *"
+       echo "************************************"
+       echo
+       echo "This script compiles the NFC modules components"
+       echo "The script can build each component as standalone by invoking: \"./wl18xx_build_nfc.sh <module name> <build/rebuild>\""
+       echo "For example: \"./wl18xx_build_nfc.sh nfc-modules rebuild\""
+       echo
+       echo "Available components are:"
+       echo "nfc-modules, expat, dbus, libIConv, zlib, gettext, glib, dbus-glib"
+       echo "firmware, nfc-demo-scripts, nfc-demo-app, uim, neard, python"
+       echo "pygobject, dbus-python"
+       echo
+       echo "You may also build all components by typing: \"./wl18xx_build_nfc.sh all build\""
+       echo
+       echo "Prerequisites"
+       echo "============="
+       echo "The following variables should be exported in order to run the script:"
+       echo "1) ROOTFS - should point to the root filesystem where the BT components will be installed"
+       echo "2) WORK_SPACE - should point to the workspace where the components will be downloaded and compiled"
+       echo "3) KLIB_BUILD - should point to the kernel which the compat bluetooth will be compiled against."
+       echo "4) Path to cross compiler in PATH"
+       echo ""
+}
+
+function all()
+{
+       get_machine_used
+       nfc-modules 1
+       libnl 1
+       neard 1
+       neardal 1
+       expat 1
+       dbus 1
+       libIConv 1
+       libffi 1
+       zlib 1
+       gettext 1
+       glib 1
+       dbus-glib 1
+       firmware 1
+       python 1
+       pygobject 1
+       dbus-python 1
+       uim 1
+       nfc-demo-scripts 1
+       nfc-demo-app 1
+}
+
+
+function nfc-modules()
+{
+       if [ x"$KLIB_BUILD" = "x" ]; then
+               echo "Please set KLIB_BUILD variable to point to your Linux kernel"
+               exit 1
+       fi
+
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME=`basename ${compat_nfc[$BUILD_VERSION]}`
+       COMPONENT_DIR="compat-nfc"
+       download_component "${compat_nfc[$BUILD_VERSION]}"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               ./scripts/driver-select nfc || exit 1
+               make KLIB=${ROOTFS} "install-modules" || exit 1
+               mkdir -p ${ROOTFS}${MY_PREFIX}/include/linux || exit 1
+               cp ./include/linux/nfc.h ${ROOTFS}${MY_PREFIX}/include/linux/
+               add_fingerprint 1
+       fi
+       echo "nfc-modules built successfully"
+}
+
+function neard()
+{
+       # dependency section, in here we build the dependencies. We do not want to rebuild them each time
+       nfc-modules
+       dbus
+       glib
+       libnl
+
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="neard"
+       COMPONENT_REV="6abe847ade787bd15512c56a9a088f69027bc0b6"
+       COMPONENT_DIR="neard"
+       download_component "git://git.kernel.org/pub/scm/network/nfc/neard.git"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+          add_fingerprint 0
+         if [ x"$MACHINE_TYPE" = "x" ]; then
+                 get_machine_used
+         fi
+         ./bootstrap || exit 1
+         ./configure --host=arm-linux --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
+         make || exit 1
+         mkdir -p ${ROOTFS}/usr/bin || exit 1
+         install -c -m 755 src/neard ${ROOTFS}/usr/bin/ || exit 1
+         install -c -m 755 src/org.neard.conf ${ROOTFS}/etc/dbus-1/system.d/ || exit 1
+         mkdir -p ${ROOTFS}/usr/share/nfc-test-scripts || exit 1
+         install -c -m 755 test/* ${ROOTFS}/usr/share/nfc-test-scripts/ || exit 1
+         mkdir -p ${ROOTFS}/etc/init.d || exit 1
+         mkdir -p ${ROOTFS}/etc/rc5.d || exit 1
+         install -c -m 755 ${old_dir}/scripts/neard.sh ${ROOTFS}/etc/init.d/ || exit 1
+         cd ${ROOTFS}/etc/init.d/ || exit 1
+         ln -s -f ../init.d/neard.sh ../rc5.d/S91neard || exit 1
+         add_fingerprint 1
+       fi
+       echo "neard built successfully"
+}
+
+function neardal()
+{
+       # dependency section, in here we build the dependencies. We do not want to rebuild them each time
+       neard
+       dbus-glib
+
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="neardal"
+       COMPONENT_REV="0.7"
+       COMPONENT_DIR="neardal"
+       download_component "git://github.com/connectivity/neardal.git"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+          add_fingerprint 0
+         if [ x"$MACHINE_TYPE" = "x" ]; then
+                 get_machine_used
+         fi
+         ./autogen.sh
+         ./configure --host=arm-linux --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --libdir=${ROOTFS}${MY_PREFIX}/lib || exit 1
+         make || exit 1
+#        sudo ldconfig || exit 1
+         make install prefix=${ROOTFS} || exit 1
+         add_fingerprint 1
+       fi
+       echo "neard application layer built successfully"
+}
+
+function nfc-demo-app()
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="nfc-demo-app.tar.gz"
+       COMPONENT_DIR="nfc-demo-app"
+       download_component "https://01.org/linux-nfc/sites/default/files/documentation/nfc-demo-app.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+          add_fingerprint 0
+         if [ x"$MACHINE_TYPE" = "x" ]; then
+                 get_machine_used
+         fi
+         ./autogen.sh
+         ./configure --host=arm-linux --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --libdir=${ROOTFS}${MY_PREFIX}/lib || exit 1
+         make || exit 1
+         make install DESTDIR=${ROOTFS} || exit 1
+         add_fingerprint 1
+       fi
+       echo "neard application layer nfc demo application built successfully"
+}
+
+function libnl()
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="libnl-2.0.tar.gz"
+       COMPONENT_DIR="libnl-2.0"
+       
+       download_component "http://www.infradead.org/~tgr/libnl/files/libnl-2.0.tar.gz"
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               patch -p1 < ${old_dir}/patches/0001-libnl-add-lnl-genl-to-default-configuration.patch || exit 1
+               ./configure --prefix=${ROOTFS}${MY_PREFIX} CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld RANLIB=${CROSS_COMPILE}ranlib --host=arm-linux || exit 1
+               make || exit 1
+               make install || exit 1
+               rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
+               add_fingerprint 1
+       fi
+       echo "libnl built successfully"
+}
+
+
+function nfc-demo-scripts
+{
+       cd ${WORK_SPACE} || exit 1
+       COMPONENT_NAME="nfc-demo-scripts-2012-10-16.tar.gz"
+       COMPONENT_DIR="nfc-demo-scripts"
+
+       if [ ${CURRENT_OPTION} = "2" ]; then
+               add_fingerprint 0
+               tar xzvf ${old_dir}/scripts/${COMPONENT_NAME} || exit 1 
+               mkdir -p ${ROOTFS}/usr/share/nfc-test-scripts || exit 1
+
+               if [ x"$MACHINE_TYPE" = "x" ]; then
+                       get_machine_used
+               fi
+
+               cp ${COMPONENT_DIR}/* ${ROOTFS}/usr/share/nfc-test-scripts || exit 1
+               add_fingerprint 1
+       fi
+       echo "nfc demo python scripts installed successfully"
+}
+
+
+old_dir=`pwd`
+MACHINE_TYPE=""
+
+source setup-env || exit 1
+
+# if there are no sufficient arguments...
+if  [ $# -lt 2 ]; then
+       usage
+       exit 0
+fi
+
+if [ x"$CROSS_COMPILE" = "x" ]; then
+       echo "define CROSS_COMPILE variable"
+       exit 1
+fi
+
+which ${CROSS_COMPILE}gcc > /dev/null
+
+if [ $? -ne 0 ]; then
+       echo "No toolchain in path"
+       exit 1
+fi
+
+
+if [ x"$ROOTFS" = "x" ]; then
+       echo "Please set ROOTFS variable to point to your root filesystem"
+       exit 1
+fi
+
+if [ x"$WORK_SPACE" = "x" ]; then
+       echo "Please set WORK_SPACE variable to point to your preferred work space"
+       exit 1
+fi
+
+FINGURE_PRINT_DIR="${WORK_SPACE}/.FingurePrint"
+mkdir -p ${FINGURE_PRINT_DIR} || exit 1
+
+USER_OPTION=0
+CURRENT_OPTION=0
+
+case "$2" in
+       build)
+               USER_OPTION=1
+       ;;
+       rebuild)
+               USER_OPTION=2
+       ;;
+       *)
+               echo "Unknown option $2"
+               exit 1
+       ;;
+esac
+
+CURRENT_OPTION=${USER_OPTION}
+
+MODULE_TO_INVOKE=$1
+$MODULE_TO_INVOKE 1
+
+cd ${old_dir}
index 631626bc966b63c2f614331973490b609f09d597..4c837bc4a5f6c0941db952f3dc898a841597470b 100755 (executable)
@@ -35,6 +35,9 @@ CONFIG_NF_NAT=y
 CONFIG_NF_NAT_NEEDED=y
 CONFIG_IP_NF_TARGET_MASQUERADE=y
 CONFIG_INPUT_UINPUT=y
+CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_FIFO=y
+CONFIG_TI_ST=y
 CONFIG
 `; do
 echo -n "Option $i: "