aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreschnett <eschnett@091d3ff0-52bc-4db5-b7a6-18201e4c0cca>2010-11-24 02:55:09 +0000
committereschnett <eschnett@091d3ff0-52bc-4db5-b7a6-18201e4c0cca>2010-11-24 02:55:09 +0000
commit409df9f2aacd007e4d30fc1bc6376dc6e0a7cb55 (patch)
tree09c2574d70320ec623f50ccf415edfc2fc64e8c7
parent219d1ee1a92eb4feb8e336c201ac9967c0d5b8f6 (diff)
Allow using a pre-installed library.
Build and install into scratch/external. Clean up after building, removing all temporary files. git-svn-id: http://svn.cactuscode.org/projects/ExternalLibraries/OpenSSL/trunk@13 091d3ff0-52bc-4db5-b7a6-18201e4c0cca
-rw-r--r--OpenSSL.sh114
1 files changed, 85 insertions, 29 deletions
diff --git a/OpenSSL.sh b/OpenSSL.sh
index d5d1a97..39f0323 100644
--- a/OpenSSL.sh
+++ b/OpenSSL.sh
@@ -8,16 +8,42 @@
set -x # Output commands
set -e # Abort on errors
-# Set locations
-NAME=openssl-0.9.8l
-SRCDIR=$(dirname $0)
-INSTALL_DIR=${SCRATCH_BUILD}
-OPENSSL_DIR=${INSTALL_DIR}/${NAME}
-# Clean up environment
-unset EXE
-unset LIBS
-unset MAKEFLAGS
+
+################################################################################
+# Search
+################################################################################
+
+if [ -z "${OPENSSL_DIR}" ]; then
+ echo "BEGIN MESSAGE"
+ echo "OpenSSL selected, but OPENSSL_DIR not set. Checking some places..."
+ echo "END MESSAGE"
+
+ FILES="include/openssl/ssl.h lib/libssl.a lib/libcrypto.a"
+ DIRS="/usr /usr/local /opt/local"
+ for dir in $DIRS; do
+ OPENSSL_DIR="$dir"
+ for file in $FILES; do
+ if [ ! -r "$dir/$file" ]; then
+ unset OPENSSL_DIR
+ break
+ fi
+ done
+ if [ -n "$OPENSSL_DIR" ]; then
+ break
+ fi
+ done
+
+ if [ -z "$OPENSSL_DIR" ]; then
+ echo "BEGIN MESSAGE"
+ echo "OpenSSL not found"
+ echo "END MESSAGE"
+ else
+ echo "BEGIN MESSAGE"
+ echo "Found OpenSSL in ${OPENSSL_DIR}"
+ echo "END MESSAGE"
+ fi
+fi
@@ -25,51 +51,81 @@ unset MAKEFLAGS
# Build
################################################################################
+if [ -z "${OPENSSL_DIR}" -o "${OPENSSL_DIR}" = 'BUILD' ]; then
+ echo "BEGIN MESSAGE"
+ echo "Building OpenSSL..."
+ echo "END MESSAGE"
+
+ # Set locations
+ THORN=OpenSSL
+ NAME=openssl-0.9.8l
+ SRCDIR=$(dirname $0)
+ BUILD_DIR=${SCRATCH_BUILD}/build/${THORN}
+ INSTALL_DIR=${SCRATCH_BUILD}/external/${THORN}
+ DONE_FILE=${SCRATCH_BUILD}/done/${THORN}
+ OPENSSL_DIR=${INSTALL_DIR}
+
(
exec >&2 # Redirect stdout to stderr
set -x # Output commands
set -e # Abort on errors
- cd ${INSTALL_DIR}
- if [ -e done-${NAME} -a done-${NAME} -nt ${SRCDIR}/dist/${NAME}.tar.gz \
- -a done-${NAME} -nt ${SRCDIR}/OpenSSL.sh ]
+ cd ${SCRATCH_BUILD}
+ if [ -e ${DONE_FILE} -a ${DONE_FILE} -nt ${SRCDIR}/dist/${NAME}.tar.gz \
+ -a ${DONE_FILE} -nt ${SRCDIR}/OpenSSL.sh ]
then
echo "OpenSSL: The enclosed OpenSSL library has already been built; doing nothing"
else
echo "OpenSSL: Building enclosed OpenSSL library"
- echo "OpenSSL: Unpacking archive..."
- rm -rf build-${NAME}
- mkdir build-${NAME}
- pushd build-${NAME}
+ # Should we use gmake or make?
+ MAKE=$(gmake --help > /dev/null 2>&1 && echo gmake || echo make)
# Should we use gtar or tar?
TAR=$(gtar --help > /dev/null 2> /dev/null && echo gtar || echo tar)
+ if [ -z "$PATCH" ]; then
+ PATCH=$(gpatch -v > /dev/null 2>&1 && echo gpatch || echo patch)
+ fi
+
+ # Set up environment
+ unset EXE
+ unset LIBS
+ unset MAKEFLAGS
+
+ echo "OpenSSL: Preparing directory structure..."
+ mkdir build external done 2> /dev/null || true
+ rm -rf ${BUILD_DIR} ${INSTALL_DIR}
+ mkdir ${BUILD_DIR} ${INSTALL_DIR}
+
+ echo "OpenSSL: Unpacking archive..."
+ pushd ${BUILD_DIR}
${TAR} xzf ${SRCDIR}/dist/${NAME}.tar.gz
- patch -p1 < ${SRCDIR}/dist/darwin.patch
- popd
+ ${PATCH} -p1 < ${SRCDIR}/dist/darwin.patch
echo "OpenSSL: Configuring..."
- rm -rf ${NAME}
- mkdir ${NAME}
- pushd build-${NAME}/${NAME}
+ cd ${NAME}
./config --prefix=${OPENSSL_DIR}
echo "OpenSSL: Building..."
- make
+ ${MAKE}
echo "OpenSSL: Installing..."
- make install
+ ${MAKE} install
popd
- echo 'done' > done-${NAME}
+ echo "OpenSSL: Cleaning up..."
+ rm -rf ${BUILD_DIR}
+
+ date > ${DONE_FILE}
echo "OpenSSL: Done."
fi
)
-if (( $? )); then
- echo 'BEGIN ERROR'
- echo 'Error while building OpenSSL. Aborting.'
- echo 'END ERROR'
- exit 1
+ if (( $? )); then
+ echo 'BEGIN ERROR'
+ echo 'Error while building OpenSSL. Aborting.'
+ echo 'END ERROR'
+ exit 1
+ fi
+
fi