Statically link applications with liboauth on Darwin/OSX

The result of the Google Group discussion on statically linking an application with liboauth (and it's dependent libraries) here's a script that does it:

Download script

#!/bin/bash
TOPDIR=/tmp/oauth-static
test -d $TOPDIR && rm -rf $TOPDIR
mkdir -p $TOPDIR
cd $TOPDIR

##############################################################################
# download sources
curl -o openssl-1.0.0a.tar.gz http://www.openssl.org/source/openssl-1.0.0a.tar.gz
curl -o curl-7.20.1.tar.gz http://curl.haxx.se/download/curl-7.20.1.tar.gz
curl -o liboauth-0.8.8.tar.gz http://liboauth.sourceforge.net/pool/liboauth-0.8.8.tar.gz

tar xzf openssl-1.0.0a.tar.gz
tar xzf curl-7.20.1.tar.gz
tar xzf liboauth-0.8.8.tar.gz

##############################################################################
# OpenSSL
cd openssl-1.0.0a
./Configure darwin-i386-cc
make

##############################################################################
# libcURL
cd $TOPDIR/curl-7.20.1
CFLAGS="-arch i386" \
./configure --disable-shared --without-nss --disable-ldap \
            --with-ssl=$TOPDIR/openssl-1.0.0a
make

##############################################################################
# liboauth
cd $TOPDIR/liboauth-0.8.8

####### NOTE: this uses system-wide libz or '/path/to/libz.a'
LIBZ="-lz"
test -d /Users/hborders/xcode-workspaces/personal/pdk-samples/simple/mac/palm-i386 && \
LIBZ="/Users/hborders/xcode-workspaces/personal/pdk-samples/simple/mac/palm-i386/lib/libz.a"

###### NOTE configure wants PKG_CONFIG to be set even if it's N/A
PKG_CONFIG="`which pkg-config || which true`" \
CFLAGS="-arch i386" \
CURL_CFLAGS="-I$TOPDIR/curl-7.20.1/include" \
CURL_LIBS="$TOPDIR/curl-7.20.1/lib/.libs/libcurl.a $LIBZ" \
HASH_CFLAGS="-I$TOPDIR/openssl-1.0.0a/include" \
HASH_LIBS="$TOPDIR/openssl-1.0.0a/libcrypto.a  $TOPDIR/openssl-1.0.0a/libssl.a $LIBZ" \
./configure --disable-shared --disable-curl --enable-libcurl

#build it
make

#run self-tests
make check

##############################################################################
# print some info about the example binary
echo "example binary:"
file tests/oauthexample

echo "example binary's library dependencies:"
LDD="ldd"
which otool >/dev/null && LDD="otool -L"
$LDD tests/oauthexample
 
oss/oauth/osx-static.txt · Last modified: 14.05.2014 21:05 by rgareus