source: trunk/configure @ 1125

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

No longer need gthread library.

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author Id
File size: 6.1 KB
RevLine 
[134]1#! /bin/sh
[260]2#
3# $Id: configure 816 2006-08-22 02:24:58Z livings124 $
[134]4
5#
6# Default settings
7#
8SYSTEM=
9BEOS_NETSERVER=no
[793]10BEOS_OLDCC=no
[134]11MATH=no
12PTHREAD=no
13OPENSSL=
[185]14GTK=
15PREFIX=/usr/local
[134]16CC="${CC-cc}"
17CFLAGS="${CFLAGS}"
[189]18CXX="${CXX-c++}"
19CXXFLAGS="${CXXFLAGS}"
[134]20LDFLAGS="${LDFLAGS}"
[420]21VERBOSE=no
[134]22
23#
24# Functions
25#
26usage()
27{
28  cat << EOF
29
30Options:
31  --disable-openssl      Disable OpenSSL, use built-in SHA1 implementation
[185]32  --disable-gtk          Don't build the GTK+ GUI
33  --prefix=PATH          Installation path
[420]34  --verbose              Display additional information for debugging
[134]35
36Some influential environment variables:
37  CC          C compiler command
38  CFLAGS      C compiler flags
[189]39  CXX         C++ compiler command
40  CXXFLAGS    C++ compiler flags
[134]41  LDFLAGS     linker flags
42
43EOF
44}
45
[420]46runcmd()
47{
48  if [ "$VERBOSE" = yes ]
49  then
50    echo "$@" >&2
51    "$@"
52  else
53    "$@" > /dev/null 2>&1
54  fi
55  return $!
56}
57
58verbose()
59{
60  if [ "$VERBOSE" = yes ]
61  then
62    echo "$@"
63  fi
64}
65
[200]66cc_test()
67{
[420]68  verbose cc_test
[200]69  cat > testconf.c <<EOF
70  int main()
71  {
72    return 0;
73  }
74EOF
[420]75  if ! runcmd $CC -o testconf testconf.c
76  then
[575]77    rm -f testconf*
[200]78    echo "Could not find a working compiler"
79    exit 1
80  fi
[575]81  rm -f testconf*
[200]82}
83
[134]84openssl_test()
85{
[420]86  verbose openssl_test
[134]87  cat > testconf.c << EOF
88  #include <stdio.h>
89  #include <openssl/sha.h>
90  int main()
91  {
92      SHA1( 0, 0, 0 );
93  }
94EOF
[420]95  if runcmd $CC $CFLAGS $LDFLAGS -o testconf testconf.c -lcrypto
[134]96  then
97    echo "yes"
98    OPENSSL=yes
99  else
100    echo "missing, using built-in SHA1 implementation"
101    OPENSSL=no
102  fi
[575]103  rm -f testconf*
[134]104}
105
[185]106lm_test()
107{
[420]108  verbose lm_test
[185]109  cat > testconf.c << EOF
110  int main()
111  {
112    return cos( 42 );
113  }
114EOF
[420]115  if ! runcmd $CC -o testconf testconf.c
[185]116  then
[420]117    if runcmd $CC -o testconf testconf.c -lm
[185]118    then
119      LDFLAGS="$LDFLAGS -lm"
120    fi
121  fi
[575]122  rm -f testconf*
[185]123}
[134]124
[185]125lrintf_test()
126{
[420]127  verbose lrintf_test
[185]128  cat > testconf.c << EOF
129  int main()
130  {
131    return ( lrintf( 3.14 ) != 3 );
132  }
133EOF
[420]134  if runcmd $CC -o testconf testconf.c $LDFLAGS && runcmd ./testconf
[185]135  then
136    CFLAGS="$CFLAGS -DHAVE_LRINTF"
137  fi
[575]138  rm -f testconf*
[185]139}
140
141gettext_test()
142{
[420]143  verbose gettext_test
[185]144  cat > testconf.c <<EOF
145  #include <libintl.h>
146  int main()
147  {
148    gettext("");
149  }
150EOF
151
[420]152  if runcmd $CC $CFLAGS_GTK $LDFLAGS_GTK -o testconf testconf.c
[185]153  then
[575]154    rm -f testconf*
[185]155    return 0
156  fi
157
158  for intl_testdir in $PREFIX/include \
159      /usr/local/include /usr/X11R6/include /usr/pkg/include
160  do
[420]161    if runcmd $CC $CFLAGS_GTK -I$intl_testdir $LDFLAGS_GTK -o testconf testconf.c
[185]162    then
[516]163      CFLAGS_GTK="$CFLAGS_GTK -I$intl_testdir"
[575]164      rm -f testconf*
[185]165      return 0
166    fi
167  done
[575]168  rm -f testconf*
[185]169  return 1
170}
171
172gtk_test()
173{
[420]174  verbose gtk_test
175  if runcmd pkg-config gtk+-2.0
[185]176  then
[559]177    if runcmd pkg-config --exists gtk+-2.0 '>=' 2.6.0
[185]178    then
179      cat > testconf.c << EOF
180      #include <gtk/gtk.h>
181      int main()
182      {
183        gtk_main();
184      }
185EOF
[420]186      if runcmd $CC `pkg-config gtk+-2.0 --cflags --libs` -o testconf testconf.c
[185]187      then
188        CFLAGS_GTK=`pkg-config gtk+-2.0 --cflags`
189        LDFLAGS_GTK=`pkg-config gtk+-2.0 --libs`
190        if gettext_test
191        then
192          echo "yes"
193          GTK=yes
[243]194          LOCALEDIR="$PREFIX/share/locale"
195          CFLAGS_GTK="$CFLAGS_GTK -DLOCALEDIR=\\"\""$LOCALEDIR\\"\"
[185]196        else
197          echo "no (could not find gettext libintl.h)"
198          GTK=no
199        fi
200      else
201        echo "no"
202        GTK=no
203      fi
[575]204      rm -f testconf*
[185]205    else
206      echo "no (2.6.0 or later is required)"
207      GTK=no
208    fi
209  else
210    echo "no"
211    GTK=no
212  fi
213}
214
[134]215#
216# Parse options
217#
218while [ $# -ne 0 ]; do
219  param=`expr "opt$1" : 'opt[^=]*=\(.*\)'`
220
221  case "x$1" in
222    x--disable-openssl)
223      OPENSSL=no
224      ;;
[185]225    x--disable-gtk)
226      GTK=no
227      ;;
[243]228    x--prefix=*)
229      PREFIX="$param"
230      ;;
[420]231    x--verbose)
232      VERBOSE=yes
233      ;;
[134]234    x--help)
235      usage
236      exit 0
237      ;;
238  esac
239  shift
240done
241
242#
243# System-specific flags
244#
245SYSTEM=`uname -s`
246case $SYSTEM in
247  BeOS)
248    RELEASE=`uname -r`
249    case $RELEASE in
[572]250      6.*|5.0.4) # Zeta or R5 / BONE beta 7
[134]251        ;;
252      5.0*)       # R5 / net_server
253        BEOS_NETSERVER=yes
254        ;;
255      *)
256        echo "Unsupported BeOS version"
257        exit 1
258        ;;
259    esac
[795]260    GCCVER=`$CC -dumpversion`
[793]261    case $GCCVER in
262      2.95.3*|3*|4*)
263        ;;
264      2.9*)
265        BEOS_OLDCC=yes
266        ;;
267      *)
268        echo "Unsupported gcc version"
269        exit 1
270        ;;
271    esac
[134]272    ;;
273
274  Darwin)
275    # Make sure the Universal SDK is installed
276    if [ ! -d /Developer/SDKs/MacOSX10.4u.sdk ]; then
277      cat << EOF
278You need to install the Universal SDK in order to build Transmission:
279  Get your Xcode CD or package
280  Restart the install
281  When it gets to "Installation Type", select "Customize"
282  Select "Mac OS X 10.4 (Universal) SDL" under "Cross Development"
283  Finish the install.
284EOF
285      exit 1
286    fi
287    PTHREAD=yes
288    ;;
289
[755]290  FreeBSD|NetBSD|OpenBSD|Linux|skyos)
[134]291    PTHREAD=yes
292    ;;
293
[575]294  CYGWIN*)
295    ;;
296
[134]297  *)
298    echo "Unsupported operating system"
299    exit 1 ;;
300esac
301echo "System:  $SYSTEM"
302
303#
[200]304# First things first, check to see if there's a compiler installed
305#
306cc_test
307
308#
[134]309# OpenSSL settings
310#
311echo -n "OpenSSL: "
312if [ "$OPENSSL" = no ]; then
313  echo "disabled, using built-in SHA1 implementation"
314else
315  openssl_test
316fi
[793]317if [ "$OPENSSL" = no ] && [ "$BEOS_OLDCC" = yes ]; then
318  echo "built-in SHA1 implementation not supported with your gcc version"
319  echo "you must either install OpenSSL or gcc 2.95.3 or newer"
320  exit 1
321fi
[134]322
323#
[185]324# GTK+ settings
325#
326echo -n "GTK+:    "
327if [ "$GTK" = no ]; then
328  echo "disabled"
329else
330  gtk_test
331fi
332
333#
334# Math functions
335#
336lm_test
337lrintf_test
338
339#
[265]340# Generate config.mk
[134]341#
[265]342rm -f mk/config.mk
343cat > mk/config.mk << EOF
[134]344SYSTEM         = $SYSTEM
[243]345PREFIX         = $PREFIX
346LOCALEDIR      = $LOCALEDIR
[134]347BEOS_NETSERVER = $BEOS_NETSERVER
348PTHREAD        = $PTHREAD
349OPENSSL        = $OPENSSL
[185]350GTK            = $GTK
[134]351CC             = $CC
352CFLAGS         = $CFLAGS
[189]353CXX            = $CXX
354CXXFLAGS       = $CXXFLAGS
[134]355LDFLAGS        = $LDFLAGS
[185]356CFLAGS_GTK     = $CFLAGS_GTK
357LDFLAGS_GTK    = $LDFLAGS_GTK
[134]358EOF
359
360echo
[196]361echo "Now use GNU make to build Transmission."
362echo "It may be called 'make' or 'gmake' depending on your system."
Note: See TracBrowser for help on using the repository browser.