#!/bin/sh

BUILDDIR=`pwd`
LZODIR=$BUILDDIR/lzo-2.02
OPENVPNDIR=$BUILDDIR/openvpn-2.0.9
#OPENVPNINSTALLDIR=$BUILDDIR/target_build

#### Building the LZO ###
cd $LZODIR
CC=/opt/hardhat/devkit/arm/xscale_be/bin/xscale_be-gcc CFLAGS=-O2 ./configure --enable-shared --host=i686 --target=arm-linux
make

### Building the OpenVPN ###
cd $OPENVPNDIR
./configure CC=/opt/hardhat/devkit/arm/xscale_be/bin/xscale_be-gcc --enable-shared --host=i686 --target=arm-linux --with-lzo-lib=$LZODIR/src/.libs --with-lzo-headers=$LZODIR/include --with-ssl-lib=../../openssl/openssl-0.9.7e --with-ssl-headers=../../openssl/openssl-0.9.7e/include
make

# Build the auto-install package
#mkdir -p $OPENVPNINSTALLDIR/sbin
#cp -a $OPENVPNDIR/openvpn $OPENVPNINSTALLDIR/sbin/
#xscale_be-strip $OPENVPNINSTALLDIR/sbin/openvpn
#tar -cvf openvpn.tar $OPENVPNINSTALLDIR/*
#make
