## Instructions for building the official dmgs for OSX.
##
## The loose table of contents:
## Single Architecture Binaries for PowerPc or i386 architecture, not both.
## Backwards compatible single-architecture binaries for OSX i386 10.4 from
## newer versions of OS X.
## Universal Binaries for OSX PPC and i386
## Each section is delineated by ###.

#######################################
#
# Section 1
#
# Single Architecture Binaries for PPC or i386, not both.
# This method works in all versions of OSX 10.3 through 10.6
#######################################

## Compiling libevent ##

1) Download the latest stable libevent from
http://www.monkey.org/~provos/libevent/

2) The first step of compiling libevent is to configure it as
follows:
./configure --enable-static --disable-shared

3) Complete the "make" and "make install". You will need to be root,
or sudo -s, to complete the "make install".

## Compiling Tor ##

4) Get your preferred version of the tor source from
https://www.torproject.org/dist/ or
http://archive.torproject.org/tor-package-archive/. Extract the tarball.

5) In the top level, this means /path/to/tor/, not tor/contrib/osx,
do a configure with these parameters:

CONFDIR=/Library/Tor ./configure --prefix=/Library/Tor \
--bindir=/Library/Tor --sysconfdir=/Library

6) In same top level dir, do a "make dist-osx". There now exists a
.dmg file in the same directory. Install from this dmg.

#######################################
#
# Section 2
# Backwards compatible single-architecture binaries for OSX x86 10.4 from
# newer versions of OS X.
#
#######################################

1) Install the latest XCode updates available from http://developer.apple.com.

## Compiling libevent ##

2) Download latest stable libevent from
http://www.monkey.org/~provos/libevent/

3) The first step of compiling libevent is to configure it as
follows:

CFLAGS="-O -g -mmacosx-version-min=10.4 -isysroot \
/Developer/SDKs/MacOSX10.4u.sdk -arch i386" \
LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" \
./configure --enable-static --disable-shared --disable-dependency-tracking \
CC="gcc-4.0"

4) Complete the "make" and "make install". You will need to be root,
or sudo -s, to complete the "make install".

5) Check for a successful universal binary of libevent.a in, by default,
/usr/local/lib by using the following command:

	"file /usr/local/lib/libevent.a"

	Your output should be:

"/usr/local/lib/libevent.a (for architecture i386):
current ar archive random library"

6) Get your preferred version of the tor source from
https://www.torproject.org/dist/ or
http://archive.torproject.org/tor-package-archive/.
Extract the tarball.

7) In the top level, this means /path/to/tor/, not tor/contrib/osx,
do a configure with these parameters:

CFLAGS="-O -g -mmacosx-version-min=10.4 -isysroot \
/Developer/SDKs/MacOSX10.4u.sdk -arch i386" \
LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" \
CONFDIR=/Library/Tor \
./configure --prefix=/Library/Tor --bindir=/Library/Tor \
--sysconfdir=/Library --disable-dependency-tracking CC="gcc-4.0"

8) "make dist-osx"

9) Confirm you have created a universal binary by issuing the follow command:
"file src/or/tor". Its output should be as follows:
src/or/tor (for architecture i386): Mach-O executable i386

10) There should exist in the top-level directory a
Tor-$VERSION-i386-Bundle.dmg

11) Congrats. You have a backwards-compatible binary.
You are now ready to install Tor.

####################################################################
#
# Section 3
#
# Universal Binaries for OSX PPC and X86
# This method works in OSX 10.4 (Tiger) and newer OSX versions.
#
####################################################################

1) Install the latest XCode updates available from http://developer.apple.com.

## Compiling libevent ##

2) Download latest stable libevent from
http://www.monkey.org/~provos/libevent/

3) The first step of compiling libevent is to configure it as
follows:
CFLAGS="-O -g -mmacosx-version-min=10.4 -isysroot \
/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc" \
LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" \
./configure --enable-static --disable-shared --disable-dependency-tracking \
CC="gcc-4.0"

4) Complete the "make" and "make install". You will need to be root,
or sudo -s, to complete the "make install".

5) Check for a successful universal binary of libevent.a in, by default,
/usr/local/lib by using the following command:
	"file /usr/local/lib/libevent.a"

	Your output should be:

/usr/local/lib/libevent.a: Mach-O fat file with 2 architectures
/usr/local/lib/libevent.a (for architecture i386):
current ar archive random library
/usr/local/lib/libevent.a (for architecture ppc):
current ar archive

6) Get your preferred version of the tor source from
https://www.torproject.org/dist/ or
http://archive.torproject.org/tor-package-archive/.
Extract the tarball.

7) In the top level, this means /path/to/tor/, not tor/contrib/osx,
do a configure with these parameters:

CFLAGS="-O -g -mmacosx-version-min=10.4 -isysroot \
/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc" \
LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" \
CONFDIR=/Library/Tor \
./configure --prefix=/Library/Tor --bindir=/Library/Tor \
--sysconfdir=/Library --disable-dependency-tracking CC="gcc-4.0"

8) "make dist-osx"

9) Confirm you have created a universal binary by issuing the follow command:
"file src/or/tor". Its output should be as follows:

src/or/tor: Mach-O fat file with 2 architectures
src/or/tor (for architecture i386): Mach-O executable i386
src/or/tor (for architecture ppc): Mach-O executable ppc

10) There should exist in the top-level directory a
Tor-$VERSION-universal-Bundle.dmg

11) Congrats. You have a universal binary. You are now ready to install Tor.
