123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- #!/bin/bash
- export CROSS_COMPILE=yes
- EXITVAL=0
- if [ ! -f autogen.sh ]
- then
- echo "Please run this script from the root of the Tor distribution"
- exit -1
- fi
- if [ ! -f configure ]
- then
- if [ -z $GEN_BUILD ]
- then
- echo "To automatically generate the build environment, set \$GEN_BUILD"
- echo "to yes; for example,"
- echo " export GEN_BUILD=yes"
- EXITVAL=-1
- fi
- fi
- if [ -z $PREFIX ]
- then
- echo "You must define \$PREFIX since you are cross-compiling."
- echo "Select a non-system location (i.e. /tmp/tor-cross):"
- echo " export PREFIX=/tmp/tor-cross"
- EXITVAL=-1
- fi
- if [ -z $CROSSPATH ]
- then
- echo "You must define the location of your cross-compiler's"
- echo "directory using \$CROSSPATH; for example,"
- echo " export CROSSPATH=/opt/cross/staging_dir_mipsel/bin"
- EXITVAL=-1
- fi
- if [ -z $HOST_TRIPLET ]
- then
- echo "You must define \$HOST_TRIPLET to continue. For example,"
- echo "if you normally cross-compile applications using"
- echo "mipsel-linux-uclibc-gcc, you would set \$HOST_TRIPLET like so:"
- echo " export HOST_TRIPLET=mipsel-linux-uclibc-"
- EXITVAL=-1
- fi
- if [ -z $HOST ]
- then
- echo "You must specify a target processor with \$HOST; for example:"
- echo " export HOST=mipsel-unknown-elf"
- EXITVAL=-1
- fi
- if [ -z $BUILD ]
- then
- echo "You should specify the host machine's type with \$BUILD; for example:"
- echo " export BUILD=i686-pc-linux-gnu"
- echo "If you wish to let configure autodetect the host, set \$BUILD to 'auto':"
- echo " export BUILD=auto"
- EXITVAL=-1
- fi
- if [ ! -x $CROSSPATH/$HOST_TRIPLETgcc ]
- then
- echo "The specified toolchain does not contain an executable C compiler."
- echo "Please double-check your settings and rerun cross.sh."
- EXITVAL=-1
- fi
- if [ $EXITVAL -ne 0 ]
- then
- echo "Remember, you can hard-code these values in cross.sh if needed."
- exit $EXITVAL
- fi
- if [ ! -z "$GEN_BUILD" -a ! -f configure ]
- then
- export NOCONF=yes
- ./autogen.sh
- fi
- if [ -f src/or/tor ]
- then
- make clean
- fi
- export PATH=$PATH:$CROSSPATH
- export RANLIB=${HOST_TRIPLET}ranlib
- export CC=${HOST_TRIPLET}gcc
- if [ $BUILD == "auto" ]
- then
- ./configure \
- --enable-debug \
- --enable-eventdns \
- --prefix=$PREFIX \
- --host=$HOST
- else
- ./configure \
- --enable-debug \
- --enable-eventdns \
- --prefix=$PREFIX \
- --host=$HOST \
- --build=$BUILD
- fi
- if [ $? -ne 0 ]
- then
- echo ""
- echo "A problem has been detected with configure."
- echo "Please check the output above and rerun cross.sh"
- echo ""
- exit -1
- fi
- make
- if [ $? -ne 0 ]
- then
- echo ""
- echo "A problem has been detected with make."
- echo "Please check the output above and rerun make."
- echo ""
- exit -1
- fi
- if [ ! -z $STRIP ]
- then
- ${HOST_TRIPLET}strip \
- src/or/tor \
- src/or/test \
- src/tools/tor-resolve
- fi
- echo ""
- echo "Tor should be compiled at this point. Now run 'make install' to"
- echo "install to $PREFIX"
- echo ""
|