release-3-0-5
[mldonkey.git] / config / configure.in
blob423bbe9a7daf84b6cd3339f6907ceacde6386cd8
2 # **********                                                                                  **********
3 # **********                            Autoconf, configure internals                         **********
4 # **********                                                                                  **********
6 AC_REVISION(norev)
7 AC_PREREQ(2.53)
8 AC_INIT(Makefile.config.in)
9 AC_CONFIG_HEADER(config.h)
11 CONFIGURE_RUN=yes
12 CONFIGURE_ARGUMENTS=$ac_configure_args
13 echo "Arguments to configure: $CONFIGURE_ARGUMENTS"
15 cd ..
16 SOURCE_DIR=`pwd`
17 cd config
19 # **********                                                                                  **********
20 # **********                                   MLDonkey version                               **********
21 # **********                                                                                  **********
23 MAJOR_VERSION=3
24 MINOR_VERSION=0
25 SUB_VERSION=5   # range 0-7 due to eMule limitations
27 # **********                                                                                  **********
28 # **********                                  check for C compiler                            **********
29 # **********                                                                                  **********
31 AC_PROG_CC
32 CC_VERSION=`$CC -dumpversion`
33 AC_EXEEXT
34 AC_PROG_CPP
36 # **********                                                                                  **********
37 # **********                                    System checks                                 **********
38 # **********                                                                                  **********
40 AC_CANONICAL_HOST
42 OS_FILES=unix
43 OS_FILES2=unix
44 SYSTEM=unknown
45 FIX_BROKEN_CPP=
46 case $host in
47   *mingw*)
48     SYSTEM=mingw
49     OS_FILES=mingw
50     OS_FILES2=mingw
51     PTHREAD_LIBS="-lpthreadGC2 -lwsock32"
52     PTHREAD_MINGW_CFLAGS="-DPTW32_STATIC_LIB"
53     AC_MSG_CHECKING(for mingw-runtime version)
54       
55 cat >mingw_rt_ver.c <<'END'
56 #include <stdio.h>
57 #include <_mingw.h>
58 main(int argc, char *argv[[]])  {
60 int required_runtime_major=3;       /**********     change required mingw-runtime   **********/
61 int required_runtime_minor=10;      /**********              version here           **********/
63 #ifdef __MINGW32_MAJOR_VERSION
64 #  ifdef __MINGW32_MINOR_VERSION
65      switch(argv[[1]][[0]]) {
66        case 'x':
67          printf("%d.%d", __MINGW32_MAJOR_VERSION, __MINGW32_MINOR_VERSION);
68          break;
69        case 'y':
70          if ((__MINGW32_MAJOR_VERSION == required_runtime_major && __MINGW32_MINOR_VERSION < required_runtime_minor) || 
71              (__MINGW32_MAJOR_VERSION < required_runtime_major)) {
72            printf("no");
73            break; }
74          else {
75            printf("yes");
76            break; }
77        case 'z':
78          printf("%d.%d", required_runtime_major, required_runtime_minor);
79          break;
80      }
81      return 0;
82 #  else
83    printf("__MINGW32_MINOR_VERSION not defined in _mingw.h");
84    return 0;
85 #  endif
86 #else
87  printf("__MINGW32_MAJOR_VERSION not defined in _mingw.h");
88  return 0;
89 #endif
91 END
93     $CC -o mingw_rt_ver ./mingw_rt_ver.c
94     MINGW_RT_VER="`./mingw_rt_ver x`"
95     MINGW_RT_VER_OK="`./mingw_rt_ver y`"
96     MINGW_RT_VER_REQ="`./mingw_rt_ver z`"
97     rm -f mingw_rt_ver mingw_rt_ver.*
98     AC_MSG_RESULT($MINGW_RT_VER)
99     if test "$MINGW_RT_VER_OK" = "no"; then
100       echo "********  mingw-runtime version $MINGW_RT_VER_REQ is required  *********" 1>&2;
101       exit 1
102     fi
103     ;;
104   *cygwin*)
105     SYSTEM=cygwin
106     OS_FILES2=cygwin
107     ;;
108   *kfreebsd*)
109     SYSTEM=kfreebsd
110     ;;
111   *freebsd*|*dragonfly*)
112     SYSTEM=freebsd
113     CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
114     LDFLAGS="${LDFLAGS} -L/usr/local/lib"
115     ;;
116   *openbsd*)
117     SYSTEM=openbsd
118     CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
119     LDFLAGS="${LDFLAGS} -L/usr/local/lib"
120     ;;
121   *netbsd*)
122     SYSTEM=netbsd
123     ;;
124   *linux*)
125     SYSTEM=linux
126     ;;
127   *solaris*)
128     SYSTEM=solaris
129     ;;
130   *morphos*|*amigaos*)
131     SYSTEM=morphos
132     ;;
133   *aix*)
134     SYSTEM=aix
135     ;;
136   *beos*)
137     SYSTEM=beos
138     ;;
139   *osf*)
140     SYSTEM=osf
141     ;;
142   *irix*)
143     SYSTEM=irix
144     ;;
145   *hppa*|*hpux*)
146     SYSTEM=hpux
147     ;;
148   *darwin*|*rhapsody*|*macosx*)
149     SYSTEM=macos
150     AC_CHECK_PROG(SED, sed, sed)
151     if test "$ac_cv_prog_SED" = "sed"; then
152       FIX_BROKEN_CPP="| sed -n '/^\#pragma/!p'"
153     else
154       AC_CHECK_PROG(GREP, grep, grep)
155       if test "$ac_cv_prog_GREP" = "grep"; then
156         FIX_BROKEN_CPP="| grep -v '^\#pragma'"
157       fi
158     fi
159     if test "xFIX_BROKEN_CPP" = "x"; then
160       echo "Apple cpp produces broken files, your system lacks sed or grep to fix it"
161       exit 1
162     fi
163     ;;
164 esac
165 if test "x$SYSTEM" = "xunknown"; then
166   echo "Unknown build system, please report to the MLDonkey development team at http://mldonkey.sourceforge.net/forums/"
167   exit 1
170 case "$host" in
171   alpha*-*-osf*)                arch=alpha; system=digital;;
172   alpha*-*-linux*)              arch=alpha; system=linux;;
173   alpha*-*-freebsd*)            arch=alpha; system=freebsd;;
174   alpha*-*-netbsd*)             arch=alpha; system=netbsd;;
175   alpha*-*-openbsd*)            arch=alpha; system=openbsd;;
176   sparc-*-sunos4.*)             arch=sparc; system=sunos;;
177   sparc-*-solaris2.*)           arch=sparc; system=solaris;;
178   sparc-*-*bsd*)                arch=sparc; system=bsd;;
179   sparc-*-linux*)               arch=sparc; system=linux;;
180   i?86-*-linux*)           arch=i386; system=linux;;
181   i386-*-*bsd*)            arch=i386; system=bsd;;
182   i486-*-*bsd*)            arch=i486; system=bsd;;
183   i586-*-*bsd*)            arch=i586; system=bsd;;
184   i686-*-*bsd*)            arch=i686; system=bsd;;
185   i?86-*-nextstep*)        arch=i386; system=nextstep;;
186   i?86-*-solaris*)         arch=i386; system=solaris;;
187   i?86-*-beos*)            arch=i386; system=beos;;
188   i?86-*-cygwin*)          arch=i386; system=cygwin;;
189   mips-*-irix6*)                arch=mips; system=irix;;
190   hppa1.1-*-hpux*)              arch=hppa; system=hpux;;
191   hppa1.1-*-nextstep*)          arch=hppa; system=nextstep;;
192   rs6000-*-aix*)                arch=power; model=rs6000; system=aix;;
193   powerpc-*-aix*)               arch=power; model=ppc; system=aix;;
194   powerpc-*-linux*)             arch=power; model=ppc; system=elf;;
195   powerpc-*-rhapsody*)          arch=power; model=ppc; system=rhapsody;;
196   powerpc-*-darwin*)            arch=power; model=ppc; system=rhapsody;;
197   arm*-*-linux*)                arch=arm; system=linux;;
198   ia64-*-linux*)                arch=ia64; system=linux;;
199 esac
201 MD4ARCH=$arch
202 case $host in
203   i386-pc-linux*|i386-*-*bsd*) MD4COMP=as; MD4ARCH=i386;;
204   i486-pc-linux*|i486-*-*bsd*) MD4COMP=as; MD4ARCH=i486;;
205   i586-pc-linux*|i586-*-*bsd*) MD4COMP=as; MD4ARCH=i586;;
206   i686-pc-linux*|i686-*-*bsd*) MD4COMP=as; MD4ARCH=i686;;
207   i386-pc-mingw32*) MD4COMP=cc; MD4ARCH=i386;;
208   i486-pc-mingw32*) MD4COMP=cc; MD4ARCH=i486;;
209   i586-pc-mingw32*) MD4COMP=cc; MD4ARCH=i586;;
210   i686-pc-mingw32*) MD4COMP=cc; MD4ARCH=i686;;
211   *) MD4COMP=cc;;
212 esac
214 ARCH=$arch
216 # **********                                                                                  **********
217 # **********               Parse checkout date (CVS) or revision (SVN) if available           **********
218 # **********                                                                                  **********
220 if test -d .svn; then
221   AC_MSG_NOTICE(checking SVN revision)
222   AC_CHECK_PROG(SVNVERSION,svnversion,svnversion)
223   if test "$ac_cv_prog_SVNVERSION" = "svnversion"; then
224     SUB_VERSION3="SVN"
225     SCM_VERSION=`svnversion -n .`
226   else AC_MSG_NOTICE(cannot checking SVN revision... no SVNVERSION)
227     SCM_VERSION="cannot find out SVN revision (no SVNVERSION)"  
228   fi     
231 if test -f ./CVS/Entries ; then
232   AC_MSG_NOTICE(checking CVS checkout date)
233   AC_CHECK_PROGS(STAT, stat gstat, stat)
234   if [ test "$ac_cv_prog_STAT" = "stat" ] || [ test "$ac_cv_prog_STAT" = "gstat" ]; then
235     AC_CHECK_PROG(SED, sed, sed)
236     if test "$ac_cv_prog_SED" = "sed"; then
237       AC_CHECK_PROG(CUT, cut, cut)
238       if test "$ac_cv_prog_CUT" = "cut"; then
239         SUB_VERSION3="CVS"
240         if [ test "$SYSTEM" = "freebsd"] || [ test "$SYSTEM" = "netbsd"] || ( [ test "$SYSTEM" = "macos" ] && [ test "$ac_cv_prog_STAT" != "gstat" ] ); then
241           SCM_VERSION=`$STAT -f "%Sm" ./CVS/Entries | $SED -e 's/\(.*\) \(.*\) \(.*\) \(.*\)/\4-\1-\2 \3/'`
242         else
243         if [ test "$SYSTEM" = "openbsd"]; then
244           AC_CHECK_PROG(GREP, grep, grep)
245           if test "$ac_cv_prog_GREP" = "grep"; then
246             SCM_VERSION=`$STAT -f %a ./CVS/Entries | $GREP -v Entries | $SED -e 's/\(.*\) \(.*\) \(.*\) \(.*\)/\1-\2-\4 \3/'`
247           fi
248         else
249         if [ test "$SYSTEM" = "mingw"] || [ test "$SYSTEM" = "cygwin"]; then
250           AC_CHECK_PROG(GREP, grep, grep)
251           if test "$ac_cv_prog_GREP" = "grep"; then
252             SCM_VERSION=`$STAT ./CVS/Entries  | $GREP Modify | $SED -e 's/\(.*\) \(.*\) \(.*\) \(.*\) \(.*\)/\5-\2-\3 \4/'`
253           fi
254         else
255           SCM_VERSION=`$STAT -Lc %y ./CVS/Entries | $SED -e 's#\.[0-9]*##' | $CUT -c 1-19`
256         fi  #if [ test "$SYSTEM" = "mingw"] || ...
257         fi  #if [ test "$SYSTEM" = "openbsd"]
258         fi  #if [ test "$SYSTEM" = "freebsd"] || ...
259       else
260         AC_MSG_NOTICE(cannot checking CVS checkout date... no CUT)
261         SCM_VERSION="cannot find out SCM Version (no CUT)"
262       fi
263     else
264       AC_MSG_NOTICE(cannot checking CVS checkout date... no SED)
265       SCM_VERSION="cannot find out SCM Version (no SED)"
266     fi
267   else
268     AC_MSG_NOTICE(cannot checking CVS checkout date... no STAT)
269     SCM_VERSION="cannot find out SCM Version (no STAT)"
270   fi
273 # **********                                                                                  **********
274 # **********             build MLDonkey version, Required Ocaml and LablGTK versions          **********
275 # **********                                                                                  **********
277 MLDONKEY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$SUB_VERSION
278 if test -f ./subrelease; then
279   MLDONKEY_VERSION=$MLDONKEY_VERSION`cat ./subrelease`
281 if test ! -z "$SUB_VERSION3"; then
282   MLDONKEY_VERSION=$MLDONKEY_VERSION.$SUB_VERSION3
285 REQUIRED_OCAML=3.12.0
286 DOWNLOAD_OCAML_MAJOR=3.12
287 DOWNLOAD_OCAML=3.12.0
289 REQUIRED_LABLGTK=1.2.7
291 touch install-sh
293 LABLGTK_NAME=lablgtk
295 # **********                                                                                  **********
296 # **********                    Network and Feature configure switch variables                **********
297 # **********                                                                                  **********
299 # **********   currently not working Networks, can't be enabled
301 SOULSEEK=no
302 OPEN_NAPSTER=no
303 OPENFT=no
305 # **********   working Networks, enabled by default
307 DONKEY=yes
308 BITTORRENT=yes
309 GNUTELLA=no
310 GNUTELLA2=no
311 FASTTRACK=yes
312 FILETP=yes
313 DIRECT_CONNECT=yes
315 # **********   predefined configure variations
317 MULTINET=yes
318 MINIMUM=no
320 # **********   Features, enabled by default
322 DONKEY_SUI=yes
323 DONKEY_SUI_FILE=DonkeySui2
324 GD=yes
325 BZIP2=yes
326 MAGIC=yes
327 ICONV=yes
328 USE_PTHREAD=yes
330 # **********
332 BATCH=no
333 FORCE_OCAML=no
334 FORCE_MINGW=no
335 PROFILE=no
336 DEBUG=no
337 GUI=no
338 CHECKBOUNDS=false
340 # **********                                                                                  **********
341 # **********                Network and Feature configure switches and dependency             **********
342 # **********                                                                                  **********
344 AC_ARG_ENABLE(multinet,      [  --disable-multinet      allows you to only compile support for eDonkey (incl. Overnet and Kademlia)], [MULTINET="$enableval"])
345 AC_ARG_ENABLE(minimum,       [  --enable-minimum        compile MLDonkey with minimum features and Networks (eDonkey, iconv and thread enabled)], [MINIMUM="$enableval"])
346 AC_ARG_ENABLE(minimum,       [  --enable-minimum=all    disable all optional features and Networks excepting eDonkey], [MINIMUM="$enableval"])
348 if [ test ! "$MULTINET" = "yes" ] || [ test "$MINIMUM" = "yes" ] || [ test "$MINIMUM" = "all" ]; then
349   GNUTELLA=no
350   GNUTELLA2=no
351   FASTTRACK=no
352   DIRECT_CONNECT=no
353   FILETP=no
354   BITTORRENT=no
356 if [ test "$MINIMUM" = "yes" ] || [ test "$MINIMUM" = "all" ]; then
357   DONKEY_SUI=no
358   GD=no
359   BZIP2=no
360   MAGIC=no
362 if [ test "$MINIMUM" = "all" ]; then
363   USE_PTHREAD=no
364   ICONV=no
367 #AC_ARG_ENABLE(soulseek,      [  --disable-soulseek      allows you to remove support for SoulSeek], [SOULSEEK="$enableval"])
368 #AC_ARG_ENABLE(opennap,       [  --disable-opennap       allows you to remove support for Open Napster], [OPEN_NAPSTER="$enableval"])
369 AC_ARG_ENABLE(directconnect, [  --disable-directconnect allows you to remove support for Direct Connect], [DIRECT_CONNECT="$enableval"])
370 #AC_ARG_ENABLE(openft,        [  --disable-openft        allows you to remove support for OpenFT], [OPENFT="$enableval"])
372 AC_ARG_ENABLE(donkey,        [  --disable-donkey        allows you to remove support for eDonkey], [DONKEY="$enableval"])
373 AC_ARG_ENABLE(donkeysui,     [  --disable-donkeysui     allows you to remove support for eMule SecureUserIdent], [DONKEY_SUI="$enableval"])
374 AC_ARG_ENABLE(bittorrent,    [  --disable-bittorrent    allows you to remove support for Bittorent], [BITTORRENT="$enableval"])
375 AC_ARG_ENABLE(filetp,        [  --disable-filetp        allows you to remove support for fileTP], [FILETP="$enableval"])
376 AC_ARG_ENABLE(gnutella,      [  --disable-gnutella      allows you to remove support for Gnutella], [GNUTELLA="$enableval"])
377 AC_ARG_ENABLE(gnutella2,     [  --disable-gnutella2     allows you to remove support for Gnutella2], [GNUTELLA2="$enableval"])
378 AC_ARG_ENABLE(fasttrack,     [  --disable-fasttrack     allows you to remove support for FastTrack], [FASTTRACK="$enableval"])
380 AC_ARG_ENABLE(batch,         [  --enable-batch          reply YES to all queries in this script], [BATCH="$enableval"])
381 AC_ARG_ENABLE(force-ocaml,   [  --enable-force-ocaml    force usage of self-compiled Ocaml], [FORCE_OCAML="$enableval"])
382 AC_ARG_ENABLE(ocamlver,      [  --enable-ocamlver=VER   force usage of specific Ocaml version (3.10.1|CVS), ], [REQUIRED_OCAML="$enableval"])
383 AC_ARG_ENABLE(mingw,         [  --enable-mingw          forces compilation with MINGW on Cygwin], [FORCE_MINGW="$enableval"])
384 AC_ARG_ENABLE(checks,        [  --enable-checks         force mldonkey to perform bound checks on array/string access], [CHECKBOUNDS="$enableval"])
385 if test "$CHECKBOUNDS" = "yes"; then
386   CHECKBOUNDS=true
389 AC_ARG_ENABLE(profile,       [  --enable-profile        allows you to profile mlnet using gprof (enables debug)], [PROFILE="$enableval"])
390 AC_ARG_ENABLE(debug,         [  --enable-debug          allows you to compile mlnet with debug symbols], [DEBUG="$enableval"])
391 if test "$PROFILE" = "yes"; then
392   DEBUG="yes"
394 AC_ARG_ENABLE(gui,           [  --disable-gui           allows you to disable GUI build (default)], [GUI="$enableval"])
395 AC_ARG_ENABLE(gui,           [  --enable-gui=oldgui|newgui1|newgui2
396                           allows you to choose a GUI (default: newgui2 - is a GTK2 GUI, other GUIs use GTK1)], [GUI="$enableval"])
397 if test "$GUI" = "yes"; then
398   GUI=newgui2
400 if test ! "$GUI" = "newgui2"; then
401   if test ! "$GUI" = "newgui1"; then
402     if test ! "$GUI" = "oldgui"; then
403       GUI=no
404     fi
405   fi
408 AC_ARG_ENABLE(pthread,       [  --disable-pthread       allows you to disable pthread support in mldonkey, hurts performance!], [USE_PTHREAD="$enableval"])
409 AC_ARG_ENABLE(pthread-lib,   [  --enable-pthread-lib    legacy option], [USE_PTHREAD="$enableval"])
410 AC_ARG_ENABLE(iconv,         [  --disable-iconv         disable the use of iconv], [ICONV="$enableval"])
411 AC_ARG_ENABLE(gd,            [  --disable-gd            disable the use of gd], [GD="$enableval"])
412 AC_ARG_ENABLE(bzip2,         [  --disable-bzip2         disable the use of bzip2], [BZIP2="$enableval"])
413 AC_ARG_ENABLE(magic,         [  --disable-magic         disable the use of libmagic (GNU file)], [MAGIC="$enableval"])
415 if test "$FORCE_MINGW" = "yes"; then
416     CC="$CC -mno-cygwin"
417     CPP="$CPP -mno-cygwin"
418     OS_FILES=mingw
419     OS_FILES2=mingw
420     SYSTEM=mingw
423 OCAML_PATH=
425 echo -e "\n--------------------------------"
426 echo "     Checking system tools."
427 echo "--------------------------------"
429 AC_PROG_RANLIB
430 AC_CHECK_PROG(GNU_MAKE, gmake, gmake)
431 AC_CHECK_PROG(GNU_MAKE, make, make)
433 if test "x$GNU_MAKE" != "x"; then
434   AC_MSG_CHECKING( [if $GNU_MAKE is GNU make] )
435   $GNU_MAKE --version > /dev/null 2>&1
436   if test "$?" != "0"; then
437     AC_MSG_RESULT([no])
438         AC_MSG_ERROR(GNU make not found)
439   else
440     AC_MSG_RESULT([yes])
441   fi
442 else
443   AC_MSG_ERROR(GNU make not found)
446 AC_CHECK_PROG(COMPRESS, bzip2, bzip2)
447 AC_CHECK_PROG(COMPRESS, gzip, gzip)
449 if test "$ac_cv_prog_COMPRESS" = "bzip2"; then
450    COMPRESS_EXT=bz2
451 else
452    COMPRESS_EXT=gz
455 AC_PATH_PROG(PERL, perl, perl)
456 AC_CHECK_PROG(RPMBUILD,rpmbuild,rpmbuild)
457 AC_CHECK_PROG(RPMBUILD,rpm,rpm)
459 AC_CHECK_PROG(WGET, wget, wget)
460 if test -z "$ac_cv_prog_WGET"; then
461   $CC -o wget wget.c || echo "Cannot compile wget.c"
462   AC_PATH_PROG(WGET, wget,,$SOURCE_DIR/config)
463   ac_cv_prog_WGET="$ac_cv_path_WGET"
465 WGET="$ac_cv_prog_WGET"
467 echo "----------------------------------------"
468 echo "     Checking system tools finished."
469 echo -e "----------------------------------------\n"
471 echo "--------------------------------"
472 echo "     Checking Ocaml compiler."
473 echo "--------------------------------"
475 CONFIG_DIR=$SOURCE_DIR/config
476 PATCH_DIR=$SOURCE_DIR/patches
477 LOCAL_DIR=$PATCH_DIR/local
478 BUILD_DIR=$PATCH_DIR/build
480 AC_ARG_ENABLE(local-prefix, [  --enable-local-prefix=DIR  allows you to specify where you want temporary tools to be installed (DIR must be absolute)], [LOCAL_DIR="$enableval"])
482 LOCAL=$LOCAL_DIR
483 LOCAL_OCAML=$LOCAL_DIR/bin
485 AC_PATH_PROG(OCAMLC,ocamlc.opt,"",[$LOCAL_DIR/bin:$PATH])
486 AC_CHECK_TOOL(OCAMLC,ocamlc,ocamlrun ocamlc)
487 AC_PATH_PROG(CAMLP4, camlp4,"",[$LOCAL_DIR/bin:$PATH])
489 BUILD_OCAML=no
490 if [ test -z "$OCAMLC" ] || [ test -z "$CAMLP4" ] || [ test "$REQUIRED_OCAML" = "CVS" ]; then
491    BUILD_OCAML=yes
492 else
493   OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
494   case "$OCAMLVERSION" in
495     "$REQUIRED_OCAML"*|3.12.*|3.11.*|3.10.1*|3.10.2*) ;;
496     *)
497         echo "Need build"
498         BUILD_OCAML=yes
499         ;;
500   esac
502 case "$REQUIRED_OCAML" in
503   3.10.0|3.0*)
504     echo "Need build"
505     REQUIRED_OCAML=3.12.0
506     BUILD_OCAML=yes
507     ;;
508 esac
509 if [ test "$BUILD_OCAML" = "yes" ] || [ test "$FORCE_OCAML" = "yes" ]; then
511   if [ test "$SYSTEM" = "mingw" ]; then
512     echo "********         Objective-Caml $REQUIRED_OCAML is required               *********" 1>&2;
513     echo "********     no valid Ocaml compiler found on your system        *********" 1>&2;
514     echo "********   on MinGW there is no possibility to let configure     *********" 1>&2;
515     echo "********   build the Ocaml compiler with the included script     *********" 1>&2;
516     echo "********    check http://mldonkey.sourceforge.net/Windows        *********" 1>&2;
517     echo "********   for instuctions how to compile Ocaml under MinGW      *********" 1>&2;
518     exit 1
519   else  
520     
521   echo "********  Objective-Caml $REQUIRED_OCAML is required  *********" 1>&2;
522   if [ test "$WGET" = "" ] && [ test "$REQUIRED_OCAML" != "CVS" ]; then
523     echo "********          wget is missing          *********" 1>&2;
524     echo "********       cannot download Ocaml       *********" 1>&2;
525     exit 1
526   fi
527   echo "*******  Check http://caml.inria.fr/  ********" 1>&2;
528   echo "Do you want this script to try to download and install ocaml"
529   echo "LOCALLY in mldonkey directory ?"
530   if test "$BATCH" = "no"; then read i <&1; else i=yes; fi
531   case "$i" in
532    y* | Y*)
533       cd $PATCH_DIR
534       if [ test "$REQUIRED_OCAML" = "CVS" ]; then
535         rm -rf $BUILD_DIR
536         mkdir -p $BUILD_DIR
537         cd $BUILD_DIR
538         cvs -d:pserver:anoncvs:""@camlcvs.inria.fr:/caml login
539         cvs -z3 -d:pserver:anoncvs@camlcvs.inria.fr:/caml co -P ocaml
540         cd ocaml
541       else
542         if test ! -f ocaml-"$REQUIRED_OCAML".tar.gz; then
543           echo Downloading ...
544           $WGET http://caml.inria.fr/pub/distrib/ocaml-"$DOWNLOAD_OCAML_MAJOR"/ocaml-"$REQUIRED_OCAML".tar.gz
545         fi
546         if test ! -f ocaml-"$REQUIRED_OCAML".tar.gz; then
547           $WGET http://caml.inria.fr/pub/distrib/ocaml-3.11/ocaml-"$REQUIRED_OCAML".tar.gz
548         fi
549         if test ! -f ocaml-"$REQUIRED_OCAML".tar.gz; then
550           $WGET http://caml.inria.fr/pub/distrib/ocaml-3.10/ocaml-"$REQUIRED_OCAML".tar.gz
551         fi
552         if test ! -f ocaml-"$REQUIRED_OCAML".tar.gz; then
553           echo "********        download Ocaml $REQUIRED_OCAML not successful, try do download it manually       *********" 1>&2;
554           echo "********        from http://caml.inria.fr/pub/distrib/                                   *********" 1>&2;
555           echo "********        and copy the tar.gz into $PATCH_DIR              *********" 1>&2;
556           exit 1
557         fi
559         echo Uncompressing ...
560         mkdir -p $BUILD_DIR
561         cd $BUILD_DIR
562         rm -rf ocaml-"$REQUIRED_OCAML"
563         gzip -cd $PATCH_DIR/ocaml-"$REQUIRED_OCAML".tar.gz | tar vxf -
564         cd ocaml-"$REQUIRED_OCAML"
565         if test -f $PATCH_DIR/ocaml-"$REQUIRED_OCAML".patch; then
566           echo Patching ...
567           patch -p1 < $PATCH_DIR/ocaml-"$REQUIRED_OCAML".patch
568         fi
569       fi
570       echo Configuring ...
571       ./configure -prefix $LOCAL_DIR -host $host -cc $CC
572       cd config
573       cp -f Makefile Makefile.old
574       sed "s/OTHERLIBRARIES=.*/OTHERLIBRARIES=unix dynlink num str bigarray threads/" Makefile.old > Makefile
575       cd ..
576       cp -f $PATCH_DIR/Makefile.ocamldoc ocamldoc/Makefile
577       echo Compiling ...
578       $GNU_MAKE world opt opt.opt
579       echo Installing ...
580       $GNU_MAKE install
581       if ! test -f $LOCAL_DIR/lib/ocaml/threads; then
582         if ! test -f $LOCAL_DIR/lib/ocaml/vmthreads; then
583           ln -s vmthreads  $LOCAL_DIR/lib/ocaml/threads
584         fi
585       fi
586       cd $BUILD_DIR
587       if [ test "$REQUIRED_OCAML" = "CVS" ]; then
588         rm -rf ocaml
589       else
590         rm -rf ocaml-"$REQUIRED_OCAML"
591       fi
592       cd $CONFIG_DIR
593       echo Ocaml locally installed for mldonkey
595       if test -f "$LOCAL_OCAML"/ocamlc.opt; then
596          OCAMLC=$LOCAL_OCAML/ocamlc.opt
597          ac_cv_prog_OCAMLC=$LOCAL_OCAML/ocamlc.opt
598       else
599       if test -f "$LOCAL_OCAML"/ocamlc; then
600          OCAMLC=$LOCAL_OCAML/ocamlc
601          ac_cv_prog_OCAMLC=$LOCAL_OCAML/ocamlc
602       else
603         echo "Ocaml installation failed"; exit 1
604       fi
605       fi
606       ;;
607    *)  exit 1;;
608   esac
609   fi
612 if test "$OCAMLC" = "$LOCAL_OCAML"/ocamlc.opt ; then
613   OCAML_PATH="$LOCAL_OCAML"/
614   OCAMLOPT=$LOCAL_OCAML/ocamlopt.opt
615   OCAMLDOC=$LOCAL_OCAML/ocamldoc
616   OCAMLMKTOP=$LOCAL_OCAML/ocamlmktop
617   OCAMLDEP=$LOCAL_OCAML/ocamldep
618   OCAMLLEX=$LOCAL_OCAML/ocamllex.opt
619   OCAMLYACC=$LOCAL_OCAML/ocamlyacc
620   CAMLP4=$LOCAL_OCAML/camlp4
621   CAMLP4OF=$LOCAL_OCAML/camlp4of
622 else
623   if test "$OCAMLC" = "$LOCAL_OCAML"/ocamlc ; then
624   OCAML_PATH="$LOCAL_OCAML"/
625   if test -f "$LOCAL_OCAML/ocamlopt"; then
626     OCAMLOPT=$LOCAL_OCAML/ocamlopt
627   else
628     OCAMLOPT=no
629   fi
630   OCAMLDOC=$LOCAL_OCAML/ocamldoc
631   OCAMLMKTOP=$LOCAL_OCAML/ocamlmktop
632   OCAMLDEP=$LOCAL_OCAML/ocamldep
633   OCAMLLEX=$LOCAL_OCAML/ocamllex
634   OCAMLYACC=$LOCAL_OCAML/ocamlyacc
635   CAMLP4=$LOCAL_OCAML/camlp4
636   CAMLP4OF=$LOCAL_OCAML/camlp4of
637   else
638   AC_CHECK_PROG(OCAMLOPT, ocamlopt.opt, ocamlopt.opt)
639   AC_CHECK_PROG(OCAMLOPT, ocamlopt, ocamlopt, no)
640   AC_CHECK_PROG(OCAMLDEP, ocamldep, ocamldep)
641   AC_CHECK_PROG(OCAMLLEX, ocamllex.opt, ocamllex.opt)
642   AC_CHECK_PROG(OCAMLLEX, ocamllex, ocamllex)
643   AC_CHECK_PROG(OCAMLYACC, ocamlyacc, ocamlyacc)
644   AC_CHECK_PROG(OCAMLDOC, ocamldoc, ocamldoc)
645   AC_CHECK_PROG(OCAMLMKTOP, ocamlmktop, ocamlmktop)
646   AC_CHECK_PROG(CAMLP4, camlp4, camlp4)
647   AC_CHECK_PROG(CAMLP4OF, camlp4of, camlp4of, $CAMLP4 pa_o.cmo pr_o.cmo Camlp4QuotationExpander.cmo Camlp4GrammarParser.cmo)
651 OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
652 OCAMLLIB=`$OCAMLC -where`
654 # check if native dynlink is supported and therefore needed for linking
655 CAMLP4LIB_OPT="camlp4lib.cmxa"
656 CAMLP4LIB_BYTE="camlp4lib.cma"
657 if test -f $OCAMLLIB/dynlink.cma; then
658   CAMLP4LIB_BYTE="dynlink.cma $CAMLP4LIB_BYTE"
660 if test -f $OCAMLLIB/dynlink.cmxa; then
661   CAMLP4LIB_OPT="dynlink.cmxa $CAMLP4LIB_OPT"
664 # force usage of supported Ocaml versions
665 case "$OCAMLVERSION" in
666     3.10.1*|3.10.2*|3.1*) ;;
667     *)
668       if [ test "$REQUIRED_OCAML" != "CVS" ]; then
669         echo "********  Version $REQUIRED_OCAML of Objective-Caml is required  *********" 1>&2;
670         echo "*******  Check http://caml.inria.fr/  ********" 1>&2;
671         exit 1
672       fi
673       ;;
674 esac
676 if test "$OCAMLOPT" = "no"; then
677   TARGET_TYPE=byte
678   OCAMLLIB_EXT=cma
679 else
680   TARGET_TYPE=opt
681   OCAMLLIB_EXT=cmxa
683   OCAMLOPTVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
685   test "$OCAMLOPTVERSION" = "$OCAMLVERSION" || {
686     echo "********  Version $REQUIRED_OCAML of ocamlopt is required  *********" 1>&2;
687     echo "*******  Check http://caml.inria.fr/  ********" 1>&2;
688     exit 1; }
692 echo "-------------------------------------------"
693 echo "     Checking Ocaml $OCAMLVERSION finished."
694 echo "-------------------------------------------"
697 if test "$PROFILE" = "yes"; then
698    OCAMLOPT="$OCAMLOPT -p"
699    CFLAGS="$CFLAGS -pg"
701 if test "$FORCE_MINGW" = "yes"; then
702     OCAMLC="$OCAMLC -ccopt -mno-cygwin"
703     OCAMLOPT="$OCAMLOPT -ccopt -mno-cygwin"
704     OCAMLMKTOP="$OCAMLMKTOP -ccopt -mno-cygwin"
706 if test "$DEBUG" = "yes"; then
707     OCAMLC="$OCAMLC -g"
708     OCAMLOPT="$OCAMLOPT -g"
711 echo -e "\n----------------------------------"
712 echo "     Checking system headers."
713 echo "----------------------------------"
715 ifelse(AC_ACVERSION, [2.13], [],
716 [dnl Large file enabled
717    AC_SYS_LARGEFILE
721 dnl Check for native endianness.
722 AC_C_BIGENDIAN(,,
723   [AC_MSG_ERROR([Machine endianness could not be determined])]
725 if test "x$WORDS_BIGENDIAN" = "x"; then
726   NATIVEENDIAN=LittleEndian
727 else
728   NATIVEENDIAN=BigEndian
730 AC_SUBST(NATIVEENDIAN)
732 # various header files
733 AC_CHECK_FUNCS(setrlimit getrlimit strerror_r strerror posix_fallocate)
734 AC_CHECK_HEADERS(byteswap.h,,)
735 AC_CHECK_HEADERS([sys/utsname.h])
736 AC_CHECK_HEADERS(arpa/inet.h,,)
737 AC_CHECK_HEADERS([sys/types.h sys/time.h sys/resource.h netinet/in_systm.h netinet/in.h netinet/ip.h],,,
738 [#ifdef HAVE_SYS_TYPES_H
739 #include <sys/types.h>
740 #endif
741 #ifdef HAVE_SYS_TIME_H
742 #include <sys/time.h>
743 #endif
744 #ifdef HAVE_NETINET_IN_SYSTM_H
745 #include <netinet/in_systm.h>
746 #endif
747 #ifdef HAVE_NETINET_IN_H
748 #include <netinet/in.h>
749 #endif
752 # poll if possible
753 AC_CHECK_HEADERS(sys/poll.h,,)
754 AC_CHECK_FUNCS(poll,,)
756 AC_CHECK_HEADERS(sys/vfs.h,,)
757 AC_CHECK_HEADERS(sys/statvfs.h,,)
758 AC_CHECK_HEADERS([sys/param.h sys/mount.h],,,
759 [#if HAVE_SYS_PARAM_H
760 #include <sys/param.h>
761 #endif
763 echo "-------------------------------------------"
764 echo "     Checking system headers finished."
765 echo -e "-------------------------------------------\n"
766 echo "-----------------------------------"
767 echo "     Checking system libraries."
768 echo "-----------------------------------"
769 echo "----- checking zlib (required)"
770 AC_CHECK_LIB(z,inflate,,[echo "Zlib missing, did you install zlib and zlib-developer packages?"; exit 1])
771 AC_CHECK_HEADERS(zlib.h,,[echo "Zlib missing, did you install zlib and zlib-developer packages?"; exit 1])
772 AC_CHECK_LIB(z,zlibVersion,[AC_DEFINE(HAVE_ZLIBVERSION, 1,)])
774 if test "$BZIP2" != "no"; then
775   echo "----- checking bzlib (optional)"
776   AC_CHECK_HEADERS(bzlib.h,[AC_CHECK_LIB(bz2,BZ2_bzReadOpen,[BZIP2=yes],[BZIP2=no])],[BZIP2=no])
779 if test "$BZIP2" = "yes"; then
780   AC_CHECK_LIB(bz2,BZ2_bzlibVersion,[AC_DEFINE(HAVE_BZLIBVERSION, 1,)])
781   AC_DEFINE(USE_BZIP2, 1, [Define to 1 if you have bzip2 support.])
782 else
783   AC_MSG_NOTICE(bzlib not available)
786 if test "$MAGIC" != "no"; then
787   echo "----- checking libmagic (GNU file) (optional)"
788   AC_CHECK_HEADERS(magic.h,
789     [AC_CHECK_LIB(magic,magic_file,
790       [AC_CHECK_DECL([MAGIC_ERROR], [MAGIC=yes], [MAGIC=no],[#include <magic.h>])],
791       [MAGIC=no])],
792     [MAGIC=no])
795 if test "$MAGIC" = "yes"; then
796   MAGICLIB=Magic_magic
797 else
798   MAGICLIB=Magic_nomagic
799   AC_MSG_NOTICE(libmagic not available)
802 GD_JPG=no
803 GD_PNG=no
804 if test "$GD" != "no"; then
805   echo "----- checking gd (optional)"
806   GD=no
807   LIBGD=no
808   SAVE_LIBS=$LIBS
809   SAVE_CFLAGS=$CFLAGS
810   SAVE_LDFLAGS=$LDFLAGS
811   AC_CHECK_PROG(GDLIBCONFIG, gdlib-config, gdlib-config)
812   if test "$ac_cv_prog_GDLIBCONFIG" = "gdlib-config"; then
813     GD_LIBS=`$GDLIBCONFIG --libs`
814     $GDLIBCONFIG --static-libs > /dev/null 2>&1
815     if test "$?" = "0"; then
816       GD_STATIC_LIBS=`$GDLIBCONFIG --static-libs`
817     fi
818     GD_LIBS2="$LIBS -lgd $GD_LIBS"
819     LIBS=$GD_LIBS2
820     GD_CFLAGS=`$GDLIBCONFIG --cflags`
821     CFLAGS="$CFLAGS $GD_CFLAGS"
822     GD_LDFLAGS=`$GDLIBCONFIG --ldflags`
823     LDFLAGS="$LDFLAGS $GD_LDFLAGS"
824     AC_MSG_CHECKING(for libgd > 2.0.14)
825     GDVERSION=`$GDLIBCONFIG --version`
826     GDMAJORVERSION=`$GDLIBCONFIG --majorversion`
827     GDMINORVERSION=`$GDLIBCONFIG --minorversion`
828     GDREVISION=`$GDLIBCONFIG --revision`
829     if [ [ $GDMAJORVERSION = 2 ] && [ $GDMINORVERSION = 0 ] && [ $GDREVISION -gt 14 ]]; then
830         AC_MSG_RESULT($GDVERSION)
831         LIBGD=yes
832     else
833         AC_MSG_RESULT(no (found $GDVERSION))
834         LIBGD=no
835     fi
836   else
837     LIBGD=yes
838   fi
840   if test "$LIBGD" = "yes"; then
841     AC_CHECK_HEADERS(gd.h,[LIBGD=yes],[LIBGD=no])
842   fi
844   if test "$LIBGD" = "yes"; then
845     AC_MSG_CHECKING(for gdImageCreate in -lgd)
846     AC_TRY_LINK([#include <gd.h>],
847     [gdImageCreate (0,0);],
848     [LIBGD=yes], [LIBGD=no])
849     AC_MSG_RESULT($LIBGD)
850     LIBS=$SAVE_LIBS
852     if test "$LIBGD" = "no"; then
853       AC_MSG_NOTICE([not found, trying another method])
854       AC_CHECK_LIB(gd, gdImageCreate, [LIBGD=yes], [LIBGD=no])
855     fi
856   fi
858   if test "$LIBGD" = "yes"; then
859     LIBPNG=no
860 # saving current variables
861     SAVE_LIBS_PNG=$LIBS
862     SAVE_CFLAGS_PNG=$CFLAGS
863     SAVE_LDFLAGS_PNG=$LDFLAGS
864     AC_CHECK_PROG(PNGLIBCONFIG, libpng-config, libpng-config)
865     if test "$ac_cv_prog_PNGLIBCONFIG" = "libpng-config"; then
866 # check libpng-config contents and update system variables
867       PNG_LIBS=`$PNGLIBCONFIG --libs`
868       LIBS="$LIBS $PNG_LIBS"
869       PNG_CFLAGS=`$PNGLIBCONFIG --cflags`
870       CFLAGS="$CFLAGS $PNG_CFLAGS"
871       PNG_LDFLAGS=`$PNGLIBCONFIG --ldflags`
872       LDFLAGS="$LDFLAGS $PNG_LDFLAGS"
873     fi
874     AC_CHECK_LIB(png, png_create_read_struct , [LIBPNG=yes])
875 # restore variables
876     LIBS=$SAVE_LIBS_PNG
877     CFLAGS=$SAVE_CFLAGS_PNG
878     LDFLAGS=$SAVE_LDFLAGS_PNG
880     if test "$LIBPNG" = "no"; then
881       AC_MSG_NOTICE(png support not available)
882     else
883       LIBGD_PNG=no
884       LIBS=$GD_LIBS2
885       AC_MSG_CHECKING(for gdImagePng in -lgd)
886       AC_TRY_LINK([#include <gd.h>],
887       [gdImagePng (0,0);],
888       [LIBGD_PNG=yes], [LIBGD_PNG=no])
889       AC_MSG_RESULT($LIBGD_PNG)
890       LIBS=$SAVE_LIBS
892       if test "$LIBGD_PNG" = "no"; then
893         AC_MSG_NOTICE([not found, trying another method])
894         AC_CHECK_LIB(gd, gdImagePng, [LIBGD_PNG=yes], [LIBGD_PNG=no])
895       fi
897       AC_MSG_CHECKING(for png support in libgd)
898       if test "$LIBGD_PNG" = "yes"; then
899         GD=yes
900         GD_PNG=yes
901         AC_MSG_RESULT(yes)
902         AC_CHECK_LIB(png, png_access_version_number,[AC_DEFINE(HAVE_PNGVERSION, 1,)])
903         AC_DEFINE(HAVE_GD_PNG, 1, [Define to 1 if you have png support in libgd.])
904       else
905         AC_MSG_RESULT(no)
906       fi
907     fi
909     LIBJPEG=no
910     AC_CHECK_LIB(jpeg, jpeg_CreateCompress, [LIBJPEG=yes])
912     if test "$LIBJPEG" = "no"; then
913       AC_MSG_NOTICE(jpeg support not available)
914     else
915       LIBGD_JPG=no
916       LIBS=$GD_LIBS2
917       AC_MSG_CHECKING(for gdImageJpeg in -lgd)
918       AC_TRY_LINK([#include <gd.h>],
919       [gdImageJpeg (0,0,0);],
920       [LIBGD_JPG=yes], [LIBGD_JPG=no])
921       AC_MSG_RESULT($LIBGD_JPG)
922       LIBS=$SAVE_LIBS
924       if test "$LIBGD_JPG" = "no"; then
925         AC_MSG_NOTICE([not found, trying another method])
926         AC_CHECK_LIB(gd, gdImageJpeg, [LIBGD_JPG=yes], [LIBGD_JPG=no])
927       fi
929       AC_MSG_CHECKING(for jpeg support in libgd)
930       if test "$LIBGD_JPG" = "yes"; then
931         GD=yes
932         GD_JPG=yes
933         AC_DEFINE(HAVE_GD_JPG, 1, [Define to 1 if you have jpg support in libgd.])
934         AC_MSG_RESULT(yes)
935       else
936         AC_MSG_RESULT(no)
937       fi
938     fi
939   else
940     AC_MSG_NOTICE(libgd not available)
941   fi
942   LIBS=$SAVE_LIBS
943   CFLAGS=$SAVE_CFLAGS
944   LDFLAGS=$SAVE_LDFLAGS
947 if test "$GD" != "no"; then
948   GDGRAPHICS=DriverGraphics_gd
949 else
950   GDGRAPHICS=DriverGraphics_nogd
953 if test "$ICONV" = "yes"; then
954   echo "----- checking iconv (optional)"
955   AM_ICONV
956   if test "$am_cv_func_iconv" != "yes"; then
957     AC_DEFINE(DISABLE_ICONV, 1, [Define to 1 if you want to replace iconv and related with stubs.])
958     ICONV=no
959   else
960   LIBS="$LIBS $LIBICONV"
961   AC_CHECK_FUNCS([locale_charset],,
962   AC_TRY_LINK([#include <langinfo.h>],
963   [char* cs = nl_langinfo(CODESET);],
964   AC_MSG_NOTICE(found nl_langinfo(CODESET)),
965   [echo "Your iconv implementation is incomplete"; exit 1]))
966   AC_CHECK_LIB(charset,locale_charset)
967   AC_CHECK_HEADERS([libcharset.h])
968   AC_CHECK_HEADERS([langinfo.h])
969   AC_CHECK_HEADERS([locale.h])
970   fi
971 else
972   AC_DEFINE(DISABLE_ICONV, 1, [Define to 1 if you want to replace iconv and related with stubs.])
973   ICONV=no
976 if test "$USE_PTHREAD" = "no"; then
977  PTHREAD_LIBS=""
978  echo "You disabled thread support, this will hurt MLDonkey performance!"
979 else
980   echo "----- checking thread support (optional, strongly advised)"
981   ACX_PTHREAD
984 # On linux plaforms, we will have to check that includes from kernel are
985 # available. glibc version test was shamelessly taken from
986 # http://public.activestate.com/gsar/APC/perl-5.8.x/Configure
987 GLIBC_VERSION=""
988 case $host in
989         *linux*)
990            echo "----- GNU C Library version"
991            AC_CHECK_HEADERS(linux/limits.h,, [
992              OLD_CPPFLAGS=$CPPFLAGS
993              CPPFLAGS="-I /usr/src/linux/include"
994              AC_CHECK_HEADER(linux/types.h,[CONFIG_INCLUDES="-I /usr/src/linux/include"])
995              CPPFLAGS=$OLD_CPPFLAGS]
996            )
997            AC_CHECK_HEADERS(gnu/libc-version.h,[AC_MSG_CHECKING(for GNU C Library version)
999 cat >try.c <<'EOCP'
1000 /* Find out version of GNU C library.  __GLIBC__ and __GLIBC_MINOR__
1001    alone are insufficient to distinguish different versions, such as
1002    2.0.6 and 2.0.7.  The function gnu_get_libc_version() appeared in
1003    libc version 2.1.0.      A. Dougherty,  June 3, 2002.
1005 #include <stdio.h>
1006 int main(void)
1008 #ifdef __GLIBC__
1009 #   ifdef __GLIBC_MINOR__
1010 #       if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
1011 #           include <gnu/libc-version.h>
1012     printf("%s\n",  gnu_get_libc_version());
1013 #       else
1014     printf("%d.%d\n",  __GLIBC__, __GLIBC_MINOR__);
1015 #       endif
1016 #   else
1017 printf("%d\n",  __GLIBC__);
1018 #   endif
1019     return 0;
1020 #else
1021     return 1;
1022 #endif
1024 EOCP
1026            $CC -o try ./try.c
1027            GLIBC_VERSION="`./try`"
1028            AC_MSG_RESULT($GLIBC_VERSION)
1029            rm -f try try.*],)
1030         ;;
1031         *)         ;;
1032 esac
1034 echo "---------------------------------------------"
1035 echo "     Checking system libraries finished."
1036 echo -e "---------------------------------------------\n"
1038 CXX_VERSION=
1039 CRYPTOPPFLAGS=
1040 echo "--------------------------------------"
1041 echo "     Checking activated networks."
1042 echo "--------------------------------------"
1044   if test "$DONKEY" = "yes"; then
1045     AC_MSG_CHECKING(eDonkey)
1046     if test -d ../src/networks/donkey; then
1047       AC_MSG_RESULT(yes)
1048       if test "$DONKEY_SUI" = "yes"; then
1049         AC_PROG_CXX
1051         AC_CHECK_TOOL(NEWCXX, [$CXX], [no])
1052         AC_MSG_CHECKING(eMule SUI)
1053         if test x"$NEWCXX" = x"no"
1054         then
1055           AC_MSG_RESULT(no)
1056           CXX=
1057           DONKEY_SUI=no
1058         else
1059           AC_MSG_RESULT(yes)
1060           ACX_CHECK_CXX_FLAGS(-fno-omit-frame-pointer,cv_no_omit_frame_pointer, CRYPTOPPFLAGS="-fno-omit-frame-pointer")
1061           ACX_CHECK_CXX_FLAGS(-mno-omit-leaf-frame-pointer,cv_no_omit_leaf_frame_pointer, CRYPTOPPFLAGS="$CRYPTOPPFLAGS -mno-omit-leaf-frame-pointer")
1062           CXX=$NEWCXX
1063           CXX_VERSION=`$CXX -dumpversion`
1064           DONKEY_SUI_FILE=DonkeySui1
1065           AC_DEFINE(HAVE_CRYPTOPP, 1,)
1066         fi
1067       fi
1068 #      AC_MSG_CHECKING(eDonkey server)
1069 #      if test -d ../src/networks/server; then
1070 #        AC_MSG_RESULT(no)
1071 #        DONKEY_SERVER=no
1072 #      else
1073 #        AC_MSG_RESULT(no)
1074 #        DONKEY_SERVER=no
1075 #      fi
1076     else
1077       DONKEY=no
1078       DONKEY_SUI=no
1079       AC_MSG_RESULT(no)
1080     fi
1081   else
1082     DONKEY_SUI=no
1083   fi
1085   if test "$BITTORRENT" = "yes"; then
1086     AC_MSG_CHECKING(BitTorrent)
1087     if test -d ../src/networks/bittorrent; then
1088       AC_MSG_RESULT(yes)
1089     else
1090       BITTORRENT=no
1091       AC_MSG_RESULT(no)
1092     fi
1093   fi
1095   if test "$FILETP" = "yes"; then
1096     AC_MSG_CHECKING(FileTP)
1097     if test -d ../src/networks/fileTP; then
1098       AC_MSG_RESULT(yes)
1099     else
1100       FILETP=no
1101       AC_MSG_RESULT(no)
1102     fi
1103   fi
1105   if test "$GNUTELLA" = "yes"; then
1106     AC_MSG_CHECKING(Gnutella)
1107     if test -d ../src/networks/gnutella; then
1108       AC_MSG_RESULT(yes)
1109     else
1110       GNUTELLA=no
1111       AC_MSG_RESULT(no)
1112     fi
1113   fi
1115   if test "$GNUTELLA2" = "yes"; then
1116     AC_MSG_CHECKING(G2)
1117     if test -d ../src/networks/gnutella2; then
1118       AC_MSG_RESULT(yes)
1119     else
1120       GNUTELLA2=no
1121       AC_MSG_RESULT(no)
1122     fi
1123   fi
1125   if test "$FASTTRACK" = "yes"; then
1126     AC_MSG_CHECKING(Fasttrack)
1127     if test -d ../src/networks/fasttrack; then
1128       AC_MSG_RESULT(yes)
1129     else
1130       FASTTRACK=no
1131       AC_MSG_RESULT(no)
1132     fi
1133   fi
1135   if test "$DIRECT_CONNECT" = "yes"; then
1136     AC_MSG_CHECKING(DirectConnect)
1137     if test "$BZIP2" = "yes"; then
1138       if test -d ../src/networks/direct_connect; then
1139         AC_MSG_RESULT(yes)
1140       else
1141         DIRECT_CONNECT=no
1142         AC_MSG_RESULT(no)
1143       fi
1144     else
1145       DIRECT_CONNECT=no
1146       AC_MSG_RESULT(no - bzip2 support missing)
1147     fi
1148   fi
1150   if test "$SOULSEEK" = "yes"; then
1151     AC_MSG_CHECKING(Soulseek)
1152     if test -d ../src/networks/soulseek; then
1153       AC_MSG_RESULT(yes)
1154     else
1155       SOULSEEK=no
1156       AC_MSG_RESULT(no)
1157     fi
1158   fi
1160   if test "$OPEN_NAPSTER" = "yes"; then
1161     AC_MSG_CHECKING(OpenNapster)
1162     if test -d ../src/networks/opennap; then
1163       AC_MSG_RESULT(yes)
1164     else
1165       OPEN_NAPSTER=no
1166       AC_MSG_RESULT(no)
1167     fi
1168   fi
1170   if test "$OPENFT" = "yes"; then
1171     AC_MSG_CHECKING(OpenFT)
1172     if test -d ../src/networks/openFT; then
1173       AC_MSG_RESULT(yes)
1174     else
1175       OPENFT=no
1176       AC_MSG_RESULT(no)
1177     fi
1178   fi
1179 echo "-----------------------------------------------"
1180 echo "     Checking activated networks finished."
1181 echo "-----------------------------------------------"
1183 if test -f $OCAMLLIB/lablgl.cma; then
1184   LABLGL_CMA=lablgl.cma
1187 if test -f $OCAMLLIB/lablgl.$OCAMLLIB_EXT; then
1188   LABLGL_CMXA=lablgl.$OCAMLLIB_EXT
1191 # Check for GTK only if we want to build the GUI
1192 if test ! "$GUI" = "no"; then
1193   echo "---------------------------------------------------------"
1194   echo "Checking the libraries required to build the GTK GUI."
1195   echo "---------------------------------------------------------"
1196   if test "$GUI" = "newgui2"; then
1197       REQUIRED_GTK=2.4.0
1198       PKG_GTK=gtk+-2.0
1199       AC_MSG_CHECKING(for GTK+ - version >= $REQUIRED_GTK)
1200       if pkg-config --atleast-version $REQUIRED_GTK $PKG_GTK; then
1201         AC_MSG_RESULT(yes)
1202         REQUIRED_RSVG=2.4.0
1203         PKG_RSVG=librsvg-2.0
1204         AC_MSG_CHECKING(for librsvg - version >= $REQUIRED_RSVG)
1205         if pkg-config --atleast-version $REQUIRED_RSVG $PKG_RSVG; then
1206           GTK_CONFIG="pkg-config $PKG_GTK $PKG_RSVG"
1207           REQUIRED_LABLGTK=2.14.1
1208           LABLGTK_NAME=lablgtk2
1209           AC_MSG_RESULT(yes)
1210         else
1211           GTK_CONFIG=no
1212           AC_MSG_RESULT(no)
1213         fi
1214       else
1215         GTK_CONFIG=no
1216         AC_MSG_RESULT(no)
1217       fi
1218   else
1219     if test "$OS_FILES2" = "mingw"; then
1220       REQUIRED_GTK=1.3.0
1221       PKG_GTK=gtk+-1.3-win32-production
1222       AC_MSG_CHECKING(for GTK+ - version >= $REQUIRED_GTK)
1223       if pkg-config --atleast-version $REQUIRED_GTK $PKG_GTK; then
1224         GTK_CONFIG="pkg-config $PKG_GTK"
1225         AC_MSG_RESULT(yes)
1226       else
1227         GTK_CONFIG=no
1228         AC_MSG_RESULT(no)
1229       fi
1230     else
1231       AC_CHECK_PROG(GTK_CONFIG, gtk-config, gtk-config, no)
1232       if test "$GTK_CONFIG" = "no"; then
1233         AC_MSG_RESULT(no)
1234       else
1235         AC_MSG_RESULT(yes)
1236       fi
1237     fi
1238   fi
1239 else
1240   GTK_CONFIG=no
1242 if test "$GTK_CONFIG" = "no"; then
1243      LABLGTK_CONFIG=no
1244 else
1245   AC_MSG_CHECKING(for native code $LABLGTK_NAME)
1246   if test -f $OCAMLLIB/$LABLGTK_NAME/lablgtk.$OCAMLLIB_EXT; then
1247      if test "$GUI" = "newgui2"; then
1248        if test -f $OCAMLLIB/$LABLGTK_NAME/lablrsvg.$OCAMLLIB_EXT; then
1249          AC_MSG_RESULT(yes)
1250          LABLGTK_CONFIG=yes
1251        else
1252          AC_MSG_RESULT(no)
1253          LABLGTK_CONFIG=no
1254          if test -f $OCAMLLIB/$LABLGTK_NAME/lablrsvg.cma; then
1255            echo "---------------------------------------------------------"
1256            echo "lablrsvg is not installed properly. See the INSTALL.txt"
1257            echo "file of mldonkey to see how to compile $LABLGTK_NAME. You"
1258            echo "probably forgot to call 'make opt' before 'make install'."
1259            echo "---------------------------------------------------------"
1260          else
1261            echo "---------------------------------------------------------"
1262            echo "lablrsvg is not installed. See the INSTALL.txt file of"
1263            echo "mldonkey to see how to compile $LABLGTK_NAME. Librsvg"
1264            echo "may not be installed when you compiled $LABLGTK_NAME."
1265            echo "---------------------------------------------------------"
1266          fi
1267        fi
1268      else
1269        AC_MSG_RESULT(yes)
1270        LABLGTK_CONFIG=yes
1271      fi
1272   else
1273      AC_MSG_RESULT(no)
1274      LABLGTK_CONFIG=no
1275      if test -f $OCAMLLIB/$LABLGTK_NAME/lablgtk.cma; then
1276        echo "-------------------------------------------------------------"
1277        echo "$LABLGTK_NAME is not installed properly. See the INSTALL.txt"
1278        echo "file of mldonkey to see how to compile $LABLGTK_NAME. You"
1279        echo "probably forgot to call 'make opt' before 'make install'."
1280        echo "-------------------------------------------------------------"
1281      else
1282        echo "Do you want this script to try to download and install $LABLGTK_NAME"
1283        echo "LOCALLY in mldonkey directory ?"
1284        if test "$BATCH" = "no"; then read i <&1; else i=yes; fi
1285        case "$i" in
1286         y* | Y*)
1288          cd $PATCH_DIR
1289          rm -rf lablgtk-"$REQUIRED_LABLGTK"
1290          if test ! -f lablgtk-"$REQUIRED_LABLGTK".tar.gz; then
1291            echo Downloading ...
1292            $WGET http://wwwfun.kurims.kyoto-u.ac.jp/soft/lsl/dist/lablgtk-"$REQUIRED_LABLGTK".tar.gz
1293          fi
1294          if test ! -f lablgtk-"$REQUIRED_LABLGTK".tar.gz; then exit 1; fi
1296          mkdir -p $BUILD_DIR
1297          cd $BUILD_DIR
1298          echo Uncompressing ...
1299          gzip -cd $PATCH_DIR/lablgtk-"$REQUIRED_LABLGTK".tar.gz | tar xf -
1300          (cd lablgtk-"$REQUIRED_LABLGTK"
1301           if test -f $PATCH_DIR/lablgtk-"$REQUIRED_LABLGTK".patch; then
1302             echo Patching ...
1303             patch -p0 < $PATCH_DIR/lablgtk-"$REQUIRED_LABLGTK".patch
1304           fi
1305           PATH=$OCAML_PATH:$PATH
1306           export PATH
1307           echo $PATH
1309           if test "$GUI" = "newgui2"; then
1310             ./configure --prefix=$LOCAL_DIR
1311             $GNU_MAKE world
1312             $GNU_MAKE install
1313           else
1314             $GNU_MAKE configure
1315             $GNU_MAKE
1316             $GNU_MAKE opt
1317             $GNU_MAKE install
1318           fi
1320           cd ..
1321           rm -rf lablgtk-"$REQUIRED_LABLGTK"
1322          )
1323          cd $CONFIG_DIR
1324          if test -f $OCAMLLIB/$LABLGTK_NAME/lablgtk.$OCAMLLIB_EXT; then
1325             LABLGTK_CONFIG=yes
1326          else
1327             echo "Installation of $LABLGTK_NAME failed"
1328             LABLGTK_CONFIG=no
1329          fi
1330          ;;
1331         *);;
1332       esac
1333      fi
1334   fi
1337 if test "$GUI" = "newgui2" ; then
1338   GUIS="mldonkey_gui\$(EXE)"
1339   GTKCFLAGS="`pkg-config --cflags-only-I gtk+-2.0`"
1340   GTKLLIBS="`pkg-config --libs-only-L gtk+-2.0`"
1341   GTKLFLAGS="`pkg-config --libs-only-l gtk+-2.0` -lX11"
1342 else
1343   GUIS="mldonkey_gui\$(EXE) mldonkey_gui2\$(EXE)"
1346 if test "$LABLGTK_CONFIG" = "no"; then
1347   GUI="no"
1348 else
1349   MORE_TARGETS="$MORE_TARGETS $GUIS"
1350   AC_MSG_CHECKING(GToolbox.popup_menu args)
1351   GTOOLBOX="$OCAMLLIB/$LABLGTK_NAME/gToolbox.mli"
1352   grep popup $GTOOLBOX | grep -i button 2> /dev/null && GTOOLBOX_ARGS=new
1353   if test "$GTOOLBOX_ARGS" = "new"; then
1354     GTOOLBOX_POPUPMENU=' ~button: button ~time: time '
1355     AC_MSG_RESULT(new)
1356   else
1357     GTOOLBOX_POPUPMENU=' ~x: button ~y: time '
1358     AC_MSG_RESULT(old)
1359   fi
1360   echo "---------------------------------------------------------"
1361   echo "End of GTK GUI configuration."
1362   echo "---------------------------------------------------------"
1365 if test "$OS_FILES" = "mingw"; then
1366    OCAMLDEP_OPTIONS="-slash"
1369 AC_SUBST(LIBS)
1370 AC_SUBST(CFLAGS)
1371 AC_SUBST(CPPFLAGS)
1372 AC_SUBST(CXXFLAGS)
1373 AC_SUBST(LDFLAGS)
1374 AC_SUBST(CC)
1375 AC_SUBST(CPP)
1376 AC_SUBST(CXX)
1377 AC_SUBST(FIX_BROKEN_CPP)
1378 AC_SUBST(CONFIG_INCLUDES)
1379 AC_SUBST(OCAMLC)
1380 AC_SUBST(OCAMLLIB)
1381 AC_SUBST(OCAMLOPT)
1382 AC_SUBST(OCAMLLEX)
1383 AC_SUBST(OCAMLYACC)
1384 AC_SUBST(OCAMLDEP)
1385 AC_SUBST(OCAMLDEP_OPTIONS)
1386 AC_SUBST(CAMLP4)
1387 AC_SUBST(CAMLP4OF)
1388 AC_SUBST(CAMLP4LIB_OPT)
1389 AC_SUBST(CAMLP4LIB_BYTE)
1390 AC_SUBST(PERL)
1391 AC_SUBST(OCAMLDOC)
1392 AC_SUBST(OCAMLMKTOP)
1393 AC_SUBST(SYSTEM)
1394 AC_SUBST(MORE_TARGETS)
1395 AC_SUBST(MORE_SUBDIRS)
1396 AC_SUBST(LABLGL_CMA)
1397 AC_SUBST(LABLGL_CMXA)
1398 AC_SUBST(MD4ARCH)
1399 AC_SUBST(MD4COMP)
1400 AC_SUBST(ICONV)
1401 AC_SUBST(OPEN_NAPSTER)
1402 AC_SUBST(DIRECT_CONNECT)
1403 AC_SUBST(GNUTELLA)
1404 AC_SUBST(GNUTELLA2)
1405 AC_SUBST(BITTORRENT)
1406 AC_SUBST(FILETP)
1407 AC_SUBST(SOULSEEK)
1408 AC_SUBST(OPENFT)
1409 AC_SUBST(FASTTRACK)
1410 AC_SUBST(DONKEY)
1411 AC_SUBST(DONKEY_SUI)
1412 AC_SUBST(CRYPTOPPFLAGS)
1413 AC_SUBST(DONKEY_SUI_FILE)
1414 AC_SUBST(DONKEY_SERVER)
1415 AC_SUBST(GUI)
1416 AC_SUBST(REQUIRED_OCAML)
1417 AC_SUBST(REQUIRED_LABLGTK)
1418 AC_SUBST(ARCH)
1419 AC_SUBST(COMPRESS)
1420 AC_SUBST(COMPRESS_EXT)
1421 AC_SUBST(CHECKBOUNDS)
1422 AC_SUBST(MLDONKEY_VERSION)
1423 AC_SUBST(SCM_VERSION)
1424 AC_SUBST(MAJOR_VERSION)
1425 AC_SUBST(MINOR_VERSION)
1426 AC_SUBST(SUB_VERSION)
1427 AC_SUBST(GTOOLBOX_POPUPMENU)
1428 AC_SUBST(OS_FILES)
1429 AC_SUBST(OS_FILES2)
1430 AC_SUBST(TARGET_TYPE)
1431 AC_SUBST(RPMBUILD)
1432 AC_SUBST(GTKCFLAGS)
1433 AC_SUBST(GTKLLIBS)
1434 AC_SUBST(GTKLFLAGS)
1435 AC_SUBST(GD)
1436 AC_SUBST(GD_JPG)
1437 AC_SUBST(GD_PNG)
1438 AC_SUBST(GDGRAPHICS)
1439 AC_SUBST(GD_LIBS)
1440 AC_SUBST(GD_STATIC_LIBS)
1441 AC_SUBST(GD_CFLAGS)
1442 AC_SUBST(GD_LDFLAGS)
1443 AC_SUBST(BZIP2)
1444 AC_SUBST(MAGIC)
1445 AC_SUBST(MAGICLIB)
1446 BUILD_SYSTEM="`uname -s` `uname -m` `uname -r`"
1447 AC_SUBST(BUILD_SYSTEM)
1448 AC_SUBST(GLIBC_VERSION)
1449 AC_SUBST(CC_VERSION)
1450 AC_SUBST(CXX_VERSION)
1451 AC_SUBST(CONFIGURE_ARGUMENTS)
1452 AC_SUBST(CONFIGURE_RUN)
1454 AUTOCONF=../src/utils/lib/autoconf.ml
1455 GTK_AUTOCONF=../src/utils/lib/gAutoconf.ml
1456 AC_OUTPUT(\
1457   Makefile.config \
1458   mldonkey.rc \
1459   $AUTOCONF.new $GTK_AUTOCONF.new \
1460    ../src/utils/bitstring/bitstring.ml \
1461    ../src/utils/lib/magic.ml \
1462    ../src/networks/donkey/donkeySui.ml \
1463    ../src/daemon/driver/driverGraphics.ml \
1464    ../packages/rpm/mldonkey.spec \
1465    ../packages/rpm/Makefile \
1466    ../packages/slackware/mldonkey.options)
1467 diff $AUTOCONF.new $AUTOCONF 2> /dev/null > /dev/null || cp -f $AUTOCONF.new $AUTOCONF
1468 diff $GTK_AUTOCONF.new $GTK_AUTOCONF 2> /dev/null > /dev/null || cp -f $GTK_AUTOCONF.new $GTK_AUTOCONF
1470 cd ..
1472 echo -e "\nBuilding dependencies (if it blocks, try '$GNU_MAKE depend' to see the problem)"
1473 $GNU_MAKE depend 2> /dev/null > /dev/null || echo "Building dependencies fails: try: '$GNU_MAKE depend'"
1475 echo -e -n "\nConfiguring MLDonkey" $MLDONKEY_VERSION
1476 if test ! -z "$SCM_VERSION"; then
1477   echo -n " - SCM: $SCM_VERSION"
1479 echo " completed."
1481 echo -e "\nNetwork modules:"
1482 echo -n " - eDonkey           "
1483 if test "$DONKEY" = "yes"; then
1484   if test "$DONKEY_SUI" = "yes"; then
1485     echo "enabled (eMule SUI enabled)"
1486   else
1487     echo "enabled (eMule SUI disabled)"
1488   fi
1489 else
1490   echo "        disabled"
1493 echo -n " - BitTorrent        "
1494 if test "$BITTORRENT" = "yes"; then
1495   echo "enabled"
1496 else
1497   echo "        disabled"
1500 echo -n " - FileTP (aka wget) "
1501 if test "$FILETP" = "yes"; then
1502   echo "enabled"
1503 else
1504   echo "        disabled"
1507 echo -n " - Fasttrack         "
1508 if test "$FASTTRACK" = "yes"; then
1509   echo "enabled"
1510 else
1511   echo "        disabled"
1514 echo -n " - Gnutella          "
1515 if test "$GNUTELLA" = "yes"; then
1516   echo "enabled (warning: this network module is unmaintained)"
1517 else
1518   echo "        disabled - unmaintained"
1521 echo -n " - Gnutella2         "
1522 if test "$GNUTELLA2" = "yes"; then
1523   echo "enabled (warning: this network module is unmaintained)"
1524 else
1525   echo "        disabled - unmaintained"
1528 echo -n " - Direct Connect    "
1529 if test "$DIRECT_CONNECT" = "yes"; then
1530   echo "enabled"
1531 else
1532   echo "        disabled"
1535 echo -n " - Open Napster      "
1536 if test "$OPEN_NAPSTER" = "yes"; then
1537   echo "enabled          - currently not usable"
1538 else
1539   echo "        disabled - currently not usable"
1542 echo -n " - Soulseek          "
1543 if test "$SOULSEEK" = "yes"; then
1544   echo "enabled          - currently not usable"
1545 else
1546   echo "        disabled - currently not usable"
1549 echo -n " - OpenFT            "
1550 if test "$OPENFT" = "yes"; then
1551   echo "enabled          - currently not usable"
1552 else
1553   echo "        disabled - currently not usable"
1556 echo -e "\nCore features:"
1558 echo " - zlib (required)   enabled"
1560 echo -n " - threads           "
1561 if test "$USE_PTHREAD" = "yes"; then
1562   echo "enabled"
1563 else
1564   echo "        disabled"
1567 echo -n " - bzip2             "
1568 if test "$BZIP2" = "yes"; then
1569   echo "enabled"
1570 else
1571   echo "        disabled"
1574 echo -n " - iconv             "
1575 if test "$ICONV" = "yes"; then
1576   echo "enabled"
1577 else
1578   echo "        disabled"
1581 echo -n " - libmagic          "
1582 if test "$MAGIC" = "yes"; then
1583   echo "enabled"
1584 else
1585   echo "        disabled"
1588 echo -n " - graphical stats   "
1589 if test "$GD" = "yes"; then
1590   echo "enabled"
1591   echo -n "   - png support     "
1592   if test "$GD_PNG" = "yes"; then
1593     echo "enabled"
1594   else
1595     echo "        disabled"
1596   fi
1598   echo -n "   - jpg support     "
1599   if test "$GD_JPG" = "yes"; then
1600     echo "enabled"
1601   else
1602     echo "        disabled"
1603   fi
1604 else
1605   echo "        disabled"
1608 if test "$LABLGTK_CONFIG" = "yes"; then
1609   echo -n -e "\n - GUI support       "
1610   if test "$GUI" = "newgui1"; then
1611     echo "GTK1 newgui"
1612   else
1613     if test "$GUI" = "newgui2"; then
1614       echo "GTK2 GUI"
1615     else
1616       echo "GTK1 oldgui"
1617     fi
1618   fi
1621 if test "$OLDGUI_NO_31" = "yes"; then
1622   echo " - GUI support       GTK1 oldgui does not work with Ocaml 3.1*, disabled"
1625 if test "$TARGET_TYPE" = "byte"; then
1626   OCAML_TYPE="- byte code"
1627   COMPILE_TARGET=".byte"
1629 echo -e "\nCompilers:"
1630 echo -e " - Ocaml version     $OCAMLVERSION $OCAML_TYPE"
1631 echo -e " - $CC version       $CC_VERSION"
1632 if test "x$CXX" != "x"; then
1633   echo -e " - $CXX version       $CXX_VERSION"
1635 echo -e "\nNow execute '$GNU_MAKE' to start compiling. Good luck!"
1637 echo -e "\nTo compile a static code execute:     $GNU_MAKE mlnet$COMPILE_TARGET.static"
1638 echo      "To produce a release tarball execute: $GNU_MAKE release.mlnet.static"
1639 echo      "To clean the build directory execute: $GNU_MAKE maintainerclean"
1640 if test "$DONKEY_SUI" = "yes"; then
1641   echo -e "\nCompiling CryptoPP.cc can take several minutes, on slow machines up to half an hour."