source: branches/oneport/configure @ 69

Last change on this file since 69 was 69, checked in by joshe, 15 years ago

Merge from trunk up to rev 68.

File size: 4.5 KB
Line 
1#! /bin/sh
2
3#
4# Functions
5#
6usage()
7{
8  cat << EOF
9
10  OpenSSL options:
11    --disable-openssl      Disable OpenSSL, use built-in SHA1 implementation
12    --openssl-prefix=PATH  Location of OpenSSL headers and library
13    --disable-gtk          Don't build the GTK+ GUI
14
15  Some influential environment variables:
16    CC          C compiler command (default "cc")
17    CFLAGS      C compiler flags (default "-g -Wall -W")
18
19EOF
20}
21
22openssl_test()
23{
24  cat > testconf.c << EOF
25  #include <stdio.h>
26  #include <openssl/sha.h>
27  int main()
28  {
29      SHA1( 0, 0, 0 );
30  }
31EOF
32  if [ -n "$PREFIX" ]; then
33    TMPFLAGS="-I$PREFIX/include -L$PREFIX/lib"
34  fi
35  if $CC $TMPFLAGS -o testconf testconf.c -lcrypto > /dev/null 2>&1
36  then
37    echo "OpenSSL: yes"
38    DEFINES="$DEFINES HAVE_OPENSSL"
39    LINKLIBS="$LINKLIBS -lcrypto"
40  else
41    echo "OpenSSL: no, using built-in SHA1 implementation"
42  fi
43  rm -f testconf.c testconf
44}
45
46gtk_test()
47{
48  if pkg-config gtk+-2.0 > /dev/null 2>&1
49  then
50    if expr `pkg-config --modversion gtk+-2.0` '>=' 2.6.0 > /dev/null 2>&1
51    then
52      cat > testconf.c << EOF
53      #include <gtk/gtk.h>
54      int main()
55      {
56        gtk_main();
57      }
58EOF
59      if $CC `pkg-config gtk+-2.0 --cflags --libs` -o testconf testconf.c > /dev/null 2>&1
60      then
61        echo "GTK+:    yes"
62        GTK=yes
63        GTKCCFLAGS=`pkg-config gtk+-2.0 --cflags`
64        GTKLINKLIBS=`pkg-config gtk+-2.0 --libs`
65      else
66        echo "GTK+:    no"
67        GTK=no
68      fi
69      rm -f testconf.c testconf
70    else
71      echo "GTK+:    no (2.6.0 or later is required)"
72      GTK=no
73    fi
74  else
75    echo "GTK+:    no"
76    GTK=no
77  fi
78}
79
80#
81# Defaults settings
82#
83CC="${CC-cc}"
84CFLAGS="${CFLAGS--g -Wall -W}"
85# For > 2 GB files
86DEFINES="_FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE"
87# For asprintf
88DEFINES="$DEFINES _GNU_SOURCE"
89openssl_disable=0
90gtk_disable=0
91GTK=no
92GTKCCFLAGS=
93GTKLINKLIBS=
94
95#
96# Parse options
97#
98while [ $# -ne 0 ]; do
99  param=`expr "opt$1" : 'opt[^=]*=\(.*\)'`
100
101  case "x$1" in
102    x--disable-openssl)
103      openssl_disable="1";
104      ;;
105    x--openssl-prefix=*)
106      OPENSSL_PREFIX="$param";
107      ;;
108    x--disable-gtk)
109      gtk_disable="1";
110      ;;
111    x--help)
112      usage
113      exit 0
114      ;;
115  esac
116  shift
117done
118
119#
120# System-specific flags
121#
122SYSTEM=`uname -s`
123case $SYSTEM in
124  BeOS)
125    DEFINES="$DEFINES SYS_BEOS"
126
127    CC="gcc"
128    MACHINE=`uname -m`
129    case $MACHINE in
130      BePC) # BeOS on x86
131        CPU="x86"
132        ;;
133      *)
134        CPU="ppc"
135        ;;
136    esac
137    SYSTEM="$SYSTEM / $CPU"
138       
139    RELEASE=`uname -r`
140    case $RELEASE in
141      6.0*|5.0.4) # Zeta or R5 / BONE beta 7
142        SYSTEM="$SYSTEM / BONE"
143        LINKLIBS="$LINKLIBS -lbind -lsocket"
144        ;;
145      5.0*)      # R5 / net_server
146        SYSTEM="$SYSTEM / net_server"
147        DEFINES="$DEFINES BEOS_NETSERVER"
148        LINKLIBS="$LINKLIBS -lnet"
149        ;;
150      *)
151        echo "Unsupported BeOS version"
152        exit 1
153        ;;
154    esac
155    ;;
156
157  Darwin)
158    DEFINES="$DEFINES SYS_DARWIN"
159    LINKLIBS="$LINKLIBS -lpthread"
160    ;;
161
162  FreeBSD)
163    DEFINES="$DEFINES SYS_FREEBSD"
164    LINKLIBS="$LINKLIBS -pthread -lm"
165    ;;
166
167  NetBSD)
168    DEFINES="$DEFINES SYS_NETBSD"
169    LINKLIBS="$LINKLIBS -lpthread -lm"
170    ;;
171
172  Linux)
173    DEFINES="$DEFINES SYS_LINUX"
174    LINKLIBS="$LINKLIBS -lpthread -lm"
175    ;;
176
177  *)
178    echo "Unsupported operating system"
179    exit 1 ;;
180esac
181echo "System:  $SYSTEM"
182
183#
184# Mac OS X check for the Universal SDK
185#
186if [ $SYSTEM = Darwin -a ! -d /Developer/SDKs/MacOSX10.4u.sdk ]; then
187  echo
188  echo "You need to install the Universal SDK in order to build Transmission:"
189  echo "  Get your Xcode CD or package"
190  echo "  Restart the install"
191  echo "  When it gets to \"Installation Type\", select \"Customize\""
192  echo "  Select \"Mac OS X 10.4 (Universal) SDL\" under \"Cross Development\""
193  echo "  Finish the install."
194  exit 1
195fi
196
197#
198# OpenSSL settings
199#
200if [ ${openssl_disable} = 1 ]; then
201  echo "OpenSSL: no, using built-in SHA1 implementation"
202else
203    openssl_test
204fi
205
206#
207# GTK settings
208#
209if [ ${gtk_disable} = 1 ]; then
210  echo "GTK+:    no"
211else
212    gtk_test
213fi
214
215#
216# Generate config.jam
217#
218rm -f config.jam
219cat > config.jam << EOF
220CC          = $CC ;
221LINK        = $CC ;
222CCFLAGS     = $CFLAGS ;
223DEFINES     = $DEFINES ;
224LINKLIBS    = $LINKLIBS ;
225GTK         = $GTK ;
226GTKCCFLAGS  = $GTKCCFLAGS ;
227GTKLINKLIBS = $GTKLINKLIBS ;
228EOF
229if [ -n "$OPENSSL_PREFIX" ]; then
230cat >> config.jam << EOF
231HDRS       += $OPENSSL_PREFIX/include ;
232LINKFLAGS  += -L$OPENSSL_PREFIX/lib ;
233EOF
234fi
235if [ -n "$CPU" ]; then
236cat >> config.jam << EOF
237CPU        = $CPU ;
238EOF
239fi
240
241echo
242echo "To build Transmission, run 'jam'."
Note: See TracBrowser for help on using the repository browser.