#!/bin/sh
#
# Building OSX fat binaries is easy.
#
# - start in a clean directory.
# - copy the shell script below to a file and edit the file to your needs.
#
# 1.) modify export GEOIP_ARCH='-arch i386 -arch x86_64 -arch ppc -arch ppc64'
# to include all architectures you need.
# 2.) add whatever you want to the ./configure line.
# 3.) execute the script.
# 4.) do a 'make install'
#
#
# make clean or make distclean before building this
#
# tell systems before leopard that we like to build for 10.4 or higher
# with MACOSX_DEPLOYMENT_TARGET=10.4
# starting with leopard we have to add -mmacosx-version-min=10.4
# to the CFLAGS and export MACOSX_DEPLOYMENT_TARGET!?

export GEOIP_ARCH='-arch i386 -arch x86_64 -arch ppc -arch ppc64'
export MACOSX_DEPLOYMENT_TARGET=10.4
export LDFLAGS=$GEOIP_ARCH
export CFLAGS="-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk $GEOIP_ARCH"
./configure --disable-dependency-tracking
perl -i.bak -pe'/^archive_cmds=/ and !/\bGEOIP_ARCH\b/ and s/-dynamiclib\b/-dynamiclib \\\$(GEOIP_ARCH)/' ./libtool
make
