]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ti-bt/build-utils.git/blob - wl18xx_build_bt.sh
added disclaimer.txt and disclaimer to the scripts
[ti-bt/build-utils.git] / wl18xx_build_bt.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         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 }
79 function bt-modules()
80 {
81         if [ x"$KLIB_BUILD" = "x" ]; then
82                 echo "Please set KLIB_BUILD variable to point to your Linux kernel"
83                 exit 1
84         fi
86         cd ${WORK_SPACE} || exit 1
87         COMPONENT_NAME=`basename ${compat_bluetooth[$BUILD_VERSION]}`
88         COMPONENT_DIR="compat-bluetooth"
89         download_component "${compat_bluetooth[$BUILD_VERSION]}"
90         if [ ${CURRENT_OPTION} = "2" ]; then
91                 add_fingerprint 0
92                 patch -p1 -i ${old_dir}/patches/0001-compat-wireless-usb-missing-macro.patch
94                 ./scripts/driver-select bt || exit 1
95                 make KLIB=${ROOTFS} bt || exit 1
97                 make KLIB=${ROOTFS} "install-modules" || exit 1
98                 add_fingerprint 1
99         fi
100         echo "bt-modules built successfully"
103 function alsa-lib
105         cd ${WORK_SPACE} || exit 1
106         COMPONENT_NAME="alsa-lib-1.0.26.tar.gz"
107         COMPONENT_DIR="alsa-lib-1.0.26"
108         download_component "http://fossies.org/linux/misc/alsa-lib-1.0.26.tar.gz"
109         if [ ${CURRENT_OPTION} = "2" ]; then
110                 add_fingerprint 0
111                 ./configure --prefix=${MY_PREFIX} --host=${BUILD_HOST} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --disable-python || exit 1
112                 make || exit 1
113                 make install DESTDIR=${ROOTFS} || exit 1
114                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
115                 add_fingerprint 1
116         fi
117         echo "alsa-lib built successfully"
120 function bluez()
122         if  [ $# -eq 1 ]; then
123                 START_MODULE="bluez-4.98"
124         fi
125         # dependency section, in here we build the dependencies. We do not want to rebuild them each time
126         check
127         dbus
128         glib
129         uim
131         cd ${WORK_SPACE} || exit 1
132         COMPONENT_NAME="bluez-4.98.tar.gz"
133         #COMPONENT_REV="18a5dc6cdcf0828443c415eaea82b6834a8f9825"
134         COMPONENT_DIR="bluez-4.98"
135         download_component "http://kernel.org/pub/linux/bluetooth/bluez-4.98.tar.gz"
136         if [ ${CURRENT_OPTION} = "2" ]; then
137                 add_fingerprint 0
138                 patch -p1 -i ${old_dir}/patches/0003-socket-enable-for-bluez-4_98.patch || exit 1
139                 patch -p1 -i ${old_dir}/patches/0004-bluez-enable-source-interface.patch || exit 1
141                 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
142                 make LIBS='-lffi' || exit 1
143                 make install DESTDIR=${ROOTFS} || exit 1
144                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
145                 cp audio/audio.conf input/input.conf ${ROOTFS}${MY_SYSCONFDIR}/bluetooth/ || exit 1
146                 cp test/agent ${ROOTFS}${MY_PREFIX}/bin/agent || exit 1
147                 mkdir -p ${ROOTFS}/usr/share/bluetooth
149                 cd test
150                 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'
151                 echo "installing tests in ${ROOTFS}/usr/share/bluetooth"
152                 cp ${list} ${ROOTFS}/usr/share/bluetooth
153                 cd -
154                 add_fingerprint 1
155         fi
156         echo "bluez built successfully"
157
159 function hcidump
161         cd ${WORK_SPACE} || exit 1
162         COMPONENT_NAME="bluez-hcidump-2.4.tar.gz"
163         COMPONENT_DIR="bluez-hcidump-2.4"
164         download_component "http://www.kernel.org/pub/linux/bluetooth/bluez-hcidump-2.4.tar.gz"
165         if [ ${CURRENT_OPTION} = "2" ]; then
166                 add_fingerprint 0
167                 patch -p1 -i ${old_dir}/patches/0001-blueti-Add-TI-Logger-dump.patch || exit 1
168                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
169                 make || exit 1
170                 make install DESTDIR=${ROOTFS} || exit 1
171                 add_fingerprint 1
172         fi
173         echo "hcidump built successfully"
176 function ncurses
178         cd ${WORK_SPACE} || exit 1
179         COMPONENT_NAME="ncurses-5.9.tar.gz"
180         COMPONENT_DIR="ncurses-5.9"
181         download_component "http://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz"
182         if [ ${CURRENT_OPTION} = "2" ]; then
183                 add_fingerprint 0
184                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR}  -with-shared --without-debug --without-normal || exit 1
185                 make || exit 1
186                 make install DESTDIR=${ROOTFS} || exit 1
187                 add_fingerprint 1
188         fi
189         echo "ncurses built successfully"
192 function readline
194         cd ${WORK_SPACE} || exit 1
195         COMPONENT_NAME="readline-6.2.tar.gz"
196         COMPONENT_DIR="readline-6.2"
197         download_component "ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz"
198         if [ ${CURRENT_OPTION} = "2" ]; then
199                 add_fingerprint 0
200                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} || exit 1
201                 make || exit 1
202                 make install DESTDIR=${ROOTFS} || exit 1
203                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
204                 add_fingerprint 1
205         fi
206         echo "readline built successfully"
210 function openobex
212         cd ${WORK_SPACE} || exit 1
213         COMPONENT_NAME="openobex-1.5.tar.gz"
214         COMPONENT_DIR="openobex-1.5"
215         download_component "http://ftp.osuosl.org/pub/linux/bluetooth/openobex-1.5.tar.gz"
216         if [ ${CURRENT_OPTION} = "2" ]; then
217         #       wget 'http://mirror.anl.gov/pub/linux/bluetooth/openobex-1.5.tar.gz' || exit 1
218                 add_fingerprint 0
219                 sed -i '11227 i *)\n;;' configure || exit 1
220                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --enable-apps --disable-usb || exit 1
221                 sed -i 's/^\(libdir=\).*/\1\$\{prefix\}\/lib/g' openobex.pc || 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 "openobex built successfully"
230 function libical
232         cd ${WORK_SPACE} || exit 1
233         COMPONENT_NAME="libical-0.44.tar.gz"
234         COMPONENT_DIR="libical-0.44"
235         download_component "http://downloads.sourceforge.net/project/freeassociation/libical/libical-0.44/libical-0.44.tar.gz"
236         if [ ${CURRENT_OPTION} = "2" ]; then
237                 add_fingerprint 0
238                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
239                 make || exit 1
240                 make install DESTDIR=${ROOTFS} || exit 1
241                 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
242                 add_fingerprint 1
243         fi
244         echo "libical built successfully"
247 function obexd
249         if  [ $# -eq 1 ]; then
250                 START_MODULE="obexd-0.34.tar.gz"
251         fi
252         # dependency section, in here we build the dependencies. We do not want to rebuild them each time
253         bluez
254         libical
255         readline
256         ncurses
258         cd ${WORK_SPACE} || exit 1
259         COMPONENT_NAME="obexd-0.34.tar.gz"
260         COMPONENT_DIR="obexd-0.34"
261         download_component "http://www.kernel.org/pub/linux/bluetooth/obexd-0.34.tar.gz"
262         if [ ${CURRENT_OPTION} = "2" ]; then
263                 add_fingerprint 0
264                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
265                 wget http://processors.wiki.ti.com/images/4/43/Obexd-patches_v1.tar.gz || exit 1
266                 echo "Openning archive: Obexd-patches_v1.tar.gz" && tar -xzf Obexd-patches_v1.tar.gz || exit 1
267                 apply_patches
268                 make || exit 1
269                 make install DESTDIR=${ROOTFS} || exit 1
270                 test -d ${ROOTFS}/usr/share/bluetooth || mkdir -p  ${ROOTFS}/usr/share/bluetooth
271                 list='exchange-business-cards  ftp-client  list-folders  pbap-client send-files'
272                 for f in ${list}; do
273                         install -c test/$f ${ROOTFS}/usr/share/bluetooth || exit 1
274                 done
275                 add_fingerprint 1
276         fi
277         echo "obexd built successfully"
280 function bt-obex
282         if  [ $# -eq 1 ]; then
283                 START_MODULE="bluez-tools"
284         fi
285         # dependency section, in here we build the dependencies. We do not want to rebuild them each time
286         dbus-glib
287         readline
288         ncurses
290         cd ${WORK_SPACE} || exit 1
291         COMPONENT_NAME="bluez-tools"
292         COMPONENT_REV="171181b6ef6c94aefc828dc7fd8de136b9f97532"
293         COMPONENT_DIR="bluez-tools"
294         download_component "git://gitorious.org/bluez-tools/bluez-tools.git"
295         if [ ${CURRENT_OPTION} = "2" ]; then
296                 add_fingerprint 0
297                 [ ! -e Bt-obex-patches.zip ] && { wget 'http://processors.wiki.ti.com/images/f/f5/Bt-obex-patches.zip' || exit 1; }
298                 unzip -o Bt-obex-patches.zip || exit 1
299                 apply_patches
300                 #patch -p1 -i ${old_dir}/patches/0001-bt-obex-new-dbus-api-for-obexd.patch
301                 #patch -p1 -i ${old_dir}/patches/0001-manager-adoptation-to-new-manager-interface-of-bluez.patch
303                 /usr/bin/libtoolize || exit 1
304                 /usr/bin/aclocal || exit 1
305                 /usr/bin/autoheader || exit 1
306                 /usr/bin/automake --add-missing || exit 1
307                 /usr/bin/autoconf || exit 1
308                 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} || exit 1
309                 make LIBS="-ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0 -liconv -lffi -lz -lncurses" || exit 1
310                 make install DESTDIR=${ROOTFS} || exit 1
311                 add_fingerprint 1
312         fi
313         echo "bt-obex built successfully"
316 function wl1271-demo
318         START_MODULE="wl1271-bluetooth"
319         cd ${WORK_SPACE} || exit 1
320         COMPONENT_NAME="wl1271-bluetooth"
321         COMPONENT_DIR="wl1271-bluetooth"
322         COMPONENT_REV="ae9a9a961dd9821d30a0b9c32612f3a552c81d4e"
323         download_component "git://github.com/TI-ECS/wl1271-bluetooth.git"
324         if [ ${CURRENT_OPTION} = "2" ]; then
325                 add_fingerprint 0
326                 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
327                 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
328                 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
330                 if [ x"$MACHINE_TYPE" = "x" ]; then
331                         get_machine_used
332                 fi
334                 cp ./gallery/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
335                 cp ./script/common/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
336                 cp ./script/${MACHINE_TYPE}/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
337                 cp ./ftp_folder/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
338                 add_fingerprint 1
339         fi
340         echo "wl1271-demo built successfully"
343 function bt-enable
345         cd ${WORK_SPACE} || exit 1
346         if [ x"$KLIB_BUILD" = "x" ]; then
347                 echo "Please set KLIB_BUILD variable to point to your Linux kernel"
348                 exit 1
349         fi
350         COMPONENT_NAME="bt_enable"
351         COMPONENT_REV="dd75971705ada8fb0e88a0fb3f68833086c5bba4"
352         COMPONENT_DIR="bt_enable"
353         download_component "git://github.com/TI-ECS/bt_enable.git"
354         if [ ${CURRENT_OPTION} = "2" ]; then
355                 [ ! -e Bt-enable-standalone-makefile.zip ] && { wget 'http://processors.wiki.ti.com/images/8/8f/Bt-enable-standalone-makefile.zip' || exit 1; }
356           unzip -o Bt-enable-standalone-makefile.zip || exit 1
357           apply_patches
359           if [ x"$MACHINE_TYPE" = "x" ]; then
360                   get_machine_used
361           fi
362           cp ./gpio_en_${MACHINE_TYPE}.c ./gpio_en.c
363           make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} || exit 1
364           make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} install || exit 1
365           add_fingerprint 1
366         fi
367         echo "bt-enable built successfully"
370 #==================================================================================
371 # Main
372 #==================================================================================
373 old_dir=`pwd`
374 MACHINE_TYPE=""
376 source setup-env || exit 1
377 source ./functions/common-functions
378 # if there are no sufficient arguments...
379 if  [ $# -lt 2 ]; then
380         usage
381         exit 0
382 fi
384 if [ x"$CROSS_COMPILE" = "x" ]; then
385         echo "define CROSS_COMPILE variable"
386         exit 1
387 fi
389 which ${CROSS_COMPILE}gcc > /dev/null
391 if [ $? -ne 0 ]; then
392         echo "No toolchain in path"
393         exit 1
394 fi
397 if [ x"$ROOTFS" = "x" ]; then
398         echo "Please set ROOTFS variable to point to your root filesystem"
399         exit 1
400 fi
402 if [ x"$WORK_SPACE" = "x" ]; then
403         echo "Please set WORK_SPACE variable to point to your preferred work space"
404         exit 1
405 fi
407 FINGURE_PRINT_DIR="${WORK_SPACE}/.FingurePrint"
408 mkdir -p ${FINGURE_PRINT_DIR} || exit 1
410 USER_OPTION=0
411 CURRENT_OPTION=0
413 case "$2" in
414         build)
415                 USER_OPTION=1
416         ;;
417         rebuild)
418                 USER_OPTION=2
419         ;;
420         *)
421                 echo "Unknown option $2"
422                 exit 1
423         ;;
424 esac
426 CURRENT_OPTION=${USER_OPTION}
428 MODULE_TO_INVOKE=$1
429 $MODULE_TO_INVOKE 1
431 cd ${old_dir}