source: trunk/configure @ 206

Last change on this file since 206 was 206, checked in by titer, 16 years ago

Fixed lrintf check when lrintf is in libm

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