transmission/configure

319 lines
6.4 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
--gettext-prefix=PATH Location of the Gettext header and library
--disable-gtk Don't build the GTK+ GUI
--prefix=PATH Install here instead of $INSTALL_PREFIX
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 "$OPENSSL_PREFIX" ]; then
TMPFLAGS="-I$OPENSSL_PREFIX/include -L$OPENSSL_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
}
gettext_test()
{
cat > testconf.c <<EOF
#include <libintl.h>
int main()
{
gettext("");
}
EOF
if [ -n "$GETTEXT_PREFIX" ] && $CC "-I$GETTEXT_PREFIX/include" "-Wl,-R$GETTEXT_PREFIX/lib" "-L$GETTEXT_PREFIX/lib" -lintl -liconv -o testconf testconf.c >/dev/null 2>&1
then
GTKCCFLAGS="-I$GETTEXT_PREFIX/include $GTKCCFLAGS"
GTKLINKLIBS="-Wl,-R$GETTEXT_PREFIX/lib -L$GETTEXT_PREFIX/lib -lintl -liconv $GTKLINKLIBS"
rm -f testconf.c testconf
return 0
fi
if $CC $GTKCCFLAGS $GTKLINKLIBS -o testconf testconf.c > /dev/null 2>&1
then
rm -f testconf.c testconf
return 0
fi
for intl_testdir in $INSTALL_PREFIX/include \
/usr/local/include /usr/X11R6/include /usr/pkg/include
do
if $CC $GTKCCFLAGS -I$intl_testdir $GTKLINKLIBS -o testconf testconf.c > /dev/null 2>&1
then
GTKCCFLAGS="$GTKCCFLAGS -I$intl_testdir"
rm -f testconf.c testconf
return 0
fi
done
rm -f testconf.c testconf
return 1
}
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
GTKCCFLAGS=`pkg-config gtk+-2.0 --cflags`
GTKLINKLIBS=`pkg-config gtk+-2.0 --libs`
if gettext_test
then
GTKLOCALEDIR="$INSTALL_PREFIX/share/locale"
GTK=yes
echo "GTK+: yes"
else
GTKCCFLAGS=
GTKLINKLIBS=
echo "GTK+: no, could not find gettext libintl.h"
GTK=no
fi
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=
GTKLOCALEDIR=
if [ -n "$PREFIX" ]; then
INSTALL_PREFIX=$PREFIX
else
INSTALL_PREFIX=/usr/local
fi
#
# 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--gettext-prefix=*)
GETTEXT_PREFIX="$param";
;;
x--disable-gtk)
gtk_disable="1";
;;
x--prefix=*)
INSTALL_PREFIX="$param";
;;
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 -lm"
;;
NetBSD)
DEFINES="$DEFINES SYS_NETBSD"
LINKLIBS="$LINKLIBS -lpthread -lm"
;;
OpenBSD)
DEFINES="$DEFINES SYS_OPENBSD"
LINKLIBS="$LINKLIBS -lpthread -lm"
;;
Linux)
DEFINES="$DEFINES SYS_LINUX"
LINKLIBS="$LINKLIBS -lpthread -lm"
;;
*)
echo "Unsupported operating system"
exit 1 ;;
esac
echo "System: $SYSTEM"
#
# Mac OS X check for the Universal SDK
#
if [ "$SYSTEM" = Darwin -a ! -d /Developer/SDKs/MacOSX10.4u.sdk ]; then
echo
echo "You need to install the Universal SDK in order to build Transmission:"
echo " Get your Xcode CD or package"
echo " Restart the install"
echo " When it gets to \"Installation Type\", select \"Customize\""
echo " Select \"Mac OS X 10.4 (Universal) SDL\" under \"Cross Development\""
echo " Finish the install."
exit 1
fi
#
# 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
if [ xyes = "x$GTK" ]; then
rm -f gtk/defines.h
cat > gtk/defines.h << EOF
#ifndef TG_DEFINES_H
#define TG_DEFINES_H
#define LOCALEDIR "$GTKLOCALEDIR"
#endif
EOF
fi
echo
echo "To build Transmission, run 'jam'."