source: trunk/configure @ 559

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

Fix GTK version check to work for 2.10.0 and newer.

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