added disclaimer.txt and disclaimer to the scripts
[ti-bt/build-utils.git] / BlueZ_5.19_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 "* This script is only for demo purposes, It is not fully verified *"
21         echo "*******************************************************************"
22         echo
23         echo "This script compiles the BT modules components"
24         echo "The script can build each component as standalone by invoking: \"./wl18xx_build_bt.sh <module name> <build/rebuild>\""
25         echo "For example: \"./wl12xx_build_bt.sh bt-modules rebuild\""
26         echo
27         echo "Available components are:"
28         echo "bt-modules, bluez, hcidump, obexd, bt-obex, firmware, wl1271-demo"
29         echo
30         echo "You may also build all components by typing: \"./wl18xx_build_bt.sh all build\""
31         echo
32         echo "Prerequisites"
33         echo "============="
34         echo "The following variables should be exported in order to run the script:"
35         echo "1) ROOTFS - should point to the root filesystem where the BT components will be installed"
36         echo "2) WORK_SPACE - should point to the workspace where the components will be downloaded and compiled"
37         echo "3) KLIB_BUILD - should point to the kernel which the compat bluetooth will be compiled against."
38         echo "4) Path to cross compiler in PATH"
39         echo ""
40 }
42 function all()
43 {
44         get_machine_used
45         #bt-modules 1
46         #uim 1
47         expat 1
48         libffi
49         glib 1
50         dbus 1
51         libIConv 1
52         zlib 1
53         gettext 1
54         alsa-lib 1
55         dbus-glib 1
56         check 1
57         python 1
58         pygobject 1
59         dbus-python 1
60         bluez 1
61         hcidump 1
62         ncurses 1
63         readline 1
64         openobex 1
65         udev 1
66         libical 1
67         obexd 1
68         bt-obex 1
69         firmware 1
70         wl1271-demo 1
71 }
73 function apply_patches()
74 {
75         [ ! -e $LS ] && echo "Please set full path of ls utility in setup-env file." && exit 1
76         files=`$LS *.patch`
77         for f in ${files}; do patch -p1 -i ${f} || exit 1; done
78         return 0
79 }
81 function alsa-lib
82 {
83         cd ${WORK_SPACE} || exit 1
84         COMPONENT_NAME="alsa-lib-1.0.27.2.tar.gz"
85         COMPONENT_DIR="alsa-lib-1.0.27.2"
86         download_component "http://fossies.org/linux/misc/alsa-lib-1.0.27.2.tar.gz"
87         if [ ${CURRENT_OPTION} = "2" ]; then
88                 add_fingerprint 0
89                 ./configure --prefix=${MY_PREFIX} --host=${BUILD_HOST} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --disable-python || exit 1
90                 make || exit 1
91                 make install DESTDIR=${ROOTFS} || exit 1
92                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
93                 add_fingerprint 1
94         fi
95         echo "alsa-lib built successfully"
96 }
98 #compat
99 function bluez()
101         if  [ $# -eq 1 ]; then
102                 START_MODULE="bluez-5.19"
103         fi
104         # dependency section, in here we build the dependencies. We do not want to rebuild them each time
105         check
106         dbus
107         glib
108         libical
109         #uim
111         cd ${WORK_SPACE} || exit 1
112         COMPONENT_NAME="bluez-5.19.tar.gz"
113         #COMPONENT_REV="18a5dc6cdcf0828443c415eaea82b6834a8f9825"
114         COMPONENT_DIR="bluez-5.19"
115         download_component "http://kernel.org/pub/linux/bluetooth/bluez-5.19.tar.gz"
116         if [ ${CURRENT_OPTION} = "2" ]; then
117                 add_fingerprint 0
118                 /usr/bin/libtoolize || exit 1
119                 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 --disable-udev --disable-systemd --disable-obex --enable-library
120                 make LIBS='-lffi' LIBS='-lncurses'|| exit 1
121                 make install DESTDIR=${ROOTFS} || exit 1
122                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null          
124                 #make || exit 1
125                 #make install DESTDIR=${ROOTFS} || exit 1
126                 #rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
127                 #cp audio/audio.conf input/input.conf ${ROOTFS}${MY_SYSCONFDIR}/bluetooth/ || exit 1
128                 #cp test/agent ${ROOTFS}${MY_PREFIX}/bin/agent || exit 1
129                 mkdir -p ${ROOTFS}/usr/share/bluetooth
131                 cd test
132                 list='ftp-client list-devices map-client monitor-bluetooth opp-client pbap-client simple-agent simple-endpoint simple-player test-adapter test-alert test-cyclingspeed test-device test-discovery test-health test-health-sink test-heartrate test-hfp test-manager test-nap test-network test-profile test-proximity test-sap-server test-thermometer'
133                 echo "installing tests in ${ROOTFS}/usr/share/bluetooth"
134                 cp ${list} ${ROOTFS}/usr/share/bluetooth
135                 cd -
136                 add_fingerprint 1
137         fi
138         echo "bluez built successfully"
139
141 function hcidump
143         cd ${WORK_SPACE} || exit 1
144         COMPONENT_NAME="bluez-hcidump-2.4.tar.gz"
145         COMPONENT_DIR="bluez-hcidump-2.4"
146         download_component "http://www.kernel.org/pub/linux/bluetooth/bluez-hcidump-2.4.tar.gz"
147         if [ ${CURRENT_OPTION} = "2" ]; then
148                 add_fingerprint 0
149                 patch -p1 -i ${old_dir}/patches/0001-blueti-Add-TI-Logger-dump.patch || exit 1
150                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
151                 make || exit 1
152                 make install DESTDIR=${ROOTFS} || exit 1
153                 add_fingerprint 1
154         fi
155         echo "hcidump built successfully"
158 function ncurses
160         cd ${WORK_SPACE} || exit 1
161         COMPONENT_NAME="ncurses-5.9.tar.gz"
162         COMPONENT_DIR="ncurses-5.9"
163         download_component "http://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz"
164         if [ ${CURRENT_OPTION} = "2" ]; then
165                 add_fingerprint 0
166                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR}  -with-shared --without-debug --without-normal || exit 1
167                 make || exit 1
168                 make install DESTDIR=${ROOTFS} || exit 1
169                 add_fingerprint 1
170         fi
171         echo "ncurses built successfully"
174 function readline
176         cd ${WORK_SPACE} || exit 1
177         COMPONENT_NAME="readline-6.2.tar.gz"
178         COMPONENT_DIR="readline-6.2"
179         download_component "ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz"
180         if [ ${CURRENT_OPTION} = "2" ]; then
181                 add_fingerprint 0
182                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
183                 make || exit 1
184                 make install DESTDIR=${ROOTFS} || exit 1
185                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
186                 add_fingerprint 1
187         fi
188         echo "readline built successfully"
192 function openobex
194         cd ${WORK_SPACE} || exit 1
195         COMPONENT_NAME="openobex-1.5.tar.gz"
196         COMPONENT_DIR="openobex-1.5"
197         download_component "http://pkgs.fedoraproject.org/repo/pkgs/openobex/openobex-1.5.tar.gz/0d83dc86445a46a1b9750107ba7ab65c/openobex-1.5.tar.gz"
198         if [ ${CURRENT_OPTION} = "2" ]; then
199         #       wget 'http://mirror.anl.gov/pub/linux/bluetooth/openobex-1.5.tar.gz' || exit 1
200                 add_fingerprint 0
201                 sed -i '11227 i *)\n;;' configure || exit 1
202                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --enable-apps --disable-usb || exit 1
203                 sed -i 's/^\(libdir=\).*/\1\$\{prefix\}\/lib/g' openobex.pc || exit 1
204                 make || exit 1
205                 make install DESTDIR=${ROOTFS} || exit 1
206                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
207                 add_fingerprint 1
208         fi
209         echo "openobex built successfully"
212 function libical
214         cd ${WORK_SPACE} || exit 1
215         COMPONENT_NAME="libical-1.0.tar.gz"
216         COMPONENT_DIR="libical-1.0"
217         download_component "http://sourceforge.net/projects/freeassociation/files/libical/libical-1.0/libical-1.0.tar.gz"
218         if [ ${CURRENT_OPTION} = "2" ]; then
219                 add_fingerprint 0
220                 /usr/bin/libtoolize || exit 1
221                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
222                 make || exit 1
223                 make install DESTDIR=${ROOTFS} || exit 1
224                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
225                 add_fingerprint 1
226         fi
227         echo "libical built successfully"
230 function obexd
232         if  [ $# -eq 1 ]; then
233                 START_MODULE="obexd-0.34.tar.gz"
234         fi
235         # dependency section, in here we build the dependencies. We do not want to rebuild them each time
236         bluez
237         libical
238         readline
239         ncurses
241         cd ${WORK_SPACE} || exit 1
242         COMPONENT_NAME="obexd-0.34.tar.gz"
243         COMPONENT_DIR="obexd-0.34"
244         download_component "http://www.kernel.org/pub/linux/bluetooth/obexd-0.34.tar.gz"
245         if [ ${CURRENT_OPTION} = "2" ]; then
246                 add_fingerprint 0
247                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
248                 #wget http://processors.wiki.ti.com/images/4/43/Obexd-patches_v1.tar.gz || exit 1
249                 #echo "Openning archive: Obexd-patches_v1.tar.gz" && tar -xzf Obexd-patches_v1.tar.gz || exit 1
250                 #apply_patches
251                 make || exit 1
252                 make install DESTDIR=${ROOTFS} || exit 1
253                 test -d ${ROOTFS}/usr/share/bluetooth || mkdir -p  ${ROOTFS}/usr/share/bluetooth
254                 list='exchange-business-cards  ftp-client  list-folders  pbap-client send-files'
255                 for f in ${list}; do
256                         install -c test/$f ${ROOTFS}/usr/share/bluetooth || exit 1
257                 done
258                 add_fingerprint 1
259         fi
260         echo "obexd built successfully"
263 function bt-obex
265         if  [ $# -eq 1 ]; then
266                 START_MODULE="bluez-tools"
267         fi
268         # dependency section, in here we build the dependencies. We do not want to rebuild them each time
269         dbus-glib
270         readline
271         ncurses
273         cd ${WORK_SPACE} || exit 1
274         COMPONENT_NAME="bluez-tools"
275         COMPONENT_REV="171181b6ef6c94aefc828dc7fd8de136b9f97532"
276         COMPONENT_DIR="bluez-tools"
277         download_component "git://gitorious.org/bluez-tools/bluez-tools.git"
278         if [ ${CURRENT_OPTION} = "2" ]; then
279                 add_fingerprint 0
280                 #[ ! -e Bt-obex-patches.zip ] && { wget 'http://processors.wiki.ti.com/images/f/f5/Bt-obex-patches.zip' || exit 1; }
281                 #unzip -o Bt-obex-patches.zip || exit 1
282                 #apply_patches
283                 #patch -p1 -i ${old_dir}/patches/0001-bt-obex-new-dbus-api-for-obexd.patch
284                 #patch -p1 -i ${old_dir}/patches/0001-manager-adoptation-to-new-manager-interface-of-bluez.patch
286                 /usr/bin/libtoolize || exit 1
287                 /usr/bin/aclocal || exit 1
288                 /usr/bin/autoheader || exit 1
289                 /usr/bin/automake --add-missing || exit 1
290                 /usr/bin/autoconf || exit 1
291                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
292                 make LIBS="-ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0 -liconv -lffi -lz -lncurses" || exit 1
293                 make install DESTDIR=${ROOTFS} || exit 1
294                 add_fingerprint 1
295         fi
296         echo "bt-obex built successfully"
299 function wl1271-demo
301         START_MODULE="wl1271-bluetooth"
302         cd ${WORK_SPACE} || exit 1
303         COMPONENT_NAME="wl1271-bluetooth"
304         COMPONENT_DIR="wl1271-bluetooth"
305         COMPONENT_REV="ae9a9a961dd9821d30a0b9c32612f3a552c81d4e"
306         download_component "git://github.com/TI-ECS/wl1271-bluetooth.git"
307         if [ ${CURRENT_OPTION} = "2" ]; then
308                 add_fingerprint 0
309                 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
310                 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
311                 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
313                 if [ x"$MACHINE_TYPE" = "x" ]; then
314                         get_machine_used
315                 fi
317                 cp ./gallery/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
318                 cp ./script/common/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
319                 cp ./script/${MACHINE_TYPE}/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
320                 cp ./ftp_folder/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
321                 add_fingerprint 1
322         fi
323         echo "wl1271-demo built successfully"
326 function bt-enable
328         cd ${WORK_SPACE} || exit 1
329         if [ x"$KLIB_BUILD" = "x" ]; then
330                 echo "Please set KLIB_BUILD variable to point to your Linux kernel"
331                 exit 1
332         fi
333         COMPONENT_NAME="bt_enable"
334         COMPONENT_REV="dd75971705ada8fb0e88a0fb3f68833086c5bba4"
335         COMPONENT_DIR="bt_enable"
336         download_component "git://github.com/TI-ECS/bt_enable.git"
337         if [ ${CURRENT_OPTION} = "2" ]; then
338                 [ ! -e Bt-enable-standalone-makefile.zip ] && { wget 'http://processors.wiki.ti.com/images/8/8f/Bt-enable-standalone-makefile.zip' || exit 1; }
339           unzip -o Bt-enable-standalone-makefile.zip || exit 1
340           apply_patches
342           if [ x"$MACHINE_TYPE" = "x" ]; then
343                   get_machine_used
344           fi
345           cp ./gpio_en_${MACHINE_TYPE}.c ./gpio_en.c
346           make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} || exit 1
347           make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} install || exit 1
348           add_fingerprint 1
349         fi
350         echo "bt-enable built successfully"
353 #==================================================================================
354 # Main
355 #==================================================================================
356 old_dir=`pwd`
357 MACHINE_TYPE=""
359 source setup-env || exit 1
360 source ./functions/common-functions
361 # if there are no sufficient arguments...
362 if  [ $# -lt 2 ]; then
363         usage
364         exit 0
365 fi
367 if [ x"$CROSS_COMPILE" = "x" ]; then
368         echo "define CROSS_COMPILE variable"
369         exit 1
370 fi
372 which ${CROSS_COMPILE}gcc > /dev/null
374 if [ $? -ne 0 ]; then
375         echo "No toolchain in path"
376         exit 1
377 fi
380 if [ x"$ROOTFS" = "x" ]; then
381         echo "Please set ROOTFS variable to point to your root filesystem"
382         exit 1
383 fi
385 if [ x"$WORK_SPACE" = "x" ]; then
386         echo "Please set WORK_SPACE variable to point to your preferred work space"
387         exit 1
388 fi
390 FINGURE_PRINT_DIR="${WORK_SPACE}/.FingurePrint"
391 mkdir -p ${FINGURE_PRINT_DIR} || exit 1
393 USER_OPTION=0
394 CURRENT_OPTION=0
396 case "$2" in
397         build)
398                 USER_OPTION=1
399         ;;
400         rebuild)
401                 USER_OPTION=2
402         ;;
403         *)
404                 echo "Unknown option $2"
405                 exit 1
406         ;;
407 esac
409 CURRENT_OPTION=${USER_OPTION}
411 MODULE_TO_INVOKE=$1
412 $MODULE_TO_INVOKE 1
414 cd ${old_dir}