2012-08-26 08:39:24 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-03-07 14:56:48 +00:00
|
|
|
#
|
|
|
|
# This file is a part of Pcompress, a chunked parallel multi-
|
|
|
|
# algorithm lossless compression and decompression program.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved.
|
|
|
|
# Use is subject to license terms.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 3 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# moinakg@belenix.org, http://moinakg.wordpress.com/
|
|
|
|
#
|
|
|
|
|
2012-08-26 08:39:24 +00:00
|
|
|
usage() {
|
|
|
|
prog=$1
|
|
|
|
cat << _EOF
|
|
|
|
${prog} [<options>]
|
|
|
|
|
|
|
|
<options> can be one of the following:
|
|
|
|
|
|
|
|
--prefix=<val> The installation prefix (default: /usr).
|
|
|
|
--enable-debug Enable debug mode compilation (default: disabled).
|
|
|
|
--disable-allocator Disable use of internal memory allocator mechanism (default: enabled).
|
|
|
|
--enable-debug-stats Enable printing of some verbose debug info (default: disabled).
|
2012-10-03 17:13:02 +00:00
|
|
|
--with-libbsc=<path to libbsc source>
|
2012-08-27 16:21:55 +00:00
|
|
|
Enable support for libbsc (See: libbsc.com). Full path to the libbsc
|
2013-03-03 14:32:14 +00:00
|
|
|
source tree must be provided. It links the library statically.
|
2012-10-03 17:13:02 +00:00
|
|
|
--with-openssl=<path to OpenSSL installation tree> (Default: System)
|
2013-03-03 14:32:14 +00:00
|
|
|
This defaults to the system's OpenSSL library. You can use this option
|
|
|
|
if you want to use an alternate OpenSSL installation.
|
2012-12-16 17:47:04 +00:00
|
|
|
--with-zlib=<path to zlib installation tree> (Default: System)
|
2013-03-03 14:32:14 +00:00
|
|
|
Enable building against an alternate Zlib installation.
|
2012-12-16 17:47:04 +00:00
|
|
|
--with-bzlib=<path to Bzip2 library installation tree> (Default: System)
|
2013-03-03 14:32:14 +00:00
|
|
|
Enable building against an alternate Bzip2 and library installation.
|
2013-01-24 18:40:12 +00:00
|
|
|
--no-sse-detect Do NOT attempt to probe the system's SSE/AVX capability for build flags.
|
2013-02-24 14:35:16 +00:00
|
|
|
--no-1.3-archive-compat Disable compatibility with compressed archives created with Pcompress
|
2013-03-03 14:32:14 +00:00
|
|
|
version 1.3 (default: retain compatibility). Hash formats changed from
|
|
|
|
version 1.3 to 1.4 so this option is required if files created using
|
|
|
|
1.3 need to be decompressed by version 1.4 onwards.
|
|
|
|
--limit-key128 Limit key length to 128-bit encryption keys. Otherwise the default is to
|
|
|
|
use 256-bit keys changeable at runtime via the '-k <keylen>' option.
|
2012-08-26 08:39:24 +00:00
|
|
|
--help Display this help message.
|
|
|
|
|
|
|
|
_EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
arg1=$1
|
|
|
|
debug=0
|
|
|
|
allocator=1
|
|
|
|
debug_stats=0
|
|
|
|
prefix=/usr
|
2012-08-27 16:21:55 +00:00
|
|
|
libbsc_dir=
|
|
|
|
libbsc_lib=
|
|
|
|
libbsclflags=
|
|
|
|
libbscwrapobj=
|
|
|
|
libbscgenopt=
|
|
|
|
libbsccppflags=
|
2012-10-03 17:13:02 +00:00
|
|
|
openssl_prefix=
|
|
|
|
openssl_libdir=
|
|
|
|
openssl_incdir=
|
2012-10-21 15:33:07 +00:00
|
|
|
libbz2_libdir=
|
|
|
|
libz_libdir=
|
2012-10-06 15:21:23 +00:00
|
|
|
sha256asmobjs=
|
|
|
|
sha256objs=
|
2012-10-15 06:40:00 +00:00
|
|
|
keylen=
|
2012-10-06 15:21:23 +00:00
|
|
|
yasm=yasm
|
2012-12-08 08:49:01 +00:00
|
|
|
keccak_srcs=
|
|
|
|
keccak_hdrs=
|
|
|
|
keccak_srcs_asm=
|
2013-01-20 17:23:36 +00:00
|
|
|
extra_opt_flags=
|
2012-12-16 17:47:04 +00:00
|
|
|
zlib_prefix=
|
|
|
|
bzlib_prefix=
|
2013-01-20 17:23:36 +00:00
|
|
|
sse_detect=1
|
2013-01-24 18:40:12 +00:00
|
|
|
sse_opt_flags="-msse2"
|
2013-02-24 14:35:16 +00:00
|
|
|
crypto_compat_objs='\$\(CRYPTO_COMPAT_OBJS\)'
|
|
|
|
crypto_compat_flags="-D__HASH_COMPATIBILITY_"
|
2013-03-04 16:26:07 +00:00
|
|
|
salsa20_stream_c=
|
|
|
|
salsa20_stream_asm='\$\(XSALSA20_STREAM_ASM\)'
|
|
|
|
salsa20_debug=
|
2012-12-08 08:49:01 +00:00
|
|
|
|
2013-01-04 18:46:15 +00:00
|
|
|
rm -rf ./buildtmp
|
|
|
|
mkdir ./buildtmp
|
|
|
|
|
2012-12-08 08:49:01 +00:00
|
|
|
# Try a simple compilation
|
|
|
|
cat << _EOF > tst.c
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
long l;
|
2012-12-17 14:53:30 +00:00
|
|
|
printf("%lu\n", sizeof (l));
|
2012-12-08 08:49:01 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
_EOF
|
|
|
|
|
|
|
|
gcc tst.c -o tst
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "ERROR:"
|
2013-01-24 18:40:12 +00:00
|
|
|
echo "Cannot compile a simple program. GCC 4.4 and above is required"
|
2012-12-08 08:49:01 +00:00
|
|
|
echo "to build this program. Please include installation bindir of GCC in the PATH."
|
|
|
|
echo ""
|
|
|
|
rm -f tst.c
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-12-17 13:07:27 +00:00
|
|
|
# Check bitness of system/toolchain
|
2012-12-08 08:49:01 +00:00
|
|
|
bitness=`./tst`
|
|
|
|
if [ $bitness -lt 8 ]
|
|
|
|
then
|
2012-12-17 13:07:27 +00:00
|
|
|
# Hmmm maybe default compilation is 32-bit. Re-try with m64 flag.
|
|
|
|
gcc -m64 tst.c -o tst
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
rm -f tst tst.c
|
|
|
|
echo "ERROR:"
|
|
|
|
echo "Only 64-bit platforms are supported."
|
|
|
|
echo ""
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If m64 compilation succeeds we assume platform to be 64-bit capable but
|
|
|
|
# explicit flag is reqd.
|
2013-01-20 17:23:36 +00:00
|
|
|
extra_opt_flags="-m64"
|
2012-12-08 08:49:01 +00:00
|
|
|
fi
|
2012-12-17 13:07:27 +00:00
|
|
|
rm -f tst tst.c
|
2012-08-27 16:21:55 +00:00
|
|
|
|
2012-08-26 08:39:24 +00:00
|
|
|
while [ "${arg1}" != "" ]
|
|
|
|
do
|
|
|
|
case "$arg1" in
|
|
|
|
--enable-debug) debug=1;;
|
|
|
|
--disable-allocator) allocator=0;;
|
|
|
|
--enable-debug-stats) debug_stats=1;;
|
|
|
|
--prefix=*)
|
|
|
|
pval=`echo ${arg1} | cut -f2 -d"="`
|
|
|
|
prefix=$pval
|
|
|
|
;;
|
2012-08-27 16:21:55 +00:00
|
|
|
--with-libbsc=*)
|
|
|
|
path=`echo ${arg1} | cut -f2 -d"="`
|
|
|
|
if [ -f ${path}/bsc.cpp -a -f ${path}/libbsc/libbsc.h ]
|
|
|
|
then
|
|
|
|
libbsc_dir="${path}"
|
|
|
|
libbsc_lib="${path}/libbsc.a"
|
|
|
|
libbsclflags='\$\(LIBBSCLFLAGS\)'
|
|
|
|
libbscwrapobj='\$\(LIBBSCWRAPOBJ\)'
|
|
|
|
libbscgenopt='\$\(LIBBSCGEN_OPT\)'
|
|
|
|
libbsccppflags='\$\(LIBBSCCPPFLAGS\)'
|
|
|
|
else
|
|
|
|
echo "Libbsc not found in ${path}, not enabling libbsc support.\n"
|
|
|
|
fi
|
|
|
|
;;
|
2012-10-03 17:13:02 +00:00
|
|
|
--with-openssl=*)
|
|
|
|
openssl_prefix=`echo ${arg1} | cut -f2 -d"="`
|
|
|
|
;;
|
2012-12-16 17:47:04 +00:00
|
|
|
--with-zlib=*)
|
|
|
|
zlib_prefix=`echo ${arg1} | cut -f2 -d"="`
|
|
|
|
;;
|
|
|
|
--with-bzlib=*)
|
|
|
|
bzlib_prefix=`echo ${arg1} | cut -f2 -d"="`
|
|
|
|
;;
|
2012-10-15 06:40:00 +00:00
|
|
|
--use-key256)
|
2013-03-03 14:32:14 +00:00
|
|
|
keylen='-DDEFAULT_KEYLEN=16'
|
2012-10-15 06:40:00 +00:00
|
|
|
;;
|
2013-01-24 18:40:12 +00:00
|
|
|
--no-sse-detect)
|
2013-01-20 17:23:36 +00:00
|
|
|
sse_detect=0
|
|
|
|
;;
|
2013-02-24 14:35:16 +00:00
|
|
|
--no-1.3-archive-compat)
|
|
|
|
crypto_compat_objs=""
|
|
|
|
crypto_compat_flags=""
|
|
|
|
;;
|
2012-08-26 08:39:24 +00:00
|
|
|
--help) usage $0;;
|
|
|
|
*)
|
|
|
|
echo "Unrecognized option: ${arg1}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
arg1=$1
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $debug -eq 1 ]
|
|
|
|
then
|
|
|
|
typ="DEBUG"
|
2013-03-04 16:26:07 +00:00
|
|
|
salsa20_stream_c='\$\(XSALSA20_STREAM_C\)'
|
|
|
|
salsa20_stream_asm=
|
|
|
|
salsa20_debug='\$\(XSALSA20_DEBUG\)'
|
2012-08-26 08:39:24 +00:00
|
|
|
else
|
|
|
|
typ="RELEASE"
|
|
|
|
fi
|
|
|
|
|
2012-09-01 09:10:15 +00:00
|
|
|
OS=$(uname)
|
|
|
|
skeinblock='\$\(SKEIN_BLOCK_C\)'
|
|
|
|
if [ "$OS" = "Linux" ]
|
|
|
|
then
|
2012-10-21 15:33:07 +00:00
|
|
|
plat=$(uname -m)
|
2012-09-01 09:10:15 +00:00
|
|
|
elif [ "$OS" = "SunOS" ]
|
|
|
|
then
|
|
|
|
plat=$(isainfo -v)
|
|
|
|
else
|
|
|
|
echo "Unsupported OS: $OS"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-12-08 08:49:01 +00:00
|
|
|
# Check GCC version
|
|
|
|
vers=`gcc -dumpversion`
|
|
|
|
OIFS="$IFS"
|
|
|
|
IFS=.
|
|
|
|
set -- ${vers}
|
|
|
|
IFS="$OIFS"
|
|
|
|
|
2013-01-24 18:40:12 +00:00
|
|
|
if [ $1 -lt 4 -o $2 -lt 4 ]
|
2012-12-08 08:49:01 +00:00
|
|
|
then
|
|
|
|
echo "ERROR:"
|
2013-01-24 18:40:12 +00:00
|
|
|
echo "GCC version 4.4 or above is required."
|
2012-12-08 08:49:01 +00:00
|
|
|
echo ""
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-01-20 17:23:36 +00:00
|
|
|
# SSE Detection
|
|
|
|
if [ $sse_detect -eq 1 ]
|
|
|
|
then
|
|
|
|
gcc -o sse_level ./utils/sse_level.c ./utils/cpuid.c -I./utils
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "ERROR:"
|
|
|
|
echo "Failed to build SSE detection utility."
|
|
|
|
echo ""
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
sse_ver=`./sse_level`
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
rm -f sse_level
|
|
|
|
echo "ERROR:"
|
|
|
|
echo "SSE version detection utility. Try configuring with --no-sse-check option."
|
|
|
|
echo ""
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
rm -f sse_level
|
2013-01-24 18:40:12 +00:00
|
|
|
sse_opt_flags="-m${sse_ver}"
|
2013-01-20 17:23:36 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2012-09-01 09:10:15 +00:00
|
|
|
echo $plat | egrep 'x86_64|amd64' > /dev/null
|
|
|
|
if [ $? -eq 0 ]
|
|
|
|
then
|
|
|
|
skeinblock='\$\(SKEIN_BLOCK_ASM\)'
|
2012-10-06 15:21:23 +00:00
|
|
|
yasm=
|
|
|
|
|
|
|
|
#
|
|
|
|
# Detect Yasm
|
|
|
|
#
|
|
|
|
for bindir in /bin /usr/bin /usr/local/bin
|
|
|
|
do
|
|
|
|
if [ -x ${bindir}/yasm ]
|
|
|
|
then
|
|
|
|
# Get yasm version
|
|
|
|
yver=`${bindir}/yasm --version | head -1 | awk '{print $2}'`
|
|
|
|
_OIFS=$IFS; IFS="."; set -- ${yver}; IFS="$_OIFS"
|
|
|
|
major=$1
|
|
|
|
minor=$2
|
|
|
|
|
|
|
|
# Minimum yasm version 1.1
|
|
|
|
[ $major -lt 1 -o $minor -lt 1 ] && continue
|
|
|
|
yasm=${bindir}/yasm
|
2013-01-25 17:25:55 +00:00
|
|
|
sha256asmobjs='\$\(SHA2ASM_OBJS\)'
|
|
|
|
sha256objs='\$\(SHA2_OBJS\)'
|
2012-10-06 15:21:23 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ "x${yasm}" = "x" ]
|
|
|
|
then
|
|
|
|
echo "Yasm version 1.1 or later is required to build on x64 platforms"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-12-08 08:49:01 +00:00
|
|
|
|
|
|
|
if [ $debug -eq 1 ]
|
|
|
|
then
|
|
|
|
keccak_srcs='\$\(KECCAK_SRC_OPT64\)'
|
|
|
|
keccak_hdrs='\$\(KECCAK_HDRS_OPT64\)'
|
|
|
|
else
|
|
|
|
keccak_srcs='\$\(KECCAK_SRC_OPT64_ASM1\)'
|
|
|
|
keccak_srcs_asm='\$\(KECCAK_SRC_OPT64_ASM2\)'
|
|
|
|
keccak_hdrs='\$\(KECCAK_HDRS_OPT64_ASM\)'
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
keccak_srcs='\$\(KECCAK_SRC_OPT64\)'
|
2012-09-01 09:10:15 +00:00
|
|
|
fi
|
|
|
|
|
2012-10-03 17:13:02 +00:00
|
|
|
# Detect OpenSSL library
|
|
|
|
for lib in "${openssl_prefix}/lib64" "${openssl_prefix}/usr/lib64" \
|
|
|
|
"${openssl_prefix}/lib" "${openssl_prefix}/usr/lib" \
|
2012-10-21 15:33:07 +00:00
|
|
|
"${openssl_prefix}/ssl/lib64" "${openssl_prefix}/ssl/lib" \
|
|
|
|
"${openssl_prefix}/lib/x86_64-linux-gnu" \
|
|
|
|
"${openssl_prefix}/usr/lib/x86_64-linux-gnu"
|
2012-10-03 17:13:02 +00:00
|
|
|
do
|
|
|
|
if [ -d ${lib} ]
|
|
|
|
then
|
2012-10-21 15:33:07 +00:00
|
|
|
if [ -f "${lib}/libcrypto.so" -o -h "${lib}/libcrypto.so" ]
|
2012-10-03 17:13:02 +00:00
|
|
|
then
|
2013-01-04 18:46:15 +00:00
|
|
|
openssl_libdir="${lib}"
|
|
|
|
(cd ./buildtmp; ln -s ${openssl_libdir}/libcrypto.so)
|
2012-10-03 17:13:02 +00:00
|
|
|
break
|
|
|
|
else
|
|
|
|
if [ -f "${lib}/libcrypto.a" ]
|
|
|
|
then
|
2013-01-04 18:46:15 +00:00
|
|
|
openssl_libdir="${lib}"
|
|
|
|
(cd ./buildtmp; ln -s ${openssl_libdir}/libcrypto.a)
|
2012-10-03 17:13:02 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "x${openssl_libdir}" = "x" ]
|
|
|
|
then
|
|
|
|
echo "ERROR: OpenSSL libraries not detected."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Detect OpenSSL headers
|
|
|
|
for inc in "${openssl_prefix}/include" \
|
|
|
|
"${openssl_prefix}/usr/include" \
|
|
|
|
"${openssl_prefix}/ssl/include"
|
|
|
|
do
|
|
|
|
if [ -d ${inc} ]
|
|
|
|
then
|
|
|
|
if [ -f "${inc}/openssl/sha.h" ]
|
|
|
|
then
|
|
|
|
openssl_incdir=${inc}
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "x${openssl_incdir}" = "x" ]
|
|
|
|
then
|
|
|
|
echo "ERROR: OpenSSL header files not detected."
|
|
|
|
if [ "x${openssl_prefix}" = "x" ]
|
|
|
|
then
|
2012-10-21 15:33:07 +00:00
|
|
|
echo "Depending on your system you may need to install the openssl-devel or openssl-dev package."
|
2012-10-03 17:13:02 +00:00
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-10-06 15:21:23 +00:00
|
|
|
|
2013-01-04 18:46:15 +00:00
|
|
|
# Check for OpenSSL version
|
|
|
|
cat << __EOF > tst.c
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <openssl/opensslv.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
if (OPENSSL_VERSION_NUMBER < 0x0090805fL)
|
|
|
|
exit (1);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
__EOF
|
|
|
|
|
2013-01-20 17:23:36 +00:00
|
|
|
gcc ${extra_opt_flags} -I${openssl_incdir} -L${openssl_libdir} tst.c -o tst
|
2013-01-04 18:46:15 +00:00
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "Unable to compile OpenSSL test program please check OpenSSL installation."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
./tst
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "OpenSSL version too old. At least version 0.9.8e is required.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for HMAC_CTX_copy function
|
|
|
|
cat << __EOF > tst.c
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <openssl/sha.h>
|
|
|
|
#include <openssl/rand.h>
|
|
|
|
#include <openssl/evp.h>
|
|
|
|
#include <openssl/hmac.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
unsigned char key[16];
|
|
|
|
HMAC_CTX *ctx = (HMAC_CTX *)malloc(sizeof (HMAC_CTX));
|
|
|
|
HMAC_CTX *ctx1 = (HMAC_CTX *)malloc(sizeof (HMAC_CTX));
|
|
|
|
|
|
|
|
HMAC_CTX_init(ctx);
|
|
|
|
HMAC_Init_ex(ctx, key, 16, EVP_sha256(), NULL);
|
|
|
|
HMAC_CTX_copy(ctx1, ctx);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
__EOF
|
|
|
|
|
2013-01-20 17:23:36 +00:00
|
|
|
gcc ${extra_opt_flags} -I${openssl_incdir} -L${openssl_libdir} -O0 -g tst.c -o tst -lcrypto >/dev/null 2>&1
|
2013-01-04 18:46:15 +00:00
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
openssl_incdir="${openssl_incdir} -D__OSSL_OLD__"
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f tst*
|
|
|
|
openssl_libdir="${openssl_libdir},--enable-new-dtags"
|
|
|
|
|
2012-10-21 15:33:07 +00:00
|
|
|
# Detect other library packages
|
2012-12-16 17:47:04 +00:00
|
|
|
for libspec in "libbz2:${bzlib_prefix}" "libz:${zlib_prefix}"
|
2012-10-21 15:33:07 +00:00
|
|
|
do
|
2012-12-16 17:47:04 +00:00
|
|
|
_OIFS="$IFS"
|
|
|
|
IFS=":"
|
|
|
|
set -- ${libspec}
|
|
|
|
libname=$1
|
|
|
|
pref=$2
|
|
|
|
IFS="$_OIFS"
|
|
|
|
|
|
|
|
use_prefix="${pref}"
|
|
|
|
if [ "x${pref}" = "x" ]
|
|
|
|
then
|
|
|
|
use_prefix="$prefix"
|
|
|
|
fi
|
|
|
|
for lib in "${pref}/lib64" "${pref}/usr/lib64" "${pref}/lib" "${pref}/usr/lib" \
|
|
|
|
"${pref}/lib/x86_64-linux-gnu" "${pref}/usr/lib/x86_64-linux-gnu" \
|
|
|
|
"${pref}/local/lib64" "${pref}/usr/local/lib64" "${pref}/local/lib" "${pref}/usr/local/lib" \
|
|
|
|
"${pref}/local/lib/x86_64-linux-gnu" "${pref}/usr/local/lib/x86_64-linux-gnu" \
|
|
|
|
"${use_prefix}/lib64" "${use_prefix}/lib" "${use_prefix}/lib/x86_64-linux-gnu" \
|
|
|
|
"${use_prefix}/usr/lib/x86_64-linux-gnu"
|
2012-10-21 15:33:07 +00:00
|
|
|
do
|
|
|
|
if [ -d ${lib} ]
|
|
|
|
then
|
|
|
|
if [ -f "${lib}/${libname}.so" -o -h "${lib}/${libname}.so" ]
|
|
|
|
then
|
2013-01-04 18:46:15 +00:00
|
|
|
eval "${libname}_libdir=${lib},--enable-new-dtags"
|
|
|
|
(cd ./buildtmp; ln -s ${lib}/${libname}.so)
|
2012-10-21 15:33:07 +00:00
|
|
|
break
|
|
|
|
else
|
|
|
|
if [ -f "${lib}/${libname}.a" ]
|
|
|
|
then
|
2013-01-04 18:46:15 +00:00
|
|
|
eval "${libname}_libdir=${lib},--enable-new-dtags"
|
|
|
|
(cd ./buildtmp; ln -s ${lib}/${libname}.a)
|
2012-10-21 15:33:07 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "x${libbz2_libdir}" = "x" ]
|
|
|
|
then
|
2012-12-16 17:47:04 +00:00
|
|
|
if [ "x$bzlib_prefix" = "x" ]
|
|
|
|
then
|
|
|
|
echo "ERROR: Libbz2 not detected."
|
|
|
|
echo " You may have to install libbz2-devel or libbz2-dev"
|
|
|
|
else
|
|
|
|
echo "ERROR: Bzip2 library not detected in given prefix."
|
|
|
|
fi
|
2012-10-21 15:33:07 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "x${libz_libdir}" = "x" ]
|
|
|
|
then
|
2012-12-16 17:47:04 +00:00
|
|
|
if [ "x$zlib_prefix" = "x" ]
|
|
|
|
then
|
|
|
|
echo "ERROR: Zlib not detected."
|
|
|
|
echo " You may have to install libz-devel or libz-dev"
|
|
|
|
else
|
|
|
|
echo "ERROR: Zlib not detected in given prefix."
|
|
|
|
fi
|
2012-10-21 15:33:07 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
libbz2_inc=
|
|
|
|
libz_inc=
|
|
|
|
# Detect other library headers
|
2012-12-16 17:47:04 +00:00
|
|
|
for hdr in "libbz2_inc:bzlib.h:${bzlib_prefix}" "libz_inc:zlib.h:${zlib_prefix}"
|
2012-10-21 15:33:07 +00:00
|
|
|
do
|
|
|
|
_OIFS="$IFS"
|
|
|
|
IFS=":"
|
|
|
|
set -- ${hdr}
|
|
|
|
var=$1
|
|
|
|
hdrf=$2
|
2012-12-16 17:47:04 +00:00
|
|
|
pref=$3
|
2012-10-21 15:33:07 +00:00
|
|
|
IFS="$_OIFS"
|
|
|
|
|
2012-12-16 17:47:04 +00:00
|
|
|
use_prefix="${pref}"
|
|
|
|
if [ "x${pref}" = "x" ]
|
|
|
|
then
|
|
|
|
use_prefix="$prefix"
|
|
|
|
fi
|
|
|
|
for inc in "${pref}/include" "${pref}/usr/include" \
|
|
|
|
"${pref}/local/include" "${pref}/usr/local/include" \
|
|
|
|
"${use_prefix}/include" "${use_prefix}/usr/include"
|
2012-10-21 15:33:07 +00:00
|
|
|
do
|
|
|
|
if [ -d ${inc} ]
|
|
|
|
then
|
|
|
|
if [ -f "${inc}/${hdrf}" ]
|
|
|
|
then
|
|
|
|
eval "${var}=\"-I${inc}\""
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2012-08-26 08:39:24 +00:00
|
|
|
linkvar="LINK"
|
|
|
|
compilevar="COMPILE"
|
|
|
|
compilecppvar="COMPILE_cpp"
|
|
|
|
vecflagsvar="VEC_FLAGS"
|
|
|
|
loopoptflagsvar="LOOP_OPTFLAGS"
|
|
|
|
cppflagsvar="CPPFLAGS"
|
|
|
|
genoptvar="GEN_OPT"
|
|
|
|
noslabcppflagsvar="NO_SLAB_CPPFLAGS"
|
|
|
|
debugstatscppflagsvar="DEBUG_STATS_CPPFLAGS"
|
|
|
|
prefixvar="PREFIX"
|
2012-09-01 09:10:15 +00:00
|
|
|
skeinblockvar="SKEIN_BLOCK"
|
2012-10-15 06:40:00 +00:00
|
|
|
keylenvar="KEYLEN"
|
2012-08-26 08:39:24 +00:00
|
|
|
|
2012-08-27 16:21:55 +00:00
|
|
|
libbscdirvar="LIBBSCDIR"
|
|
|
|
libbsclibvar="LIBBSCLIB"
|
|
|
|
libbsclflagsvar="LIBBSCLFLAGS"
|
|
|
|
libbscwrapobjvar="LIBBSCWRAPOBJ"
|
|
|
|
libbscgenoptvar="LIBBSCGEN_OPT"
|
|
|
|
libbsccppflagsvar="LIBBSCCPPFLAGS"
|
2013-01-25 17:25:55 +00:00
|
|
|
sha256asmobjsvar="SHA2ASM_OBJS"
|
|
|
|
sha256objsvar="SHA2_OBJS"
|
2012-10-06 15:21:23 +00:00
|
|
|
yasmvar="YASM"
|
2012-12-08 08:49:01 +00:00
|
|
|
fptr_flag_var="FPTR_FLAG"
|
2013-01-20 17:23:36 +00:00
|
|
|
extra_opt_flags_var="EXTRA_OPT_FLAGS"
|
2013-01-24 18:40:12 +00:00
|
|
|
sse_opt_flags_var="SSE_OPT_FLAGS"
|
2012-08-27 16:21:55 +00:00
|
|
|
|
2012-10-03 17:13:02 +00:00
|
|
|
openssllibdirvar="OPENSSL_LIBDIR"
|
|
|
|
opensslincdirvar="OPENSSL_INCDIR"
|
2012-10-21 15:33:07 +00:00
|
|
|
libbz2libdirvar="LIBBZ2_DIR"
|
|
|
|
libzlibdirvar="LIBZ_DIR"
|
|
|
|
libbz2incvar="LIBBZ2_INC"
|
|
|
|
libzincvar="LIBZ_INC"
|
2012-10-03 17:13:02 +00:00
|
|
|
|
2012-12-08 08:49:01 +00:00
|
|
|
keccak_srcs_var="KECCAK_SRCS"
|
|
|
|
keccak_hdrs_var="KECCAK_HDRS"
|
|
|
|
keccak_srcs_asm_var="KECCAK_SRCS_ASM"
|
|
|
|
|
2013-02-24 14:35:16 +00:00
|
|
|
crypto_compat_objs_var="CRYPTO_COMPAT_OBJS"
|
|
|
|
crypto_compat_flags_var="COMPAT_CPPFLAGS"
|
2013-03-04 16:26:07 +00:00
|
|
|
salsa20_stream_c_var="XSALSA20_STREAM_C"
|
|
|
|
salsa20_stream_asm_var="XSALSA20_STREAM_ASM"
|
|
|
|
salsa20_debug_var="XSALSA20_DEBUG"
|
2013-02-24 14:35:16 +00:00
|
|
|
|
2012-08-26 08:39:24 +00:00
|
|
|
noslabcppflagsval=
|
|
|
|
debugstatscppflagsval=
|
|
|
|
|
|
|
|
[ $allocator -eq 0 ] && noslabcppflagsval='\$\(NO_SLAB_CPPFLAGS\)'
|
|
|
|
[ $debug_stats -eq 1 ] && debugstatscppflagsval='\$\(DEBUG_STATS_CPPFLAGS\)'
|
|
|
|
|
|
|
|
cat Makefile.in | sed "
|
|
|
|
s#@${linkvar}@#\\\$\\(${typ}_${linkvar}\\)#g
|
|
|
|
s#@${compilevar}@#\\\$\\(${typ}_${compilevar}\\)#g
|
|
|
|
s#@${compilecppvar}@#\\\$\\(${typ}_${compilecppvar}\\)#g
|
|
|
|
s#@${vecflagsvar}@#\\\$\\(${typ}_${vecflagsvar}\\)#g
|
|
|
|
s#@${loopoptflagsvar}@#\\\$\\(${typ}_${loopoptflagsvar}\\)#g
|
|
|
|
s#@${cppflagsvar}@#\\\$\\(${typ}_${cppflagsvar}\\)#g
|
|
|
|
s#@${genoptvar}@#\\\$\\(${typ}_${genoptvar}\\)#g
|
2012-12-08 08:49:01 +00:00
|
|
|
s#@${fptr_flag_var}@#\\\$\\(${typ}_${fptr_flag_var}\\)#g
|
2012-08-26 08:39:24 +00:00
|
|
|
s#@${noslabcppflagsvar}@#${noslabcppflagsval}#g
|
|
|
|
s#@${debugstatscppflagsvar}@#${debugstatscppflagsval}#g
|
|
|
|
s#@${prefixvar}@#${prefix}#g
|
2012-08-27 16:21:55 +00:00
|
|
|
s#@${libbscdirvar}@#${libbsc_dir}#g
|
|
|
|
s#@${libbsclibvar}@#${libbsc_lib}#g
|
|
|
|
s#@${libbsclflagsvar}@#${libbsclflags}#g
|
|
|
|
s#@${libbscwrapobjvar}@#${libbscwrapobj}#g
|
|
|
|
s#@${libbscgenoptvar}@#${libbscgenopt}#g
|
|
|
|
s#@${libbsccppflagsvar}@#${libbsccppflags}#g
|
2012-09-01 09:10:15 +00:00
|
|
|
s#@${skeinblockvar}@#${skeinblock}#g
|
2012-10-03 17:13:02 +00:00
|
|
|
s#@${openssllibdirvar}@#${openssl_libdir}#g
|
|
|
|
s#@${opensslincdirvar}@#${openssl_incdir}#g
|
2012-10-06 15:21:23 +00:00
|
|
|
s#@${sha256asmobjsvar}@#${sha256asmobjs}#g
|
|
|
|
s#@${sha256objsvar}@#${sha256objs}#g
|
|
|
|
s#@${yasmvar}@#${yasm}#g
|
2012-10-15 06:40:00 +00:00
|
|
|
s#@${keylenvar}@#${keylen}#g
|
2012-10-21 15:33:07 +00:00
|
|
|
s#@${libbz2libdirvar}@#${libbz2_libdir}#g
|
|
|
|
s#@${libzlibdirvar}@#${libz_libdir}#g
|
|
|
|
s#@${libbz2incvar}@#${libbz2_inc}#g
|
|
|
|
s#@${libzincvar}@#${libz_inc}#g
|
2012-12-08 08:49:01 +00:00
|
|
|
s#@${keccak_srcs_var}@#${keccak_srcs}#g
|
|
|
|
s#@${keccak_hdrs_var}@#${keccak_hdrs}#g
|
|
|
|
s#@${keccak_srcs_var}@#${keccak_srcs}#g
|
|
|
|
s#@${keccak_srcs_asm_var}@#${keccak_srcs_asm}#g
|
2013-01-20 17:23:36 +00:00
|
|
|
s#@${extra_opt_flags_var}@#${extra_opt_flags}#g
|
2013-01-24 18:40:12 +00:00
|
|
|
s#@${sse_opt_flags_var}@#${sse_opt_flags}#g
|
2013-02-24 14:35:16 +00:00
|
|
|
s#@${crypto_compat_objs_var}@#${crypto_compat_objs}#g
|
|
|
|
s#@${crypto_compat_flags_var}@#${crypto_compat_flags}#g
|
2013-03-04 16:26:07 +00:00
|
|
|
s#@${salsa20_stream_c_var}@#${salsa20_stream_c}#g
|
|
|
|
s#@${salsa20_stream_asm_var}@#${salsa20_stream_asm}#g
|
|
|
|
s#@${salsa20_debug_var}@#${salsa20_debug}#g
|
2012-08-26 08:39:24 +00:00
|
|
|
" > Makefile
|
|
|
|
|