2006-01-12 17:43:21 +00:00
|
|
|
#! /bin/sh
|
2006-05-29 21:21:23 +00:00
|
|
|
#
|
|
|
|
# $Id$
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-04-03 19:29:09 +00:00
|
|
|
#
|
|
|
|
# Default settings
|
|
|
|
#
|
|
|
|
SYSTEM=
|
|
|
|
BEOS_NETSERVER=no
|
|
|
|
MATH=no
|
|
|
|
PTHREAD=no
|
|
|
|
OPENSSL=
|
|
|
|
GTK=
|
|
|
|
PREFIX=/usr/local
|
|
|
|
CC="${CC-cc}"
|
|
|
|
CFLAGS="${CFLAGS}"
|
|
|
|
CXX="${CXX-c++}"
|
|
|
|
CXXFLAGS="${CXXFLAGS}"
|
|
|
|
LDFLAGS="${LDFLAGS}"
|
2006-06-20 23:29:11 +00:00
|
|
|
VERBOSE=no
|
2006-04-03 19:29:09 +00:00
|
|
|
|
2006-01-12 18:20:48 +00:00
|
|
|
#
|
|
|
|
# Functions
|
|
|
|
#
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat << EOF
|
|
|
|
|
2006-04-03 19:29:09 +00:00
|
|
|
Options:
|
|
|
|
--disable-openssl Disable OpenSSL, use built-in SHA1 implementation
|
|
|
|
--disable-gtk Don't build the GTK+ GUI
|
|
|
|
--prefix=PATH Installation path
|
2006-06-20 23:29:11 +00:00
|
|
|
--verbose Display additional information for debugging
|
2006-01-12 18:20:48 +00:00
|
|
|
|
2006-04-03 19:29:09 +00:00
|
|
|
Some influential environment variables:
|
|
|
|
CC C compiler command
|
|
|
|
CFLAGS C compiler flags
|
|
|
|
CXX C++ compiler command
|
|
|
|
CXXFLAGS C++ compiler flags
|
|
|
|
LDFLAGS linker flags
|
2006-01-12 18:20:48 +00:00
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2006-06-20 23:29:11 +00:00
|
|
|
runcmd()
|
|
|
|
{
|
|
|
|
if [ "$VERBOSE" = yes ]
|
|
|
|
then
|
|
|
|
echo "$@" >&2
|
|
|
|
"$@"
|
|
|
|
else
|
|
|
|
"$@" > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
return $!
|
|
|
|
}
|
|
|
|
|
|
|
|
verbose()
|
|
|
|
{
|
|
|
|
if [ "$VERBOSE" = yes ]
|
|
|
|
then
|
|
|
|
echo "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2006-04-05 00:41:47 +00:00
|
|
|
cc_test()
|
|
|
|
{
|
2006-06-20 23:29:11 +00:00
|
|
|
verbose cc_test
|
2006-04-05 00:41:47 +00:00
|
|
|
cat > testconf.c <<EOF
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2006-06-20 23:29:11 +00:00
|
|
|
if ! runcmd $CC -o testconf testconf.c
|
|
|
|
then
|
2006-07-14 21:57:46 +00:00
|
|
|
rm -f testconf*
|
2006-04-05 00:41:47 +00:00
|
|
|
echo "Could not find a working compiler"
|
|
|
|
exit 1
|
|
|
|
fi
|
2006-07-14 21:57:46 +00:00
|
|
|
rm -f testconf*
|
2006-04-05 00:41:47 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 18:20:48 +00:00
|
|
|
openssl_test()
|
|
|
|
{
|
2006-06-20 23:29:11 +00:00
|
|
|
verbose openssl_test
|
2006-01-12 18:20:48 +00:00
|
|
|
cat > testconf.c << EOF
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <openssl/sha.h>
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
SHA1( 0, 0, 0 );
|
|
|
|
}
|
|
|
|
EOF
|
2006-06-20 23:29:11 +00:00
|
|
|
if runcmd $CC $CFLAGS $LDFLAGS -o testconf testconf.c -lcrypto
|
2006-01-12 18:20:48 +00:00
|
|
|
then
|
2006-04-03 19:29:09 +00:00
|
|
|
echo "yes"
|
|
|
|
OPENSSL=yes
|
2006-01-12 18:20:48 +00:00
|
|
|
else
|
2006-04-03 19:29:09 +00:00
|
|
|
echo "missing, using built-in SHA1 implementation"
|
|
|
|
OPENSSL=no
|
2006-01-12 18:20:48 +00:00
|
|
|
fi
|
2006-07-14 21:57:46 +00:00
|
|
|
rm -f testconf*
|
2006-01-12 18:20:48 +00:00
|
|
|
}
|
|
|
|
|
2006-04-03 09:05:47 +00:00
|
|
|
lm_test()
|
|
|
|
{
|
2006-06-20 23:29:11 +00:00
|
|
|
verbose lm_test
|
2006-04-03 09:05:47 +00:00
|
|
|
cat > testconf.c << EOF
|
|
|
|
int main()
|
|
|
|
{
|
2006-04-03 19:29:09 +00:00
|
|
|
return cos( 42 );
|
2006-04-03 09:05:47 +00:00
|
|
|
}
|
|
|
|
EOF
|
2006-06-20 23:29:11 +00:00
|
|
|
if ! runcmd $CC -o testconf testconf.c
|
2006-04-03 09:05:47 +00:00
|
|
|
then
|
2006-06-20 23:29:11 +00:00
|
|
|
if runcmd $CC -o testconf testconf.c -lm
|
2006-04-03 09:05:47 +00:00
|
|
|
then
|
2006-04-03 19:29:09 +00:00
|
|
|
LDFLAGS="$LDFLAGS -lm"
|
2006-04-03 09:05:47 +00:00
|
|
|
fi
|
|
|
|
fi
|
2006-07-14 21:57:46 +00:00
|
|
|
rm -f testconf*
|
2006-04-03 09:05:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lrintf_test()
|
|
|
|
{
|
2006-06-20 23:29:11 +00:00
|
|
|
verbose lrintf_test
|
2006-04-03 09:05:47 +00:00
|
|
|
cat > testconf.c << EOF
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
return ( lrintf( 3.14 ) != 3 );
|
|
|
|
}
|
|
|
|
EOF
|
2006-06-20 23:29:11 +00:00
|
|
|
if runcmd $CC -o testconf testconf.c $LDFLAGS && runcmd ./testconf
|
2006-04-03 09:05:47 +00:00
|
|
|
then
|
2006-04-03 19:29:09 +00:00
|
|
|
CFLAGS="$CFLAGS -DHAVE_LRINTF"
|
2006-04-03 09:05:47 +00:00
|
|
|
fi
|
2006-07-14 21:57:46 +00:00
|
|
|
rm -f testconf*
|
2006-04-03 09:05:47 +00:00
|
|
|
}
|
|
|
|
|
2006-02-09 05:55:41 +00:00
|
|
|
gettext_test()
|
|
|
|
{
|
2006-06-20 23:29:11 +00:00
|
|
|
verbose gettext_test
|
2006-02-09 05:55:41 +00:00
|
|
|
cat > testconf.c <<EOF
|
|
|
|
#include <libintl.h>
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
gettext("");
|
|
|
|
}
|
|
|
|
EOF
|
2006-02-10 20:52:44 +00:00
|
|
|
|
2006-06-20 23:29:11 +00:00
|
|
|
if runcmd $CC $CFLAGS_GTK $LDFLAGS_GTK -o testconf testconf.c
|
2006-02-09 05:55:41 +00:00
|
|
|
then
|
2006-07-14 21:57:46 +00:00
|
|
|
rm -f testconf*
|
2006-02-09 05:55:41 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2006-04-03 19:29:09 +00:00
|
|
|
for intl_testdir in $PREFIX/include \
|
2006-02-10 20:52:44 +00:00
|
|
|
/usr/local/include /usr/X11R6/include /usr/pkg/include
|
2006-02-09 05:55:41 +00:00
|
|
|
do
|
2006-06-20 23:29:11 +00:00
|
|
|
if runcmd $CC $CFLAGS_GTK -I$intl_testdir $LDFLAGS_GTK -o testconf testconf.c
|
2006-02-09 05:55:41 +00:00
|
|
|
then
|
2006-07-04 17:31:44 +00:00
|
|
|
CFLAGS_GTK="$CFLAGS_GTK -I$intl_testdir"
|
2006-07-14 21:57:46 +00:00
|
|
|
rm -f testconf*
|
2006-02-09 05:55:41 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
2006-07-14 21:57:46 +00:00
|
|
|
rm -f testconf*
|
2006-02-09 05:55:41 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2006-01-12 18:32:29 +00:00
|
|
|
gtk_test()
|
|
|
|
{
|
2006-06-20 23:29:11 +00:00
|
|
|
verbose gtk_test
|
|
|
|
if runcmd pkg-config gtk+-2.0
|
2006-01-12 18:32:29 +00:00
|
|
|
then
|
2006-07-11 20:18:42 +00:00
|
|
|
if runcmd pkg-config --exists gtk+-2.0 '>=' 2.6.0
|
2006-01-12 18:33:20 +00:00
|
|
|
then
|
2006-01-12 18:45:41 +00:00
|
|
|
cat > testconf.c << EOF
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
gtk_main();
|
|
|
|
}
|
|
|
|
EOF
|
2006-06-20 23:29:11 +00:00
|
|
|
if runcmd $CC `pkg-config gtk+-2.0 --cflags --libs` -o testconf testconf.c
|
2006-01-12 18:45:41 +00:00
|
|
|
then
|
2006-04-03 19:29:09 +00:00
|
|
|
CFLAGS_GTK=`pkg-config gtk+-2.0 --cflags`
|
|
|
|
LDFLAGS_GTK=`pkg-config gtk+-2.0 --libs`
|
2006-02-09 05:55:41 +00:00
|
|
|
if gettext_test
|
|
|
|
then
|
2006-04-03 19:29:09 +00:00
|
|
|
echo "yes"
|
2006-02-09 05:55:41 +00:00
|
|
|
GTK=yes
|
2006-04-25 08:14:37 +00:00
|
|
|
LOCALEDIR="$PREFIX/share/locale"
|
|
|
|
CFLAGS_GTK="$CFLAGS_GTK -DLOCALEDIR=\\"\""$LOCALEDIR\\"\"
|
2006-02-09 05:55:41 +00:00
|
|
|
else
|
2006-04-03 19:29:09 +00:00
|
|
|
echo "no (could not find gettext libintl.h)"
|
2006-02-09 05:55:41 +00:00
|
|
|
GTK=no
|
|
|
|
fi
|
2006-01-12 18:45:41 +00:00
|
|
|
else
|
2006-04-03 19:29:09 +00:00
|
|
|
echo "no"
|
2006-01-12 18:45:41 +00:00
|
|
|
GTK=no
|
|
|
|
fi
|
2006-07-14 21:57:46 +00:00
|
|
|
rm -f testconf*
|
2006-01-12 18:33:20 +00:00
|
|
|
else
|
2006-04-03 19:29:09 +00:00
|
|
|
echo "no (2.6.0 or later is required)"
|
2006-01-12 18:33:20 +00:00
|
|
|
GTK=no
|
|
|
|
fi
|
2006-01-12 18:32:29 +00:00
|
|
|
else
|
2006-04-03 19:29:09 +00:00
|
|
|
echo "no"
|
2006-01-12 18:32:29 +00:00
|
|
|
GTK=no
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2006-01-12 18:20:48 +00:00
|
|
|
#
|
|
|
|
# Parse options
|
|
|
|
#
|
|
|
|
while [ $# -ne 0 ]; do
|
|
|
|
param=`expr "opt$1" : 'opt[^=]*=\(.*\)'`
|
|
|
|
|
|
|
|
case "x$1" in
|
|
|
|
x--disable-openssl)
|
2006-04-03 19:29:09 +00:00
|
|
|
OPENSSL=no
|
2006-02-10 20:52:44 +00:00
|
|
|
;;
|
2006-01-12 18:32:29 +00:00
|
|
|
x--disable-gtk)
|
2006-04-03 19:29:09 +00:00
|
|
|
GTK=no
|
2006-02-04 18:03:05 +00:00
|
|
|
;;
|
2006-04-25 08:14:37 +00:00
|
|
|
x--prefix=*)
|
|
|
|
PREFIX="$param"
|
|
|
|
;;
|
2006-06-20 23:29:11 +00:00
|
|
|
x--verbose)
|
|
|
|
VERBOSE=yes
|
|
|
|
;;
|
2006-01-12 18:20:48 +00:00
|
|
|
x--help)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-01-12 18:20:48 +00:00
|
|
|
#
|
2006-01-12 17:43:21 +00:00
|
|
|
# System-specific flags
|
2006-01-12 18:20:48 +00:00
|
|
|
#
|
2006-01-12 17:43:21 +00:00
|
|
|
SYSTEM=`uname -s`
|
|
|
|
case $SYSTEM in
|
|
|
|
BeOS)
|
|
|
|
RELEASE=`uname -r`
|
|
|
|
case $RELEASE in
|
2006-07-14 01:49:27 +00:00
|
|
|
6.*|5.0.4) # Zeta or R5 / BONE beta 7
|
2006-01-12 17:43:21 +00:00
|
|
|
;;
|
2006-04-03 19:29:09 +00:00
|
|
|
5.0*) # R5 / net_server
|
|
|
|
BEOS_NETSERVER=yes
|
2006-01-12 17:43:21 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unsupported BeOS version"
|
2006-01-12 18:52:15 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
2006-01-12 17:43:21 +00:00
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
Darwin)
|
2006-04-03 19:29:09 +00:00
|
|
|
# Make sure the Universal SDK is installed
|
|
|
|
if [ ! -d /Developer/SDKs/MacOSX10.4u.sdk ]; then
|
|
|
|
cat << EOF
|
|
|
|
You need to install the Universal SDK in order to build Transmission:
|
|
|
|
Get your Xcode CD or package
|
|
|
|
Restart the install
|
|
|
|
When it gets to "Installation Type", select "Customize"
|
|
|
|
Select "Mac OS X 10.4 (Universal) SDL" under "Cross Development"
|
|
|
|
Finish the install.
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
PTHREAD=yes
|
2006-02-09 05:55:41 +00:00
|
|
|
;;
|
|
|
|
|
2006-04-03 19:29:09 +00:00
|
|
|
FreeBSD|NetBSD|OpenBSD|Linux)
|
|
|
|
PTHREAD=yes
|
2006-01-12 17:43:21 +00:00
|
|
|
;;
|
|
|
|
|
2006-07-14 21:57:46 +00:00
|
|
|
CYGWIN*)
|
|
|
|
;;
|
|
|
|
|
2006-01-12 17:43:21 +00:00
|
|
|
*)
|
|
|
|
echo "Unsupported operating system"
|
|
|
|
exit 1 ;;
|
|
|
|
esac
|
|
|
|
echo "System: $SYSTEM"
|
|
|
|
|
2006-04-05 00:41:47 +00:00
|
|
|
#
|
|
|
|
# First things first, check to see if there's a compiler installed
|
|
|
|
#
|
|
|
|
cc_test
|
|
|
|
|
2006-01-12 18:20:48 +00:00
|
|
|
#
|
|
|
|
# OpenSSL settings
|
|
|
|
#
|
2006-04-03 19:29:09 +00:00
|
|
|
echo -n "OpenSSL: "
|
|
|
|
if [ "$OPENSSL" = no ]; then
|
|
|
|
echo "disabled, using built-in SHA1 implementation"
|
2006-01-12 18:20:48 +00:00
|
|
|
else
|
2006-04-03 19:29:09 +00:00
|
|
|
openssl_test
|
|
|
|
fi
|
2006-01-12 17:43:21 +00:00
|
|
|
|
2006-01-12 18:32:29 +00:00
|
|
|
#
|
2006-04-03 19:29:09 +00:00
|
|
|
# GTK+ settings
|
2006-01-12 18:32:29 +00:00
|
|
|
#
|
2006-04-03 19:29:09 +00:00
|
|
|
echo -n "GTK+: "
|
|
|
|
if [ "$GTK" = no ]; then
|
|
|
|
echo "disabled"
|
2006-01-12 18:32:29 +00:00
|
|
|
else
|
2006-04-03 19:29:09 +00:00
|
|
|
gtk_test
|
|
|
|
fi
|
2006-01-12 18:32:29 +00:00
|
|
|
|
2006-04-03 09:05:47 +00:00
|
|
|
#
|
|
|
|
# Math functions
|
|
|
|
#
|
|
|
|
lm_test
|
|
|
|
lrintf_test
|
|
|
|
|
2006-01-12 18:20:48 +00:00
|
|
|
#
|
2006-05-31 12:54:53 +00:00
|
|
|
# Generate config.mk
|
2006-01-12 18:20:48 +00:00
|
|
|
#
|
2006-05-31 12:54:53 +00:00
|
|
|
rm -f mk/config.mk
|
|
|
|
cat > mk/config.mk << EOF
|
2006-04-03 19:29:09 +00:00
|
|
|
SYSTEM = $SYSTEM
|
2006-04-25 08:14:37 +00:00
|
|
|
PREFIX = $PREFIX
|
|
|
|
LOCALEDIR = $LOCALEDIR
|
2006-04-03 19:29:09 +00:00
|
|
|
BEOS_NETSERVER = $BEOS_NETSERVER
|
|
|
|
PTHREAD = $PTHREAD
|
|
|
|
OPENSSL = $OPENSSL
|
|
|
|
GTK = $GTK
|
|
|
|
CC = $CC
|
|
|
|
CFLAGS = $CFLAGS
|
|
|
|
CXX = $CXX
|
|
|
|
CXXFLAGS = $CXXFLAGS
|
|
|
|
LDFLAGS = $LDFLAGS
|
|
|
|
CFLAGS_GTK = $CFLAGS_GTK
|
|
|
|
LDFLAGS_GTK = $LDFLAGS_GTK
|
2006-01-12 17:43:21 +00:00
|
|
|
EOF
|
2006-02-04 18:03:05 +00:00
|
|
|
|
2006-01-12 17:43:21 +00:00
|
|
|
echo
|
2006-04-04 10:53:33 +00:00
|
|
|
echo "Now use GNU make to build Transmission."
|
|
|
|
echo "It may be called 'make' or 'gmake' depending on your system."
|