#! /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 #include 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 cat > testconf.c << EOF #include 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" 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" 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 echo echo "To build Transmission, run 'jam'."