4ff9f607121404b71d317e4be910b072dc7d1981
[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 "************************************"
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         udev 1
65         libical 1
66         obexd 1
67         bt-obex 1
68         firmware 1
69         wl1271-demo 1
70 }
72 function apply_patches()
73 {
74         [ ! -e $LS ] && echo "Please set full path of ls utility in setup-env file." && exit 1
75         files=`$LS *.patch`
76         for f in ${files}; do patch -p1 -i ${f} || exit 1; done
77         return 0
78 }
80 function alsa-lib
81 {
82         cd ${WORK_SPACE} || exit 1
83         COMPONENT_NAME="alsa-lib-1.0.27.2.tar.gz"
84         COMPONENT_DIR="alsa-lib-1.0.27.2"
85         download_component "http://fossies.org/linux/misc/alsa-lib-1.0.27.2.tar.gz"
86         if [ ${CURRENT_OPTION} = "2" ]; then
87                 add_fingerprint 0
88                 ./configure --prefix=${MY_PREFIX} --host=${BUILD_HOST} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --disable-python || exit 1
89                 make || exit 1
90                 make install DESTDIR=${ROOTFS} || exit 1
91                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
92                 add_fingerprint 1
93         fi
94         echo "alsa-lib built successfully"
95 }
97 #compat
98 function bluez()
99 {
100         if  [ $# -eq 1 ]; then
101                 START_MODULE="bluez-5.19"
102         fi
103         # dependency section, in here we build the dependencies. We do not want to rebuild them each time
104         check
105         dbus
106         glib
107         libical
108         #uim
110         cd ${WORK_SPACE} || exit 1
111         COMPONENT_NAME="bluez-5.19.tar.gz"
112         #COMPONENT_REV="18a5dc6cdcf0828443c415eaea82b6834a8f9825"
113         COMPONENT_DIR="bluez-5.19"
114         download_component "http://kernel.org/pub/linux/bluetooth/bluez-5.19.tar.gz"
115         if [ ${CURRENT_OPTION} = "2" ]; then
116                 add_fingerprint 0
117                 /usr/bin/libtoolize || 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 --disable-udev --disable-systemd --disable-obex --enable-library
119                 make LIBS='-lffi' LIBS='-lncurses'|| exit 1
120                 make install DESTDIR=${ROOTFS} || exit 1
121                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null          
123                 #make || exit 1
124                 #make install DESTDIR=${ROOTFS} || exit 1
125                 #rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
126                 #cp audio/audio.conf input/input.conf ${ROOTFS}${MY_SYSCONFDIR}/bluetooth/ || exit 1
127                 #cp test/agent ${ROOTFS}${MY_PREFIX}/bin/agent || exit 1
128                 mkdir -p ${ROOTFS}/usr/share/bluetooth
130                 cd test
131                 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'
132                 echo "installing tests in ${ROOTFS}/usr/share/bluetooth"
133                 cp ${list} ${ROOTFS}/usr/share/bluetooth
134                 cd -
135                 add_fingerprint 1
136         fi
137         echo "bluez built successfully"
138
140 function hcidump
142         cd ${WORK_SPACE} || exit 1
143         COMPONENT_NAME="bluez-hcidump-2.4.tar.gz"
144         COMPONENT_DIR="bluez-hcidump-2.4"
145         download_component "http://www.kernel.org/pub/linux/bluetooth/bluez-hcidump-2.4.tar.gz"
146         if [ ${CURRENT_OPTION} = "2" ]; then
147                 add_fingerprint 0
148                 patch -p1 -i ${old_dir}/patches/0001-blueti-Add-TI-Logger-dump.patch || exit 1
149                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
150                 make || exit 1
151                 make install DESTDIR=${ROOTFS} || exit 1
152                 add_fingerprint 1
153         fi
154         echo "hcidump built successfully"
157 function ncurses
159         cd ${WORK_SPACE} || exit 1
160         COMPONENT_NAME="ncurses-5.9.tar.gz"
161         COMPONENT_DIR="ncurses-5.9"
162         download_component "http://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz"
163         if [ ${CURRENT_OPTION} = "2" ]; then
164                 add_fingerprint 0
165                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR}  -with-shared --without-debug --without-normal || exit 1
166                 make || exit 1
167                 make install DESTDIR=${ROOTFS} || exit 1
168                 add_fingerprint 1
169         fi
170         echo "ncurses built successfully"
173 function readline
175         cd ${WORK_SPACE} || exit 1
176         COMPONENT_NAME="readline-6.2.tar.gz"
177         COMPONENT_DIR="readline-6.2"
178         download_component "ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz"
179         if [ ${CURRENT_OPTION} = "2" ]; then
180                 add_fingerprint 0
181                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
182                 make || exit 1
183                 make install DESTDIR=${ROOTFS} || exit 1
184                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
185                 add_fingerprint 1
186         fi
187         echo "readline built successfully"
191 function openobex
193         cd ${WORK_SPACE} || exit 1
194         COMPONENT_NAME="openobex-1.5.tar.gz"
195         COMPONENT_DIR="openobex-1.5"
196         download_component "http://pkgs.fedoraproject.org/repo/pkgs/openobex/openobex-1.5.tar.gz/0d83dc86445a46a1b9750107ba7ab65c/openobex-1.5.tar.gz"
197         if [ ${CURRENT_OPTION} = "2" ]; then
198         #       wget 'http://mirror.anl.gov/pub/linux/bluetooth/openobex-1.5.tar.gz' || exit 1
199                 add_fingerprint 0
200                 sed -i '11227 i *)\n;;' configure || exit 1
201                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --enable-apps --disable-usb || exit 1
202                 sed -i 's/^\(libdir=\).*/\1\$\{prefix\}\/lib/g' openobex.pc || exit 1
203                 make || exit 1
204                 make install DESTDIR=${ROOTFS} || exit 1
205                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
206                 add_fingerprint 1
207         fi
208         echo "openobex built successfully"
211 function libical
213         cd ${WORK_SPACE} || exit 1
214         COMPONENT_NAME="libical-1.0.tar.gz"
215         COMPONENT_DIR="libical-1.0"
216         download_component "http://sourceforge.net/projects/freeassociation/files/libical/libical-1.0/libical-1.0.tar.gz"
217         if [ ${CURRENT_OPTION} = "2" ]; then
218                 add_fingerprint 0
219                 /usr/bin/libtoolize || exit 1
220                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
221                 make || exit 1
222                 make install DESTDIR=${ROOTFS} || exit 1
223                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
224                 add_fingerprint 1
225         fi
226         echo "libical built successfully"
229 function obexd
231         if  [ $# -eq 1 ]; then
232                 START_MODULE="obexd-0.34.tar.gz"
233         fi
234         # dependency section, in here we build the dependencies. We do not want to rebuild them each time
235         bluez
236         libical
237         readline
238         ncurses
240         cd ${WORK_SPACE} || exit 1
241         COMPONENT_NAME="obexd-0.34.tar.gz"
242         COMPONENT_DIR="obexd-0.34"
243         download_component "http://www.kernel.org/pub/linux/bluetooth/obexd-0.34.tar.gz"
244         if [ ${CURRENT_OPTION} = "2" ]; then
245                 add_fingerprint 0
246                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
247                 #wget http://processors.wiki.ti.com/images/4/43/Obexd-patches_v1.tar.gz || exit 1
248                 #echo "Openning archive: Obexd-patches_v1.tar.gz" && tar -xzf Obexd-patches_v1.tar.gz || exit 1
249                 #apply_patches
250                 make || exit 1
251                 make install DESTDIR=${ROOTFS} || exit 1
252                 test -d ${ROOTFS}/usr/share/bluetooth || mkdir -p  ${ROOTFS}/usr/share/bluetooth
253                 list='exchange-business-cards  ftp-client  list-folders  pbap-client send-files'
254                 for f in ${list}; do
255                         install -c test/$f ${ROOTFS}/usr/share/bluetooth || exit 1
256                 done
257                 add_fingerprint 1
258         fi
259         echo "obexd built successfully"
262 function bt-obex
264         if  [ $# -eq 1 ]; then
265                 START_MODULE="bluez-tools"
266         fi
267         # dependency section, in here we build the dependencies. We do not want to rebuild them each time
268         dbus-glib
269         readline
270         ncurses
272         cd ${WORK_SPACE} || exit 1
273         COMPONENT_NAME="bluez-tools"
274         COMPONENT_REV="171181b6ef6c94aefc828dc7fd8de136b9f97532"
275         COMPONENT_DIR="bluez-tools"
276         download_component "git://gitorious.org/bluez-tools/bluez-tools.git"
277         if [ ${CURRENT_OPTION} = "2" ]; then
278                 add_fingerprint 0
279                 #[ ! -e Bt-obex-patches.zip ] && { wget 'http://processors.wiki.ti.com/images/f/f5/Bt-obex-patches.zip' || exit 1; }
280                 #unzip -o Bt-obex-patches.zip || exit 1
281                 #apply_patches
282                 #patch -p1 -i ${old_dir}/patches/0001-bt-obex-new-dbus-api-for-obexd.patch
283                 #patch -p1 -i ${old_dir}/patches/0001-manager-adoptation-to-new-manager-interface-of-bluez.patch
285                 /usr/bin/libtoolize || exit 1
286                 /usr/bin/aclocal || exit 1
287                 /usr/bin/autoheader || exit 1
288                 /usr/bin/automake --add-missing || exit 1
289                 /usr/bin/autoconf || exit 1
290                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
291                 make LIBS="-ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0 -liconv -lffi -lz -lncurses" || exit 1
292                 make install DESTDIR=${ROOTFS} || exit 1
293                 add_fingerprint 1
294         fi
295         echo "bt-obex built successfully"
298 function wl1271-demo
300         START_MODULE="wl1271-bluetooth"
301         cd ${WORK_SPACE} || exit 1
302         COMPONENT_NAME="wl1271-bluetooth"
303         COMPONENT_DIR="wl1271-bluetooth"
304         COMPONENT_REV="ae9a9a961dd9821d30a0b9c32612f3a552c81d4e"
305         download_component "git://github.com/TI-ECS/wl1271-bluetooth.git"
306         if [ ${CURRENT_OPTION} = "2" ]; then
307                 add_fingerprint 0
308                 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
309                 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
310                 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
312                 if [ x"$MACHINE_TYPE" = "x" ]; then
313                         get_machine_used
314                 fi
316                 cp ./gallery/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
317                 cp ./script/common/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
318                 cp ./script/${MACHINE_TYPE}/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
319                 cp ./ftp_folder/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
320                 add_fingerprint 1
321         fi
322         echo "wl1271-demo built successfully"
325 function bt-enable
327         cd ${WORK_SPACE} || exit 1
328         if [ x"$KLIB_BUILD" = "x" ]; then
329                 echo "Please set KLIB_BUILD variable to point to your Linux kernel"
330                 exit 1
331         fi
332         COMPONENT_NAME="bt_enable"
333         COMPONENT_REV="dd75971705ada8fb0e88a0fb3f68833086c5bba4"
334         COMPONENT_DIR="bt_enable"
335         download_component "git://github.com/TI-ECS/bt_enable.git"
336         if [ ${CURRENT_OPTION} = "2" ]; then
337                 [ ! -e Bt-enable-standalone-makefile.zip ] && { wget 'http://processors.wiki.ti.com/images/8/8f/Bt-enable-standalone-makefile.zip' || exit 1; }
338           unzip -o Bt-enable-standalone-makefile.zip || exit 1
339           apply_patches
341           if [ x"$MACHINE_TYPE" = "x" ]; then
342                   get_machine_used
343           fi
344           cp ./gpio_en_${MACHINE_TYPE}.c ./gpio_en.c
345           make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} || exit 1
346           make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} install || exit 1
347           add_fingerprint 1
348         fi
349         echo "bt-enable built successfully"
352 #==================================================================================
353 # Main
354 #==================================================================================
355 old_dir=`pwd`
356 MACHINE_TYPE=""
358 source setup-env || exit 1
359 source ./functions/common-functions
360 # if there are no sufficient arguments...
361 if  [ $# -lt 2 ]; then
362         usage
363         exit 0
364 fi
366 if [ x"$CROSS_COMPILE" = "x" ]; then
367         echo "define CROSS_COMPILE variable"
368         exit 1
369 fi
371 which ${CROSS_COMPILE}gcc > /dev/null
373 if [ $? -ne 0 ]; then
374         echo "No toolchain in path"
375         exit 1
376 fi
379 if [ x"$ROOTFS" = "x" ]; then
380         echo "Please set ROOTFS variable to point to your root filesystem"
381         exit 1
382 fi
384 if [ x"$WORK_SPACE" = "x" ]; then
385         echo "Please set WORK_SPACE variable to point to your preferred work space"
386         exit 1
387 fi
389 FINGURE_PRINT_DIR="${WORK_SPACE}/.FingurePrint"
390 mkdir -p ${FINGURE_PRINT_DIR} || exit 1
392 USER_OPTION=0
393 CURRENT_OPTION=0
395 case "$2" in
396         build)
397                 USER_OPTION=1
398         ;;
399         rebuild)
400                 USER_OPTION=2
401         ;;
402         *)
403                 echo "Unknown option $2"
404                 exit 1
405         ;;
406 esac
408 CURRENT_OPTION=${USER_OPTION}
410 MODULE_TO_INVOKE=$1
411 $MODULE_TO_INVOKE 1
413 cd ${old_dir}