#!/bin/sh
#
# Copyright 2004 Dagmar d'Surreal <rivyqntzne@tznvy.pbz>
# Available under the terms of the GNU GPL.
#

NAME="openssl"
VERSION="0.9.7i"
REVISION="1"

PKG_SOURCEURL='http://www.openssl.org/source/openssl-$VERSION.tar.gz'
PKG_DESTDIRVAR="INSTALL_PREFIX"
PKG_PATCH[0]='openssl.soname.diff'

. $DLG_ROOT/config
. $DLG_ROOT/SCRIPTS/dropline-functions.sh

configfile /etc/ssl/openssl.cnf
prepare

applypatch 0 0 

tmp=${PKG_ARCH:+"-march=$PKG_ARCH"}
tmp=$tmp${PKG_CPU:+"${tmp:+" "}-mcpu=$PKG_CPU"}
sed -i -e "s/\"linux-elf\",\t\"gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486/\"linux-elf\",\t\"gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer $tmp/;" $PKG_SRCROOT/Configure

analyzesource

# MDC-2: 4,908,861 expires 13/03/2007.
# IDEA:  5,214,703 expires 25/05/2010.
# RC5:   5,724,428 expires 03/03/2015.
cd $PKG_BUILDROOT
loggedcommand configure "./config --prefix=/usr --openssldir=/etc/ssl no-mdc2 no-idea no-rc5 shared"

make depend
make
makecheck test
makeinstall

# The makefile for this package is a little crazy
spewdo "mv $PKG_STAGEROOT/etc/ssl/man $PKG_STAGEROOT$PKG_PREFIX/man"
# ...and why they make hard links in there I have no idea.
#cd $PKG_STAGEROOT$PKG_PREFIX/man
#for mandir in man*; do
#  cd $PKG_STAGEROOT$PKG_PREFIX/man/$mandir
#  for manpage in *.?; do
#    softenhardlink $manpage
#  done
#done

tidydocumentation
analyzebinaries
finalizepackage
packagize
cleanup
