229 lines
4.1 KiB
Bash
Executable File
229 lines
4.1 KiB
Bash
Executable File
#! /bin/sh
|
|
|
|
#
|
|
# Functions
|
|
#
|
|
usage()
|
|
{
|
|
cat << EOF
|
|
|
|
OpenSSL options:
|
|
--disable-openssl Disable OpenSSL, use built-in SHA1 implementation
|
|
--openssl-prefix=PATH Location of OpenSSL headers and library
|
|
--disable-gtk Don't build the GTK+ GUI
|
|
|
|
Some influential environment variables:
|
|
CC C compiler command (default "cc")
|
|
CFLAGS C compiler flags (default "-g -Wall -W")
|
|
|
|
EOF
|
|
}
|
|
|
|
openssl_test()
|
|
{
|
|
cat > testconf.c << EOF
|
|
#include <stdio.h>
|
|
#include <openssl/sha.h>
|
|
int main()
|
|
{
|
|
SHA1( 0, 0, 0 );
|
|
}
|
|
EOF
|
|
if [ -n "$PREFIX" ]; then
|
|
TMPFLAGS="-I$PREFIX/include -L$PREFIX/lib"
|
|
fi
|
|
if $CC $TMPFLAGS -o testconf testconf.c -lcrypto > /dev/null 2>&1
|
|
then
|
|
echo "OpenSSL: yes"
|
|
DEFINES="$DEFINES HAVE_OPENSSL"
|
|
LINKLIBS="$LINKLIBS -lcrypto"
|
|
else
|
|
echo "OpenSSL: no, using built-in SHA1 implementation"
|
|
fi
|
|
rm -f testconf.c testconf
|
|
}
|
|
|
|
gtk_test()
|
|
{
|
|
if pkg-config gtk+-2.0 > /dev/null 2>&1
|
|
then
|
|
if expr `pkg-config --modversion gtk+-2.0` '>=' 2.6.0 > /dev/null 2>&1
|
|
then
|
|
cat > testconf.c << EOF
|
|
#include <gtk/gtk.h>
|
|
int main()
|
|
{
|
|
gtk_main();
|
|
}
|
|
EOF
|
|
if $CC `pkg-config gtk+-2.0 --cflags --libs` -o testconf testconf.c > /dev/null 2>&1
|
|
then
|
|
echo "GTK+: yes"
|
|
GTK=yes
|
|
GTKCCFLAGS=`pkg-config gtk+-2.0 --cflags`
|
|
GTKLINKLIBS=`pkg-config gtk+-2.0 --libs`
|
|
else
|
|
echo "GTK+: no"
|
|
GTK=no
|
|
fi
|
|
rm -f testconf.c testconf
|
|
else
|
|
echo "GTK+: no (2.6.0 or later is required)"
|
|
GTK=no
|
|
fi
|
|
else
|
|
echo "GTK+: no"
|
|
GTK=no
|
|
fi
|
|
}
|
|
|
|
#
|
|
# Defaults settings
|
|
#
|
|
CC="${CC-cc}"
|
|
CFLAGS="${CFLAGS--g -Wall -W}"
|
|
# For > 2 GB files
|
|
DEFINES="_FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE"
|
|
# For asprintf
|
|
DEFINES="$DEFINES _GNU_SOURCE"
|
|
openssl_disable=0
|
|
gtk_disable=0
|
|
GTK=no
|
|
GTKCCFLAGS=
|
|
GTKLINKLIBS=
|
|
|
|
#
|
|
# Parse options
|
|
#
|
|
while [ $# -ne 0 ]; do
|
|
param=`expr "opt$1" : 'opt[^=]*=\(.*\)'`
|
|
|
|
case "x$1" in
|
|
x--disable-openssl)
|
|
openssl_disable="1";
|
|
;;
|
|
x--openssl-prefix=*)
|
|
OPENSSL_PREFIX="$param";
|
|
;;
|
|
x--disable-gtk)
|
|
gtk_disable="1";
|
|
;;
|
|
x--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
#
|
|
# System-specific flags
|
|
#
|
|
SYSTEM=`uname -s`
|
|
case $SYSTEM in
|
|
BeOS)
|
|
DEFINES="$DEFINES SYS_BEOS"
|
|
|
|
CC="gcc"
|
|
MACHINE=`uname -m`
|
|
case $MACHINE in
|
|
BePC) # BeOS on x86
|
|
CPU="x86"
|
|
;;
|
|
*)
|
|
CPU="ppc"
|
|
;;
|
|
esac
|
|
SYSTEM="$SYSTEM / $CPU"
|
|
|
|
RELEASE=`uname -r`
|
|
case $RELEASE in
|
|
6.0*|5.0.4) # Zeta or R5 / BONE beta 7
|
|
SYSTEM="$SYSTEM / BONE"
|
|
LINKLIBS="$LINKLIBS -lbind -lsocket"
|
|
;;
|
|
5.0*) # R5 / net_server
|
|
SYSTEM="$SYSTEM / net_server"
|
|
DEFINES="$DEFINES BEOS_NETSERVER"
|
|
LINKLIBS="$LINKLIBS -lnet"
|
|
;;
|
|
*)
|
|
echo "Unsupported BeOS version"
|
|
exit 1
|
|
;;
|
|
esac
|
|
;;
|
|
|
|
Darwin)
|
|
DEFINES="$DEFINES SYS_DARWIN"
|
|
LINKLIBS="$LINKLIBS -lpthread"
|
|
;;
|
|
|
|
FreeBSD)
|
|
DEFINES="$DEFINES SYS_FREEBSD"
|
|
LINKLIBS="$LINKLIBS -pthread"
|
|
;;
|
|
|
|
NetBSD)
|
|
DEFINES="$DEFINES SYS_NETBSD"
|
|
LINKLIBS="$LINKLIBS -lpthread"
|
|
;;
|
|
|
|
Linux)
|
|
DEFINES="$DEFINES SYS_LINUX"
|
|
LINKLIBS="$LINKLIBS -lpthread"
|
|
;;
|
|
|
|
*)
|
|
echo "Unsupported operating system"
|
|
exit 1 ;;
|
|
esac
|
|
echo "System: $SYSTEM"
|
|
|
|
#
|
|
# OpenSSL settings
|
|
#
|
|
if [ ${openssl_disable} = 1 ]; then
|
|
echo "OpenSSL: no, using built-in SHA1 implementation"
|
|
else
|
|
openssl_test
|
|
fi
|
|
|
|
#
|
|
# GTK settings
|
|
#
|
|
if [ ${gtk_disable} = 1 ]; then
|
|
echo "GTK+: no"
|
|
else
|
|
gtk_test
|
|
fi
|
|
|
|
#
|
|
# Generate config.jam
|
|
#
|
|
rm -f config.jam
|
|
cat > config.jam << EOF
|
|
CC = $CC ;
|
|
LINK = $CC ;
|
|
CCFLAGS = $CFLAGS ;
|
|
DEFINES = $DEFINES ;
|
|
LINKLIBS = $LINKLIBS ;
|
|
GTK = $GTK ;
|
|
GTKCCFLAGS = $GTKCCFLAGS ;
|
|
GTKLINKLIBS = $GTKLINKLIBS ;
|
|
EOF
|
|
if [ -n "$OPENSSL_PREFIX" ]; then
|
|
cat >> config.jam << EOF
|
|
HDRS += $OPENSSL_PREFIX/include ;
|
|
LINKFLAGS += -L$OPENSSL_PREFIX/lib ;
|
|
EOF
|
|
fi
|
|
if [ -n "$CPU" ]; then
|
|
cat >> config.jam << EOF
|
|
CPU = $CPU ;
|
|
EOF
|
|
fi
|
|
|
|
echo
|
|
echo "To build Transmission, run 'jam'."
|