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 #
12 function usage()
13 {
14 echo
15 echo
16 echo "************************************"
17 echo "* Bluetooth Modules Builder Script *"
18 echo "************************************"
19 echo
20 echo "This script compiles the BT modules components"
21 echo "The script can build each component as standalone by invoking: \"./wl12xx_build_bt.sh <module name> <build/rebuild>\""
22 echo "For example: \"./wl12xx_build_bt.sh bt-modules rebuild\""
23 echo
24 echo "Available components are:"
25 echo "bt-modules, expat, dbus, libIConv, zlib, gettext, glib, dbus-glib, check, bluez, hcidump, ncurses"
26 echo "readline, alsa-lib, openobex, libical, obexd, bt-obex, firmware, wl1271-demo, bt-enable"
27 echo
28 echo "You may also build all components by typing: \"./wl12xx_build_bt.sh all build\""
29 echo
30 echo "Prerequisites"
31 echo "============="
32 echo "The following variables should be exported in order to run the script:"
33 echo "1) ROOTFS - should point to the root filesystem where the BT components will be installed"
34 echo "2) WORK_SPACE - should point to the workspace where the components will be downloaded and compiled"
35 echo "3) KLIB_BUILD - should point to the kernel which the compat bluetooth will be compiled against."
36 echo "4) Path to cross compiler in PATH"
37 echo ""
38 }
40 function all()
41 {
42 get_machine_used
43 bt-modules 1
44 expat 1
45 dbus 1
46 libIConv 1
47 zlib 1
48 gettext 1
49 glib 1
50 dbus-glib 1
51 check 1
52 bluez 1
53 hcidump 1
54 ncurses 1
55 readline 1
56 alsa-lib 1
57 openobex 1
58 libical 1
59 obexd 1
60 bt-obex 1
61 firmware 1
62 wl1271-demo 1
63 bt-enable 1
64 }
66 function apply_patches()
67 {
68 [ ! -e $LS ] && echo "Please set full path of ls utility in setup-env file." && exit 1
69 files=`$LS *.patch`
70 for f in ${files}; do patch -p1 -i ${f} || exit 1; done
71 return 0
72 }
73 function bt-modules()
74 {
75 if [ x"$KLIB_BUILD" = "x" ]; then
76 echo "Please set KLIB_BUILD variable to point to your Linux kernel"
77 exit 1
78 fi
80 cd ${WORK_SPACE} || exit 1
81 COMPONENT_NAME="ti-compat-bluetooth-2012-02-20.tar.gz"
82 COMPONENT_DIR="compat-bluetooth"
83 download_component "https://gforge.ti.com/gf/download/frsrelease/802/5435/ti-compat-bluetooth-2012-02-20.tar.gz"
84 if [ ${CURRENT_OPTION} = "2" ]; then
85 add_fingerprint 0
86 [ ! -e Compat-patch-zip-v1.zip ] && { wget http://processors.wiki.ti.com/images/9/99/Compat-patch-zip-v1.zip || exit 1; }
87 unzip -o Compat-patch-zip-v1.zip || exit 1
88 apply_patches
90 ./scripts/driver-select bt || exit 1
91 make KLIB=${ROOTFS} INSTALL_MOD_PATH=${ROOTFS} "install-modules" || exit 1
92 add_fingerprint 1
93 fi
94 echo "bt-modules built successfully"
95 }
97 function expat()
98 {
99 cd ${WORK_SPACE} || exit 1
100 COMPONENT_NAME="expat-2.0.1.tar.gz"
101 COMPONENT_DIR="expat-2.0.1"
103 download_component "http://downloads.sourceforge.net/project/expat/expat/2.0.1/expat-2.0.1.tar.gz"
104 if [ ${CURRENT_OPTION} = "2" ]; then
105 add_fingerprint 0
106 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} 2>&1>${BUILD_LOG_FILE} || exit 1
107 make 2>&1>>${BUILD_LOG_FILE} || exit 1
108 make install DESTDIR=${ROOTFS} || exit 1
109 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
110 add_fingerprint 1
111 fi
112 echo "expat built successfully"
113 }
116 function dbus()
117 {
118 if [ $# -eq 1 ]; then
119 START_MODULE="dbus-1.4.1.tar.gz"
120 fi
121 # dependency section, in here we build the dependencies. We do not want to rebuild them each time
122 expat
124 cd ${WORK_SPACE} || exit 1
125 COMPONENT_NAME="dbus-1.4.1.tar.gz"
126 COMPONENT_DIR="dbus-1.4.1"
127 download_component "http://dbus.freedesktop.org/releases/dbus/dbus-1.4.1.tar.gz"
128 if [ ${CURRENT_OPTION} = "2" ]; then
129 add_fingerprint 0
130 echo "ac_cv_func_pipe2=no" > arm-linux.cache || exit 1
131 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --cache-file=arm-linux.cache --disable-inotify --without-x 2>&1>>${BUILD_LOG_FILE} || exit 1
132 make 2>&1>>${BUILD_LOG_FILE} || exit 1
133 make install DESTDIR=${ROOTFS} || exit 1
134 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
135 echo "messagebus:x:102:105::${MY_LOCALSTATEDIR}/run/dbus:/bin/false" >> ${ROOTFS}${MY_SYSCONFDIR}/passwd || exit 1
136 add_fingerprint 1
137 fi
138 echo "dbus built successfully"
139 }
142 function libIConv()
143 {
144 cd ${WORK_SPACE} || exit 1
145 COMPONENT_NAME="libiconv-1.13.1.tar.gz"
146 COMPONENT_DIR="libiconv-1.13.1"
147 download_component "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz"
148 if [ ${CURRENT_OPTION} = "2" ]; then
149 add_fingerprint 0
150 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} 2>&1>>${BUILD_LOG_FILE} || exit 1
151 make 2>&1>>${BUILD_LOG_FILE} || exit 1
152 make install DESTDIR=${ROOTFS} || exit 1
153 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
154 add_fingerprint 1
155 fi
156 echo "libIConv built successfully"
157 }
159 function zlib()
160 {
161 cd ${WORK_SPACE} || exit 1
162 COMPONENT_NAME="zlib-1.2.7.tar.gz"
163 COMPONENT_DIR="zlib-1.2.7"
164 download_component "http://zlib.net/zlib-1.2.7.tar.gz"
165 if [ ${CURRENT_OPTION} = "2" ]; then
166 add_fingerprint 0
167 ./configure --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} 2>&1>>${BUILD_LOG_FILE} || exit 1
168 make 2>&1>>${BUILD_LOG_FILE} || exit 1
169 make install DESTDIR=${ROOTFS} || exit 1
170 add_fingerprint 1
171 fi
172 echo "zlib built successfully"
173 }
175 function gettext()
176 {
177 cd ${WORK_SPACE} || exit 1
178 COMPONENT_NAME="gettext-0.18.tar.gz"
179 COMPONENT_DIR="gettext-0.18"
180 download_component "http://ftp.gnu.org/gnu/gettext/gettext-0.18.tar.gz"
181 if [ ${CURRENT_OPTION} = "2" ]; then
182 add_fingerprint 0
183 echo "ac_cv_func_unsetenv=no" > arm-linux.cache || exit 1
184 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --cache-file=arm-linux.cache 2>&1>>${BUILD_LOG_FILE} || exit 1
185 make 2>&1>>${BUILD_LOG_FILE} || exit 1
186 make install DESTDIR=${ROOTFS} || exit 1
187 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
188 add_fingerprint 1
189 fi
190 echo "gettext built successfully"
191 }
193 function glib()
194 {
195 if [ $# -eq 1 ]; then
196 START_MODULE="glib-2.24.1.tar.bz2"
197 fi
198 # dependency section, in here we build the dependencies. We do not want to rebuild them each time
199 libIConv
200 zlib
202 cd ${WORK_SPACE} || exit 1
203 COMPONENT_NAME="glib-2.24.1.tar.bz2"
204 COMPONENT_DIR="glib-2.24.1"
205 download_component "http://ftp.gnome.org/pub/GNOME/sources/glib/2.24/glib-2.24.1.tar.bz2"
206 if [ ${CURRENT_OPTION} = "2" ]; then
207 add_fingerprint 0
208 echo "glib_cv_stack_grows=no
209 glib_cv_uscore=yes
210 ac_cv_func_posix_getpwuid_r=yes
211 ac_cv_func_posix_getgrgid_r=yes
212 ac_cv_func_pipe2=no" > arm-linux.cache || exit 1
213 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --cache-file=arm-linux.cache --with-libiconv=gnu 2>&1>>${BUILD_LOG_FILE} || exit 1
214 sed -i 's/\(^Libs: .*\)/\1 -liconv/g' glib-2.0.pc || exit 1
215 make 2>&1>>${BUILD_LOG_FILE} || exit 1
216 make install DESTDIR=${ROOTFS} || exit 1
217 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
218 add_fingerprint 1
219 fi
220 echo "glib built successfully"
221 }
223 function dbus-glib()
224 {
225 if [ $# -eq 1 ]; then
226 START_MODULE="dbus-glib-0.84.tar.gz"
227 fi
228 # dependency section, in here we build the dependencies. We do not want to rebuild them each time
229 dbus
230 glib
232 cd ${WORK_SPACE} || exit 1
233 COMPONENT_NAME="dbus-glib-0.84.tar.gz"
234 COMPONENT_DIR="dbus-glib-0.84"
235 download_component "http://dbus.freedesktop.org/releases/dbus-glib/dbus-glib-0.84.tar.gz"
236 if [ ${CURRENT_OPTION} = "2" ]; then
237 add_fingerprint 0
238 echo "ac_cv_have_abstract_sockets=yes" > arm-linux.cache || exit 1
239 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --cache-file=arm-linux.cache 2>&1>>${BUILD_LOG_FILE} || exit 1
240 sed -i 's/examples//g' dbus/Makefile || exit 1
241 sed -i 's/tools test/test/g' Makefile || exit 1
242 make 2>&1>>${BUILD_LOG_FILE} || exit 1
243 make install DESTDIR=${ROOTFS} || exit 1
244 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
245 add_fingerprint 1
246 fi
247 echo "dbus-glib built successfully"
248 }
251 function check()
252 {
253 cd ${WORK_SPACE} || exit 1
254 COMPONENT_NAME="check-0.9.6.tar.gz"
255 COMPONENT_DIR="check-0.9.6"
256 download_component "http://downloads.sourceforge.net/check/check-0.9.6.tar.gz"
257 if [ ${CURRENT_OPTION} = "2" ]; then
258 add_fingerprint 0
259 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} 2>&1>>${BUILD_LOG_FILE} || exit 1
260 make 2>&1>>${BUILD_LOG_FILE} || exit 1
261 make install DESTDIR=${ROOTFS} || exit 1
262 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
263 add_fingerprint 1
264 fi
265 echo "check built successfully"
266 }
268 function bluez()
269 {
270 if [ $# -eq 1 ]; then
271 START_MODULE="bluez-4.98.tar.gz"
272 fi
273 # dependency section, in here we build the dependencies. We do not want to rebuild them each time
274 check
275 dbus
276 glib
278 cd ${WORK_SPACE} || exit 1
279 COMPONENT_NAME="bluez-4.98.tar.gz"
280 COMPONENT_DIR="bluez-4.98"
281 download_component "http://kernel.org/pub/linux/bluetooth/bluez-4.98.tar.gz"
282 if [ ${CURRENT_OPTION} = "2" ]; then
283 add_fingerprint 0
284 [ ! -e BlueZ_patches-v2.zip ] && { wget http://processors.wiki.ti.com/images/7/7e/BlueZ_patches-v2.zip || exit 1; }
285 unzip -o BlueZ_patches-v2.zip || exit 1
286 apply_patches
288 ./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 2>&1>>${BUILD_LOG_FILE}
289 make 2>&1>>${BUILD_LOG_FILE} || exit 1
290 make install DESTDIR=${ROOTFS} || exit 1
291 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
292 cp audio/audio.conf tools/rfcomm.conf input/input.conf ${ROOTFS}${MY_SYSCONFDIR}/bluetooth/ || exit 1
293 cp test/agent ${ROOTFS}${MY_PREFIX}/bin/agent || exit 1
294 add_fingerprint 1
295 fi
296 echo "bluez built successfully"
297 }
299 function hcidump
300 {
301 cd ${WORK_SPACE} || exit 1
302 COMPONENT_NAME="bluez-hcidump-2.2.tar.gz"
303 COMPONENT_DIR="bluez-hcidump-2.2"
304 download_component "http://pkgs.fedoraproject.org/repo/pkgs/bluez-hcidump/bluez-hcidump-2.2.tar.gz/3c298a8be67099fe227f3e4d9de539d5/bluez-hcidump-2.2.tar.gz"
305 if [ ${CURRENT_OPTION} = "2" ]; then
306 add_fingerprint 0
307 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} 2>&1>>${BUILD_LOG_FILE} || exit 1
308 make 2>&1>>${BUILD_LOG_FILE} || exit 1
309 make install DESTDIR=${ROOTFS} || exit 1
310 add_fingerprint 1
311 fi
312 echo "hcidump built successfully"
313 }
315 function ncurses
316 {
317 cd ${WORK_SPACE} || exit 1
318 COMPONENT_NAME="ncurses-5.9.tar.gz"
319 COMPONENT_DIR="ncurses-5.9"
320 download_component "http://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz"
321 if [ ${CURRENT_OPTION} = "2" ]; then
322 add_fingerprint 0
323 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} -with-shared --without-debug --without-normal 2>&1>>${BUILD_LOG_FILE} || exit 1
324 make 2>&1>>${BUILD_LOG_FILE} || exit 1
325 make install DESTDIR=${ROOTFS} || exit 1
326 add_fingerprint 1
327 fi
328 echo "ncurses built successfully"
329 }
331 function readline
332 {
333 cd ${WORK_SPACE} || exit 1
334 COMPONENT_NAME="readline-6.2.tar.gz"
335 COMPONENT_DIR="readline-6.2"
336 download_component " http://ftp.gnu.org/gnu/readline/readline-6.2.tar.gz"
337 if [ ${CURRENT_OPTION} = "2" ]; then
338 add_fingerprint 0
339 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} 2>&1>>${BUILD_LOG_FILE} || exit 1
340 make 2>&1>>${BUILD_LOG_FILE} || exit 1
341 make install DESTDIR=${ROOTFS} || exit 1
342 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
343 add_fingerprint 1
344 fi
345 echo "readline built successfully"
346 }
349 function alsa-lib
350 {
351 cd ${WORK_SPACE} || exit 1
352 COMPONENT_NAME="alsa-lib-1.0.24.1.tar.gz"
353 COMPONENT_DIR="alsa-lib-1.0.26"
354 download_component "http://fossies.org/linux/misc/alsa-lib-1.0.24.1.tar.gz"
355 if [ ${CURRENT_OPTION} = "2" ]; then
356 add_fingerprint 0
357 ./configure --prefix=${MY_PREFIX} --host=${BUILD_HOST} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} 2>&1>>${BUILD_LOG_FILE} || exit 1
358 make 2>&1>>${BUILD_LOG_FILE} || exit 1
359 make install DESTDIR=${ROOTFS} || exit 1
360 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
361 add_fingerprint 1
362 fi
363 echo "alsa-lib built successfully"
364 }
366 function openobex
367 {
368 cd ${WORK_SPACE} || exit 1
369 COMPONENT_NAME="openobex-1.5.tar.gz"
370 COMPONENT_DIR="openobex-1.5"
371 download_component "http://ftp.osuosl.org/pub/linux/bluetooth/openobex-1.5.tar.gz"
372 if [ ${CURRENT_OPTION} = "2" ]; then
373 # wget 'http://mirror.anl.gov/pub/linux/bluetooth/openobex-1.5.tar.gz' || exit 1
374 add_fingerprint 0
375 sed -i '11227 i *)\n;;' configure 2>&1>>${BUILD_LOG_FILE} || exit 1
376 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} --localstatedir=${MY_LOCALSTATEDIR} --enable-apps --disable-usb 2>&1>>${BUILD_LOG_FILE} || exit 1
377 sed -i 's/^\(libdir=\).*/\1\$\{prefix\}\/lib/g' openobex.pc || exit 1
378 make 2>&1>>${BUILD_LOG_FILE} || exit 1
379 make install DESTDIR=${ROOTFS} || exit 1
380 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
381 add_fingerprint 1
382 fi
383 echo "openobex built successfully"
384 }
386 function libical
387 {
388 cd ${WORK_SPACE} || exit 1
389 COMPONENT_NAME="libical-0.44.tar.gz"
390 COMPONENT_DIR="libical-0.44"
391 download_component "http://downloads.sourceforge.net/project/freeassociation/libical/libical-0.44/libical-0.44.tar.gz"
392 if [ ${CURRENT_OPTION} = "2" ]; then
393 add_fingerprint 0
394 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} 2>&1>>${BUILD_LOG_FILE} || exit 1
395 make 2>&1>>${BUILD_LOG_FILE} || exit 1
396 make install DESTDIR=${ROOTFS} || exit 1
397 rm `find ${ROOTFS}${MY_PREFIX}/lib/ -name '*.la'` >& /dev/null
398 add_fingerprint 1
399 fi
400 echo "libical built successfully"
401 }
403 function obexd
404 {
405 if [ $# -eq 1 ]; then
406 START_MODULE="obexd-0.34.tar.gz"
407 fi
408 # dependency section, in here we build the dependencies. We do not want to rebuild them each time
409 bluez
410 openobex
411 libical
413 cd ${WORK_SPACE} || exit 1
414 COMPONENT_NAME="obexd-0.34.tar.gz"
415 COMPONENT_DIR="obexd-0.34"
416 download_component "http://www.kernel.org/pub/linux/bluetooth/obexd-0.34.tar.gz"
417 if [ ${CURRENT_OPTION} = "2" ]; then
418 add_fingerprint 0
419 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} 2>&1>>${BUILD_LOG_FILE} || exit 1
420 wget http://processors.wiki.ti.com/images/4/43/Obexd-patches_v1.tar.gz || exit 1
421 echo "Openning archive: Obexd-patches_v1.tar.gz" && tar -xzf Obexd-patches_v1.tar.gz || exit 1
422 apply_patches
423 make 2>&1>>${BUILD_LOG_FILE} || exit 1
424 make install DESTDIR=${ROOTFS} || exit 1
425 add_fingerprint 1
426 fi
427 echo "obexd built successfully"
428 }
430 function bt-obex
431 {
432 if [ $# -eq 1 ]; then
433 START_MODULE="171181b6ef6c94aefc828dc7fd8de136b9f97532"
434 fi
435 # dependency section, in here we build the dependencies. We do not want to rebuild them each time
436 dbus-glib
437 readline
438 ncurses
440 cd ${WORK_SPACE} || exit 1
441 COMPONENT_NAME="171181b6ef6c94aefc828dc7fd8de136b9f97532"
442 COMPONENT_DIR="bluez-tools"
443 download_component "git://gitorious.org/bluez-tools/bluez-tools.git"
444 if [ ${CURRENT_OPTION} = "2" ]; then
445 add_fingerprint 0
446 [ ! -e Bt-obex-patches.zip ] && { wget 'http://processors.wiki.ti.com/images/f/f5/Bt-obex-patches.zip' || exit 1; }
447 unzip -o Bt-obex-patches.zip || exit 1
448 apply_patches
450 /usr/bin/libtoolize || exit 1
451 /usr/bin/aclocal || exit 1
452 /usr/bin/autoheader || exit 1
453 /usr/bin/automake --add-missing || exit 1
454 /usr/bin/autoconf || exit 1
455 ./configure --host=${BUILD_HOST} --prefix=${MY_PREFIX} --sysconfdir=${MY_SYSCONFDIR} 2>&1>>${BUILD_LOG_FILE} || exit 1
456 make 2>&1>>${BUILD_LOG_FILE} || exit 1
457 make install DESTDIR=${ROOTFS} || exit 1
458 add_fingerprint 1
459 fi
460 echo "bt-obex built successfully"
461 }
463 function firmware
464 {
465 cd ${WORK_SPACE} || exit 1
466 COMPONENT_NAME="db43d1f05efda9777d7ac1ac366637e29e21f77f"
467 COMPONENT_DIR="bt-firmware"
468 download_component "git://github.com/TI-ECS/bt-firmware.git"
469 if [ ${CURRENT_OPTION} = "2" ]; then
470 add_fingerprint 0
471 mkdir -p ${ROOTFS}/lib/firmware || exit 1
473 if [ x"$MACHINE_TYPE" = "x" ]; then
474 get_machine_used
475 fi
477 PRINT_STR="Invoking: cp ${MACHINE_TYPE}/TIInit_7.2.31.bts ${ROOTFS}/lib/firmware/"
478 echo ${PRINT_STR}
479 cp ./${MACHINE_TYPE}/TIInit_7.2.31.bts ${ROOTFS}/lib/firmware/ || exit 1
480 add_fingerprint 1
481 fi
482 echo "firmware built successfully"
483 }
485 function wl1271-demo
486 {
487 cd ${WORK_SPACE} || exit 1
488 COMPONENT_NAME="wl1271-bluetooth-2012-03-26.tar.gz"
489 COMPONENT_DIR="wl1271-bluetooth"
490 download_component "https://gforge.ti.com/gf/download/frsrelease/827/5494/wl1271-bluetooth-2012-03-26.tar.gz"
491 if [ ${CURRENT_OPTION} = "2" ]; then
492 add_fingerprint 0
493 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
494 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
495 mkdir -p ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
497 if [ x"$MACHINE_TYPE" = "x" ]; then
498 get_machine_used
499 fi
501 cp ./gallery/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/gallery || exit 1
502 cp ./script/common/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
503 cp ./script/${MACHINE_TYPE}/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/scripts || exit 1
504 cp ./ftp_folder/* ${ROOTFS}/usr/share/wl1271-demos/bluetooth/ftp_folder || exit 1
505 add_fingerprint 1
506 fi
507 echo "wl1271-demo built successfully"
508 }
510 function bt-enable
511 {
512 cd ${WORK_SPACE} || exit 1
513 if [ x"$KLIB_BUILD" = "x" ]; then
514 echo "Please set KLIB_BUILD variable to point to your Linux kernel"
515 exit 1
516 fi
517 COMPONENT_NAME="dd75971705ada8fb0e88a0fb3f68833086c5bba4"
518 COMPONENT_DIR="bt_enable"
519 download_component "git://github.com/TI-ECS/bt_enable.git"
520 if [ ${CURRENT_OPTION} = "2" ]; then
521 [ ! -e Bt-enable-standalone-makefile.zip ] && { wget 'http://processors.wiki.ti.com/images/8/8f/Bt-enable-standalone-makefile.zip' || exit 1; }
522 unzip -o Bt-enable-standalone-makefile.zip || exit 1
523 apply_patches
525 if [ x"$MACHINE_TYPE" = "x" ]; then
526 get_machine_used
527 fi
528 cp ./gpio_en_${MACHINE_TYPE}.c ./gpio_en.c
529 make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} || exit 1
530 make DEST_DIR=${ROOTFS} KERNEL_DIR=${KLIB_BUILD} install || exit 1
531 add_fingerprint 1
532 fi
533 echo "bt-enable built successfully"
534 }
536 function add_fingerprint()
537 {
538 if [ x"$1" = "x" ]; then
539 echo "Function add_fingerprint() called with no parameters!!!"
540 exit 1
541 fi
542 local FILENAME="${FINGURE_PRINT_DIR}/${COMPONENT_NAME##*/}"
543 touch ${FILENAME} || exit 1
544 echo $1 > ${FILENAME} || exit
545 }
547 function fingerprint()
548 {
549 local FILENAME="${FINGURE_PRINT_DIR}/${COMPONENT_NAME##*/}"
550 # if no file exists
551 if [ ! -e ${FILENAME} ]; then
552 return 0
553 fi
554 read MAX < ${FILENAME}
555 return ${MAX}
556 }
558 function download_component()
559 {
560 if [ x"$1" = "x" ]; then
561 echo "Function called with no parameters!!!"
562 exit 1
563 fi
565 if [ ! x"${START_MODULE}" = "x" ]; then # if the START_MODULE is not empty
566 if [ ${START_MODULE} = ${COMPONENT_NAME} ]; then # if we are building the start module
567 CURRENT_OPTION=${USER_OPTION} # take the user option as is
568 else
569 CURRENT_OPTION="1" # else, we are building dependency, so we should only build not rebuild
570 fi
571 else
572 CURRENT_OPTION=${USER_OPTION} # take the user option as is
573 fi
574 # get the extension of the file
575 local EXT=${1/*./}
577 # check the fingerprint value
578 fingerprint
579 case "$?" in
580 0) # 0 - File not compiled nor installed
581 CURRENT_OPTION="2" # override to "rebuild" option
582 ;;
583 1) # 1 - File was installed properly
584 # if the option is build and fingerprint OK, nothing to do
585 if [ ${CURRENT_OPTION} = "1" ]; then
586 return
587 fi
588 ;;
589 *)
590 echo "Corrupted fingerprint for component ${COMPONENT_NAME}"
591 exit 1
592 ;;
593 esac
594 # echo "Decided to rebuild for ${COMPONENT_NAME}"
595 # read
596 # I get here in one situation : USER_OPTION = 2
597 case "${EXT}" in
598 git)
599 # if git directory exist, do not clone it again
600 if [ ! -d ${COMPONENT_DIR} ]; then
601 git clone $1 || exit 1
602 fi
603 cd ${COMPONENT_DIR} || exit 1
604 git reset --hard ${COMPONENT_NAME} || exit 1
605 ;;
607 gz|bz2)
608 # delete the working directory if exists
609 if [ ! x"${COMPONENT_DIR}" = "x" ]; then
610 rm -rf ${COMPONENT_DIR} || exit 1
611 fi
613 local TAR_FLAGS="-xzf"
615 if [ ${EXT} = "bz2" ]; then
616 TAR_FLAGS="-xjf"
617 fi
618 # if component doesn't exist, bring it
619 if [ ! -e ${COMPONENT_NAME} ]; then
620 wget $1 || exit 1
621 fi
622 echo "Openning archive: ${COMPONENT_NAME}"
623 tar ${TAR_FLAGS} ${COMPONENT_NAME} || exit 1
624 # move to the directory if not empty
625 if [ ! x"${COMPONENT_DIR}" = "x" ]; then
626 cd ${COMPONENT_DIR} || exit 1
627 fi;
628 ;;
630 *)
631 echo "Unknown extension of remote package"
632 exit 1
633 ;;
634 esac
635 }
637 function get_machine_used()
638 {
639 # check if the machine type is already defined
640 if [ ! x"${MACHINE_TYPE}" = "x" ]; then
641 return;
642 fi
643 echo ""
644 echo "Please select the machine you use:"
645 echo "==================================="
646 echo "1. am180x-evm (am1808)"
647 echo "2. am37x-evm (omap3evm)"
648 echo "3. am335x-evm (am335x)"
649 read choice
650 case $choice in
651 1) MACHINE_TYPE="am1808" ;;
652 2) MACHINE_TYPE="omap3evm" ;;
653 3) MACHINE_TYPE="am335x" ;;
654 *)
655 echo "This is not a valid choice... Exitiing script"
656 exit 1
657 ;;
658 esac
659 }
661 function check_env()
662 {
663 [ -e ${WORK_SPACE}/.check_env.stamp ] && return 0
664 which dpkg
665 if [ $? -ne 0 ]
666 then
667 echo "The following packages should be installed on the system:"
668 echo "bash bison flex perl bc python python-m2crypto corkscrew"
669 echo "git autoconf automake libtool gettext patch libglib2.0-dev"
670 echo "Please check before to continue."
671 return 0
672 fi
673 err=0
674 ret=0
675 packages="bash bison flex perl bc python python-m2crypto corkscrew git autoconf automake libtool gettext patch libglib2.0-dev"
676 for p in ${packages}
677 do
678 echo -n "Checking ${p}..."
679 present=`dpkg-query -W ${p} 2>/dev/null | awk '{print $1}'`
680 [ x"${present}" != x"${p}" ] && echo "Package ${p} is not found. Please run 'apt-get install ${p}' to install it." && err=1 && ret=1
681 [ ${err} -ne 1 ] && echo "OK"
682 err=0
683 done
684 return ${ret}
685 }
686 ############################################# MAIN ###############################################
687 old_dir=`pwd`
688 MACHINE_TYPE=""
690 source setup-env || exit 1
691 # if there are no sufficient arguments...
692 if [ $# -lt 2 ]; then
693 usage
694 exit 0
695 fi
697 if [ x"$CROSS_COMPILE" = "x" ]; then
698 echo "define CROSS_COMPILE variable"
699 exit 1
700 fi
702 which ${CROSS_COMPILE}gcc > /dev/null
704 if [ $? -ne 0 ]; then
705 echo "No toolchain in path"
706 exit 1
707 fi
709 BUILD_HOST=`echo $CROSS_COMPILE | sed s/-$//`
711 if [ x"$ROOTFS" = "x" ]; then
712 echo "Please set ROOTFS variable to point to your root filesystem"
713 exit 1
714 fi
716 if [ x"$WORK_SPACE" = "x" ]; then
717 echo "Please set WORK_SPACE variable to point to your preferred work space"
718 exit 1
719 fi
721 FINGURE_PRINT_DIR="${WORK_SPACE}/.FingurePrint"
722 mkdir -p ${FINGURE_PRINT_DIR} || exit 1
723 check_env || exit 1
724 touch ${WORK_SPACE}/.check_env.stamp
725 BUILD_LOG_FILE=${FINGURE_PRINT_DIR}/build.log
726 USER_OPTION=0
727 CURRENT_OPTION=0
729 case "$2" in
730 build)
731 USER_OPTION=1
732 ;;
733 rebuild)
734 USER_OPTION=2
735 ;;
736 *)
737 echo "Unknown option $2"
738 exit 1
739 ;;
740 esac
742 CURRENT_OPTION=${USER_OPTION}
744 MODULE_TO_INVOKE=$1
745 $MODULE_TO_INVOKE 1
747 cd ${old_dir}