source: trunk/configure @ 260

Last change on this file since 260 was 260, checked in by titer, 17 years ago

Added $Id$ keywords and updated a few headers

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