source: trunk/configure @ 804

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

Add a debug output window.

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