source: trunk/configure @ 168

Last change on this file since 168 was 125, checked in by joshe, 17 years ago

Improve libintl.h search and add a --gettext-prefix configure option.
Update a couple copyright dates that slipped through earlier.
Spell GTK as GTK+ in a couple of places.

File size: 6.4 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
228  NetBSD)
229    DEFINES="$DEFINES SYS_NETBSD"
230    LINKLIBS="$LINKLIBS -lpthread -lm"
231    ;;
232
233  OpenBSD)
234    DEFINES="$DEFINES SYS_OPENBSD"
235    LINKLIBS="$LINKLIBS -lpthread -lm"
236    ;;
237
238  Linux)
239    DEFINES="$DEFINES SYS_LINUX"
240    LINKLIBS="$LINKLIBS -lpthread -lm"
241    ;;
242
243  *)
244    echo "Unsupported operating system"
245    exit 1 ;;
246esac
247echo "System:  $SYSTEM"
248
249#
250# Mac OS X check for the Universal SDK
251#
252if [ "$SYSTEM" = Darwin -a ! -d /Developer/SDKs/MacOSX10.4u.sdk ]; then
253  echo
254  echo "You need to install the Universal SDK in order to build Transmission:"
255  echo "  Get your Xcode CD or package"
256  echo "  Restart the install"
257  echo "  When it gets to \"Installation Type\", select \"Customize\""
258  echo "  Select \"Mac OS X 10.4 (Universal) SDL\" under \"Cross Development\""
259  echo "  Finish the install."
260  exit 1
261fi
262
263#
264# OpenSSL settings
265#
266if [ ${openssl_disable} = 1 ]; then
267  echo "OpenSSL: no, using built-in SHA1 implementation"
268else
269    openssl_test
270fi
271
272#
273# GTK settings
274#
275if [ ${gtk_disable} = 1 ]; then
276  echo "GTK+:    no"
277else
278    gtk_test
279fi
280
281#
282# Generate config.jam
283#
284rm -f config.jam
285cat > config.jam << EOF
286CC          = $CC ;
287LINK        = $CC ;
288CCFLAGS     = $CFLAGS ;
289DEFINES     = $DEFINES ;
290LINKLIBS    = $LINKLIBS ;
291GTK         = $GTK ;
292GTKCCFLAGS  = $GTKCCFLAGS ;
293GTKLINKLIBS = $GTKLINKLIBS ;
294EOF
295if [ -n "$OPENSSL_PREFIX" ]; then
296cat >> config.jam << EOF
297HDRS       += $OPENSSL_PREFIX/include ;
298LINKFLAGS  += -L$OPENSSL_PREFIX/lib ;
299EOF
300fi
301if [ -n "$CPU" ]; then
302cat >> config.jam << EOF
303CPU        = $CPU ;
304EOF
305fi
306
307if [ xyes = "x$GTK" ]; then
308    rm -f gtk/defines.h
309    cat > gtk/defines.h << EOF
310#ifndef TG_DEFINES_H
311#define TG_DEFINES_H
312#define LOCALEDIR               "$GTKLOCALEDIR"
313#endif
314EOF
315fi
316
317echo
318echo "To build Transmission, run 'jam'."
Note: See TracBrowser for help on using the repository browser.