source: trunk/configure @ 795

Last change on this file since 795 was 795, checked in by titer, 15 years ago

Fix BeOS gcc check with gcc >=3

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author Id
File size: 6.1 KB
Line 
1#! /bin/sh
2#
3# $Id: configure 795 2006-08-20 02:22:48Z titer $
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 gettext_test
191        then
192          echo "yes"
193          GTK=yes
194          LOCALEDIR="$PREFIX/share/locale"
195          CFLAGS_GTK="$CFLAGS_GTK -DLOCALEDIR=\\"\""$LOCALEDIR\\"\"
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
204      rm -f testconf*
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
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      ;;
225    x--disable-gtk)
226      GTK=no
227      ;;
228    x--prefix=*)
229      PREFIX="$param"
230      ;;
231    x--verbose)
232      VERBOSE=yes
233      ;;
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
250      6.*|5.0.4) # Zeta or R5 / BONE beta 7
251        ;;
252      5.0*)       # R5 / net_server
253        BEOS_NETSERVER=yes
254        ;;
255      *)
256        echo "Unsupported BeOS version"
257        exit 1
258        ;;
259    esac
260    GCCVER=`$CC -dumpversion`
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
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
290  FreeBSD|NetBSD|OpenBSD|Linux|skyos)
291    PTHREAD=yes
292    ;;
293
294  CYGWIN*)
295    ;;
296
297  *)
298    echo "Unsupported operating system"
299    exit 1 ;;
300esac
301echo "System:  $SYSTEM"
302
303#
304# First things first, check to see if there's a compiler installed
305#
306cc_test
307
308#
309# OpenSSL settings
310#
311echo -n "OpenSSL: "
312if [ "$OPENSSL" = no ]; then
313  echo "disabled, using built-in SHA1 implementation"
314else
315  openssl_test
316fi
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
322
323#
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#
340# Generate config.mk
341#
342rm -f mk/config.mk
343cat > mk/config.mk << EOF
344SYSTEM         = $SYSTEM
345PREFIX         = $PREFIX
346LOCALEDIR      = $LOCALEDIR
347BEOS_NETSERVER = $BEOS_NETSERVER
348PTHREAD        = $PTHREAD
349OPENSSL        = $OPENSSL
350GTK            = $GTK
351CC             = $CC
352CFLAGS         = $CFLAGS
353CXX            = $CXX
354CXXFLAGS       = $CXXFLAGS
355LDFLAGS        = $LDFLAGS
356CFLAGS_GTK     = $CFLAGS_GTK
357LDFLAGS_GTK    = $LDFLAGS_GTK
358EOF
359
360echo
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.