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