2012-08-26 08:39:24 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
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
|
|
|
|
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)
|
|
|
|
This defaults to the system's OpenSSL library. You can use this option
|
|
|
|
if you want to use an alternate OpenSSL installation.
|
2012-10-15 06:40:00 +00:00
|
|
|
--use-key256 Use 256-bit encryption keys. Default key length is 128-bit.
|
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-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-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-10-15 06:40:00 +00:00
|
|
|
--use-key256)
|
|
|
|
keylen='-DKEYLEN=32'
|
|
|
|
;;
|
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"
|
|
|
|
else
|
|
|
|
typ="RELEASE"
|
|
|
|
fi
|
|
|
|
|
2012-09-01 09:10:15 +00:00
|
|
|
OS=$(uname)
|
|
|
|
skeinblock='\$\(SKEIN_BLOCK_C\)'
|
|
|
|
if [ "$OS" = "Linux" ]
|
|
|
|
then
|
|
|
|
plat=$(uname -r)
|
|
|
|
elif [ "$OS" = "SunOS" ]
|
|
|
|
then
|
|
|
|
plat=$(isainfo -v)
|
|
|
|
else
|
|
|
|
echo "Unsupported OS: $OS"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
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
|
|
|
|
sha256asmobjs='\$\(SHA256ASM_OBJS\)'
|
|
|
|
sha256objs='\$\(SHA256_OBJS\)'
|
|
|
|
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-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" \
|
|
|
|
"${openssl_prefix}/ssl/lib64" "${openssl_prefix}/ssl/lib"
|
|
|
|
do
|
|
|
|
if [ -d ${lib} ]
|
|
|
|
then
|
|
|
|
if [ -f "${lib}/libcrypto.so" ]
|
|
|
|
then
|
|
|
|
openssl_libdir=${lib}
|
|
|
|
break
|
|
|
|
else
|
|
|
|
if [ -f "${lib}/libcrypto.a" ]
|
|
|
|
then
|
|
|
|
openssl_libdir=${lib}
|
|
|
|
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
|
|
|
|
echo "Depending on your system you may need to install the openssl-devel package."
|
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-10-06 15:21:23 +00:00
|
|
|
|
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"
|
|
|
|
rabinoptvar="RABIN_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"
|
2012-10-06 15:21:23 +00:00
|
|
|
sha256asmobjsvar="SHA256ASM_OBJS"
|
|
|
|
sha256objsvar="SHA256_OBJS"
|
|
|
|
yasmvar="YASM"
|
2012-08-27 16:21:55 +00:00
|
|
|
|
2012-10-03 17:13:02 +00:00
|
|
|
openssllibdirvar="OPENSSL_LIBDIR"
|
|
|
|
opensslincdirvar="OPENSSL_INCDIR"
|
|
|
|
|
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
|
|
|
|
s#@${rabinoptvar}@#\\\$\\(${typ}_${rabinoptvar}\\)#g
|
|
|
|
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-08-26 08:39:24 +00:00
|
|
|
" > Makefile
|
|
|
|
|