| 
									
										
										
										
											2008-02-11 17:19:10 -05:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Programs returning != 0 will not cause script to exit | 
					
						
							|  |  |  | set +e | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Case insensitive string comparison | 
					
						
							|  |  |  | shopt -s nocaseglob | 
					
						
							|  |  |  | #shopt -s nocasematch | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  | ECHO=echo | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | OS= | 
					
						
							|  |  |  | ARCH= | 
					
						
							|  |  |  | WORD= | 
					
						
							| 
									
										
										
										
											2007-11-24 22:49:38 -05:00
										 |  |  | NO_UI= | 
					
						
							| 
									
										
										
										
											2008-02-11 17:19:10 -05:00
										 |  |  | GIT_PROTOCOL=${GIT_PROTOCOL:="git"} | 
					
						
							|  |  |  | GIT_URL=${GIT_URL:=$GIT_PROTOCOL"://factorcode.org/git/factor.git"} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-13 14:38:41 -05:00
										 |  |  | test_program_installed() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |     if ! [[ -n `type -p $1` ]] ; then | 
					
						
							|  |  |  |         return 0; | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     fi | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |     return 1; | 
					
						
							| 
									
										
										
										
											2008-02-13 14:38:41 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ensure_program_installed() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |     installed=0; | 
					
						
							|  |  |  |     for i in $* ; | 
					
						
							|  |  |  |     do | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |         $ECHO -n "Checking for $i..." | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |         test_program_installed $i | 
					
						
							|  |  |  |         if [[ $? -eq 0 ]]; then | 
					
						
							|  |  |  |             echo -n "not " | 
					
						
							|  |  |  |         else     | 
					
						
							|  |  |  |             installed=$(( $installed + 1 )) | 
					
						
							|  |  |  |         fi | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |         $ECHO "found!" | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |     done | 
					
						
							|  |  |  |     if [[ $installed -eq 0 ]] ; then | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |         $ECHO -n "Install " | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |         if [[ $# -eq 1 ]] ; then | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |             $ECHO -n $1 | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |             $ECHO -n "any of [ $* ]" | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |         fi | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |         $ECHO " and try again." | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |         exit 1 | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | check_ret() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     RET=$? | 
					
						
							|  |  |  |     if [[ $RET -ne 0 ]] ; then | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |        $ECHO $1 failed | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |        exit 2 | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | check_gcc_version() { | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |     $ECHO -n "Checking gcc version..." | 
					
						
							| 
									
										
										
										
											2008-03-11 14:05:17 -04:00
										 |  |  |     GCC_VERSION=`$CC --version` | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     check_ret gcc | 
					
						
							|  |  |  |     if [[ $GCC_VERSION == *3.3.* ]] ; then | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |         $ECHO "You have a known buggy version of gcc (3.3)" | 
					
						
							|  |  |  |         $ECHO "Install gcc 3.4 or higher and try again." | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |         exit 3 | 
					
						
							| 
									
										
										
										
											2008-11-07 22:56:57 -05:00
										 |  |  |     elif [[ $GCC_VERSION == *4.3.* ]] ; then | 
					
						
							|  |  |  |        MAKE_OPTS="$MAKE_OPTS SITE_CFLAGS=-fno-forward-propagate" | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     fi | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |     $ECHO "ok." | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-13 14:38:41 -05:00
										 |  |  | set_downloader() { | 
					
						
							| 
									
										
										
										
											2008-03-08 13:00:40 -05:00
										 |  |  |     test_program_installed wget curl | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |     if [[ $? -ne 0 ]] ; then | 
					
						
							| 
									
										
										
										
											2008-03-08 13:00:40 -05:00
										 |  |  |         DOWNLOADER=wget | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2008-03-08 13:00:40 -05:00
										 |  |  |         DOWNLOADER="curl -O" | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |     fi | 
					
						
							| 
									
										
										
										
											2008-02-13 14:38:41 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-13 15:32:43 -05:00
										 |  |  | set_md5sum() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |     test_program_installed md5sum | 
					
						
							|  |  |  |     if [[ $? -ne 0 ]] ; then | 
					
						
							|  |  |  |         MD5SUM=md5sum | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         MD5SUM="md5 -r" | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2008-02-13 15:32:43 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-11 16:44:50 -04:00
										 |  |  | set_gcc() { | 
					
						
							|  |  |  |     case $OS in | 
					
						
							|  |  |  |         openbsd) ensure_program_installed egcc; CC=egcc;; | 
					
						
							|  |  |  |         *) CC=gcc;; | 
					
						
							|  |  |  |     esac | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set_make() { | 
					
						
							|  |  |  |     case $OS in | 
					
						
							|  |  |  |         netbsd) MAKE='gmake';; | 
					
						
							|  |  |  |         freebsd) MAKE='gmake';; | 
					
						
							|  |  |  |         openbsd) MAKE='gmake';; | 
					
						
							|  |  |  |         dragonflybsd) MAKE='gmake';; | 
					
						
							|  |  |  |         *) MAKE='make';; | 
					
						
							|  |  |  |     esac | 
					
						
							|  |  |  |     if ! [[ $MAKE -eq 'gmake' ]] ; then | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |         ensure_program_installed gmake | 
					
						
							| 
									
										
										
										
											2008-03-11 16:44:50 -04:00
										 |  |  |     fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | check_installed_programs() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     ensure_program_installed chmod | 
					
						
							|  |  |  |     ensure_program_installed uname | 
					
						
							|  |  |  |     ensure_program_installed git | 
					
						
							|  |  |  |     ensure_program_installed wget curl | 
					
						
							|  |  |  |     ensure_program_installed gcc | 
					
						
							| 
									
										
										
										
											2008-03-11 16:44:50 -04:00
										 |  |  |     ensure_program_installed make gmake | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     ensure_program_installed md5sum md5 | 
					
						
							|  |  |  |     ensure_program_installed cut | 
					
						
							|  |  |  |     check_gcc_version | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 22:03:32 -05:00
										 |  |  | check_library_exists() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     GCC_TEST=factor-library-test.c | 
					
						
							|  |  |  |     GCC_OUT=factor-library-test.out | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |     $ECHO -n "Checking for library $1..." | 
					
						
							|  |  |  |     $ECHO "int main(){return 0;}" > $GCC_TEST | 
					
						
							| 
									
										
										
										
											2008-03-11 14:05:17 -04:00
										 |  |  |     $CC $GCC_TEST -o $GCC_OUT -l $1 | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     if [[ $? -ne 0 ]] ; then | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |         $ECHO "not found!" | 
					
						
							|  |  |  |         $ECHO "Warning: library $1 not found." | 
					
						
							|  |  |  |         $ECHO "***Factor will compile NO_UI=1" | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |         NO_UI=1 | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  |     $DELETE -f $GCC_TEST | 
					
						
							|  |  |  |     check_ret $DELETE | 
					
						
							|  |  |  |     $DELETE -f $GCC_OUT | 
					
						
							|  |  |  |     check_ret $DELETE | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |     $ECHO "found." | 
					
						
							| 
									
										
										
										
											2007-11-24 22:03:32 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | check_X11_libraries() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     check_library_exists GLU | 
					
						
							|  |  |  |     check_library_exists GL | 
					
						
							|  |  |  |     check_library_exists X11 | 
					
						
							| 
									
										
										
										
											2009-03-23 21:09:01 -04:00
										 |  |  |     check_library_exists pango-1.0 | 
					
						
							| 
									
										
										
										
											2007-11-24 22:03:32 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | check_libraries() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     case $OS in | 
					
						
							|  |  |  |             linux) check_X11_libraries;; | 
					
						
							|  |  |  |     esac | 
					
						
							| 
									
										
										
										
											2007-11-24 22:03:32 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 19:03:01 -05:00
										 |  |  | check_factor_exists() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     if [[ -d "factor" ]] ; then | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |         $ECHO "A directory called 'factor' already exists." | 
					
						
							|  |  |  |         $ECHO "Rename or delete it and try again." | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |         exit 4 | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2007-11-24 19:03:01 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | find_os() { | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |     if [[ -n $OS ]] ; then return; fi | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |     $ECHO "Finding OS..." | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     uname_s=`uname -s` | 
					
						
							|  |  |  |     check_ret uname | 
					
						
							|  |  |  |     case $uname_s in | 
					
						
							|  |  |  |         CYGWIN_NT-5.2-WOW64) OS=winnt;; | 
					
						
							|  |  |  |         *CYGWIN_NT*) OS=winnt;; | 
					
						
							|  |  |  |         *CYGWIN*) OS=winnt;; | 
					
						
							|  |  |  |         *darwin*) OS=macosx;; | 
					
						
							|  |  |  |         *Darwin*) OS=macosx;; | 
					
						
							|  |  |  |         *linux*) OS=linux;; | 
					
						
							|  |  |  |         *Linux*) OS=linux;; | 
					
						
							|  |  |  |         *NetBSD*) OS=netbsd;; | 
					
						
							| 
									
										
										
										
											2008-03-11 14:52:59 -04:00
										 |  |  |         *FreeBSD*) OS=freebsd;; | 
					
						
							|  |  |  |         *OpenBSD*) OS=openbsd;; | 
					
						
							| 
									
										
										
										
											2008-03-11 16:44:50 -04:00
										 |  |  |         *DragonFly*) OS=dragonflybsd;; | 
					
						
							| 
									
										
										
										
											2008-11-11 11:19:42 -05:00
										 |  |  |         SunOS) OS=solaris;; | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     esac | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | find_architecture() { | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |     if [[ -n $ARCH ]] ; then return; fi | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |     $ECHO "Finding ARCH..." | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     uname_m=`uname -m` | 
					
						
							|  |  |  |     check_ret uname | 
					
						
							|  |  |  |     case $uname_m in | 
					
						
							|  |  |  |        i386) ARCH=x86;; | 
					
						
							|  |  |  |        i686) ARCH=x86;; | 
					
						
							| 
									
										
										
										
											2008-09-16 16:59:07 -04:00
										 |  |  |        i86pc) ARCH=x86;; | 
					
						
							| 
									
										
										
										
											2008-03-07 08:51:00 -05:00
										 |  |  |        amd64) ARCH=x86;; | 
					
						
							| 
									
										
										
										
											2008-04-09 15:01:04 -04:00
										 |  |  |        ppc64) ARCH=ppc;; | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |        *86) ARCH=x86;; | 
					
						
							|  |  |  |        *86_64) ARCH=x86;; | 
					
						
							|  |  |  |        "Power Macintosh") ARCH=ppc;; | 
					
						
							|  |  |  |     esac | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | write_test_program() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     echo "#include <stdio.h>" > $C_WORD.c | 
					
						
							|  |  |  |     echo "int main(){printf(\"%d\", 8*sizeof(void*)); return 0; }" >> $C_WORD.c | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-13 22:24:36 -04:00
										 |  |  | c_find_word_size() { | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |     $ECHO "Finding WORD..." | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     C_WORD=factor-word-size | 
					
						
							|  |  |  |     write_test_program | 
					
						
							|  |  |  |     gcc -o $C_WORD $C_WORD.c | 
					
						
							|  |  |  |     WORD=$(./$C_WORD) | 
					
						
							|  |  |  |     check_ret $C_WORD | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  |     $DELETE -f $C_WORD* | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-13 23:00:54 -04:00
										 |  |  | intel_macosx_word_size() { | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |     ensure_program_installed sysctl | 
					
						
							|  |  |  |     $ECHO -n "Testing if your Intel Mac supports 64bit binaries..." | 
					
						
							|  |  |  |     sysctl machdep.cpu.extfeatures | grep EM64T >/dev/null | 
					
						
							| 
									
										
										
										
											2008-09-13 22:24:36 -04:00
										 |  |  |     if [[ $? -eq 0 ]] ; then | 
					
						
							| 
									
										
										
										
											2008-09-20 16:53:18 -04:00
										 |  |  |         WORD=64 | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |         $ECHO "yes!" | 
					
						
							| 
									
										
										
										
											2008-09-13 22:24:36 -04:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |         WORD=32 | 
					
						
							|  |  |  |         $ECHO "no." | 
					
						
							| 
									
										
										
										
											2008-09-13 22:24:36 -04:00
										 |  |  |     fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | find_word_size() { | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |     if [[ -n $WORD ]] ; then return; fi | 
					
						
							|  |  |  |     if [[ $OS == macosx && $ARCH == x86 ]] ; then | 
					
						
							|  |  |  |         intel_macosx_word_size | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         c_find_word_size | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2008-09-13 22:24:36 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | set_factor_binary() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     case $OS in | 
					
						
							| 
									
										
										
										
											2009-02-04 19:21:58 -05:00
										 |  |  |         winnt) FACTOR_BINARY=factor.com;; | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |         *) FACTOR_BINARY=factor;; | 
					
						
							|  |  |  |     esac | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  | set_factor_library() { | 
					
						
							|  |  |  |     case $OS in | 
					
						
							|  |  |  |         winnt) FACTOR_LIBRARY=factor.dll;; | 
					
						
							|  |  |  |         macosx) FACTOR_LIBRARY=libfactor.dylib;; | 
					
						
							|  |  |  |         *) FACTOR_LIBRARY=libfactor.a;; | 
					
						
							|  |  |  |     esac | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set_factor_image() { | 
					
						
							|  |  |  |     FACTOR_IMAGE=factor.image | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | echo_build_info() { | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |     $ECHO OS=$OS | 
					
						
							|  |  |  |     $ECHO ARCH=$ARCH | 
					
						
							|  |  |  |     $ECHO WORD=$WORD | 
					
						
							|  |  |  |     $ECHO FACTOR_BINARY=$FACTOR_BINARY | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  |     $ECHO FACTOR_LIBRARY=$FACTOR_LIBRARY | 
					
						
							|  |  |  |     $ECHO FACTOR_IMAGE=$FACTOR_IMAGE | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |     $ECHO MAKE_TARGET=$MAKE_TARGET | 
					
						
							|  |  |  |     $ECHO BOOT_IMAGE=$BOOT_IMAGE | 
					
						
							|  |  |  |     $ECHO MAKE_IMAGE_TARGET=$MAKE_IMAGE_TARGET | 
					
						
							|  |  |  |     $ECHO GIT_PROTOCOL=$GIT_PROTOCOL | 
					
						
							|  |  |  |     $ECHO GIT_URL=$GIT_URL | 
					
						
							|  |  |  |     $ECHO DOWNLOADER=$DOWNLOADER | 
					
						
							|  |  |  |     $ECHO CC=$CC | 
					
						
							|  |  |  |     $ECHO MAKE=$MAKE | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  |     $ECHO COPY=$COPY | 
					
						
							|  |  |  |     $ECHO DELETE=$DELETE | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-13 23:00:54 -04:00
										 |  |  | check_os_arch_word() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     if ! [[ -n $OS && -n $ARCH && -n $WORD ]] ; then | 
					
						
							| 
									
										
										
										
											2008-03-28 22:40:02 -04:00
										 |  |  |         $ECHO "OS: $OS" | 
					
						
							|  |  |  |         $ECHO "ARCH: $ARCH" | 
					
						
							|  |  |  |         $ECHO "WORD: $WORD" | 
					
						
							| 
									
										
										
										
											2008-09-13 23:00:54 -04:00
										 |  |  |         $ECHO "OS, ARCH, or WORD is empty.  Please report this." | 
					
						
							| 
									
										
										
										
											2008-09-17 01:56:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-11 11:19:42 -05:00
										 |  |  |         echo $MAKE_TARGET | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |         exit 5 | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |     fi | 
					
						
							| 
									
										
										
										
											2008-09-13 23:00:54 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-13 23:00:54 -04:00
										 |  |  | set_build_info() { | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |     check_os_arch_word | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     if [[ $OS == macosx && $ARCH == ppc ]] ; then | 
					
						
							| 
									
										
										
										
											2008-11-07 22:09:42 -05:00
										 |  |  |         MAKE_IMAGE_TARGET=macosx-ppc | 
					
						
							| 
									
										
										
										
											2008-11-08 21:36:05 -05:00
										 |  |  |         MAKE_TARGET=macosx-ppc | 
					
						
							| 
									
										
										
										
											2008-11-07 22:09:42 -05:00
										 |  |  |     elif [[ $OS == linux && $ARCH == ppc ]] ; then | 
					
						
							|  |  |  |         MAKE_IMAGE_TARGET=linux-ppc | 
					
						
							| 
									
										
										
										
											2008-11-08 21:36:05 -05:00
										 |  |  |         MAKE_TARGET=linux-ppc | 
					
						
							| 
									
										
										
										
											2008-11-07 22:09:42 -05:00
										 |  |  |     elif [[ $OS == winnt && $ARCH == x86 && $WORD == 64 ]] ; then | 
					
						
							|  |  |  |         MAKE_IMAGE_TARGET=winnt-x86.64 | 
					
						
							| 
									
										
										
										
											2008-11-08 21:36:05 -05:00
										 |  |  |         MAKE_TARGET=winnt-x86-64 | 
					
						
							| 
									
										
										
										
											2008-11-07 22:09:42 -05:00
										 |  |  |     elif [[ $ARCH == x86 && $WORD == 64 ]] ; then | 
					
						
							|  |  |  |         MAKE_IMAGE_TARGET=unix-x86.64 | 
					
						
							| 
									
										
										
										
											2008-11-08 21:36:05 -05:00
										 |  |  |         MAKE_TARGET=$OS-x86-64 | 
					
						
							|  |  |  |     else | 
					
						
							| 
									
										
										
										
											2008-11-07 22:09:42 -05:00
										 |  |  |         MAKE_IMAGE_TARGET=$ARCH.$WORD | 
					
						
							| 
									
										
										
										
											2008-11-08 21:36:05 -05:00
										 |  |  |         MAKE_TARGET=$OS-$ARCH-$WORD | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     fi | 
					
						
							| 
									
										
										
										
											2008-11-07 22:56:57 -05:00
										 |  |  |     BOOT_IMAGE=boot.$MAKE_IMAGE_TARGET.image | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-13 23:00:54 -04:00
										 |  |  | parse_build_info() { | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |     ensure_program_installed cut | 
					
						
							|  |  |  |     $ECHO "Parsing make target from command line: $1" | 
					
						
							|  |  |  |     OS=`echo $1 | cut -d '-' -f 1` | 
					
						
							|  |  |  |     ARCH=`echo $1 | cut -d '-' -f 2` | 
					
						
							|  |  |  |     WORD=`echo $1 | cut -d '-' -f 3` | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2008-09-13 23:18:56 -04:00
										 |  |  |     if [[ $OS == linux && $ARCH == ppc ]] ; then WORD=32; fi | 
					
						
							|  |  |  |     if [[ $OS == linux && $ARCH == arm ]] ; then WORD=32; fi | 
					
						
							|  |  |  |     if [[ $OS == macosx && $ARCH == ppc ]] ; then WORD=32; fi | 
					
						
							|  |  |  |     if [[ $OS == wince && $ARCH == arm ]] ; then WORD=32; fi | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |      | 
					
						
							|  |  |  |     $ECHO "OS=$OS" | 
					
						
							|  |  |  |     $ECHO "ARCH=$ARCH" | 
					
						
							|  |  |  |     $ECHO "WORD=$WORD" | 
					
						
							| 
									
										
										
										
											2008-09-13 23:00:54 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | find_build_info() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     find_os | 
					
						
							|  |  |  |     find_architecture | 
					
						
							|  |  |  |     find_word_size | 
					
						
							|  |  |  |     set_factor_binary | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  |     set_factor_library | 
					
						
							|  |  |  |     set_factor_image | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     set_build_info | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |     set_downloader | 
					
						
							|  |  |  |     set_gcc | 
					
						
							|  |  |  |     set_make | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     echo_build_info | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-11 17:19:10 -05:00
										 |  |  | invoke_git() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     git $* | 
					
						
							|  |  |  |     check_ret git | 
					
						
							| 
									
										
										
										
											2008-02-11 17:19:10 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | git_clone() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     echo "Downloading the git repository from factorcode.org..." | 
					
						
							|  |  |  |     invoke_git clone $GIT_URL | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | git_pull_factorcode() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     echo "Updating the git repository from factorcode.org..." | 
					
						
							|  |  |  |     invoke_git pull $GIT_URL master | 
					
						
							| 
									
										
										
										
											2008-02-06 20:49:07 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | cd_factor() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     cd factor | 
					
						
							|  |  |  |     check_ret cd | 
					
						
							| 
									
										
										
										
											2007-11-24 19:51:24 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  | set_copy() { | 
					
						
							|  |  |  |     case $OS in | 
					
						
							|  |  |  |         winnt) COPY=cp;; | 
					
						
							|  |  |  |         *) COPY=cp;; | 
					
						
							|  |  |  |     esac | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set_delete() { | 
					
						
							|  |  |  |     case $OS in | 
					
						
							|  |  |  |         winnt) DELETE=rm;; | 
					
						
							|  |  |  |         *) DELETE=rm;; | 
					
						
							|  |  |  |     esac | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | backup_factor() { | 
					
						
							|  |  |  |     $ECHO "Backing up factor..." | 
					
						
							|  |  |  |     $COPY $FACTOR_BINARY $FACTOR_BINARY.bak | 
					
						
							|  |  |  |     $COPY $FACTOR_LIBRARY $FACTOR_LIBRARY.bak | 
					
						
							| 
									
										
										
										
											2008-11-19 18:00:35 -05:00
										 |  |  |     $COPY $BOOT_IMAGE $BOOT_IMAGE.bak | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  |     $COPY $FACTOR_IMAGE $FACTOR_IMAGE.bak | 
					
						
							|  |  |  |     $ECHO "Done with backup." | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-11 11:19:42 -05:00
										 |  |  | check_makefile_exists() { | 
					
						
							|  |  |  |     if [[ ! -e "Makefile" ]] ; then | 
					
						
							|  |  |  |         echo "" | 
					
						
							|  |  |  |         echo "***Makefile not found***" | 
					
						
							|  |  |  |         echo "You are likely in the wrong directory." | 
					
						
							|  |  |  |         echo "Run this script from your factor directory:" | 
					
						
							|  |  |  |         echo "     ./build-support/factor.sh" | 
					
						
							|  |  |  |         exit 6 | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-11 17:19:10 -05:00
										 |  |  | invoke_make() { | 
					
						
							| 
									
										
										
										
											2008-11-11 11:19:42 -05:00
										 |  |  |     check_makefile_exists | 
					
						
							|  |  |  |     $MAKE $MAKE_OPTS $* | 
					
						
							|  |  |  |     check_ret $MAKE | 
					
						
							| 
									
										
										
										
											2008-02-11 17:19:10 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 19:51:24 -05:00
										 |  |  | make_clean() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     invoke_make clean | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | make_factor() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     invoke_make NO_UI=$NO_UI $MAKE_TARGET -j5 | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-13 15:20:37 -05:00
										 |  |  | update_boot_images() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     echo "Deleting old images..." | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  |     $DELETE checksums.txt* > /dev/null 2>&1 | 
					
						
							| 
									
										
										
										
											2008-11-19 18:00:35 -05:00
										 |  |  | 	# delete boot images with one or two characters after the dot | 
					
						
							|  |  |  |     $DELETE $BOOT_IMAGE.{?,??} > /dev/null 2>&1 | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  |     $DELETE temp/staging.*.image > /dev/null 2>&1 | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     if [[ -f $BOOT_IMAGE ]] ; then | 
					
						
							|  |  |  |         get_url http://factorcode.org/images/latest/checksums.txt | 
					
						
							|  |  |  |         factorcode_md5=`cat checksums.txt|grep $BOOT_IMAGE|cut -f2 -d' '`; | 
					
						
							|  |  |  |         set_md5sum | 
					
						
							| 
									
										
										
										
											2008-03-20 20:11:04 -04:00
										 |  |  |         case $OS in | 
					
						
							|  |  |  |              netbsd) disk_md5=`md5 $BOOT_IMAGE | cut -f4 -d' '`;; | 
					
						
							|  |  |  |              *) disk_md5=`$MD5SUM $BOOT_IMAGE|cut -f1 -d' '` ;; | 
					
						
							|  |  |  |         esac | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |         echo "Factorcode md5: $factorcode_md5"; | 
					
						
							|  |  |  |         echo "Disk md5: $disk_md5"; | 
					
						
							|  |  |  |         if [[ "$factorcode_md5" == "$disk_md5" ]] ; then | 
					
						
							|  |  |  |             echo "Your disk boot image matches the one on factorcode.org." | 
					
						
							|  |  |  |         else | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  |             $DELETE $BOOT_IMAGE > /dev/null 2>&1 | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |             get_boot_image; | 
					
						
							|  |  |  |         fi | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         get_boot_image | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | get_boot_image() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |     echo "Downloading boot image $BOOT_IMAGE." | 
					
						
							|  |  |  |     get_url http://factorcode.org/images/latest/$BOOT_IMAGE | 
					
						
							| 
									
										
										
										
											2008-02-13 14:38:41 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | get_url() { | 
					
						
							| 
									
										
										
										
											2008-03-08 13:00:40 -05:00
										 |  |  |     if [[ $DOWNLOADER -eq "" ]] ; then | 
					
						
							| 
									
										
										
										
											2008-03-04 16:19:00 -05:00
										 |  |  |         set_downloader; | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2008-03-08 13:00:40 -05:00
										 |  |  |     echo $DOWNLOADER $1 ; | 
					
						
							|  |  |  |     $DOWNLOADER $1 | 
					
						
							|  |  |  |     check_ret $DOWNLOADER | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-19 15:18:35 -05:00
										 |  |  | get_config_info() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     find_build_info | 
					
						
							|  |  |  |     check_installed_programs | 
					
						
							|  |  |  |     check_libraries | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-19 15:18:35 -05:00
										 |  |  | bootstrap() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     ./$FACTOR_BINARY -i=$BOOT_IMAGE | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 22:03:32 -05:00
										 |  |  | install() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     check_factor_exists | 
					
						
							|  |  |  |     get_config_info | 
					
						
							|  |  |  |     git_clone | 
					
						
							|  |  |  |     cd_factor | 
					
						
							|  |  |  |     make_factor | 
					
						
							|  |  |  |     get_boot_image | 
					
						
							|  |  |  |     bootstrap | 
					
						
							| 
									
										
										
										
											2007-11-24 22:03:32 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-06 20:49:07 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 22:03:32 -05:00
										 |  |  | update() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     get_config_info | 
					
						
							|  |  |  |     git_pull_factorcode | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  |     backup_factor | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     make_clean | 
					
						
							|  |  |  |     make_factor | 
					
						
							| 
									
										
										
										
											2007-12-04 14:44:46 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | update_bootstrap() { | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     update_boot_images | 
					
						
							|  |  |  |     bootstrap | 
					
						
							| 
									
										
										
										
											2007-11-24 22:03:32 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-04 14:44:46 -05:00
										 |  |  | refresh_image() { | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  |     ./$FACTOR_BINARY -script -e="USE: vocabs.loader USE: system refresh-all USE: memory save 0 exit" | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     check_ret factor | 
					
						
							| 
									
										
										
										
											2007-12-18 18:07:24 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | make_boot_image() { | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  |     ./$FACTOR_BINARY -script -e="\"$MAKE_IMAGE_TARGET\" USE: system USE: bootstrap.image make-image save 0 exit" | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     check_ret factor | 
					
						
							| 
									
										
										
										
											2008-01-06 12:30:23 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-04 14:44:46 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-08 13:00:40 -05:00
										 |  |  | install_build_system_apt() { | 
					
						
							| 
									
										
										
										
											2009-03-20 19:39:38 -04:00
										 |  |  |     sudo apt-get --yes install libc6-dev libpango1.0-dev libx11-dev xorg-dev glutg3-dev wget git-core git-doc rlwrap gcc make | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     check_ret sudo | 
					
						
							| 
									
										
										
										
											2007-12-03 22:17:23 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-08 13:00:40 -05:00
										 |  |  | install_build_system_port() { | 
					
						
							|  |  |  |     test_program_installed git | 
					
						
							|  |  |  |     if [[ $? -ne 1 ]] ; then | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |         ensure_program_installed yes | 
					
						
							|  |  |  |         echo "git not found." | 
					
						
							|  |  |  |         echo "This script requires either git-core or port." | 
					
						
							|  |  |  |         echo "If it fails, install git-core or port and try again." | 
					
						
							|  |  |  |         ensure_program_installed port | 
					
						
							|  |  |  |         echo "Installing git-core with port...this will take awhile." | 
					
						
							|  |  |  |         yes | sudo port install git-core | 
					
						
							| 
									
										
										
										
											2008-03-08 13:00:40 -05:00
										 |  |  |     fi | 
					
						
							| 
									
										
										
										
											2008-03-04 16:11:00 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-19 15:18:35 -05:00
										 |  |  | usage() { | 
					
						
							| 
									
										
										
										
											2008-09-13 23:00:54 -04:00
										 |  |  |     echo "usage: $0 install|install-x11|install-macosx|self-update|quick-update|update|bootstrap|dlls|net-bootstrap|make-target|report [optional-target]" | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     echo "If you are behind a firewall, invoke as:" | 
					
						
							|  |  |  |     echo "env GIT_PROTOCOL=http $0 <command>" | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |     echo "" | 
					
						
							|  |  |  |     echo "Example for overriding the default target:" | 
					
						
							|  |  |  |     echo "    $0 update macosx-x86-32" | 
					
						
							| 
									
										
										
										
											2008-01-19 15:18:35 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-16 16:56:17 -04:00
										 |  |  | MAKE_TARGET=unknown | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-13 23:00:54 -04:00
										 |  |  | # -n is nonzero length, -z is zero length | 
					
						
							|  |  |  | if [[ -n "$2" ]] ; then | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |     parse_build_info $2 | 
					
						
							| 
									
										
										
										
											2008-09-13 23:00:54 -04:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 17:27:12 -05:00
										 |  |  | set_copy | 
					
						
							|  |  |  | set_delete | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | case "$1" in | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     install) install ;; | 
					
						
							| 
									
										
										
										
											2008-03-08 13:00:40 -05:00
										 |  |  |     install-x11) install_build_system_apt; install ;; | 
					
						
							|  |  |  |     install-macosx) install_build_system_port; install ;; | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     self-update) update; make_boot_image; bootstrap;; | 
					
						
							|  |  |  |     quick-update) update; refresh_image ;; | 
					
						
							|  |  |  |     update) update; update_bootstrap ;; | 
					
						
							|  |  |  |     bootstrap) get_config_info; bootstrap ;; | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |     report) find_build_info ;; | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     net-bootstrap) get_config_info; update_boot_images; bootstrap ;; | 
					
						
							| 
									
										
										
										
											2008-09-13 23:24:45 -04:00
										 |  |  |     make-target) ECHO=false; find_build_info; echo $MAKE_TARGET ;; | 
					
						
							| 
									
										
										
										
											2008-03-04 16:25:36 -05:00
										 |  |  |     *) usage ;; | 
					
						
							| 
									
										
										
										
											2007-11-24 18:59:11 -05:00
										 |  |  | esac |