Added BlueZ build scripts
[ti-bt/build-utils.git] / BlueZ_4.98_wl18xx_build_bt_for_SDK7.sh
1 #!/bin/bash
3 #                            \\\// 
4 #                           -(o o)- 
5 #========================oOO==(_)==OOo=======================
6 #
7 # This file contains the Bluetooth components which should
8 # be built and installed on the target filesystem
9 #
11 BUILD_VERSION="r8"
12 #declare -A compat_bluetooth["r8"]="https://gforge.ti.com/gf/download/frsrelease/990/6319/compat-bluetooth-ol-r8.a5.01_Nov_12_2012.tar.gz"
14 function usage()
15 {
16         echo
17         echo
18         echo "************************************"
19         echo "* Bluetooth Modules Builder Script *"
20         echo "************************************"
21         echo
22         echo "This script compiles the BT modules components"
23         echo "The script can build each component as standalone by invoking: \"./wl18xx_build_bt.sh <module name> <build/rebuild>\""
24         echo "For example: \"./wl12xx_build_bt.sh bt-modules rebuild\""
25         echo
26         echo "Available components are:"
27         echo "bt-modules, bluez, hcidump, obexd, bt-obex, firmware, wl1271-demo"
28         echo
29         echo "You may also build all components by typing: \"./wl18xx_build_bt.sh all build\""
30         echo
31         echo "Prerequisites"
32         echo "============="
33         echo "The following variables should be exported in order to run the script:"
34         echo "1) ROOTFS - should point to the root filesystem where the BT components will be installed"
35         echo "2) WORK_SPACE - should point to the workspace where the components will be downloaded and compiled"
36         echo "3) KLIB_BUILD - should point to the kernel which the compat bluetooth will be compiled against."
37         echo "4) Path to cross compiler in PATH"
38         echo ""
39 }
41 function all()
42 {
43         get_machine_used
44         #bt-modules 1
45         #uim 1
46         expat 1
47         libffi
48         glib 1
49         dbus 1
50         libIConv 1
51         zlib 1
52         gettext 1
53         alsa-lib 1
54         dbus-glib 1
55         check 1
56         python 1
57         pygobject 1
58         dbus-python 1
59         bluez 1
60         hcidump 1
61         ncurses 1
62         readline 1
63         openobex 1
64         libical 1
65         obexd 1
66         bt-obex 1
67         firmware 1
68         wl1271-demo 1
69 }
71 function apply_patches()
72 {
73         [ ! -e $LS ] && echo "Please set full path of ls utility in setup-env file." && exit 1
74         files=`$LS *.patch`
75         for f in ${files}; do patch -p1 -i ${f} || exit 1; done
76         return 0
77 }
79 function alsa-lib
80 {
81         cd ${WORK_SPACE} || exit 1
82         COMPONENT_NAME="alsa-lib-1.0.27.2.tar.gz"
83         COMPONENT_DIR="alsa-lib-1.0.27.2"
84         download_component "http://fossies.org/linux/misc/alsa-lib-1.0.27.2.tar.gz"
85         if [ ${CURRENT_OPTION} = "2" ]; then
86                 add_fingerprint 0
87                 ./configure --prefix=${MY_PREFIX} --host=${BUILD_HOST} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --disable-python || exit 1
88                 make || exit 1
89                 make install DESTDIR=${ROOTFS} || exit 1
90                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
91                 add_fingerprint 1
92         fi
93         echo "alsa-lib built successfully"
94 }
96 #compat
97 function bluez()
98 {
99         if  [ $# -eq 1 ]; then
100                 START_MODULE="bluez-4.98"
101         fi
102         # dependency section, in here we build the dependencies. We do not want to rebuild them each time
103         check
104         dbus
105         glib
106         #uim
108         cd ${WORK_SPACE} || exit 1
109         COMPONENT_NAME="bluez-4.98.tar.gz"
110         #COMPONENT_REV="18a5dc6cdcf0828443c415eaea82b6834a8f9825"
111         COMPONENT_DIR="bluez-4.98"
112         download_component "http://kernel.org/pub/linux/bluetooth/bluez-4.98.tar.gz"
113         if [ ${CURRENT_OPTION} = "2" ]; then
114                 add_fingerprint 0
115                 patch -p1 -i ${old_dir}/patches/0003-socket-enable-for-bluez-4_98.patch || exit 1
116                 patch -p1 -i ${old_dir}/patches/0004-bluez-enable-source-interface.patch || exit 1
118                 LIBS='-liconv' ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --enable-alsa --enable-tools --enable-test --enable-audio --enable-serial --enable-service --enable-gstreamer --enable-usb --enable-tools --enable-bccmd --enable-hid2hci --enable-dfutool --enable-pand --disable-cups --enable-debug --enable-gatt --enable-hid2hci --enable-health
119                 make LIBS='-lffi' || exit 1
120                 make install DESTDIR=${ROOTFS} || exit 1
121                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
122                 cp audio/audio.conf input/input.conf ${ROOTFS}${MY_SYSCONFDIR}/bluetooth/ || exit 1
123                 cp test/agent ${ROOTFS}${MY_PREFIX}/bin/agent || exit 1
124                 mkdir -p ${ROOTFS}/usr/share/bluetooth
126                 cd test
127                 list='simple-agent list-devices simple-service test-adapter test-attrib test-audio test-device test-discovery test-health test-health-sink test-input test-manager test-network test-oob test-proximity test-sap-server test-service test-telephony test-textfile test-thermometer uuidtest rctest monitor-bluetooth mpris-player lmptest gaptest hciemu hsmicro hsplay hstest l2test attest avtest bdaddr btiotest'
128                 echo "installing tests in ${ROOTFS}/usr/share/bluetooth"
129                 cp ${list} ${ROOTFS}/usr/share/bluetooth
130                 cd -
131                 add_fingerprint 1
132         fi
133         echo "bluez built successfully"
134
136 function hcidump
138         cd ${WORK_SPACE} || exit 1
139         COMPONENT_NAME="bluez-hcidump-2.4.tar.gz"
140         COMPONENT_DIR="bluez-hcidump-2.4"
141         download_component "http://www.kernel.org/pub/linux/bluetooth/bluez-hcidump-2.4.tar.gz"
142         if [ ${CURRENT_OPTION} = "2" ]; then
143                 add_fingerprint 0
144                 patch -p1 -i ${old_dir}/patches/0001-blueti-Add-TI-Logger-dump.patch || exit 1
145                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
146                 make || exit 1
147                 make install DESTDIR=${ROOTFS} || exit 1
148                 add_fingerprint 1
149         fi
150         echo "hcidump built successfully"
153 function ncurses
155         cd ${WORK_SPACE} || exit 1
156         COMPONENT_NAME="ncurses-5.9.tar.gz"
157         COMPONENT_DIR="ncurses-5.9"
158         download_component "http://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz"
159         if [ ${CURRENT_OPTION} = "2" ]; then
160                 add_fingerprint 0
161                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR}  -with-shared --without-debug --without-normal || exit 1
162                 make || exit 1
163                 make install DESTDIR=${ROOTFS} || exit 1
164                 add_fingerprint 1
165         fi
166         echo "ncurses built successfully"
169 function readline
171         cd ${WORK_SPACE} || exit 1
172         COMPONENT_NAME="readline-6.2.tar.gz"
173         COMPONENT_DIR="readline-6.2"
174         download_component "ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz"
175         if [ ${CURRENT_OPTION} = "2" ]; then
176                 add_fingerprint 0
177                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
178                 make || exit 1
179                 make install DESTDIR=${ROOTFS} || exit 1
180                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
181                 add_fingerprint 1
182         fi
183         echo "readline built successfully"
187 function openobex
189         cd ${WORK_SPACE} || exit 1
190         COMPONENT_NAME="openobex-1.5.tar.gz"
191         COMPONENT_DIR="openobex-1.5"
192         download_component "http://ftp.osuosl.org/pub/linux/bluetooth/openobex-1.5.tar.gz"
193         if [ ${CURRENT_OPTION} = "2" ]; then
194         #       wget 'http://mirror.anl.gov/pub/linux/bluetooth/openobex-1.5.tar.gz' || exit 1
195                 add_fingerprint 0
196                 sed -i '11227 i *)\n;;' configure || exit 1
197                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --enable-apps --disable-usb || exit 1
198                 sed -i 's/^\(libdir=\).*/\1\$\{prefix\}\/lib/g' openobex.pc || exit 1
199                 make || exit 1
200                 make install DESTDIR=${ROOTFS} || exit 1
201                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
202                 add_fingerprint 1
203         fi
204         echo "openobex built successfully"
207 function libical
209         cd ${WORK_SPACE} || exit 1
210         COMPONENT_NAME="libical-0.44.tar.gz"
211         COMPONENT_DIR="libical-0.44"
212         download_component "http://downloads.sourceforge.net/project/freeassociation/libical/libical-0.44/libical-0.44.tar.gz"
213         if [ ${CURRENT_OPTION} = "2" ]; then
214                 add_fingerprint 0
215                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
216                 make || exit 1
217                 make install DESTDIR=${ROOTFS} || exit 1
218                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
219                 add_fingerprint 1
220         fi
221         echo "libical built successfully"
224 function obexd
226         if  [ $# -eq 1 ]; then
227                 START_MODULE="obexd-0.34.tar.gz"
228         fi
229         # dependency section, in here we build the dependencies. We do not want to rebuild them each time
230         bluez
231         libical
232         readline
233         ncurses
235         cd ${WORK_SPACE} || exit 1
236         COMPONENT_NAME="obexd-0.34.tar.gz"
237         COMPONENT_DIR="obexd-0.34"
238         download_component "http://www.kernel.org/pub/linux/bluetooth/obexd-0.34.tar.gz"
239         if [ ${CURRENT_OPTION} = "2" ]; then
240                 add_fingerprint 0
241                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
242                 #wget http://processors.wiki.ti.com/images/4/43/Obexd-patches_v1.tar.gz || exit 1
243                 #echo "Openning archive: Obexd-patches_v1.tar.gz" && tar -xzf Obexd-patches_v1.tar.gz || exit 1
244                 apply_patches
245                 make || exit 1
246                 make install DESTDIR=${ROOTFS} || exit 1
247                 test -d ${ROOTFS}/usr/share/bluetooth || mkdir -p  ${ROOTFS}/usr/share/bluetooth
248                 list='exchange-business-cards  ftp-client  list-folders  pbap-client send-files'
249                 for f in ${list}; do
250                         install -c test/$f ${ROOTFS}/usr/share/bluetooth || exit 1
251                 done
252                 add_fingerprint 1
253         fi
254         echo "obexd built successfully"
257 function bt-obex
259         if  [ $# -eq 1 ]; then
260                 START_MODULE="bluez-tools"
261         fi
262         # dependency section, in here we build the dependencies. We do not want to rebuild them each time
263         dbus-glib
264         readline
265         ncurses
267         cd ${WORK_SPACE} || exit 1
268         COMPONENT_NAME="bluez-tools"
269         COMPONENT_REV="171181b6ef6c94aefc828dc7fd8de136b9f97532"
270         COMPONENT_DIR="bluez-tools"
271         download_component "git://gitorious.org/bluez-tools/bluez-tools.git"
272         if [ ${CURRENT_OPTION} = "2" ]; then
273                 add_fingerprint 0
274                 #[ ! -e Bt-obex-patches.zip ] && { wget 'http://processors.wiki.ti.com/images/f/f5/Bt-obex-patches.zip' || exit 1; }
275                 #unzip -o Bt-obex-patches.zip || exit 1
276                 apply_patches
277                 #patch -p1 -i ${old_dir}/patches/0001-bt-obex-new-dbus-api-for-obexd.patch
278                 #patch -p1 -i ${old_dir}/patches/0001-manager-adoptation-to-new-manager-interface-of-bluez.patch
280                 /usr/bin/libtoolize || exit 1
281                 /usr/bin/aclocal || exit 1
282                 /usr/bin/autoheader || exit 1
283                 /usr/bin/automake --add-missing || exit 1
284                 /usr/bin/autoconf || exit 1
285                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
286                 make LIBS="-ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0 -liconv -lffi -lz -lncurses" || exit 1
287                 make install DESTDIR=${ROOTFS} || exit 1
288                 add_fingerprint 1
289         fi
290         echo "bt-obex built successfully"
293 function wl1271-demo
295         START_MODULE="wl1271-bluetooth"
296         cd ${WORK_SPACE} || exit 1
297         COMPONENT_NAME="wl1271-bluetooth"
298         COMPONENT_DIR="wl1271-bluetooth"
299         COMPONENT_REV="ae9a9a961dd9821d30a0b9c32612f3a552c81d4e"
300         download_component "git://github.com/TI-ECS/wl1271-bluetooth.git"
301         if [ ${CURRENT_OPTION} = "2" ]; then
302                 add_fingerprint 0
303                 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
304                 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
305                 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
307                 if [ x"$MACHINE_TYPE" = "x" ]; then
308                         get_machine_used
309                 fi
311                 cp ./gallery/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
312                 cp ./script/common/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
313                 cp ./script/${MACHINE_TYPE}/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
314                 cp ./ftp_folder/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
315                 add_fingerprint 1
316         fi
317         echo "wl1271-demo built successfully"
320 function bt-enable
322         cd ${WORK_SPACE} || exit 1
323         if [ x"$KLIB_BUILD" = "x" ]; then
324                 echo "Please set KLIB_BUILD variable to point to your Linux kernel"
325                 exit 1
326         fi
327         COMPONENT_NAME="bt_enable"
328         COMPONENT_REV="dd75971705ada8fb0e88a0fb3f68833086c5bba4"
329         COMPONENT_DIR="bt_enable"
330         download_component "git://github.com/TI-ECS/bt_enable.git"
331         if [ ${CURRENT_OPTION} = "2" ]; then
332                 [ ! -e Bt-enable-standalone-makefile.zip ] && { wget 'http://processors.wiki.ti.com/images/8/8f/Bt-enable-standalone-makefile.zip' || exit 1; }
333           unzip -o Bt-enable-standalone-makefile.zip || exit 1
334           apply_patches
336           if [ x"$MACHINE_TYPE" = "x" ]; then
337                   get_machine_used
338           fi
339           cp ./gpio_en_${MACHINE_TYPE}.c ./gpio_en.c
340           make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} || exit 1
341           make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} install || exit 1
342           add_fingerprint 1
343         fi
344         echo "bt-enable built successfully"
347 #==================================================================================
348 # Main
349 #==================================================================================
350 old_dir=`pwd`
351 MACHINE_TYPE=""
353 source setup-env || exit 1
354 source ./functions/common-functions
355 # if there are no sufficient arguments...
356 if  [ $# -lt 2 ]; then
357         usage
358         exit 0
359 fi
361 if [ x"$CROSS_COMPILE" = "x" ]; then
362         echo "define CROSS_COMPILE variable"
363         exit 1
364 fi
366 which ${CROSS_COMPILE}gcc > /dev/null
368 if [ $? -ne 0 ]; then
369         echo "No toolchain in path"
370         exit 1
371 fi
374 if [ x"$ROOTFS" = "x" ]; then
375         echo "Please set ROOTFS variable to point to your root filesystem"
376         exit 1
377 fi
379 if [ x"$WORK_SPACE" = "x" ]; then
380         echo "Please set WORK_SPACE variable to point to your preferred work space"
381         exit 1
382 fi
384 FINGURE_PRINT_DIR="${WORK_SPACE}/.FingurePrint"
385 mkdir -p ${FINGURE_PRINT_DIR} || exit 1
387 USER_OPTION=0
388 CURRENT_OPTION=0
390 case "$2" in
391         build)
392                 USER_OPTION=1
393         ;;
394         rebuild)
395                 USER_OPTION=2
396         ;;
397         *)
398                 echo "Unknown option $2"
399                 exit 1
400         ;;
401 esac
403 CURRENT_OPTION=${USER_OPTION}
405 MODULE_TO_INVOKE=$1
406 $MODULE_TO_INVOKE 1
408 cd ${old_dir}