source: trunk/configure @ 171

Last change on this file since 171 was 171, checked in by joshe, 16 years ago

Patch from Jeremy Messenger to build on FreeBSD 4.

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