source: branches/compat-10.2/configure @ 187

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

Now use Makefile's configure

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