build wpa_supplicant: add SYSLOG option to configuration file
[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 build all/one of the relevent wl18xx software package."
23     echo "A web guide can be found here : http://processors.wiki.ti.com/index.php/WL18xx_System_Build_Scripts"
24     echo ""
25     echo "Usage : "
26     echo ""
27     echo "Building full package : "
28     echo "        ./wl18xx_build.sh init         <head|TAG>  [ Download and Update w/o build  ] "
29     echo "                          update       <head|TAG>  [ Update to specific TAG & Build ] "
30     echo "                          clean                    [ Clean & Build                  ] "
31     echo "                          <empty>                  [ Build w/o update               ] "
32     echo ""
33     echo "Building specific component :"
34     echo "                          hostapd                  [ Clean & Build hostapd          ] "
35     echo "                          wpa_supplicant           [ Clean & Build wpa_supplicant   ] "
36     echo "                          modules                  [ Clean & Build driver modules   ] "
37     echo "                          firmware                 [ Install firmware file          ] "
38     echo "                          scripts                  [ Install scripts                ] "
39     echo "                          utils                    [ Clean & Build scripts          ] "
40     echo "                          iw                       [ Clean & Build iw               ] "
41     echo "                          openssl                  [ Clean & Build openssll         ] "
42     echo "                          libnl                    [ Clean & Build libnl            ] "
43     echo "                          crda                     [ Clean & Build crda             ] "
45     exit 1
46 }
48 function assert_no_error()
49 {
50         if [ $? -ne 0 ]; then
51                 echo "****** ERROR $? $@*******"
52                 exit 1
53         fi
54         echo "****** $1 *******"
55 }
57 function repo_id()
58 {
59         i="0"
60         while [ $i -lt ${#repositories[@]} ]; do
61                 [ $1 == "${repositories[i]}" ] && echo $i
62                 i=$[$i + 3]
63         done
64 }
66 function repo_url()
67 {
68         echo "${repositories[`repo_id $1` + 1]}"
69 }
71 function repo_branch()
72 {
73         echo "${repositories[`repo_id $1` + 2]}"
74 }
76 function path()
77 {
78         i="0"
79         while [ $i -lt "${#paths[@]}" ]; do
80                 [ $1 == "${paths[i]}" ] && echo "${paths[i + 1]}"
81                 i=$[$i + 2]
82         done
83 }
85 function set_path()
86 {
87         i="0"    
88         while [ $i -lt "${#paths[@]}" ]; do
89                 [ $1 == "${paths[i]}" ] && paths[i+1]=$2    
90                 i=$[$i + 2]
91         done
92 }
94 function repo_path()
95 {
96         echo `path src`/$1
97 }
99 function cd_path()
101         cd `path $1`
104 function cd_repo()
106         cd `repo_path $1`
109 function cd_back()
111         cd - > /dev/null
114 function check_for_build_updates()
116         count=`git status -uno | grep behind | wc -l`
117         if [ $count -ne 0 ]
118         then
119                 echo ""
120                 echo "*** Please note, there is an updated build script avilalable ***"
121                 echo "*** Use 'git pull' to get the latest update. ***" 
122                 echo ""
123                 sleep 5
124         fi
127 function read_kernel_version()
129         filename=$KERNEL_PATH/Makefile
131         if [ ! -f $filename ]
132         then
133             KERNEL_VERSION=0
134             KERNEL_PATCHLEVEL=0
135             KERNEL_SUBLEVEL=0
136             echo "No Makefile was found. Kernel version was set to default." 
137         else 
138             exec 6< $filename
139             read version <&6
140             read patchlevel <&6
141             read sublevel <&6
142             exec 6<&-
144             KERNEL_VERSION=$(echo $version|sed 's/[^0-9]//g')
145             KERNEL_PATCHLEVEL=$(echo $patchlevel|sed 's/[^0-9]//g')
146             KERNEL_SUBLEVEL=$(echo $sublevel|sed 's/[^0-9]//g')
147             echo "Makefile was found. Kernel version was set to $KERNEL_VERSION.$KERNEL_PATCHLEVEL.$KERNEL_SUBLEVEL." 
148         fi
151 #----------------------------------------------------------j
152 function setup_environment()
154     if [ ! -e setup-env ]
155     then
156         echo "No setup-env"
157         exit 1
158     fi
159     
160     #if a rootfs path is set - replace the default.
161     if [[ "$ROOTFS" != "DEFAULT" ]]
162     then            
163         echo " Changing ROOTFS path to $ROOTFS"
164         set_path filesystem $ROOTFS
165         [ ! -d $ROOTFS ] && echo "Error ROOTFS: $ROOTFS dir does not exist" && exit 1
166     fi   
167     #if no toolchain path is set - download it.
168     if [[ "$TOOLCHAIN_PATH" == "DEFAULT" ]]
169     then            
170         echo " Setting TOOLCHAIN_PATH path to default"
171         export TOOLCHAIN_PATH=`path toolchain`/arm/bin
172         DEFAULT_TOOLCHAIN=1
173     fi   
175     #if no kernel path is set - download it.
176     if [[ "$KERNEL_PATH" == "DEFAULT" ]]
177     then            
178         echo " Setting KERNEL_PATH path to default"
179         export KERNEL_PATH=`repo_path kernel`
180         DEFAULT_KERNEL=1
181     else 
182         echo " Using user defined kernel"                        
183         [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
184     fi  
185     
186         export PROCESSORS_NUMBER=$(egrep '^processor' /proc/cpuinfo | wc -l)
187         export PKG_CONFIG_PATH=`path filesystem`/lib/pkgconfig
188         export INSTALL_PREFIX=`path filesystem`
189         export LIBNL_PATH=`repo_path libnl`     
190         export KLIB=`path filesystem`
191         export KLIB_BUILD=${KERNEL_PATH}
192         export GIT_TREE=`repo_path driver`
193         export PATH=$TOOLCHAIN_PATH:$PATH
194     
197 function setup_filesystem_skeleton()
199         mkdir -p `path filesystem`/usr/bin
200         mkdir -p `path filesystem`/etc
201         mkdir -p `path filesystem`/usr/lib/crda
202         mkdir -p `path filesystem`/lib/firmware/ti-connectivity
203         mkdir -p `path filesystem`/usr/share/wl18xx
204         mkdir -p `path filesystem`/usr/sbin/wlconf
205         mkdir -p `path filesystem`/usr/sbin/wlconf/official_inis
206         mkdir -p `path filesystem`/etc/wireless-regdb/pubkeys
209 function setup_directories()
211         i="0"
212         while [ $i -lt ${#paths[@]} ]; do
213                 mkdir -p ${paths[i + 1]}
214                 i=$[$i + 2]
215         done
216         setup_filesystem_skeleton
220 function setup_repositories()
222         i="0"
223         while [ $i -lt ${#repositories[@]} ]; do
224                 url=${repositories[$i + 1]}
225                 name=${repositories[$i]}
226         echo -e "${NORMAL}Cloning into: ${GREEN} $name ${NORMAL}"        
227         #Skip kernel clone if it was user defined 
228                 [ "$name" != "kernel" -o "$DEFAULT_KERNEL" ] && [ ! -d `repo_path $name` ] && git clone $url `repo_path $name`
229                 i=$[$i + 3]
230         done        
233 function setup_branches()
235         i="0"    
236         while [ $i -lt ${#repositories[@]} ]; do
237                 name=${repositories[$i]}
238                 url=${repositories[$i + 1]}
239         branch=${repositories[$i + 2]}   
240         checkout_type="branch"       
241         #for all the openlink repo. we use a tag if provided.               
242         [ "$name" == "kernel" ] && [ -z "$DEFAULT_KERNEL" ] && i=$[$i + 3] && continue
243         cd_repo $name   
244         echo -e "\n${NORMAL}Checking out branch ${GREEN}$branch  ${NORMAL}in repo ${GREEN}$name ${NORMAL} "
245                 git checkout $branch        
246         git fetch origin
247         git fetch origin --tags  
248         if [[ "$url" == *git.ti.com* ]]
249         then            
250            [[ -n $RESET ]] && echo -e "${PURPLE}Reset to latest in repo ${GREEN}$name ${NORMAL} branch  ${GREEN}$branch ${NORMAL}"  && git reset --hard origin/$branch
251            [[ -n $USE_TAG ]] && git reset --hard $USE_TAG  && echo -e "${NORMAL}Reset to tag ${GREEN}$USE_TAG   ${NORMAL}in repo ${GREEN}$name ${NORMAL} "            
252         fi        
253                 cd_back
254                 i=$[$i + 3]
255         done
258 function setup_toolchain()
260         if [ ! -f `path downloads`/arm-toolchain.tar.bz2 ]; then
261         echo "Setting toolchain"
262                 wget ${toolchain[0]} -O `path downloads`/arm-toolchain.tar.bz2
263                 tar -xjf `path downloads`/arm-toolchain.tar.bz2 -C `path toolchain`
264                 mv `path toolchain`/* `path toolchain`/arm
265         fi
268 function build_uimage()
270     cd_repo kernel
271         [ -z $NO_CONFIG ] && cp `path configuration`/kernel_$KERNEL_VERSION.$KERNEL_PATCHLEVEL.config `repo_path kernel`/.config
272         [ -z $NO_CLEAN ] && make clean
273         [ -z $NO_CLEAN ] && assert_no_error
274        
275     if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
276     then
277         make -j${PROCESSORS_NUMBER} uImage
278         cp `repo_path kernel`/arch/arm/boot/uImage `path tftp`/uImage
279     else
280         if [ -z $NO_DTB ] 
281         then
282             make -j${PROCESSORS_NUMBER} zImage
283             make -j${PROCESSORS_NUMBER} am335x-evm.dtb
284             make -j${PROCESSORS_NUMBER} modules
285             INSTALL_MOD_PATH=`path filesystem` make -j${PROCESSORS_NUMBER} modules_install
286             cp `repo_path kernel`/arch/arm/boot/zImage `path tftp`/zImage
287             cp `repo_path kernel`/arch/arm/boot/dts/am335x-evm.dtb `path tftp`/am335x-evm.dtb
288         else
289             LOADADDR=0x80008000 make -j${PROCESSORS_NUMBER} uImage.am335x-evm 
290             cp `repo_path kernel`/arch/arm/boot/uImage.am335x-evm `path tftp`/uImage
291         fi
292     fi
293         assert_no_error
294         cd_back
297 function generate_compat()
299         cd_repo backports
300         python ./gentree.py --clean `repo_path driver` `path compat_wireless`
301         cd_back
304 function build_modules()
306         generate_compat
307         cd_repo compat_wireless
308         if [ -z $NO_CLEAN ]; then
309                 make clean
310         fi
311         make defconfig-wl18xx
312         make -j${PROCESSORS_NUMBER}
313         assert_no_error
314         #find . -name \*.ko -exec cp {} `path debugging`/ \;
315         find . -name \*.ko -exec ${CROSS_COMPILE}strip -g {} \;
316     
317         make  modules_install
318         assert_no_error
319         cd_back
322 function build_openssl()
324         cd_repo openssl
325         [ -z $NO_CONFIG ] && ./Configure linux-generic32
326         [ -z $NO_CLEAN ] && make clean
327         [ -z $NO_CLEAN ] && assert_no_error
328         make
329         assert_no_error
330         make install_sw
331         assert_no_error
332         cd_back
336 function build_iw()
338         cd_repo iw
339         [ -z $NO_CLEAN ] && make clean
340         [ -z $NO_CLEAN ] && assert_no_error
341         CC=${CROSS_COMPILE}gcc LIBS+=" -lpthread -lm" make V=1
342         assert_no_error
343         DESTDIR=`path filesystem` make install
344         assert_no_error
345         cd_back
347 function build_libnl()
349         cd_repo libnl
350         [ -z $NO_CONFIG ] && ./autogen.sh
351         [ -z $NO_CONFIG ] && ./configure --prefix=`path filesystem` --host=${ARCH} CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar
352         ([ -z $NO_CONFIG ] || [ -z $NO_CLEAN ]) && make clean
353         [ -z $NO_CLEAN ] && assert_no_error
354         make
355         assert_no_error
356         make install
357         assert_no_error
358         cd_back
361 function build_wpa_supplicant()
363         cd `repo_path hostap`/wpa_supplicant
364         [ -z $NO_CONFIG ] && cp android.config .config
365     [ -n "$SYSLOG_EN" ] && echo "Enable DEBUG_SYSLOG config" && sed -i "/#CONFIG_DEBUG_SYSLOG=y/ s/# *//" .config
366         CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
367         assert_no_error
368         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
369         assert_no_error
370         CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
371         assert_no_error
372         cd_back    
373     cp `repo_path scripts_download`/conf/*_supplicant.conf  `path filesystem`/etc/
376 function build_hostapd()
377 {              
378     cd `repo_path hostap`/hostapd
379         [ -z $NO_CONFIG ] && cp android.config .config
380         [ -n "$UPNP_EN" ] && echo "Enable UPNP config" && sed -i "/#CONFIG_WPS_UPNP=y/ s/# *//" .config
381         CONFIG_LIBNL32=y DESTDIR=`path filesystem` make clean
382         assert_no_error
383         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
384         assert_no_error
385         CONFIG_LIBNL32=y DESTDIR=`path filesystem` make install
386         assert_no_error
387         cd_back
388     cp `repo_path scripts_download`/conf/hostapd.conf  `path filesystem`/etc/    
391 function build_crda()
392 {       
393         cp `repo_path wireless_regdb`/regulatory.bin `path filesystem`/usr/lib/crda/regulatory.bin
394         cp `repo_path wireless_regdb`/linville.key.pub.pem `path filesystem`/etc/wireless-regdb/pubkeys/
395     cd_repo crda
396         
397         [ -z $NO_CLEAN ] && DESTDIR=`path filesystem` make clean
398         [ -z $NO_CLEAN ] && assert_no_error
399         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
400         assert_no_error
401         DESTDIR=`path filesystem` make install
402         assert_no_error
403         cd_back
406 function build_calibrator()
408         cd_repo ti_utils
409         [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
410         [ -z $NO_CLEAN ] && assert_no_error
411         NLVER=3 NLROOT=`repo_path libnl`/include NFSROOT=`path filesystem` LIBS+=-lpthread make
412         assert_no_error
413         NFSROOT=`path filesystem` make install
414         #assert_no_error
415         cd_back
418 function build_wlconf()
420         files_to_copy="dictionary.txt struct.bin default.conf wl18xx-conf-default.bin README example.conf example.ini configure-device.sh"
421         cd `repo_path ti_utils`/wlconf
422         if [ -z $NO_CLEAN ]; then
423                 NFSROOT=`path filesystem` make clean
424                 assert_no_error
425                 for file_to_copy in $files_to_copy; do
426                         rm -f `path filesstem`/usr/sbin/wlconf/$file_to_copy
427                 done
428                 rm -f `path filesystem`/usr/sbin/wlconf/official_inis/*
429         fi
430         NFSROOT=`path filesystem` make CC=${CROSS_COMPILE}gcc LD=${CROSS_COMPILE}ld
431         assert_no_error
433         # install
434         cp -f `repo_path ti_utils`/wlconf/wlconf `path filesystem`/usr/sbin/wlconf
435         chmod 755 `path filesystem`/usr/sbin/wlconf
436         for file_to_copy in $files_to_copy; do
437                 cp $file_to_copy `path filesystem`/usr/sbin/wlconf/$file_to_copy
438                 echo "echoying files $file_to_copy"
439         done
440         cp official_inis/* `path filesystem`/usr/sbin/wlconf/official_inis/
441         cd_back
444 function build_fw_download()
446         cp `repo_path fw_download`/*.bin `path filesystem`/lib/firmware/ti-connectivity
450 function build_scripts_download()
452         cd_repo scripts_download
453         echo "Copying scripts"
454         scripts_download_path=`repo_path scripts_download`
455         for script_dir in `ls $scripts_download_path`
456         do
457                 echo "Copying everything from ${script_dir} to `path filesystem`/usr/share/wl18xx directory"
458                 cp -rf `repo_path scripts_download`/${script_dir}/* `path filesystem`/usr/share/wl18xx
459         done
460         cd_back
463 function clean_kernel()
465         [ "$DEFAULT_KERNEL" ] && echo "Cleaning kernel folder"
466         [ "$DEFAULT_KERNEL" ] && cd_repo kernel
467         [ "$DEFAULT_KERNEL" ] && git clean -fdx > /dev/null
470 function clean_outputs()
472     if [[ "$ROOTFS" == "DEFAULT" ]]
473     then
474         echo "Cleaning outputs"
475         rm -rf `path filesystem`/*
476         rm -f `path outputs`/*
477    fi
480 function build_outputs()
482         if [[ "$ROOTFS" == "DEFAULT" ]]
483     then  
484         echo "Building outputs"    
485         cd_path filesystem
486         tar cpjf `path outputs`/${tar_filesystem[0]} .
487         cd_back
488                 
489         if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
490         then
491             cp `path tftp`/uImage `path outputs`/uImage
492         else
493             if [ -z $NO_DTB ]
494             then
495                 cp `path tftp`/zImage `path outputs`/zImage
496                 cp `path tftp`/am335x-evm.dtb `path outputs`/am335x-evm.dtb
497             else
498                 cp `path tftp`/uImage `path outputs`/uImage
499             fi
500         fi              
501     fi
504 function install_outputs()
506     echo "Installing outputs"
507         tftp_path=${setup[2]}
508         sitara_left_path=${setup[5]}
509         sitara_right_path=${setup[8]}
511         cp `path outputs`/uImage ${tftp_path}
512         cp `path outputs`/${tar_filesystem[0]} $sitara_left_path
513         cp `path outputs`/${tar_filesystem[0]} $sitara_right_path
515         cd $sitara_left_path
516         tar xjf ${tar_filesystem[0]}
517         cd_back
519         cd $sitara_right_path
520         tar xjf ${tar_filesystem[0]}
521         cd_back
524 function set_files_to_verify()
526         files_to_verify=(
527         # skeleton path
528         # source path
529         # pattern in output of file
531         `path filesystem`/usr/local/sbin/wpa_supplicant
532         `repo_path hostap`/wpa_supplicant/wpa_supplicant
533         "ELF 32-bit LSB executable, ARM"
535         `path filesystem`/usr/local/bin/hostapd
536         `repo_path hostap`/hostapd/hostapd
537         "ELF 32-bit LSB executable, ARM"
539         `path filesystem`/sbin/crda
540         `repo_path crda`/crda
541         "ELF 32-bit LSB executable, ARM"
543         `path filesystem`/usr/lib/crda/regulatory.bin
544         `repo_path wireless_regdb`/regulatory.bin
545         "CRDA wireless regulatory database file"
547         `path filesystem`/lib/firmware/ti-connectivity/wl18xx-fw-4.bin
548         `repo_path fw_download`/wl18xx-fw-4.bin
549         "data"
551         `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/updates/drivers/net/wireless/ti/wl18xx/wl18xx.ko
552         `path compat_wireless`/drivers/net/wireless/ti/wl18xx/wl18xx.ko
553         "ELF 32-bit LSB relocatable, ARM"
555         `path filesystem`/lib/modules/$KERNEL_VERSION.$KERNEL_PATCHLEVEL.*/updates/drivers/net/wireless/ti/wlcore/wlcore.ko
556         `path compat_wireless`/drivers/net/wireless/ti/wlcore/wlcore.ko
557         "ELF 32-bit LSB relocatable, ARM"
559         #`path filesystem`/usr/bin/calibrator
560         #`repo_path ti_utils`/calibrator
561         #"ELF 32-bit LSB executable, ARM"
563         `path filesystem`/usr/sbin/wlconf/wlconf
564         `repo_path ti_utils`/wlconf/wlconf
565         "ELF 32-bit LSB executable, ARM"
566         )
569 function get_tag()
571        i="0"
572        while [ $i -lt ${#repositories[@]} ]; do
573                name=${repositories[$i]}
574                url=${repositories[$i + 1]}
575         branch=${repositories[$i + 2]}
576         checkout_type="branch"
577         cd_repo $name
578         if [[ "$url" == *git.ti.com* ]]
579         then
580                 echo -e "${PURPLE}Describe of ${NORMAL} repo : ${GREEN}$name ${NORMAL} "  ;
581                 git describe
582         fi
583                cd_back
584                i=$[$i + 3]
585        done
590 function admin_tag()
592         i="0"    
593         while [ $i -lt ${#repositories[@]} ]; do
594                 name=${repositories[$i]}
595                 url=${repositories[$i + 1]}
596         branch=${repositories[$i + 2]}   
597         checkout_type="branch"              
598         cd_repo $name    
599         if [[ "$url" == *git.ti.com* ]]
600         then                                   
601                 echo -e "${PURPLE}Adding tag ${GREEN} $1 ${NORMAL} to repo : ${GREEN}$name ${NORMAL} "  ;
602                 git show --summary        
603                 read -p "Do you want to tag this commit ?" yn
604                 case $yn in
605                     [Yy]* )  git tag -a $1 -m "$1" ;
606                              git push --tags ;;
607                     [Nn]* ) echo -e "${PURPLE}Tag was not applied ${NORMAL} " ;;
608                     
609                     * ) echo "Please answer yes or no.";;
610                 esac
611            
612         fi        
613                 cd_back
614                 i=$[$i + 3]
615         done
619 function verify_skeleton()
621         echo "Verifying filesystem skeleton..."
623         set_files_to_verify
625         i="0"
626         while [ $i -lt ${#files_to_verify[@]} ]; do
627                 skeleton_path=${files_to_verify[i]}
628                 source_path=${files_to_verify[i + 1]}
629                 file_pattern=${files_to_verify[i + 2]}
630                 file $skeleton_path | grep "${file_pattern}" >/dev/null
631         if [ $? -eq 1 ]; then
632         echo -e "${RED}ERROR " $skeleton_path " Not found ! ${NORMAL}"
633         #exit
634         fi
636                 md5_skeleton=$(md5sum $skeleton_path | awk '{print $1}')
637                 md5_source=$(md5sum $source_path     | awk '{print $1}')
638                 if [ $md5_skeleton != $md5_source ]; then
639                         echo "ERROR: file mismatch"
640                         echo $skeleton_path
641                         exit 1
642                 fi
643                 i=$[$i + 3]
644         done
646         which regdbdump > /dev/null
647         if [ $? -eq 0 ]; then
648                 regdbdump `path filesystem`/usr/lib/crda/regulatory.bin > /dev/null
649                 assert_no_error
650         fi
653 function setup_workspace()
655         setup_directories       
656         setup_repositories
657         setup_branches
658     #Download toolchain only if it was not set
659     [ DEFAULT_TOOLCHAIN ] && setup_toolchain   
663 function build_all()
665     if [ -z $NO_EXTERNAL ] 
666     then        
667         [ $DEFAULT_KERNEL ] && build_uimage
668         build_openssl
669         build_libnl
670         build_crda
671     fi
672     
673     if [ -z $NO_TI ] 
674     then
675         build_modules
676         build_iw
677         build_wpa_supplicant
678         build_hostapd   
679         build_calibrator
680         build_wlconf
681         build_fw_download
682         build_scripts_download
683     fi
684     
685     [ -z $NO_VERIFY ] && verify_skeleton
688 function setup_and_build()
690     setup_workspace
691     build_all
694 function main()
696         [[ "$1" == "-h" || "$1" == "--help"  ]] && usage
697     check_for_build_updates
698     setup_environment
699     setup_directories
700     read_kernel_version
701     
702         case "$1" in
703         'init')                
704         print_highlight " initializing workspace (w/o build) "       
705                 [[  -n "$2" ]] && echo "Using tag $2 " && USE_TAG=$2                
706         NO_BUILD=1 
707         setup_workspace
708         read_kernel_version #####read kernel version again after init#####
709                 ;;
710               
711         'clean')        
712         print_highlight " cleaning & building all "       
713         clean_outputs
714         setup_directories
715         build_all        
716                 ;;
718         'update')
719         print_highlight " setting up workspace and building all "
720                 if [  -n "$2" ]
721         then
722             print_highlight "Using tag $2 "
723             USE_TAG=$2
724         else
725             print_highlight "Updating all to head (this will revert local changes)"
726             RESET=1
727         fi
728         #clean_kernel
729         clean_outputs
730         setup_workspace
731         read_kernel_version #####read kernel version again after update#####
732         build_all
733                 ;;
734         
735                 'openlink')
736         print_highlight " building all (w/o clean) "       
737                 NO_EXTERNAL=1 setup_and_build
738                 ;;
740         #################### Building single components #############################
741                 'kernel')
742                 print_highlight " building only Kernel "
743                 #clean_kernel
744                 build_uimage
745                 ;;
746                 
747                 'kernel_modules')
748         print_highlight " building only Driver modules "
749                 build_uimage
750                 build_modules
751                 ;;
752                 'modules')
753         print_highlight " building only Driver modules "
754                 build_modules
755                 ;;
757                 'wpa_supplicant')
758         print_highlight " building only wpa_supplicant "
759                 build_wpa_supplicant      
760                 ;;
762                 'hostapd')
763         print_highlight " building only hostapd "
764                 build_hostapd
765                 ;;
767                 'crda')
768         print_highlight " building only CRDA "
769                 build_crda
770                 ;;
771         
772                 'libnl')
773                 print_highlight " building only libnl"
774                 build_libnl
775                 ;;
777                 'iw')
778                 print_highlight " building only iw"
779                 build_iw
780                 ;;
782                 'openssl')
783                 print_highlight " building only openssl"
784                 build_openssl
785                 ;;
787                 'scripts')
788                 print_highlight " Copying scripts "
789                 build_scripts_download
790                 ;;
791                 
792                 'utils')
793                 print_highlight " building only ti-utils "
794                 build_calibrator
795                 build_wlconf            
796                 ;;        
797                 'firmware')
798                 print_highlight " building only firmware"
799                 build_fw_download
800                 ;;
801         ############################################################
802         'get_tag')
803         get_tag
804         exit
805         ;;
806                 
807         'admin_tag')        
808                 admin_tag $2
809                 ;;
810         
811         '')
812         print_highlight " building all (No clean & no source code update) "  
813                 #clean_outputs
814         NO_CLEAN=1 build_all
815                 ;;
817         *)
818         echo " "
819         echo "**** Unknown parameter - please see usage below **** "
820         usage
821         ;;
822         esac
823         
824         [[ -z $NO_BUILD ]] && build_outputs
825         [[ -n $INSTALL_NFS ]] && install_outputs
827 main $@