mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-22 14:23:04 +01:00
Add cross.sh cross-compilation script from Michael Mohr. Trivial backport candidate, since adding a new script cannot possibly break anything.
svn:r6475
This commit is contained in:
parent
c1054ffe92
commit
820a7a2c24
2 changed files with 168 additions and 1 deletions
|
@ -3,7 +3,7 @@ DIST_SUBDIRS = osx
|
|||
|
||||
confdir = $(sysconfdir)/tor
|
||||
|
||||
EXTRA_DIST = exitlist tor-tsocks.conf torify.1 TorControl.py tor.nsi.in tor.sh torctl rc.subr ExerciseServer.py PathDemo.py
|
||||
EXTRA_DIST = exitlist tor-tsocks.conf torify.1 TorControl.py tor.nsi.in tor.sh torctl rc.subr ExerciseServer.py PathDemo.py cross.sh
|
||||
|
||||
conf_DATA = tor-tsocks.conf
|
||||
|
||||
|
|
167
contrib/cross.sh
Normal file
167
contrib/cross.sh
Normal file
|
@ -0,0 +1,167 @@
|
|||
#!/bin/bash
|
||||
# $Id$
|
||||
# Copyright 2006 Michael Mohr
|
||||
# See LICENSE for licensing information.
|
||||
|
||||
#######################################################################
|
||||
# Tor-cross: a tool to help cross-compile Tor
|
||||
#
|
||||
# mailto:tor-assistants@freehaven.net
|
||||
#
|
||||
# The purpose of a cross-compiler is to produce an executable for
|
||||
# one system (CPU) on another. This is useful, for example, when
|
||||
# the target system does not have a native compiler available.
|
||||
# You might, for example, wish to cross-compile a program on your
|
||||
# host (the computer you're working on now) for a target such as
|
||||
# a router or handheld computer.
|
||||
#
|
||||
# This script automatically patches two files in the Tor source:
|
||||
# configure.in : remove test programs
|
||||
# compat.h : remove check for NULL==0
|
||||
#
|
||||
# A number of environment variables must be set in order for this
|
||||
# script to work:
|
||||
# $PREFIX, $CROSSPATH, $ARCH_PREFIX, $HOST,
|
||||
# and (optionally) $BUILD
|
||||
# Please run the script for a description of each one. If automated
|
||||
# builds are desired, the above variables can be exported at the top
|
||||
# of this script.
|
||||
#
|
||||
# Recent releases of Tor include test programs in configure. Normally
|
||||
# this is a good thing, since it catches a number of problems.
|
||||
# However, this also presents a problem when cross compiling, since
|
||||
# you can't run binary images for the target system on the host.
|
||||
#
|
||||
# Tor-cross assumes that you know what you're doing and removes a
|
||||
# number of checks known to cause problems with this process.
|
||||
# Note that this does not guarantee that the program will run or
|
||||
# even compile; it simply allows configure to generate the Makefiles.
|
||||
#
|
||||
# Stripping the binaries should almost always be done for an
|
||||
# embedded environment where space is at an exacting premium.
|
||||
# However, the default is NOT to strip them since they are useful for
|
||||
# debugging. If you do not plan to do any debugging and you
|
||||
# don't care about the debugging symbols, set $STRIP to "yes" before
|
||||
# running this script.
|
||||
#
|
||||
# Tor-cross was written by Michael Mohr. He can be contacted at
|
||||
# m(dot)mohr(at)laposte(dot)net. Comments are appreciated, but
|
||||
# flames go to /dev/null.
|
||||
#
|
||||
# The target with which this script is tested is little-endian
|
||||
# MIPS Linux, built on an Athlon-based Linux desktop.
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
# disable some show-stopping bugs (see cross.patch for more)
|
||||
export CROSS_COMPILE=yes
|
||||
|
||||
if [ ! -f configure.in ]
|
||||
then
|
||||
echo "Please run this script from the root of the Tor distribution."
|
||||
exit -1
|
||||
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"
|
||||
exit -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"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ -z $ARCH_PREFIX ]
|
||||
then
|
||||
echo "You must define \$ARCH_PREFIX to continue. For example,"
|
||||
echo "if you normally cross-compile applications using"
|
||||
echo "mipsel-linux-uclibc-gcc, you would set \$ARCH_PREFIX like so:"
|
||||
echo " export ARCH_PREFIX=mipsel-linux-uclibc-"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ -z $HOST ]
|
||||
then
|
||||
echo "You must specify a target processor with \$HOST; for example:"
|
||||
echo " export HOST=mipsel-unknown-elf"
|
||||
exit -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"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# clean up any existing object files
|
||||
if [ -f src/or/tor ]
|
||||
then
|
||||
make clean
|
||||
fi
|
||||
|
||||
# check if the source has already been patched
|
||||
patch -f -p1 -R --dry-run < contrib/cross.patch > /dev/null 2>&1
|
||||
# if it hasn't, rerun the autotools
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
patch -p1 < contrib/cross.patch
|
||||
aclocal
|
||||
autoconf
|
||||
autoheader
|
||||
automake --add-missing
|
||||
fi
|
||||
|
||||
# Set up the buld environment and try to run configure
|
||||
export PATH=$PATH:$CROSSPATH
|
||||
export RANLIB=${ARCH_PREFIX}ranlib
|
||||
export CC=${ARCH_PREFIX}gcc
|
||||
|
||||
if [ $BUILD == "auto" ]
|
||||
then
|
||||
./configure \
|
||||
--prefix=$PREFIX \
|
||||
--host=$HOST
|
||||
else
|
||||
./configure \
|
||||
--prefix=$PREFIX \
|
||||
--host=$HOST \
|
||||
--build=$BUILD
|
||||
fi
|
||||
|
||||
# has a problem occurred?
|
||||
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
|
||||
|
||||
# Now we're cookin'
|
||||
|
||||
make
|
||||
|
||||
# if $STRIP has length (i.e. STRIP=yes), strip the binaries
|
||||
if [ ! -z $STRIP ]
|
||||
then
|
||||
${ARCH_PREFIX}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 ""
|
Loading…
Add table
Reference in a new issue