source: trunk/configure @ 86

Last change on this file since 86 was 86, checked in by joshe, 15 years ago

Add internationalization support for the GTK GUI.

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