source: trunk/configure @ 262

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

Get revision at build time

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