1 #!/bin/bash
3 declare -A gen_tag="ol_R5.SP8.01"
4 #### R5 SP3.05
5 declare -A wl12xx_download_target="git@git.ti.com:wl12xx/wl12xx.git"
6 declare -A wl12xx_tag=${gen_tag}
7 declare -A compatwireless_download_target="git@git.ti.com:wl12xx/compat-wireless.git"
8 declare -A compat_wireless_tag=${gen_tag}
9 declare -A compat_download_target="git@git.ti.com:wl12xx/compat.git"
10 declare -A compat_tag=${gen_tag}
11 declare -A iw_download_target="git://git.sipsolutions.net/iw.git"
12 declare -A iw_tag="0a236ef5f8e4ba7218aac7d0cdacf45673d5b35c"
14 declare -A ti_utils_download_target="git@git.ti.com:wl12xx/ti-utils.git"
15 declare -A ti_utils_commit_id=${gen_tag}
16 declare -A hostap_download_target="git@git.ti.com:wl12xx/hostap.git"
17 declare -A hostap_commit_id=${gen_tag}
21 if [ ! -e setup-env ]
22 then
23 echo "No setup-env"
24 exit 1
25 fi
26 source setup-env
27 unset PKG_CONFIG_SYSROOT_DIR
28 ME=$0
29 components="libnl openssl iw hostap wpa_supplicant crda ti-utils ti-utils-firmware compat-wireless"
30 export GIT_TREE=${WORK_SPACE}/wl12xx
31 export GIT_COMPAT_TREE=${WORK_SPACE}/compat
33 old_dir=`pwd`
35 function download ()
36 {
37 file="$2"
38 [ -e ${WORK_SPACE}/${file} ] && echo "File $file already exists. Skipping download." && return 0
39 wget "$1"
40 if [ $? -ne 0 ]
41 then
42 echo "Failed to download $file"
43 exit 1
44 fi
45 }
47 function git_clone ()
48 {
49 file="$2"
50 if [ -e ${WORK_SPACE}/${file} ]
51 then
52 echo "File $file alread exists. Skipping git clone."
53 cd ${WORK_SPACE}/${file}
54 git fetch || exit 1
55 echo "git $file fetched."
56 return 0
57 fi
58 git clone "$1"
59 if [ $? -ne 0 ]
60 then
61 echo "Failed to download $2 git repository"
62 exit 1
63 fi
64 echo "git $file cloned."
65 }
67 function compat-wireless()
68 {
69 stage=$1
72 if [ x"$stage" = "xdownload" -o x"$stage" = "xall" ]
73 then
74 cd ${WORK_SPACE}
75 git_clone ${wl12xx_download_target} wl12xx
76 cd ${WORK_SPACE}/wl12xx
77 git reset --hard ${wl12xx_tag} || exit 1
78 cd ${WORK_SPACE}
79 git_clone ${compat_download_target} compat
80 cd ${WORK_SPACE}/compat
81 git reset --hard ${compat_tag} || exit 1
82 cd ${WORK_SPACE}
83 git_clone ${compatwireless_download_target} compat-wireless
84 cd ${WORK_SPACE}/compat-wireless
85 git reset --hard ${compat_wireless_tag} || exit 1
86 fi
87 if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
88 then
89 cd ${WORK_SPACE}/compat-wireless
90 ./scripts/admin-update.sh
91 ./scripts/driver-select wl12xx
92 patch -p1 -i ${old_dir}/patches/0001-wl12xx-additional-two-members-for-wl12xx_platform_da.patch || exit 1
93 make KLIB_BUILD=${KLIB_BUILD} KLIB=${ROOTFS} || exit 1
94 fi
95 if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
96 then
97 cd ${WORK_SPACE}/compat-wireless
98 make KLIB_BUILD=${KLIB_BUILD} KLIB=${ROOTFS} install-modules
99 fi
101 if [ x"$stage" = "xclean" ]
102 then
103 cd $WORK_SPACE/compat-wireless
104 #make KLIB=${ROOTFS} uninstall
105 cd $WORK_SPACE && rm -rf compat-wireless
106 fi
108 cd $WORK_SPACE
109 }
110 function crda ()
111 {
112 stage=$1
113 if [ x"$stage" = "xdownload" -o x"$stage" = "xall" ]
114 then
115 download "http://wireless.kernel.org/download/crda/crda-1.1.1.tar.bz2" "crda-1.1.1.tar.bz2"
116 download "http://linuxwireless.org/download/wireless-regdb/regulatory.bins/2011.04.28-regulatory.bin" "2011.04.28-regulatory.bin"
117 tar xjf crda-1.1.1.tar.bz2
118 cd ${WORK_SPACE}/crda-1.1.1
119 cp ${WORK_SPACE}/2011.04.28-regulatory.bin .
120 fi
121 if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
122 then
123 cd ${WORK_SPACE}/crda-1.1.1
124 make USE_OPENSSL=1 all_noverify || exit 1
125 fi
126 if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
127 then
128 cd ${WORK_SPACE}/crda-1.1.1
129 DESTDIR=${ROOTFS} make USE_OPENSSL=1 UDEV_RULE_DIR="etc/udev/rules.d/" install || exit 1
130 mkdir -p ${ROOTFS}/usr/lib/crda
131 cp 2011.04.28-regulatory.bin ${ROOTFS}/usr/lib/crda/regulatory.bin
132 fi
133 if [ x"$stage" = "xclean" ]
134 then
135 cd $WORK_SPACE/crda-1.1.1
136 DESTDIR=${ROOTFS} make clean
137 cd $WORK_SPACE && rm -rf crda-1.1.1
138 fi
139 cd $WORK_SPACE
140 }
142 function iw ()
143 {
144 stage=$1
145 if [ x"$stage" = "xdownload" -o x"$stage" = "xall" ]
146 then
147 git_clone "${iw_download_target}" iw
148 cd ${WORK_SPACE}/iw
149 git reset --hard ${iw_tag} || exit 1
150 fi
151 if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
152 then
153 cd ${WORK_SPACE}/iw
154 make || exit 1
155 fi
157 if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
158 then
159 cd ${WORK_SPACE}/iw
160 DESTDIR=${ROOTFS} make install || exit 1
161 fi
162 if [ x"$stage" = "xclean" ]
163 then
164 cd $WORK_SPACE/iw
165 make clean
166 fi
167 cd $WORK_SPACE
168 }
169 function libnl ()
170 {
171 stage=$1
172 if [ x"$stage" = x"download" -o x"$stage" = "xall" ]
173 then
174 download http://www.infradead.org/~tgr/libnl/files/libnl-2.0.tar.gz libnl-2.0.tar.gz
175 tar xzf libnl-2.0.tar.gz
176 cd ${WORK_SPACE}/libnl-2.0
177 ./configure --prefix=${ROOTFS} CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld RANLIB=${CROSS_COMPILE}ranlib --host=arm-linux
178 if [ $? != 0 ]
179 then
180 echo "libnl failed to be configured"
181 exit 1
182 fi
183 fi
185 if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
186 then
187 cd ${WORK_SPACE}/libnl-2.0
188 make || exit 1
189 fi
190 if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
191 then
192 cd ${WORK_SPACE}/libnl-2.0
193 make install || exit 1
194 fi
195 if [ x"$stage" = "xclean" ]
196 then
197 cd $WORK_SPACE/libnl-2.0
198 make uninstall
199 cd .. && rm -rf libnl-2.0
200 fi
201 cd $WORK_SPACE
203 }
204 function openssl ()
205 {
206 stage=$1
207 if [ x"$stage" = x"download" -o x"$stage" = "xall" ]
208 then
209 cd ${WORK_SPACE}
210 download "http://www.openssl.org/source/openssl-1.0.0d.tar.gz" "openssl-1.0.0d.tar.gz"
211 tar xzf openssl-1.0.0d.tar.gz
212 download http://processors.wiki.ti.com/images/e/ee/Openssl-1.0.0d-new-compilation-target-for-configure.zip Openssl-1.0.0d-new-compilation-target-for-configure.zip
213 cd ${WORK_SPACE}/openssl-1.0.0d
214 unzip ${WORK_SPACE}/Openssl-1.0.0d-new-compilation-target-for-configure.zip || exit 1
215 patch -p1 -i 0001-openssl-1.0.0d-new-target-os-for-configure.patch || exit 1
216 CROSS_COMPILE= perl ./Configure shared --prefix=$ROOTFS/usr --openssldir=$ROOTFS/usr/lib/ssl linux-elf-arm
217 fi || exit 1
218 if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
219 then
220 cd ${WORK_SPACE}/openssl-1.0.0d
221 make || exit 1
222 fi
223 if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
224 then
225 cd ${WORK_SPACE}/openssl-1.0.0d
226 make install_sw || exit 1
227 fi
228 if [ x"$stage" = "xclean" ]
229 then
230 cd ${WORK_SPACE}/openssl-1.0.0d
231 rm -f ${ROOTFS}/usr/lib/*ssl* ${ROOTFS}/usr/lib/pkgconfig/*ssl*
232 cd .. && rm -rf openssl-1.0.0d
233 fi
234 cd $WORK_SPACE
235 }
236 function ti-utils ()
237 {
238 stage=$1
240 if [ x"$stage" = x"download" -o x"$stage" = "xall" ]
241 then
242 git_clone "${ti_utils_download_target}" ti-utils
243 cd ${WORK_SPACE}/ti-utils
244 git reset --hard "${ti_utils_commit_id}"
245 fi
247 if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
248 then
249 cd ${WORK_SPACE}/ti-utils
250 NFSROOT=${ROOTFS} make || exit 1
251 fi
252 if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
253 then
254 cd ${WORK_SPACE}/ti-utils
255 #NFSROOT=${ROOTFS} make install || exit 1
256 if [ ! -x calibrator ]
257 then
258 echo "calibrator is not built, run 'make' first"
259 exit 1
260 fi
261 cp -f ./calibrator ${ROOTFS}/home/root
262 chmod 755 ${ROOTFS}/home/root/calibrator
263 fi
264 if [ x"$stage" = "xclean" ]
265 then
266 cd ${WORK_SPACE}/ti-utils
267 NFSROOT=${ROOTFS} make clean
268 rm -f ${ROOTFS}/home/root/calibrator ${ROOTFS}/home/root/wl12xx-tool.sh
269 fi
270 cd $WORK_SPACE
271 }
272 function ti-utils-firmware()
273 {
274 stage=$1
276 if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
277 then
278 mkdir -p $ROOTFS/lib/firmware/ti-connectivity
279 cp ${WORK_SPACE}/ti-utils/hw/firmware/* $ROOTFS/lib/firmware/ti-connectivity
280 rm -f $ROOTFS/lib/hw/firmware/ti-connectivity/Makefile
281 cp -r ${WORK_SPACE}/ti-utils/hw/ini_files $ROOTFS/lib/firmware/ti-connectivity
282 fi
283 if [ x"$stage" = "xclean" ]
284 then
285 rm -rf $ROOTFS/lib/firmware/ti-connectivity
286 fi
287 cd $WORK_SPACE
288 }
290 function make_hostapd_defconfig ()
291 {
292 cat > .config <<"hostapd_defconfig"
293 # Example hostapd build time configuration
294 #
295 # This file lists the configuration options that are used when building the
296 # hostapd binary. All lines starting with # are ignored. Configuration option
297 # lines must be commented out complete, if they are not to be included, i.e.,
298 # just setting VARIABLE=n is not disabling that variable.
299 #
300 # This file is included in Makefile, so variables like CFLAGS and LIBS can also
301 # be modified from here. In most cass, these lines should use += in order not
302 # to override previous values of the variables.
304 DESTDIR=$(ROOTFS)
305 # Driver interface for Host AP driver
306 CONFIG_DRIVER_HOSTAP=y
308 # Driver interface for wired authenticator
309 #CONFIG_DRIVER_WIRED=y
311 # Driver interface for drivers using the nl80211 kernel interface
312 CONFIG_DRIVER_NL80211=y
313 CONFIG_LIBNL20=y
314 # driver_nl80211.c requires a rather new libnl (version 1.1) which may not be
315 # shipped with your distribution yet. If that is the case, you need to build
316 # newer libnl version and point the hostapd build to use it.
317 #LIBNL=/usr/src/libnl
318 #CFLAGS += -I$(LIBNL)/include
319 #LIBS += -L$(LIBNL)/lib
321 # Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
322 #CONFIG_DRIVER_BSD=y
323 #CFLAGS += -I/usr/local/include
324 #LIBS += -L/usr/local/lib
325 #LIBS_p += -L/usr/local/lib
326 #LIBS_c += -L/usr/local/lib
328 # Driver interface for no driver (e.g., RADIUS server only)
329 #CONFIG_DRIVER_NONE=y
331 # IEEE 802.11F/IAPP
332 CONFIG_IAPP=y
334 # WPA2/IEEE 802.11i RSN pre-authentication
335 CONFIG_RSN_PREAUTH=y
337 # PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
338 CONFIG_PEERKEY=y
340 # IEEE 802.11w (management frame protection)
341 # This version is an experimental implementation based on IEEE 802.11w/D1.0
342 # draft and is subject to change since the standard has not yet been finalized.
343 # Driver support is also needed for IEEE 802.11w.
344 #CONFIG_IEEE80211W=y
346 # Integrated EAP server
347 CONFIG_EAP=y
349 # EAP-MD5 for the integrated EAP server
350 CONFIG_EAP_MD5=y
352 # EAP-TLS for the integrated EAP server
353 CONFIG_EAP_TLS=y
355 # EAP-MSCHAPv2 for the integrated EAP server
356 CONFIG_EAP_MSCHAPV2=y
358 # EAP-PEAP for the integrated EAP server
359 CONFIG_EAP_PEAP=y
361 # EAP-GTC for the integrated EAP server
362 CONFIG_EAP_GTC=y
364 # EAP-TTLS for the integrated EAP server
365 CONFIG_EAP_TTLS=y
367 # EAP-SIM for the integrated EAP server
368 #CONFIG_EAP_SIM=y
370 # EAP-AKA for the integrated EAP server
371 #CONFIG_EAP_AKA=y
373 # EAP-AKA' for the integrated EAP server
374 # This requires CONFIG_EAP_AKA to be enabled, too.
375 #CONFIG_EAP_AKA_PRIME=y
377 # EAP-PAX for the integrated EAP server
378 #CONFIG_EAP_PAX=y
380 # EAP-PSK for the integrated EAP server (this is _not_ needed for WPA-PSK)
381 #CONFIG_EAP_PSK=y
383 # EAP-SAKE for the integrated EAP server
384 #CONFIG_EAP_SAKE=y
386 # EAP-GPSK for the integrated EAP server
387 #CONFIG_EAP_GPSK=y
388 # Include support for optional SHA256 cipher suite in EAP-GPSK
389 #CONFIG_EAP_GPSK_SHA256=y
391 # EAP-FAST for the integrated EAP server
392 # Note: Default OpenSSL package does not include support for all the
393 # functionality needed for EAP-FAST. If EAP-FAST is enabled with OpenSSL,
394 # the OpenSSL library must be patched (openssl-0.9.9-session-ticket.patch)
395 # to add the needed functions.
396 #CONFIG_EAP_FAST=y
398 # Wi-Fi Protected Setup (WPS)
399 CONFIG_WPS=y
400 # Enable WSC 2.0 support
401 CONFIG_WPS2=y
402 # Enable UPnP support for external WPS Registrars
403 CONFIG_WPS_UPNP=y
405 # EAP-IKEv2
406 #CONFIG_EAP_IKEV2=y
408 # Trusted Network Connect (EAP-TNC)
409 #CONFIG_EAP_TNC=y
411 # PKCS#12 (PFX) support (used to read private key and certificate file from
412 # a file that usually has extension .p12 or .pfx)
413 CONFIG_PKCS12=y
415 # RADIUS authentication server. This provides access to the integrated EAP
416 # server from external hosts using RADIUS.
417 #CONFIG_RADIUS_SERVER=y
419 # Build IPv6 support for RADIUS operations
420 CONFIG_IPV6=y
422 # IEEE Std 802.11r-2008 (Fast BSS Transition)
423 #CONFIG_IEEE80211R=y
425 # Use the hostapd's IEEE 802.11 authentication (ACL), but without
426 # the IEEE 802.11 Management capability (e.g., madwifi or FreeBSD/net80211)
427 #CONFIG_DRIVER_RADIUS_ACL=y
429 # IEEE 802.11n (High Throughput) support
430 CONFIG_IEEE80211N=y
432 # Remove debugging code that is printing out debug messages to stdout.
433 # This can be used to reduce the size of the hostapd considerably if debugging
434 # code is not needed.
435 #CONFIG_NO_STDOUT_DEBUG=y
437 # Remove support for RADIUS accounting
438 #CONFIG_NO_ACCOUNTING=y
440 # Remove support for RADIUS
441 #CONFIG_NO_RADIUS=y
443 # Remove support for VLANs
444 #CONFIG_NO_VLAN=y
446 # Remove support for dumping state into a file on SIGUSR1 signal
447 # This can be used to reduce binary size at the cost of disabling a debugging
448 # option.
449 #CONFIG_NO_DUMP_STATE=y
451 CONFIG_NO_RANDOM_POOL=y
452 LIBNL=$(ROOTFS)
453 CFLAGS += -I$(LIBNL)/include -I$(ROOTFS)/usr/include/
454 LIBS += -L$(LIBNL)/lib -L$(LIBNL)/lib -L$(ROOTFS)/usr/lib -lssl -lcrypto -ldl
455 LIBS_p += -L$(LIBNL)/lib -L$(LIBNL)/lib -L$(ROOTFS)/usr/lib -lssl -lcrypto -ldl
456 hostapd_defconfig
457 }
459 function hostap()
460 {
461 stage=$1
462 if [ x"$stage" = x"download" -o x"$stage" = "xall" ]
463 then
464 git_clone "${hostap_download_target}" hostap
465 cd ${WORK_SPACE}/hostap
466 git reset --hard "${hostap_commit_id}"
467 fi
468 if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
469 then
470 cd ${WORK_SPACE}/hostap/hostapd
471 make_hostapd_defconfig
472 make clean || exit 1
473 make || exit 1
474 fi
475 if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
476 then
477 cd ${WORK_SPACE}/hostap/hostapd
478 make install || exit 1
479 for i in hostapd hostapd_cli; do cp -f $i ${ROOTFS}/usr/sbin/$i || exit 1; done
480 fi
481 if [ x"$stage" = "xclean" ]
482 then
483 cd ${WORK_SPACE}/hostap/hostapd
484 make clean
485 cd ../wpa_supplicant
486 make clean
487 fi
488 cd $WORK_SPACE
490 }
492 function make_wpa_sup_defconfig ()
493 {
494 cat > .config <<"wpa_sup_defconfig"
495 # Example wpa_supplicant build time configuration
496 DESTDIR=$(ROOTFS)
497 CFLAGS += -I$(ROOTFS)/usr/include/
498 LIBS += -L$(ROOTFS)/usr/lib
499 LIBS_p += -L$(ROOTFS)/usr/lib
500 CONFIG_WAPI=y
501 CONFIG_LIBNL20=y
502 NEED_BGSCAN=y
503 CONFIG_BGSCAN_LEARN=y
504 # Driver interface for generic Linux wireless extensions
505 CONFIG_DRIVER_WEXT=y
506 # Driver interface for Linux drivers using the nl80211 kernel interface
507 CONFIG_DRIVER_NL80211=y
508 # Driver interface for wired Ethernet drivers
509 CONFIG_DRIVER_WIRED=y
510 # Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
511 # included)
512 CONFIG_IEEE8021X_EAPOL=y
513 # EAP-MD5
514 CONFIG_EAP_MD5=y
515 # EAP-MSCHAPv2
516 CONFIG_EAP_MSCHAPV2=y
517 # EAP-TLS
518 CONFIG_EAP_TLS=y
519 # EAL-PEAP
520 CONFIG_EAP_PEAP=y
521 # EAP-TTLS
522 CONFIG_EAP_TTLS=y
523 # EAP-GTC
524 CONFIG_EAP_GTC=y
525 # EAP-OTP
526 CONFIG_EAP_OTP=y
527 # LEAP
528 CONFIG_EAP_LEAP=y
529 # Wi-Fi Protected Setup (WPS)
530 CONFIG_WPS=y
531 # Enable WSC 2.0 support
532 CONFIG_WPS2=y
533 # PKCS#12 (PFX) support (used to read private key and certificate file from
534 # a file that usually has extension .p12 or .pfx)
535 CONFIG_PKCS12=y
536 # Smartcard support (i.e., private key on a smartcard), e.g., with openssl
537 # engine.
538 CONFIG_SMARTCARD=y
539 # Select control interface backend for external programs, e.g, wpa_cli:
540 # unix = UNIX domain sockets (default for Linux/*BSD)
541 # udp = UDP sockets using localhost (127.0.0.1)
542 # named_pipe = Windows Named Pipe (default for Windows)
543 # y = use default (backwards compatibility)
544 # If this option is commented out, control interface is not included in the
545 # build.
546 CONFIG_CTRL_IFACE=y
547 # Select configuration backend:
548 # file = text file (e.g., wpa_supplicant.conf; note: the configuration file
549 # path is given on command line, not here; this option is just used to
550 # select the backend that allows configuration files to be used)
551 # winreg = Windows registry (see win_example.reg for an example)
552 CONFIG_BACKEND=file
553 # PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
554 CONFIG_PEERKEY=y
555 # Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
556 CONFIG_DEBUG_FILE=y
557 LIBNL=$(ROOTFS)
558 CFLAGS += -I$(LIBNL)/include
559 LIBS += -L$(LIBNL)/lib -lssl -lcrypto -ldl
560 LIBS_p += -L$(LIBNL)/lib -lssl -lcrypto -ldl
561 # for p2p
562 CONFIG_P2P=y
563 CONFIG_AP=y
564 wpa_sup_defconfig
565 }
567 function wpa_supplicant ()
568 {
569 stage=$1
570 if [ x"$stage" = x"build" -o x"$stage" = "xall" ]
571 then
572 cd ${WORK_SPACE}/hostap/wpa_supplicant
573 make clean
574 make_wpa_sup_defconfig
575 make || exit 1
576 fi
577 if [ x"$stage" = x"install" -o x"$stage" = "xall" ]
578 then
579 cd ${WORK_SPACE}/hostap/wpa_supplicant
580 make install || exit 1
581 for i in wpa_supplicant wpa_cli wpa_passphrase; do cp $i ${ROOTFS}/usr/sbin//$i || exit 1; done
582 fi
583 cd $WORK_SPACE
584 }
586 function bridge ()
587 {
588 stage=$1
589 if [ x"$stage" = x"download" -o x"$stage" = "xall" ]
590 then
591 download "http://downloads.sourceforge.net/project/bridge/bridge/bridge-utils-1.5.tar.gz" "bridge-utils-1.5.tar.gz"
592 tar -xvzf bridge-utils-1.5.tar.gz
593 cd ${WORK_SPACE}/bridge-utils-1.5
594 autoconf
595 ./configure --prefix=${ROOTFS} CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld RANLIB=${CROSS_COMPILE}ranlib --host=arm-linux
596 if [ $? != 0 ]
597 then
598 echo "bridge failed to be configured"
599 exit 1
600 fi
601 fi
602 if [ x"$stage" = "xbuild" -o x"$stage" = "xall" ]
603 then
604 cd ${WORK_SPACE}/bridge-utils-1.5
605 make || exit 1
606 fi
607 if [ x"$stage" = "xinstall" -o x"$stage" = "xall" ]
608 then
609 cd ${WORK_SPACE}/bridge-utils-1.5
610 make install
611 cp ./brctl/brctl ${ROOTFS}/usr/sbin/ || exit 1
612 fi
613 if [ x"$stage" = "xclean" ]
614 then
615 cd $WORK_SPACE/bridge-utils-1.5
616 # make uninstall
617 cd .. && rm -rf bridge-utils-1.5
618 fi
619 cd $WORK_SPACE
620 }
624 function usage ()
625 {
626 echo "This script compiles one of following utilities: libnl, openssl, hostapd, wpa_supplicant,wl12xx_modules,firmware,crda,calibrator"
627 echo "by calling specific utility name and action."
628 echo "In case the options is 'all' all utilities will be downloaded and installed on root file system."
629 echo "File setup-env contains all required environment variables, for example:"
630 echo " ROOTFS=<path to target root file system>."
631 echo "Part of operations requires root access."
632 echo "Usage: `basename $ME` target <libnl"
633 echo " openssl"
634 echo " hostapd"
635 echo " wpa_supplicant"
636 echo " wl12xx_modules"
637 echo " firmware"
638 echo " crda"
639 echo " bridge"
640 echo " calibrator> action <download|build|install>"
641 echo " all"
642 echo " clean-all"
643 }
645 function check_libs()
646 {
647 local openssl=`pkg-config --exists openssl`
648 local libnl=`pkg-config --exists libnl-2.0`
649 package=$1
651 if [ $openssl -ne 0 -o $libnl -ne 0 ]
652 then
653 echo "Cannot build $1: openssl and libnl should be installed first."
654 exit 1
655 fi
656 }
657 function package_dir_exists()
658 {
659 if [ -d "$1" ]
660 then
661 echo "Package $2 already downloaded at: $1"
662 return 1
663 fi
664 return 0
665 }
666 function check_env()
667 {
668 [ -e ${WORK_SPACE}/.check_env.stamp ] && return 0
669 which dpkg 2>&1>/dev/null || return 0
670 err=0
671 ret=0
672 packages="python python-m2crypto bash bison flex perl bc corkscrew"
673 for p in ${packages}
674 do
675 echo -n "Checking ${p}..."
676 present=`dpkg --get-selections ${p} 2>/dev/null | awk '{print $1}'`
677 [ x"${present}" != x"${p}" ] && echo "Package ${p} is not found. Please run 'apt-get install ${p}' to install it." && err=1 && ret=1
678 [ ${err} -ne 1 ] && echo "OK"
679 err=0
680 done
681 return ${ret}
682 }
684 ############################# MAIN ##############################################
685 # First building environment should be checked
686 check_env || exit 1
687 if [ -z $CROSS_COMPILE ]
688 then
689 #lets find some
690 tool_path=`which arm-none-linux-gnueabi-gcc`
691 if [ $? -ne 0 ]
692 then
693 echo "No tool chain is found"
694 exit 1
695 fi
696 export CROSS_COMPILE=`dirname $tool_path`/arm-none-linux-gnueabi-
697 fi
699 if [ -z $KLIB_BUILD ]
700 then
701 echo "Path to kernel sources has to be defined"
702 exit 1
703 fi
705 if [ -z $ROOTFS ]
706 then
707 echo "No path to root file system"
708 exit 1
709 fi
710 argc=$#
711 if [ $argc -lt 1 ]
712 then
713 usage
714 exit 1
715 elif [ $argc -eq 1 ]
716 then
717 if [ x"$1" != x"all" -a x"$1" != x"clean-all" ]
718 then
719 usage
720 exit 1
721 else
722 package="$1"
723 fi
724 fi
726 if [ $argc -eq 2 ]
727 then
728 package=$1
729 stage=$2
730 fi
731 if [ ! -d $WORK_SPACE ]
732 then
733 mkdir -p $WORK_SPACE
734 touch ${WORK_SPACE}/.check_env.stamp
735 fi
736 cd $WORK_SPACE
738 case $package in
739 libnl)
740 case $stage in
741 download )
742 package_dir_exists ${WORK_SPACE}/libnl-2.0 libnl-2 && libnl "download"
743 ;;
744 build)
745 package_dir_exists ${WORK_SPACE}/libnl-2.0 libnl-2
746 if [ ! $? ]
747 then
748 libnl "download"
749 fi
750 cd ${WORK_SPACE}/libnl-2.0
751 libnl "build"
752 ;;
753 install)
754 package_dir_exists ${WORK_SPACE}/libnl-2.0 libnl-2
755 if [ ! $? ]
756 then
757 libnl "all" && exit
758 else
759 cd ${WORK_SPACE}/libnl-2.0
760 libnl "install"
761 fi
762 ;;
763 all)
764 package_dir_exists ${WORK_SPACE}/libnl-2.0 libnl-2 || rm -rf libnl-2.0
765 libnl "all"
766 ;;
767 *)
768 echo "Error: illegal action for libnl"
769 exit 1
770 esac
771 ;;
772 openssl)
773 case $stage in
774 download )
775 package_dir_exists ${WORK_SPACE}/openssl-1.0.0d openssl || exit 1
776 openssl "download"
777 ;;
778 build)
779 package_dir_exists ${WORK_SPACE}/openssl-1.0.0d openssl
780 if [ ! $? ]
781 then
782 openssl "download"
783 fi
784 cd ${WORK_SPACE}/openssl-1.0.0d
785 openssl "build"
786 ;;
787 install)
788 package_dir_exists ${WORK_SPACE}/openssl-1.0.0d openssl
789 test [ ! $? ] && openssl "all" && exit 0
790 cd ${WORK_SPACE}/openssl-1.0.0d
791 openssl "install"
792 ;;
793 all)
794 package_dir_exists ${WORK_SPACE}/openssl-1.0.0d openssl || rm -rf openssl-1.0.0d
795 openssl "all"
796 ;;
797 esac
798 ;;
799 iw)
800 case $stage in
801 download )
802 package_dir_exists ${WORK_SPACE}/iw iw || exit 1
803 iw "download"
804 ;;
805 build)
806 package_dir_exists ${WORK_SPACE}/iw iw
807 [ ! $? ] && iw "download"
808 check_libs iw
809 iw "build"
810 ;;
811 install)
812 package_dir_exists ${WORK_SPACE}/iw iw
813 [ ! $? ] && iw "donwload"
814 [ ! -x ${WORK_SPACE}/iw/iw ] && iw "build"
815 iw "install"
816 ;;
817 all)
819 package_dir_exists ${WORK_SPACE}/iw iw || rm -rf ${WORK_SPACE}/iw
820 iw "all"
821 ;;
822 *)
823 echo "Error: illegal action for iw"
824 exit 1
825 ;;
826 esac
827 ;;
828 hostapd)
829 case $stage in
830 download)
831 package_dir_exists ${WORK_SPACE}/hostap hostapd || exit 1
832 hostap "download"
833 ;;
834 build)
835 if [ ! -d ${WORK_SPACE}/hostap ]
836 then
837 hostap "download"
838 fi
839 cd ${WORK_SPACE}/hostap
840 hostap "build"
841 ;;
842 install)
843 if [ ! -d ${WORK_SPACE}/hostap ]
844 then
845 hostap "download"
846 fi
847 if [ ! -e ${WORK_SPACE}/hostap/hostapd/hostapd ]
848 then
849 hostap "build"
850 fi
851 hostap "install"
852 ;;
853 all)
854 package_dir_exists ${WORK_SPACE}/hostap hostapd || rm -rf ${WORK_SPACE}/hostap
855 hostap "all"
856 ;;
857 *)
858 echo "Error: illegal action for hostapd"
859 exit 1
860 ;;
861 esac
863 ;;
864 wpa_supplicant)
865 case $stage in
866 download)
867 package_dir_exists ${WORK_SPACE}/hostap wpa_supplicant || exit 1
868 hostap "download"
869 ;;
870 build)
871 if [ ! -e ${WORK_SPACE}/hostap ]
872 then
873 hostap "download"
874 fi
875 wpa_supplicant "build"
876 ;;
877 install)
878 if [ ! -e ${WORK_SPACE}/hostap ]
879 then
880 hostap "download"
881 fi
882 if [ ! -e ${WORK_SPACE}/hostap/wpa_supplicant/wpa_supplicant ]
883 then
884 wpa_supplicant "build"
885 fi
886 wpa_supplicant "install"
887 ;;
888 *)
889 echo "Error: illegal action for hostapd"
890 exit 1
891 ;;
892 esac
893 ;;
894 wl12xx_modules)
895 case $stage in
896 download)
897 package_dir_exists ${WORK_SPACE}/compat-wireless compat-wireless || exit 1
898 compat-wireless "download"
899 ;;
900 build)
901 if [ ! -d ${WORK_SPACE}/compat-wireless ]
902 then
903 compat-wireless "download"
904 fi
905 cd ${WORK_SPACE}/compat-wireless
906 compat-wireless "build"
907 ;;
908 install)
909 if [ ! -d ${WORK_SPACE}/compat-wireless ]
910 then
911 compat-wireless "all"
912 else
913 cd ${WORK_SPACE}/compat-wireless
914 compat-wireless "install"
915 fi
916 ;;
917 all)
918 package_dir_exists ${WORK_SPACE}/compat-wireless compat-wireless || rm -rf ${WORK_SPACE}/compat-wireless
919 compat-wireless "all"
920 ;;
921 *)
922 echo "Error: illegal action for wl12xx_modules"
923 exit 1
924 ;;
925 esac
927 ;;
928 calibrator)
929 case $stage in
930 download)
931 if [ -d ${WORK_SPACE}/ti-utils ]
932 then
933 echo "Calibrator is part of ti-utils package that already exists at: ${WORK_SPACE}/ti-utils"
934 exit 0
935 fi
936 ti-utils "download"
937 ;;
938 build)
939 if [ ! -d ${WORK_SPACE}/ti-utils ]
940 then
941 ti-utils "download"
942 fi
943 cd ${WORK_SPACE}/ti-utils
944 ti-utils "build"
945 ;;
946 install)
947 if [ ! -d ${WORK_SPACE}/ti-utils ]
948 then
949 ti-utils "all"
950 else
951 if [ ! -e ${WORK_SPACE}/ti-utils/calibrator ]
952 then
953 ti-utils "build"
954 fi
955 ti-utils "install"
956 fi
957 ;;
958 all)
959 ti-utils "all"
960 ;;
961 *)
962 echo "Error: illegal action for calibrator"
963 exit 1
964 ;;
965 esac
966 ;;
967 firmware)
968 if [ x$stage = "xclean" -o x$stage = "xinstall" -o x$stage = "xall" ]
969 then
971 if [ ! -d ti-utils/ ]
972 then
973 ti-utils "download"
974 fi
976 ti-utils-firmware $2
977 else
978 echo "illegal action for firmware"
979 exit 1
980 fi
981 ;;
982 crda)
983 case $stage in
984 download)
985 package_dir_exists ${WORK_SPACE}/crda-1.1.1 crda || exit 1
986 crda "download"
987 ;;
988 build)
989 if [ ! -d ${WORK_SPACE}/crda-1.1.1 ]
990 then
991 crda "download"
992 fi
993 cd ${WORK_SPACE}/crda-1.1.1
994 crda "build"
995 ;;
996 install)
997 if [ ! -d ${WORK_SPACE}/crda-1.1.1 ]
998 then
999 crda "all"
1000 else
1001 cd ${WORK_SPACE}/crda-1.1.1
1002 crda "install"
1003 fi
1004 ;;
1005 all)
1006 package_dir_exists ${WORK_SPACE}/crda-1.1.1 crda || rm -rf ${WORK_SPACE}/crda-1.1.1
1007 crda "all"
1008 ;;
1009 *)
1010 echo "Error: illegal action for crda"
1011 exit 1
1012 ;;
1013 esac
1014 ;;
1015 bridge)
1016 case $stage in
1017 download)
1018 package_dir_exists ${WORK_SPACE}/bridge-utils-1.5 bridge || exit 1
1019 bridge "download"
1020 ;;
1021 build)
1022 if [ ! -d ${WORK_SPACE}/bridge-utils-1.5 ]
1023 then
1024 bridge "download"
1025 fi
1026 cd ${WORK_SPACE}/bridge-utils-1.5
1027 bridge "build"
1028 ;;
1029 install)
1030 if [ ! -d ${WORK_SPACE}/bridge-utils-1.5 ]
1031 then
1032 bridge "all"
1033 else
1034 cd ${WORK_SPACE}/bridge-utils-1.5
1035 bridge "install"
1036 fi
1037 ;;
1038 all)
1039 package_dir_exists ${WORK_SPACE}/bridge-utils-1.5 bridge || rm -rf ${WORK_SPACE}/bridge-utils-1.5
1040 bridge "all"
1041 ;;
1042 *)
1043 echo "Error: illegal action for bridge"
1044 exit 1
1045 ;;
1046 esac
1047 ;;
1048 all)
1049 echo "bridge ***********************************************************************************"
1050 bridge "all"
1051 echo "libnl ***********************************************************************************"
1052 libnl "all"
1053 echo "openssl ***********************************************************************************"
1054 openssl "all"
1055 echo "iw ***********************************************************************************"
1056 iw "all"
1057 echo "hostap ***********************************************************************************"
1058 hostap "all"
1059 echo "wpa_supplicant ***********************************************************************************"
1060 wpa_supplicant "all"
1061 echo "crda ***********************************************************************************"
1062 crda "all"
1063 echo "ti-utils ***********************************************************************************"
1064 ti-utils "all"
1065 echo "ti-utils-firmware ***********************************************************************************"
1066 ti-utils-firmware "all"
1067 echo "compat-wireless ***********************************************************************************"
1068 compat-wireless "all"
1069 ;;
1070 clean-all)
1071 bridge "clean"
1072 compat-wireless "clean"
1073 ti-utils "clean"
1074 crda "clean"
1075 hostap "clean"
1076 iw "clean"
1077 openssl "clean"
1078 libnl "clean"
1079 ti-utils-firmware "clean"
1080 ;;
1081 *)
1082 usage
1083 exit 1
1084 esac