]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - wilink8-wlan/build-utilites.git/blob - build_wl18xx.sh
687d1a788bb099cc425c6789cc96cc71f8e59ba6
[wilink8-wlan/build-utilites.git] / build_wl18xx.sh
1 export PATH__ROOT=`pwd`    
2 . configuration.sh    
3 . setup-env
4 # Pretty colors
5 GREEN="\033[01;32m"
6 YELLOW="\033[01;33m"
7 NORMAL="\033[00m"
8 BLUE="\033[34m"
9 RED="\033[31m"
10 PURPLE="\033[35m"
11 CYAN="\033[36m"
12 UNDERLINE="\033[02m"
14 function print_highlight()
15 {      
16     echo -e "   ${YELLOW}***** $1 ***** ${NORMAL} "
17 }
19 function usage ()
20 {
21     echo ""
22     echo "This script compiles one/all of the following utilities: kernel, libnl, openssl, hostapd, wpa_supplicant,wl18xx_modules,firmware,crda,calibrator"
23     echo "by calling specific utility name and action."
24     echo ""
25     echo " Usage: ./wl18xx_build.sh init         <head|TAG>  [ Update w/o build        ] "
26     echo "                          update       <head|TAG>  [ Update & build          ] "
27     echo "                          rebuild                  [ Build w/o update        ] "
28     echo "                          clean                    [ Clean, Update & build   ] "
29     echo "                              "
30     echo " Building a specific module usage "
31     echo "       ./build.sh    hostapd "
32     echo "                     wpa_supplicant "
33     echo "                     modules(driver) "
34     echo "                     firmware "
35     echo "                     scripts "
36     echo "                     calibrator "
37     echo "                     wlconf "
38     echo "                     uimage "
39     echo "                     openssl "
40     echo "                     libnl "
41     echo "                     crda "
43     exit 1
44 }
46 function assert_no_error()
47 {
48         if [ $? -ne 0 ]; then
49                 echo "****** ERROR $? $@*******"
50                 exit 1
51         fi
52         echo "****** $1 *******"
53 }
55 function repo_id()
56 {
57         i="0"
58         while [ $i -lt ${#repositories[@]} ]; do
59                 [ $1 == "${repositories[i]}" ] && echo $i
60                 i=$[$i + 3]
61         done
62 }
64 function repo_url()
65 {
66         echo "${repositories[`repo_id $1` + 1]}"
67 }
69 function repo_branch()
70 {
71         echo "${repositories[`repo_id $1` + 2]}"
72 }
74 function path()
75 {
76         i="0"
77         while [ $i -lt "${#paths[@]}" ]; do
78                 [ $1 == "${paths[i]}" ] && echo "${paths[i + 1]}"
79                 i=$[$i + 2]
80         done
81 }
83 function set_path()
84 {
85         i="0"    
86         while [ $i -lt "${#paths[@]}" ]; do
87                 [ $1 == "${paths[i]}" ] && paths[i+1]=$2    
88                 i=$[$i + 2]
89         done
90 }
92 function repo_path()
93 {
94         echo `path src`/$1
95 }
97 function cd_path()
98 {
99         cd `path $1`
102 function cd_repo()
104         cd `repo_path $1`
107 function cd_back()
109         cd - > /dev/null
112 function read_kernel_version()
114         filename=`repo_path kernel`/Makefile
116         if [ ! -f $filename ]
117         then
118             KERNEL_VERSION=0
119             KERNEL_PATCHLEVEL=0
120             KERNEL_SUBLEVEL=0
121             echo "No Makefile was found. Kernel version was set to default." 
122         else 
123             exec 6< $filename
124             read version <&6
125             read patchlevel <&6
126             read sublevel <&6
127             exec 6<&-
129             KERNEL_VERSION=$(echo $version|sed 's/[^0-9]//g')
130             KERNEL_PATCHLEVEL=$(echo $patchlevel|sed 's/[^0-9]//g')
131             KERNEL_SUBLEVEL=$(echo $sublevel|sed 's/[^0-9]//g')
132             echo "Makefile was found. Kernel version was set to $KERNEL_VERSION.$KERNEL_PATCHLEVEL.$KERNEL_SUBLEVEL." 
133         fi
136 #----------------------------------------------------------j
137 function setup_environment()
139     if [ ! -e setup-env ]
140     then
141         echo "No setup-env"
142         exit 1
143     fi
144     
145     #if a rootfs path is set - replace the default.
146     if [[ "$ROOTFS" != "DEFAULT" ]]
147     then            
148         echo " Changing ROOTFS path to $ROOTFS"
149         set_path filesystem $ROOTFS
150         [ ! -d $ROOTFS ] && echo "Error ROOTFS: $ROOTFS dir does not exist" && exit 1
151     fi   
152     #if no toolchain path is set - download it.
153     if [[ "$TOOLCHAIN_PATH" == "DEFAULT" ]]
154     then            
155         echo " Setting TOOLCHAIN_PATH path to default"
156         export TOOLCHAIN_PATH=`path toolchain`/arm/bin
157         DEFAULT_TOOLCHAIN=1
158     fi   
160     #if no kernel path is set - download it.
161     if [[ "$KERNEL_PATH" == "DEFAULT" ]]
162     then            
163         echo " Setting KERNEL_PATH path to default"
164         export KERNEL_PATH=`repo_path kernel`
165         DEFAULT_KERNEL=1
166     else 
167         echo " Using user defined kernel"                        
168         [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
169     fi  
170     
171         export PROCESSORS_NUMBER=$(egrep '^processor' /proc/cpuinfo | wc -l)
172         export PKG_CONFIG_PATH=`path filesystem`/lib/pkgconfig
173         export INSTALL_PREFIX=`path filesystem`
174         export LIBNL_PATH=`repo_path libnl`     
175         export KLIB=${KERNEL_PATH}
176         export KLIB_BUILD=${KERNEL_PATH}
177         export GIT_TREE=`repo_path driver`
178         export PATH=$TOOLCHAIN_PATH:$PATH
179     
182 function setup_filesystem_skeleton()
184         mkdir -p `path filesystem`/usr/bin
185         mkdir -p `path filesystem`/etc
186         mkdir -p `path filesystem`/usr/lib/crda
187         mkdir -p `path filesystem`/lib/firmware/ti-connectivity
188         mkdir -p `path filesystem`/usr/share/wl18xx
189         mkdir -p `path filesystem`/usr/sbin/wlconf
190         mkdir -p `path filesystem`/usr/sbin/wlconf/official_inis
191         mkdir -p `path filesystem`/etc/wireless-regdb/pubkeys
194 function setup_directories()
196         i="0"
197         while [ $i -lt ${#paths[@]} ]; do
198                 mkdir -p ${paths[i + 1]}
199                 i=$[$i + 2]
200         done
201         setup_filesystem_skeleton
205 function setup_repositories()
207         i="0"
208         while [ $i -lt ${#repositories[@]} ]; do
209                 url=${repositories[$i + 1]}
210                 name=${repositories[$i]}
211         echo -e "${NORMAL}Cloning into: ${GREEN} $name ${NORMAL}"        
212         #Skip kernel clone if it was user defined 
213                 [ "$name" != "kernel" -o "$DEFAULT_KERNEL" ] && [ ! -d `repo_path $name` ] && git clone $url `repo_path $name`
214                 i=$[$i + 3]
215         done        
218 function setup_branches()
220         i="0"    
221         while [ $i -lt ${#repositories[@]} ]; do
222                 name=${repositories[$i]}
223                 url=${repositories[$i + 1]}
224         branch=${repositories[$i + 2]}   
225         checkout_type="branch"       
226         #for all the openlink repo. we use a tag if provided.               
227         [ "$name" == "kernel" ] && [ -z "$DEFAULT_KERNEL" ] && i=$[$i + 3] && continue
228         cd_repo $name   
229         echo -e "\n${NORMAL}Checking out branch ${GREEN}$branch  ${NORMAL}in repo ${GREEN}$name ${NORMAL} "
230                 git checkout $branch        
231         git fetch origin
232         git fetch origin --tags  
233         if [[ "$url" == *git.ti.com* ]]
234         then            
235            [[ -n $RESET ]] && echo -e "${PURPLE}Reset to latest in repo ${GREEN}$name ${NORMAL} branch  ${GREEN}$branch ${NORMAL}"  && git reset --hard origin/$branch
236            [[ -n $USE_TAG ]] && git reset --hard $USE_TAG  && echo -e "${NORMAL}Reset to tag ${GREEN}$USE_TAG   ${NORMAL}in repo ${GREEN}$name ${NORMAL} "            
237         fi        
238                 cd_back
239                 i=$[$i + 3]
240         done
243 function setup_toolchain()
245         if [ ! -f `path downloads`/arm-toolchain.tar.bz2 ]; then
246         echo "Setting toolchain"
247                 wget ${toolchain[0]} -O `path downloads`/arm-toolchain.tar.bz2
248                 tar -xjf `path downloads`/arm-toolchain.tar.bz2 -C `path toolchain`
249                 mv `path toolchain`/* `path toolchain`/arm
250         fi
253 function build_uimage()
255     cd_repo kernel
256         [ -z $NO_CONFIG ] && cp `path configuration`/kernel_$KERNEL_VERSION.$KERNEL_PATCHLEVEL.config `repo_path kernel`/.config
257         [ -z $NO_CLEAN ] && make clean
258         [ -z $NO_CLEAN ] && assert_no_error
259        
260     make -j${PROCESSORS_NUMBER} uImage
261         
262     #TODO: Add support for kernel compilation with dtb file integrated to uImage:
263     #LOADADDR=0x80008000 make -j${PROCESSORS_NUMBER} uImage.am335x-evm
264                 
265     if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
266     then
267         cp `repo_path kernel`/arch/arm/boot/uImage `path tftp`/uImage
268     else                
269         make -j${PROCESSORS_NUMBER} am335x-evm.dtb
270         cp `repo_path kernel`/arch/arm/boot/zImage `path tftp`/zImage
271         cp `repo_path kernel`/arch/arm/boot/dts/am335x-evm.dtb `path tftp`/am335x-evm.dtb
272     fi
273         
274         assert_no_error
275         cd_back
278 function generate_compat()
280         cd_repo backports
281         python ./gentree.py --clean `repo_path driver` `path compat_wireless`
282         cd_back
285 function build_modules()
287     generate_compat
288         cd_repo compat_wireless
289         if [ -z $NO_CLEAN ]; then
290                 make clean
291         fi
292         make defconfig-wl18xx
293     make -j${PROCESSORS_NUMBER} 
294         assert_no_error
295         find . -name \*.ko -exec cp {} `path debugging`/ \;
296         find . -name \*.ko -exec ${CROSS_COMPILE}strip -g {} \;
297     
298         make -C ${KERNEL_PATH} M=`pwd` "INSTALL_MOD_PATH=`path filesystem`" modules_install
299         assert_no_error
300         #chmod -R 0777 ${PATH__FILESYSTEM}/lib/modules/
301         cd_back
304 function build_openssl()
306         cd_repo openssl
307         [ -z $NO_CONFIG ] && ./Configure s/compiler:gcc
308         [ -z $NO_CLEAN ] && make clean
309         [ -z $NO_CLEAN ] && assert_no_error
310         make
311         assert_no_error
312         make install_sw
313         assert_no_error
314         cd_back
317 function build_libnl()
319         cd_repo libnl
320         [ -z $NO_CONFIG ] && ./autogen.sh
321         [ -z $NO_CONFIG ] && ./configure --prefix=`path filesystem` --host=${ARCH} CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar
322         [ -z $NO_CLEAN ] && make clean
323         [ -z $NO_CLEAN ] && assert_no_error
324         make
325         assert_no_error
326         make install
327         assert_no_error
328         cd_back
331 function build_wpa_supplicant()
333         cd `repo_path hostap`/wpa_supplicant
334         [ -z $NO_CONFIG ] && cp android.config .config
335         CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
336         assert_no_error
337         CONFIG_LIBNL32=y DESTDIR=`path filesystem` CFLAGS+="-I`path filesystem`/usr/local/ssl/include -I`repo_path libnl`/include" LIBS+="-L`path filesystem`/lib -L`path filesystem`/usr/local/ssl/lib -lssl -lcrypto -lm -ldl -lpthread" LIBS_p+="-L`path filesystem`/lib -L`path filesystem`/usr/local/ssl/lib -lssl -lcrypto -lm -ldl -lpthread" make -j${PROCESSORS_NUMBER} CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld AR=${CROSS_COMPILE}ar
338         assert_no_error
339         CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
340         assert_no_error
341         cd_back    
342     cp `repo_path scripts_download`/conf/*_supplicant.conf  `path filesystem`/etc/
345 function build_hostapd()
346 {              
347     cd `repo_path hostap`/hostapd
348         [ -z $NO_CONFIG ] && cp android.config .config
349         CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
350         assert_no_error
351         CONFIG_LIBNL32=y DESTDIR=`path filesystem` CFLAGS+="-I`path filesystem`/usr/local/ssl/include -I`repo_path libnl`/include" LIBS+="-L`path filesystem`/lib -L`path filesystem`/usr/local/ssl/lib -lssl -lcrypto -lm -ldl -lpthread" LIBS_p+="-L`path filesystem`/lib -L`path filesystem`/usr/local/ssl/lib -lssl -lcrypto -lm -ldl -lpthread" make -j${PROCESSORS_NUMBER} CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld AR=${CROSS_COMPILE}ar
352         assert_no_error
353         CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
354         assert_no_error
355         cd_back
356     cp `repo_path scripts_download`/conf/hostapd.conf  `path filesystem`/etc/    
359 function build_crda()
360 {       
361         cp `repo_path wireless_regdb`/regulatory.bin `path filesystem`/usr/lib/crda/regulatory.bin
362         cp `repo_path wireless_regdb`/linville.key.pub.pem `path filesystem`/etc/wireless-regdb/pubkeys/
363     cd_repo crda
364         
365         [ -z $NO_CLEAN ] && DESTDIR=`path filesystem` make clean
366         [ -z $NO_CLEAN ] && assert_no_error
367         PKG_CONFIG_LIBDIR="`path filesystem`/lib/pkgconfig" PKG_CONFIG_PATH="`path filesystem`/usr/local/ssl/lib/pkgconfig" DESTDIR=`path filesystem` CFLAGS+="-I`path filesystem`/usr/local/ssl/include -I`path filesystem`/include -L`path filesystem`/usr/local/ssl/lib -L`path filesystem`/lib" LDLIBS+=-lpthread V=1 USE_OPENSSL=1 make -j${PROCESSORS_NUMBER} all_noverify CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld AR=${CROSS_COMPILE}ar
368         assert_no_error
369         DESTDIR=`path filesystem` make install
370         assert_no_error
371         cd_back
374 function build_calibrator()
376         cd_repo ti_utils
377         [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
378         [ -z $NO_CLEAN ] && assert_no_error
379         NLVER=3 NLROOT=`repo_path libnl`/include NFSROOT=`path filesystem` LIBS+=-lpthread make
380         assert_no_error
381         NFSROOT=`path filesystem` make install
382         #assert_no_error
383         cd_back
386 function build_wlconf()
388         files_to_copy="dictionary.txt struct.bin default.conf wl18xx-conf-default.bin README example.conf example.ini configure-device.sh"
389         cd `repo_path ti_utils`/wlconf
390         if [ -z $NO_CLEAN ]; then
391                 NFSROOT=`path filesystem` make clean
392                 assert_no_error
393                 for file_to_copy in $files_to_copy; do
394                         rm -f `path filesstem`/usr/sbin/wlconf/$file_to_copy
395                 done
396                 rm -f `path filesystem`/usr/sbin/wlconf/official_inis/*
397         fi
398         NFSROOT=`path filesystem` make CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld
399         assert_no_error
401         # install
402         cp -f `repo_path ti_utils`/wlconf/wlconf `path filesystem`/usr/sbin/wlconf
403         chmod 755 `path filesystem`/usr/sbin/wlconf
404         for file_to_copy in $files_to_copy; do
405                 cp $file_to_copy `path filesystem`/usr/sbin/wlconf/$file_to_copy
406         done
407         cp official_inis/* `path filesystem`/usr/sbin/wlconf/official_inis/
408         cd_back
411 function build_fw_download()
413         cp `repo_path fw_download`/*.bin `path filesystem`/lib/firmware/ti-connectivity
417 function build_scripts_download()
419         cd_repo scripts_download
420         echo "Copying scripts"
421         scripts_download_path=`repo_path scripts_download`
422         for script_dir in `ls $scripts_download_path`
423         do
424                 echo "Copying everything from ${script_dir} to `path filesystem`/usr/share/wl18xx directory"
425                 cp -rf `repo_path scripts_download`/${script_dir}/* `path filesystem`/usr/share/wl18xx
426         done
427         cd_back
430 function clean_kernel()
432         echo "Cleaning kernel folder"
433         cd_repo kernel
434         git clean -fdx > /dev/null      
437 function clean_outputs()
439         echo "Cleaning outputs"   
440     rm -rf `path filesystem`/*
441     rm -f `path outputs`/${tar_filesystem[0]}
442         rm -f `path outputs`/uImage
443         
446 function build_outputs()
448         if [[ "$ROOTFS" == "DEFAULT" ]]
449     then  
450         echo "Building outputs"    
451         cd_path filesystem
452         tar cpjf `path outputs`/${tar_filesystem[0]} .
453         cd_back
454                 
455         if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
456         then
457             cp `path tftp`/uImage `path outputs`/uImage
458         else                   
459             cp `path tftp`/zImage `path outputs`/zImage
460             cp `path tftp`/am335x-evm.dtb `path outputs`/am335x-evm.dtb
461         fi              
462     fi
465 function install_outputs()
467     echo "Installing outputs"
468         tftp_path=${setup[2]}
469         sitara_left_path=${setup[5]}
470         sitara_right_path=${setup[8]}
472         cp `path outputs`/uImage ${tftp_path}
473         cp `path outputs`/${tar_filesystem[0]} $sitara_left_path
474         cp `path outputs`/${tar_filesystem[0]} $sitara_right_path
476         cd $sitara_left_path
477         tar xjf ${tar_filesystem[0]}
478         cd_back
480         cd $sitara_right_path
481         tar xjf ${tar_filesystem[0]}
482         cd_back
485 function set_files_to_verify()
487         files_to_verify=(
488         # skeleton path
489         # source path
490         # pattern in output of file
492         `path filesystem`/usr/local/sbin/wpa_supplicant
493         `repo_path hostap`/wpa_supplicant/wpa_supplicant
494         "ELF 32-bit LSB executable, ARM"
496         `path filesystem`/usr/local/bin/hostapd
497         `repo_path hostap`/hostapd/hostapd
498         "ELF 32-bit LSB executable, ARM"
500         `path filesystem`/sbin/crda
501         `repo_path crda`/crda
502         "ELF 32-bit LSB executable, ARM"
504         `path filesystem`/usr/lib/crda/regulatory.bin
505         `repo_path wireless_regdb`/regulatory.bin
506         "CRDA wireless regulatory database file"
508         `path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
509         `repo_path fw_download`/wl18xx-fw-4.bin
510         "data"
512         `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/extra/drivers/net/wireless/ti/wl18xx/wl18xx.ko
513         `path compat_wireless`/drivers/net/wireless/ti/wl18xx/wl18xx.ko
514         "ELF 32-bit LSB relocatable, ARM"
516         `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/extra/drivers/net/wireless/ti/wlcore/wlcore.ko
517         `path compat_wireless`/drivers/net/wireless/ti/wlcore/wlcore.ko
518         "ELF 32-bit LSB relocatable, ARM"
520         #`path filesystem`/usr/bin/calibrator
521         #`repo_path ti_utils`/calibrator
522         #"ELF 32-bit LSB executable, ARM"
524         `path filesystem`/usr/sbin/wlconf/wlconf
525         `repo_path ti_utils`/wlconf/wlconf
526         "ELF 32-bit LSB executable, ARM"
527         )
530 function get_tag()
532        i="0"
533        while [ $i -lt ${#repositories[@]} ]; do
534                name=${repositories[$i]}
535                url=${repositories[$i + 1]}
536         branch=${repositories[$i + 2]}
537         checkout_type="branch"
538         cd_repo $name
539         if [[ "$url" == *git.ti.com* ]]
540         then
541                 echo -e "${PURPLE}Describe of ${NORMAL} repo : ${GREEN}$name ${NORMAL} "  ;
542                 git describe
543         fi
544                cd_back
545                i=$[$i + 3]
546        done
551 function admin_tag()
553         i="0"    
554         while [ $i -lt ${#repositories[@]} ]; do
555                 name=${repositories[$i]}
556                 url=${repositories[$i + 1]}
557         branch=${repositories[$i + 2]}   
558         checkout_type="branch"              
559         cd_repo $name    
560         if [[ "$url" == *git.ti.com* ]]
561         then                                   
562                 echo -e "${PURPLE}Adding tag ${GREEN} $1 ${NORMAL} to repo : ${GREEN}$name ${NORMAL} "  ;
563                 git show --summary        
564                 read -p "Do you want to tag this commit ?" yn
565                 case $yn in
566                     [Yy]* )  git tag -a $1 -m "$1" ;
567                              git push --tags ;;
568                     [Nn]* ) echo -e "${PURPLE}Tag was not applied ${NORMAL} " ;;
569                     
570                     * ) echo "Please answer yes or no.";;
571                 esac
572            
573         fi        
574                 cd_back
575                 i=$[$i + 3]
576         done
580 function verify_skeleton()
582         echo "Verifying filesystem skeleton..."
584         set_files_to_verify
586         i="0"
587         while [ $i -lt ${#files_to_verify[@]} ]; do
588                 skeleton_path=${files_to_verify[i]}
589                 source_path=${files_to_verify[i + 1]}
590                 file_pattern=${files_to_verify[i + 2]}
591                 file $skeleton_path | grep "${file_pattern}" >/dev/null
592         if [ $? -eq 1 ]; then
593         echo -e "${RED}ERROR " $skeleton_path " Not found ! ${NORMAL}"
594         #exit
595         fi
597                 md5_skeleton=$(md5sum $skeleton_path | awk '{print $1}')
598                 md5_source=$(md5sum $source_path     | awk '{print $1}')
599                 if [ $md5_skeleton != $md5_source ]; then
600                         echo "ERROR: file mismatch"
601                         echo $skeleton_path
602                         exit 1
603                 fi
604                 i=$[$i + 3]
605         done
607         which regdbdump > /dev/null
608         if [ $? -eq 0 ]; then
609                 regdbdump `path filesystem`/usr/lib/crda/regulatory.bin > /dev/null
610                 assert_no_error
611         fi
614 function setup_workspace()
616         setup_directories       
617         setup_repositories
618         setup_branches
619     #Download toolchain only if it was not set
620     [ DEFAULT_TOOLCHAIN ] && setup_toolchain   
624 function build_all()
626     if [ -z $NO_EXTERNAL ] 
627     then        
628         [ $DEFAULT_KERNEL ] && build_uimage
629         build_openssl
630         build_libnl
631         build_crda
632     fi
633     
634     if [ -z $NO_TI ] 
635     then
636         build_modules
637         build_wpa_supplicant
638         build_hostapd   
639         build_calibrator
640         build_wlconf
641         build_fw_download
642         build_scripts_download
643     fi
644     
645     [ -z $NO_VERIFY ] && verify_skeleton
648 function setup_and_build()
650     setup_workspace
651     build_all
654 function main()
656         [[ "$1" == "-h" || "$1" == "--help"  ]] && usage
658     setup_environment
659     setup_directories
660     read_kernel_version
661     
662         case "$1" in
663                 'update')                
664         print_highlight " setting up workspace and building all "       
665                 if [  -n "$2" ]
666         then
667             print_highlight "Using tag $2 " 
668             USE_TAG=$2
669         else
670             print_highlight "Updating all to head (this will revert local changes)" 
671             RESET=1    
672         fi
673         clean_kernel
674         clean_outputs        
675         setup_workspace
676         read_kernel_version #####read kernel version again after update#####
677         build_all
678                 ;;
679         
680         'init')                
681         print_highlight " initializing workspace (w/o build) "       
682                 [[  -n "$2" ]] && echo "Using tag $2 " && USE_TAG=$2                
683         NO_BUILD=1 
684         setup_workspace
685         read_kernel_version #####read kernel version again after init#####
686                 ;;
687               
688         'clean')        
689         print_highlight " cleaning & building all "       
690         clean_outputs
691         setup_directories
692         build_all        
693                 ;;
695                 'rebuild')
696         print_highlight " building all (w/o clean) "       
697                 NO_CLEAN=1 build_all
698                 ;;
699         
700                 'openlink')
701         print_highlight " building all (w/o clean) "       
702                 NO_EXTERNAL=1 setup_and_build
703                 ;;
704         #################### Building single components #############################
705                 'kernel')
706                 print_highlight " building only Kernel "
707                 build_uimage
708                 ;;
710                 'modules')
711         print_highlight " building only Driver modules "
712                 build_modules
713                 ;;
715                 'wpa_supplicant')
716         print_highlight " building only wpa_supplicant "
717                 build_wpa_supplicant      
718                 ;;
720                 'hostapd')
721         print_highlight " building only hostapd "
722                 build_hostapd
723                 ;;
725                 'crda')
726         print_highlight " building only CRDA "
727                 build_crda
728                 ;;
729         
730         'scripts')
731         print_highlight " Copying scripts "
732                 build_scripts_download
733                 ;;
734                 
735         'utils')
736         print_highlight " building only ti-utils "
737         build_calibrator
738         build_wlconf            
739                 ;;        
740         ############################################################
741         'get_tag')
742         get_tag
743         exit
744         ;;
745                 
746         'admin_tag')        
747                 admin_tag $2
748                 ;;
749         
750         *)
751         print_highlight " building all (No clean & no source code update) "  
752                 #clean_outputs
753         NO_CLEAN=1 build_all
754                 ;;
755         esac
756         
757         [[ -z $NO_BUILD ]] && build_outputs
758         [[ -n $INSTALL_NFS ]] && install_outputs
760 main $@