source: trunk/configure @ 191

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

Merge compat-10.2 branch. This adds Jaguar compatibility on OS X, and
completes the Jam -> Make/XCode switch. Hope it doesn't break too much.

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