patch #6752
[mldonkey.git] / config / configure.in
blob265dde4ac8741b3d1d09986f469b51ff2848ec3f
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=2
24 MINOR_VERSION=9
25 SUB_VERSION=7   # 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_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   *freebsd*|*dragonfly*)
109     SYSTEM=freebsd
110     CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
111     LDFLAGS="${LDFLAGS} -L/usr/local/lib"
112     ;;
113   *openbsd*)
114     SYSTEM=openbsd
115     CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
116     LDFLAGS="${LDFLAGS} -L/usr/local/lib"
117     ;;
118   *netbsd*)
119     SYSTEM=netbsd
120     ;;
121   *linux*)
122     SYSTEM=linux
123     ;;
124   *solaris*)
125     SYSTEM=solaris
126     ;;
127   *morphos*|*amigaos*)
128     SYSTEM=morphos
129     ;;
130   *aix*)
131     SYSTEM=aix
132     ;;
133   *beos*)
134     SYSTEM=beos
135     ;;
136   *osf*)
137     SYSTEM=osf
138     ;;
139   *irix*)
140     SYSTEM=irix
141     ;;
142   *hppa*|*hpux*)
143     SYSTEM=hpux
144     ;;
145   *darwin*|*rhapsody*|*macosx*)
146     SYSTEM=macos
147     AC_CHECK_PROG(SED, sed, sed)
148     if test "$ac_cv_prog_SED" = "sed"; then
149       FIX_BROKEN_CPP="| sed -n '/^\#pragma/!p'"
150     else
151       AC_CHECK_PROG(GREP, grep, grep)
152       if test "$ac_cv_prog_GREP" = "grep"; then
153         FIX_BROKEN_CPP="| grep -v '^\#pragma'"
154       fi
155     fi
156     if test "xFIX_BROKEN_CPP" = "x"; then
157       echo "Apple cpp produces broken files, your system lacks sed or grep to fix it"
158       exit 1
159     fi
160     ;;
161 esac
162 if test "x$SYSTEM" = "xunknown"; then
163   echo "Unknown build system, please report to the MLDonkey development team at http://mldonkey.sourceforge.net/forums/"
164   exit 1
167 case "$host" in
168   alpha*-*-osf*)                arch=alpha; system=digital;;
169   alpha*-*-linux*)              arch=alpha; system=linux;;
170   alpha*-*-freebsd*)            arch=alpha; system=freebsd;;
171   alpha*-*-netbsd*)             arch=alpha; system=netbsd;;
172   alpha*-*-openbsd*)            arch=alpha; system=openbsd;;
173   sparc-*-sunos4.*)             arch=sparc; system=sunos;;
174   sparc-*-solaris2.*)           arch=sparc; system=solaris;;
175   sparc-*-*bsd*)                arch=sparc; system=bsd;;
176   sparc-*-linux*)               arch=sparc; system=linux;;
177   i?86-*-linux*)           arch=i386; system=linux;;
178   i386-*-*bsd*)            arch=i386; system=bsd;;
179   i486-*-*bsd*)            arch=i486; system=bsd;;
180   i586-*-*bsd*)            arch=i586; system=bsd;;
181   i686-*-*bsd*)            arch=i686; system=bsd;;
182   i?86-*-nextstep*)        arch=i386; system=nextstep;;
183   i?86-*-solaris*)         arch=i386; system=solaris;;
184   i?86-*-beos*)            arch=i386; system=beos;;
185   i?86-*-cygwin*)          arch=i386; system=cygwin;;
186   mips-*-irix6*)                arch=mips; system=irix;;
187   hppa1.1-*-hpux*)              arch=hppa; system=hpux;;
188   hppa1.1-*-nextstep*)          arch=hppa; system=nextstep;;
189   rs6000-*-aix*)                arch=power; model=rs6000; system=aix;;
190   powerpc-*-aix*)               arch=power; model=ppc; system=aix;;
191   powerpc-*-linux*)             arch=power; model=ppc; system=elf;;
192   powerpc-*-rhapsody*)          arch=power; model=ppc; system=rhapsody;;
193   powerpc-*-darwin*)            arch=power; model=ppc; system=rhapsody;;
194   arm*-*-linux*)                arch=arm; system=linux;;
195   ia64-*-linux*)                arch=ia64; system=linux;;
196 esac
198 MD4ARCH=$arch
199 case $host in
200   i386-pc-linux*|i386-*-*bsd*) MD4COMP=as; MD4ARCH=i386;;
201   i486-pc-linux*|i486-*-*bsd*) MD4COMP=as; MD4ARCH=i486;;
202   i586-pc-linux*|i586-*-*bsd*) MD4COMP=as; MD4ARCH=i586;;
203   i686-pc-linux*|i686-*-*bsd*) MD4COMP=as; MD4ARCH=i686;;
204   i386-pc-mingw32*) MD4COMP=cc; MD4ARCH=i386;;
205   i486-pc-mingw32*) MD4COMP=cc; MD4ARCH=i486;;
206   i586-pc-mingw32*) MD4COMP=cc; MD4ARCH=i586;;
207   i686-pc-mingw32*) MD4COMP=cc; MD4ARCH=i686;;
208   *) MD4COMP=cc;;
209 esac
211 ARCH=$arch
213 # **********                                                                                  **********
214 # **********               Parse checkout date (CVS) or revision (SVN) if available           **********
215 # **********                                                                                  **********
217 if test -d .svn; then
218   AC_MSG_NOTICE(checking SVN revision)
219   AC_CHECK_PROG(SVNVERSION,svnversion,svnversion)
220   if test "$ac_cv_prog_SVNVERSION" = "svnversion"; then
221     SUB_VERSION3="SVN"
222     SCM_VERSION=`svnversion -n .`
223   else AC_MSG_NOTICE(cannot checking SVN revision... no SVNVERSION)
224     SCM_VERSION="cannot find out SVN revision (no SVNVERSION)"  
225   fi     
228 if test -f ./CVS/Entries ; then
229   AC_MSG_NOTICE(checking CVS checkout date)
230   AC_CHECK_PROGS(STAT, stat gstat, stat)
231   if [ test "$ac_cv_prog_STAT" = "stat" ] || [ test "$ac_cv_prog_STAT" = "gstat" ]; then
232     AC_CHECK_PROG(SED, sed, sed)
233     if test "$ac_cv_prog_SED" = "sed"; then
234       AC_CHECK_PROG(CUT, cut, cut)
235       if test "$ac_cv_prog_CUT" = "cut"; then
236         SUB_VERSION3="CVS"
237         if [ test "$SYSTEM" = "freebsd"] || [ test "$SYSTEM" = "netbsd"] || ( [ test "$SYSTEM" = "macos" ] && [ test "$ac_cv_prog_STAT" != "gstat" ] ); then
238           SCM_VERSION=`$STAT -f "%Sm" ./CVS/Entries | $SED -e 's/\(.*\) \(.*\) \(.*\) \(.*\)/\4-\1-\2 \3/'`
239         else
240         if [ test "$SYSTEM" = "openbsd"]; then
241           AC_CHECK_PROG(GREP, grep, grep)
242           if test "$ac_cv_prog_GREP" = "grep"; then
243             SCM_VERSION=`$STAT -f %a ./CVS/Entries | $GREP -v Entries | $SED -e 's/\(.*\) \(.*\) \(.*\) \(.*\)/\1-\2-\4 \3/'`
244           fi
245         else
246         if [ test "$SYSTEM" = "mingw"] || [ test "$SYSTEM" = "cygwin"]; then
247           AC_CHECK_PROG(GREP, grep, grep)
248           if test "$ac_cv_prog_GREP" = "grep"; then
249             SCM_VERSION=`$STAT ./CVS/Entries  | $GREP Modify | $SED -e 's/\(.*\) \(.*\) \(.*\) \(.*\) \(.*\)/\5-\2-\3 \4/'`
250           fi
251         else
252           SCM_VERSION=`$STAT -Lc %y ./CVS/Entries | $SED -e 's#\.[0-9]*##' | $CUT -c 1-19`
253         fi  #if [ test "$SYSTEM" = "mingw"] || ...
254         fi  #if [ test "$SYSTEM" = "openbsd"]
255         fi  #if [ test "$SYSTEM" = "freebsd"] || ...
256       else
257         AC_MSG_NOTICE(cannot checking CVS checkout date... no CUT)
258         SCM_VERSION="cannot find out SCM Version (no CUT)"
259       fi
260     else
261       AC_MSG_NOTICE(cannot checking CVS checkout date... no SED)
262       SCM_VERSION="cannot find out SCM Version (no SED)"
263     fi
264   else
265     AC_MSG_NOTICE(cannot checking CVS checkout date... no STAT)
266     SCM_VERSION="cannot find out SCM Version (no STAT)"
267   fi
270 # **********                                                                                  **********
271 # **********             build MLDonkey version, Required Ocaml and LablGTK versions          **********
272 # **********                                                                                  **********
274 MLDONKEY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$SUB_VERSION
275 if test -f ./subrelease; then
276   MLDONKEY_VERSION=$MLDONKEY_VERSION`cat ./subrelease`
278 if test ! -z "$SUB_VERSION3"; then
279   MLDONKEY_VERSION=$MLDONKEY_VERSION.$SUB_VERSION3
282 REQUIRED_OCAML=3.10.2
283 DOWNLOAD_OCAML_MAJOR=3.10
284 DOWNLOAD_OCAML=3.10.2
286 REQUIRED_LABLGTK=1.2.7
288 touch install-sh
290 LABLGTK_NAME=lablgtk
292 # **********                                                                                  **********
293 # **********                    Network and Feature configure switch variables                **********
294 # **********                                                                                  **********
296 # **********   currently not working Networks, can't be enabled
298 SOULSEEK=no
299 OPEN_NAPSTER=no
300 OPENFT=no
302 # **********   working Networks, enabled by default
304 DONKEY=yes
305 BITTORRENT=yes
306 GNUTELLA=no
307 GNUTELLA2=no
308 FASTTRACK=yes
309 FILETP=yes
310 DIRECT_CONNECT=yes
312 # **********   predefined configure variations
314 MULTINET=yes
315 MINIMUM=no
317 # **********   Features, enabled by default
319 DONKEY_SUI=yes
320 DONKEY_SUI_FILE=DonkeySui2
321 GD=yes
322 BZIP2=yes
323 MAGIC=yes
324 ICONV=yes
325 USE_PTHREAD=yes
327 # **********
329 BATCH=no
330 FORCE_OCAML=no
331 FORCE_MINGW=no
332 PROFILE=no
333 DEBUG=no
334 GUI=no
335 CHECKBOUNDS=false
337 # **********                                                                                  **********
338 # **********                Network and Feature configure switches and dependency             **********
339 # **********                                                                                  **********
341 AC_ARG_ENABLE(multinet,      [  --disable-multinet      allows you to only compile support for eDonkey (incl. Overnet and Kademlia)], [MULTINET="$enableval"])
342 AC_ARG_ENABLE(minimum,       [  --enable-minimum        compile MLDonkey with minimum features and Networks (eDonkey, iconv and thread enabled)], [MINIMUM="$enableval"])
343 AC_ARG_ENABLE(minimum,       [  --enable-minimum=all    disable all optional features and Networks excepting eDonkey], [MINIMUM="$enableval"])
345 if [ test ! "$MULTINET" = "yes" ] || [ test "$MINIMUM" = "yes" ] || [ test "$MINIMUM" = "all" ]; then
346   GNUTELLA=no
347   GNUTELLA2=no
348   FASTTRACK=no
349   DIRECT_CONNECT=no
350   FILETP=no
351   BITTORRENT=no
353 if [ test "$MINIMUM" = "yes" ] || [ test "$MINIMUM" = "all" ]; then
354   DONKEY_SUI=no
355   GD=no
356   BZIP2=no
357   MAGIC=no
359 if [ test "$MINIMUM" = "all" ]; then
360   USE_PTHREAD=no
361   ICONV=no
364 #AC_ARG_ENABLE(soulseek,      [  --disable-soulseek      allows you to remove support for SoulSeek], [SOULSEEK="$enableval"])
365 #AC_ARG_ENABLE(opennap,       [  --disable-opennap       allows you to remove support for Open Napster], [OPEN_NAPSTER="$enableval"])
366 AC_ARG_ENABLE(directconnect, [  --disable-directconnect allows you to remove support for Direct Connect], [DIRECT_CONNECT="$enableval"])
367 #AC_ARG_ENABLE(openft,        [  --disable-openft        allows you to remove support for OpenFT], [OPENFT="$enableval"])
369 AC_ARG_ENABLE(donkey,        [  --disable-donkey        allows you to remove support for eDonkey], [DONKEY="$enableval"])
370 AC_ARG_ENABLE(donkeysui,     [  --disable-donkeysui     allows you to remove support for eMule SecureUserIdent], [DONKEY_SUI="$enableval"])
371 AC_ARG_ENABLE(bittorrent,    [  --disable-bittorrent    allows you to remove support for Bittorent], [BITTORRENT="$enableval"])
372 AC_ARG_ENABLE(filetp,        [  --disable-filetp        allows you to remove support for fileTP], [FILETP="$enableval"])
373 AC_ARG_ENABLE(gnutella,      [  --disable-gnutella      allows you to remove support for Gnutella], [GNUTELLA="$enableval"])
374 AC_ARG_ENABLE(gnutella2,     [  --disable-gnutella2     allows you to remove support for Gnutella2], [GNUTELLA2="$enableval"])
375 AC_ARG_ENABLE(fasttrack,     [  --disable-fasttrack     allows you to remove support for FastTrack], [FASTTRACK="$enableval"])
377 AC_ARG_ENABLE(batch,         [  --enable-batch          reply YES to all queries in this script], [BATCH="$enableval"])
378 AC_ARG_ENABLE(force-ocaml,   [  --enable-force-ocaml    force usage of self-compiled Ocaml], [FORCE_OCAML="$enableval"])
379 AC_ARG_ENABLE(ocamlver,      [  --enable-ocamlver=VER   force usage of specific Ocaml version (3.08.1|CVS), ], [REQUIRED_OCAML="$enableval"])
380 AC_ARG_ENABLE(mingw,         [  --enable-mingw          forces compilation with MINGW on Cygwin], [FORCE_MINGW="$enableval"])
381 AC_ARG_ENABLE(checks,        [  --enable-checks         force mldonkey to perform bound checks on array/string access], [CHECKBOUNDS="$enableval"])
382 if test "$CHECKBOUNDS" = "yes"; then
383   CHECKBOUNDS=true
386 AC_ARG_ENABLE(profile,       [  --enable-profile        allows you to profile mlnet using gprof], [PROFILE="$enableval"])
387 AC_ARG_ENABLE(debug,         [  --enable-debug          allows you to compile mlnet with debug symbols], [DEBUG="$enableval"])
388 AC_ARG_ENABLE(gui,           [  --disable-gui           allows you to disable GUI build (default)], [GUI="$enableval"])
389 AC_ARG_ENABLE(gui,           [  --enable-gui=oldgui|newgui1|newgui2
390                           allows you to choose a GUI (default: newgui2 - is a GTK2 GUI, other GUIs use GTK1)], [GUI="$enableval"])
391 if test "$GUI" = "yes"; then
392   GUI=newgui2
394 if test ! "$GUI" = "newgui2"; then
395   if test ! "$GUI" = "newgui1"; then
396     if test ! "$GUI" = "oldgui"; then
397       GUI=no
398     fi
399   fi
402 AC_ARG_ENABLE(pthread,       [  --disable-pthread       allows you to disable pthread support in mldonkey, hurts performance!], [USE_PTHREAD="$enableval"])
403 AC_ARG_ENABLE(pthread-lib,   [  --enable-pthread-lib    legacy option], [USE_PTHREAD="$enableval"])
404 AC_ARG_ENABLE(iconv,         [  --disable-iconv         disable the use of iconv], [ICONV="$enableval"])
405 AC_ARG_ENABLE(gd,            [  --disable-gd            disable the use of gd], [GD="$enableval"])
406 AC_ARG_ENABLE(bzip2,         [  --disable-bzip2         disable the use of bzip2], [BZIP2="$enableval"])
407 AC_ARG_ENABLE(magic,         [  --disable-magic         disable the use of libmagic (GNU file)], [MAGIC="$enableval"])
409 if test "$FORCE_MINGW" = "yes"; then
410     CC="$CC -mno-cygwin"
411     CPP="$CPP -mno-cygwin"
412     OS_FILES=mingw
413     OS_FILES2=mingw
414     SYSTEM=mingw
417 OCAML_PATH=
419 echo -e "\n--------------------------------"
420 echo "     Checking system tools."
421 echo "--------------------------------"
423 AC_PROG_RANLIB
424 AC_CHECK_PROG(GNU_MAKE, gmake, gmake)
425 AC_CHECK_PROG(GNU_MAKE, make, make)
427 if test "x$GNU_MAKE" != "x"; then
428   AC_MSG_CHECKING( [if $GNU_MAKE is GNU make] )
429   $GNU_MAKE --version > /dev/null 2>&1
430   if test "$?" != "0"; then
431     AC_MSG_RESULT([no])
432         AC_MSG_ERROR(GNU make not found)
433   else
434     AC_MSG_RESULT([yes])
435   fi
436 else
437   AC_MSG_ERROR(GNU make not found)
440 AC_CHECK_PROG(COMPRESS, bzip2, bzip2)
441 AC_CHECK_PROG(COMPRESS, gzip, gzip)
443 if test "$ac_cv_prog_COMPRESS" = "bzip2"; then
444    COMPRESS_EXT=bz2
445 else
446    COMPRESS_EXT=gz
449 AC_PATH_PROG(PERL, perl, perl)
450 AC_CHECK_PROG(RPMBUILD,rpmbuild,rpmbuild)
451 AC_CHECK_PROG(RPMBUILD,rpm,rpm)
453 AC_CHECK_PROG(WGET, wget, wget)
454 if test -z "$ac_cv_prog_WGET"; then
455   $CC -o wget wget.c || echo "Cannot compile wget.c"
456   AC_PATH_PROG(WGET, wget,,$SOURCE_DIR/config)
457   ac_cv_prog_WGET="$ac_cv_path_WGET"
459 WGET="$ac_cv_prog_WGET"
461 echo "----------------------------------------"
462 echo "     Checking system tools finished."
463 echo -e "----------------------------------------\n"
465 echo "--------------------------------"
466 echo "     Checking Ocaml compiler."
467 echo "--------------------------------"
469 CONFIG_DIR=$SOURCE_DIR/config
470 PATCH_DIR=$SOURCE_DIR/patches
471 LOCAL_DIR=$PATCH_DIR/local
472 BUILD_DIR=$PATCH_DIR/build
474 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"])
476 LOCAL=$LOCAL_DIR
477 LOCAL_OCAML=$LOCAL_DIR/bin
479 AC_PATH_PROG(OCAMLC,ocamlc.opt,"",[$LOCAL_DIR/bin:$PATH])
480 AC_CHECK_TOOL(OCAMLC,ocamlc,ocamlrun ocamlc)
481 AC_PATH_PROG(CAMLP4, camlp4,"",[$LOCAL_DIR/bin:$PATH])
483 BUILD_OCAML=no
484 if [ test -z "$OCAMLC" ] || [ test -z "$CAMLP4" ] || [ test "$REQUIRED_OCAML" = "CVS" ]; then
485    BUILD_OCAML=yes
486 else
487   OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
488   case "$OCAMLVERSION" in
489     "$REQUIRED_OCAML"*|3.11.0*|3.10.*|3.09.*|3.08.4*|3.08.3*) ;;
490     *)
491         echo "Need build"
492         BUILD_OCAML=yes
493         ;;
494   esac
497 if [ test "$BUILD_OCAML" = "yes" ] || [ test "$FORCE_OCAML" = "yes" ]; then
499   if [ test "$SYSTEM" = "mingw" ]; then
500     echo "********         Objective-Caml $REQUIRED_OCAML is required               *********" 1>&2;
501     echo "********     no valid Ocaml compiler found on your system        *********" 1>&2;
502     echo "********   on MinGW there is no possibility to let configure     *********" 1>&2;
503     echo "********   build the Ocaml compiler with the included script     *********" 1>&2;
504     echo "********    check http://mldonkey.sourceforge.net/Windows        *********" 1>&2;
505     echo "********   for instuctions how to compile Ocaml under MinGW      *********" 1>&2;
506     exit 1
507   else  
508     
509   echo "********  Objective-Caml $REQUIRED_OCAML is required  *********" 1>&2;
510   if [ test "$WGET" = "" ] && [ test "$REQUIRED_OCAML" != "CVS" ]; then
511     echo "********          wget is missing          *********" 1>&2;
512     echo "********       cannot download Ocaml       *********" 1>&2;
513     exit 1
514   fi
515   echo "*******  Check http://caml.inria.fr/  ********" 1>&2;
516   echo "Do you want this script to try to download and install ocaml"
517   echo "LOCALLY in mldonkey directory ?"
518   if test "$BATCH" = "no"; then read i <&1; else i=yes; fi
519   case "$i" in
520    y* | Y*)
521       cd $PATCH_DIR
522       if [ test "$REQUIRED_OCAML" = "CVS" ]; then
523         rm -rf $BUILD_DIR
524         mkdir -p $BUILD_DIR
525         cd $BUILD_DIR
526         cvs -d:pserver:anoncvs:""@camlcvs.inria.fr:/caml login
527         cvs -z3 -d:pserver:anoncvs@camlcvs.inria.fr:/caml co -P ocaml
528         cd ocaml
529       else
530         if test ! -f ocaml-"$REQUIRED_OCAML".tar.gz; then
531           echo Downloading ...
532           $WGET http://caml.inria.fr/pub/distrib/ocaml-"$DOWNLOAD_OCAML_MAJOR"/ocaml-"$REQUIRED_OCAML".tar.gz
533         fi
534         if test ! -f ocaml-"$REQUIRED_OCAML".tar.gz; then
535           $WGET http://caml.inria.fr/pub/distrib/ocaml-3.09/ocaml-"$REQUIRED_OCAML".tar.gz
536         fi
537         if test ! -f ocaml-"$REQUIRED_OCAML".tar.gz; then
538           $WGET http://caml.inria.fr/pub/distrib/ocaml-3.11/ocaml-"$REQUIRED_OCAML".tar.gz
539         fi
540         if test ! -f ocaml-"$REQUIRED_OCAML".tar.gz; then
541           $WGET http://caml.inria.fr/pub/distrib/ocaml-3.08/ocaml-"$REQUIRED_OCAML".tar.gz
542         fi
543         if test ! -f ocaml-"$REQUIRED_OCAML".tar.gz; then
544           echo "********        download Ocaml $REQUIRED_OCAML not successful, try do download it manually       *********" 1>&2;
545           echo "********        from http://caml.inria.fr/pub/distrib/                                   *********" 1>&2;
546           echo "********        and copy the tar.gz into $PATCH_DIR              *********" 1>&2;
547           exit 1
548         fi
550         echo Uncompressing ...
551         mkdir -p $BUILD_DIR
552         cd $BUILD_DIR
553         rm -rf ocaml-"$REQUIRED_OCAML"
554         gzip -cd $PATCH_DIR/ocaml-"$REQUIRED_OCAML".tar.gz | tar vxf -
555         cd ocaml-"$REQUIRED_OCAML"
556         if test -f $PATCH_DIR/ocaml-"$REQUIRED_OCAML".patch; then
557           echo Patching ...
558           patch -p1 < $PATCH_DIR/ocaml-"$REQUIRED_OCAML".patch
559         fi
560       fi
561       echo Configuring ...
562       ./configure -prefix $LOCAL_DIR -host $host -cc $CC
563       cd config
564       cp -f Makefile Makefile.old
565       sed "s/OTHERLIBRARIES=.*/OTHERLIBRARIES=unix dynlink num str bigarray threads/" Makefile.old > Makefile
566       cd ..
567       cp -f $PATCH_DIR/Makefile.ocamldoc ocamldoc/Makefile
568       echo Compiling ...
569       $GNU_MAKE world opt opt.opt
570       echo Installing ...
571       $GNU_MAKE install
572       if ! test -f $LOCAL_DIR/lib/ocaml/threads; then
573         if ! test -f $LOCAL_DIR/lib/ocaml/vmthreads; then
574           ln -s vmthreads  $LOCAL_DIR/lib/ocaml/threads
575         fi
576       fi
577       cd $BUILD_DIR
578       if [ test "$REQUIRED_OCAML" = "CVS" ]; then
579         rm -rf ocaml
580       else
581         rm -rf ocaml-"$REQUIRED_OCAML"
582       fi
583       cd $CONFIG_DIR
584       echo Ocaml locally installed for mldonkey
586       if test -f "$LOCAL_OCAML"/ocamlc.opt; then
587          OCAMLC=$LOCAL_OCAML/ocamlc.opt
588          ac_cv_prog_OCAMLC=$LOCAL_OCAML/ocamlc.opt
589       else
590       if test -f "$LOCAL_OCAML"/ocamlc; then
591          OCAMLC=$LOCAL_OCAML/ocamlc
592          ac_cv_prog_OCAMLC=$LOCAL_OCAML/ocamlc
593       else
594         echo "Ocaml installation failed"; exit 1
595       fi
596       fi
597       ;;
598    *)  exit 1;;
599   esac
600   fi
603 if test "$OCAMLC" = "$LOCAL_OCAML"/ocamlc.opt ; then
604   OCAML_PATH="$LOCAL_OCAML"/
605   OCAMLOPT=$LOCAL_OCAML/ocamlopt.opt
606   OCAMLDOC=$LOCAL_OCAML/ocamldoc
607   OCAMLMKTOP=$LOCAL_OCAML/ocamlmktop
608   OCAMLDEP=$LOCAL_OCAML/ocamldep
609   OCAMLLEX=$LOCAL_OCAML/ocamllex.opt
610   OCAMLYACC=$LOCAL_OCAML/ocamlyacc
611   CAMLP4=$LOCAL_OCAML/camlp4
612 else
613   if test "$OCAMLC" = "$LOCAL_OCAML"/ocamlc ; then
614   OCAML_PATH="$LOCAL_OCAML"/
615   if test -f "$LOCAL_OCAML/ocamlopt"; then
616     OCAMLOPT=$LOCAL_OCAML/ocamlopt
617   else
618     OCAMLOPT=no
619   fi
620   OCAMLDOC=$LOCAL_OCAML/ocamldoc
621   OCAMLMKTOP=$LOCAL_OCAML/ocamlmktop
622   OCAMLDEP=$LOCAL_OCAML/ocamldep
623   OCAMLLEX=$LOCAL_OCAML/ocamllex
624   OCAMLYACC=$LOCAL_OCAML/ocamlyacc
625   CAMLP4=$LOCAL_OCAML/camlp4
626   else
627   AC_CHECK_PROG(OCAMLOPT, ocamlopt.opt, ocamlopt.opt)
628   AC_CHECK_PROG(OCAMLOPT, ocamlopt, ocamlopt, no)
629   AC_CHECK_PROG(OCAMLDEP, ocamldep, ocamldep)
630   AC_CHECK_PROG(OCAMLLEX, ocamllex.opt, ocamllex.opt)
631   AC_CHECK_PROG(OCAMLLEX, ocamllex, ocamllex)
632   AC_CHECK_PROG(OCAMLYACC, ocamlyacc, ocamlyacc)
633   AC_CHECK_PROG(OCAMLDOC, ocamldoc, ocamldoc)
634   AC_CHECK_PROG(OCAMLMKTOP, ocamlmktop, ocamlmktop)
635   AC_CHECK_PROG(CAMLP4, camlp4, camlp4)
639 OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
640 OCAMLLIB=`$OCAMLC -where`
641 REBUILD_OCAML=no
642 case "$OCAMLVERSION" in
643     3.10*|3.11*)
644       if test "$GUI" = "oldgui"; then
645         OLDGUI_NO_310=yes
646         GUI=no
647       fi
648       ;;
649     "$REQUIRED_OCAML"*|3.09.*|3.08.4*|3.08.3*) ;;
650     *)
651       if [ test "$REQUIRED_OCAML" != "CVS" ]; then
652         REBUILD_OCAML=yes
653       fi
654       ;;
655 esac
656 if test "$REBUILD_OCAML" = "yes"; then
657   echo "********  Version $REQUIRED_OCAML of Objective-Caml is required  *********" 1>&2;
658   echo "*******  Check http://caml.inria.fr/  ********" 1>&2;
659   exit 1;
662 if test "$OCAMLOPT" = "no"; then
663   TARGET_TYPE=byte
664   OCAMLLIB_EXT=cma
665 else
666   TARGET_TYPE=opt
667   OCAMLLIB_EXT=cmxa
669   OCAMLOPTVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
671   test "$OCAMLOPTVERSION" = "$OCAMLVERSION" || {
672     echo "********  Version $REQUIRED_OCAML of ocamlopt is required  *********" 1>&2;
673     echo "*******  Check http://caml.inria.fr/  ********" 1>&2;
674     exit 1; }
678 echo "-------------------------------------------"
679 echo "     Checking Ocaml $OCAMLVERSION finished."
680 echo "-------------------------------------------"
683 if test "$PROFILE" = "yes"; then
684    OCAMLOPT="$OCAMLOPT -p"
685    CFLAGS="$CFLAGS -pg"
687 if test "$FORCE_MINGW" = "yes"; then
688     OCAMLC="$OCAMLC -ccopt -mno-cygwin"
689     OCAMLOPT="$OCAMLOPT -ccopt -mno-cygwin"
690     OCAMLMKTOP="$OCAMLMKTOP -ccopt -mno-cygwin"
692 if test "$DEBUG" = "yes"; then
693     OCAMLC="$OCAMLC -g"
696 echo -e "\n----------------------------------"
697 echo "     Checking system headers."
698 echo "----------------------------------"
700 ifelse(AC_ACVERSION, [2.13], [],
701 [dnl Large file enabled
702    AC_SYS_LARGEFILE
706 # various header files
707 AC_CHECK_FUNCS(setrlimit getrlimit strerror_r strerror)
708 AC_CHECK_HEADERS(byteswap.h,,)
709 AC_CHECK_HEADERS([sys/utsname.h])
710 AC_CHECK_HEADERS(arpa/inet.h,,)
711 AC_CHECK_HEADERS([sys/types.h sys/time.h sys/resource.h netinet/in_systm.h netinet/in.h netinet/ip.h],,,
712 [#ifdef HAVE_SYS_TYPES_H
713 #include <sys/types.h>
714 #endif
715 #ifdef HAVE_SYS_TIME_H
716 #include <sys/time.h>
717 #endif
718 #ifdef HAVE_NETINET_IN_SYSTM_H
719 #include <netinet/in_systm.h>
720 #endif
721 #ifdef HAVE_NETINET_IN_H
722 #include <netinet/in.h>
723 #endif
726 # poll if possible
727 AC_CHECK_HEADERS(sys/poll.h,,)
728 AC_CHECK_FUNCS(poll,,)
730 AC_CHECK_HEADERS(sys/vfs.h,,)
731 AC_CHECK_HEADERS(sys/statvfs.h,,)
732 AC_CHECK_HEADERS([sys/param.h sys/mount.h],,,
733 [#if HAVE_SYS_PARAM_H
734 #include <sys/param.h>
735 #endif
737 echo "-------------------------------------------"
738 echo "     Checking system headers finished."
739 echo -e "-------------------------------------------\n"
740 echo "-----------------------------------"
741 echo "     Checking system libraries."
742 echo "-----------------------------------"
743 echo "----- checking zlib (required)"
744 AC_CHECK_LIB(z,inflate,,[echo "Zlib missing, did you install zlib and zlib-developer packages?"; exit 1])
745 AC_CHECK_HEADERS(zlib.h,,[echo "Zlib missing, did you install zlib and zlib-developer packages?"; exit 1])
746 AC_CHECK_LIB(z,zlibVersion,[AC_DEFINE(HAVE_ZLIBVERSION, 1,)])
748 if test "$BZIP2" != "no"; then
749   echo "----- checking bzlib (optional)"
750   AC_CHECK_HEADERS(bzlib.h,[AC_CHECK_LIB(bz2,BZ2_bzReadOpen,[BZIP2=yes],[BZIP2=no])],[BZIP2=no])
753 if test "$BZIP2" = "yes"; then
754   AC_CHECK_LIB(bz2,BZ2_bzlibVersion,[AC_DEFINE(HAVE_BZLIBVERSION, 1,)])
755   AC_DEFINE(USE_BZIP2, 1, [Define to 1 if you have bzip2 support.])
756 else
757   AC_MSG_NOTICE(bzlib not available)
760 if test "$MAGIC" != "no"; then
761   echo "----- checking libmagic (GNU file) (optional)"
762   AC_CHECK_HEADERS(magic.h,
763     [AC_CHECK_LIB(magic,magic_file,
764       [AC_CHECK_DECL([MAGIC_ERROR], [MAGIC=yes], [MAGIC=no],[#include <magic.h>])],
765       [MAGIC=no])],
766     [MAGIC=no])
769 if test "$MAGIC" = "yes"; then
770   MAGICLIB=Magic_magic
771 else
772   MAGICLIB=Magic_nomagic
773   AC_MSG_NOTICE(libmagic not available)
776 GD_JPG=no
777 GD_PNG=no
778 if test "$GD" != "no"; then
779   echo "----- checking gd (optional)"
780   GD=no
781   LIBGD=no
782   SAVE_LIBS=$LIBS
783   SAVE_CFLAGS=$CFLAGS
784   SAVE_LDFLAGS=$LDFLAGS
785   AC_CHECK_PROG(GDLIBCONFIG, gdlib-config, gdlib-config)
786   if test "$ac_cv_prog_GDLIBCONFIG" = "gdlib-config"; then
787     GD_LIBS=`$GDLIBCONFIG --libs`
788     $GDLIBCONFIG --static-libs > /dev/null 2>&1
789     if test "$?" = "0"; then
790       GD_STATIC_LIBS=`$GDLIBCONFIG --static-libs`
791     fi
792     GD_LIBS2="$LIBS -lgd $GD_LIBS"
793     LIBS=$GD_LIBS2
794     GD_CFLAGS=`$GDLIBCONFIG --cflags`
795     CFLAGS="$CFLAGS $GD_CFLAGS"
796     GD_LDFLAGS=`$GDLIBCONFIG --ldflags`
797     LDFLAGS="$LDFLAGS $GD_LDFLAGS"
798     AC_MSG_CHECKING(for libgd > 2.0.14)
799     GDVERSION=`$GDLIBCONFIG --version`
800     GDMAJORVERSION=`$GDLIBCONFIG --majorversion`
801     GDMINORVERSION=`$GDLIBCONFIG --minorversion`
802     GDREVISION=`$GDLIBCONFIG --revision`
803     if [ [ $GDMAJORVERSION = 2 ] && [ $GDMINORVERSION = 0 ] && [ $GDREVISION -gt 14 ]]; then
804         AC_MSG_RESULT($GDVERSION)
805         LIBGD=yes
806     else
807         AC_MSG_RESULT(no (found $GDVERSION))
808         LIBGD=no
809     fi
810   else
811     LIBGD=yes
812   fi
814   if test "$LIBGD" = "yes"; then
815     AC_CHECK_HEADERS(gd.h,[LIBGD=yes],[LIBGD=no])
816   fi
818   if test "$LIBGD" = "yes"; then
819     AC_MSG_CHECKING(for gdImageCreate in -lgd)
820     AC_TRY_LINK([#include <gd.h>],
821     [gdImageCreate (0,0);],
822     [LIBGD=yes], [LIBGD=no])
823     AC_MSG_RESULT($LIBGD)
824     LIBS=$SAVE_LIBS
826     if test "$LIBGD" = "no"; then
827       AC_MSG_NOTICE([not found, trying another method])
828       AC_CHECK_LIB(gd, gdImageCreate, [LIBGD=yes], [LIBGD=no])
829     fi
830   fi
832   if test "$LIBGD" = "yes"; then
833     LIBPNG=no
834 # saving current variables
835     SAVE_LIBS_PNG=$LIBS
836     SAVE_CFLAGS_PNG=$CFLAGS
837     SAVE_LDFLAGS_PNG=$LDFLAGS
838     AC_CHECK_PROG(PNGLIBCONFIG, libpng-config, libpng-config)
839     if test "$ac_cv_prog_PNGLIBCONFIG" = "libpng-config"; then
840 # check libpng-config contents and update system variables
841       PNG_LIBS=`$PNGLIBCONFIG --libs`
842       LIBS="$LIBS $PNG_LIBS"
843       PNG_CFLAGS=`$PNGLIBCONFIG --cflags`
844       CFLAGS="$CFLAGS $PNG_CFLAGS"
845       PNG_LDFLAGS=`$PNGLIBCONFIG --ldflags`
846       LDFLAGS="$LDFLAGS $PNG_LDFLAGS"
847     fi
848     AC_CHECK_LIB(png, png_create_read_struct , [LIBPNG=yes])
849 # restore variables
850     LIBS=$SAVE_LIBS_PNG
851     CFLAGS=$SAVE_CFLAGS_PNG
852     LDFLAGS=$SAVE_LDFLAGS_PNG
854     if test "$LIBPNG" = "no"; then
855       AC_MSG_NOTICE(png support not available)
856     else
857       LIBGD_PNG=no
858       LIBS=$GD_LIBS2
859       AC_MSG_CHECKING(for gdImagePng in -lgd)
860       AC_TRY_LINK([#include <gd.h>],
861       [gdImagePng (0,0);],
862       [LIBGD_PNG=yes], [LIBGD_PNG=no])
863       AC_MSG_RESULT($LIBGD_PNG)
864       LIBS=$SAVE_LIBS
866       if test "$LIBGD_PNG" = "no"; then
867         AC_MSG_NOTICE([not found, trying another method])
868         AC_CHECK_LIB(gd, gdImagePng, [LIBGD_PNG=yes], [LIBGD_PNG=no])
869       fi
871       AC_MSG_CHECKING(for png support in libgd)
872       if test "$LIBGD_PNG" = "yes"; then
873         GD=yes
874         GD_PNG=yes
875         AC_MSG_RESULT(yes)
876         AC_CHECK_LIB(png, png_access_version_number,[AC_DEFINE(HAVE_PNGVERSION, 1,)])
877         AC_DEFINE(HAVE_GD_PNG, 1, [Define to 1 if you have png support in libgd.])
878       else
879         AC_MSG_RESULT(no)
880       fi
881     fi
883     LIBJPEG=no
884     AC_CHECK_LIB(jpeg, jpeg_CreateCompress, [LIBJPEG=yes])
886     if test "$LIBJPEG" = "no"; then
887       AC_MSG_NOTICE(jpeg support not available)
888     else
889       LIBGD_JPG=no
890       LIBS=$GD_LIBS2
891       AC_MSG_CHECKING(for gdImageJpeg in -lgd)
892       AC_TRY_LINK([#include <gd.h>],
893       [gdImageJpeg (0,0,0);],
894       [LIBGD_JPG=yes], [LIBGD_JPG=no])
895       AC_MSG_RESULT($LIBGD_JPG)
896       LIBS=$SAVE_LIBS
898       if test "$LIBGD_JPG" = "no"; then
899         AC_MSG_NOTICE([not found, trying another method])
900         AC_CHECK_LIB(gd, gdImageJpeg, [LIBGD_JPG=yes], [LIBGD_JPG=no])
901       fi
903       AC_MSG_CHECKING(for jpeg support in libgd)
904       if test "$LIBGD_JPG" = "yes"; then
905         GD=yes
906         GD_JPG=yes
907         AC_DEFINE(HAVE_GD_JPG, 1, [Define to 1 if you have jpg support in libgd.])
908         AC_MSG_RESULT(yes)
909       else
910         AC_MSG_RESULT(no)
911       fi
912     fi
913   else
914     AC_MSG_NOTICE(libgd not available)
915   fi
916   LIBS=$SAVE_LIBS
917   CFLAGS=$SAVE_CFLAGS
918   LDFLAGS=$SAVE_LDFLAGS
921 if test "$GD" != "no"; then
922   GDGRAPHICS=DriverGraphics_gd
923 else
924   GDGRAPHICS=DriverGraphics_nogd
927 if test "$ICONV" = "yes"; then
928   echo "----- checking iconv (optional)"
929   AM_ICONV
930   if test "$am_cv_func_iconv" != "yes"; then
931     AC_DEFINE(DISABLE_ICONV, 1, [Define to 1 if you want to replace iconv and related with stubs.])
932     ICONV=no
933   else
934   LIBS="$LIBS $LIBICONV"
935   AC_CHECK_FUNCS([locale_charset],,
936   AC_TRY_LINK([#include <langinfo.h>],
937   [char* cs = nl_langinfo(CODESET);],
938   AC_MSG_NOTICE(found nl_langinfo(CODESET)),
939   [echo "Your iconv implementation is incomplete"; exit 1]))
940   AC_CHECK_LIB(charset,locale_charset)
941   AC_CHECK_HEADERS([libcharset.h])
942   AC_CHECK_HEADERS([langinfo.h])
943   AC_CHECK_HEADERS([locale.h])
944   fi
945 else
946   AC_DEFINE(DISABLE_ICONV, 1, [Define to 1 if you want to replace iconv and related with stubs.])
947   ICONV=no
950 if test "$USE_PTHREAD" = "no"; then
951  PTHREAD_LIBS=""
952  echo "You disabled thread support, this will hurt MLDonkey performance!"
953 else
954   echo "----- checking thread support (optional, strongly advised)"
955   ACX_PTHREAD
958 # On linux plaforms, we will have to check that includes from kernel are
959 # available. glibc version test was shamelessly taken from
960 # http://public.activestate.com/gsar/APC/perl-5.8.x/Configure
961 GLIBC_VERSION=""
962 case $host in
963         *linux*)
964            echo "----- GNU C Library version"
965            AC_CHECK_HEADERS(linux/limits.h,, [
966              OLD_CPPFLAGS=$CPPFLAGS
967              CPPFLAGS="-I /usr/src/linux/include"
968              AC_CHECK_HEADER(linux/types.h,[CONFIG_INCLUDES="-I /usr/src/linux/include"])
969              CPPFLAGS=$OLD_CPPFLAGS]
970            )
971            AC_CHECK_HEADERS(gnu/libc-version.h,[AC_MSG_CHECKING(for GNU C Library version)
973 cat >try.c <<'EOCP'
974 /* Find out version of GNU C library.  __GLIBC__ and __GLIBC_MINOR__
975    alone are insufficient to distinguish different versions, such as
976    2.0.6 and 2.0.7.  The function gnu_get_libc_version() appeared in
977    libc version 2.1.0.      A. Dougherty,  June 3, 2002.
979 #include <stdio.h>
980 int main(void)
982 #ifdef __GLIBC__
983 #   ifdef __GLIBC_MINOR__
984 #       if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
985 #           include <gnu/libc-version.h>
986     printf("%s\n",  gnu_get_libc_version());
987 #       else
988     printf("%d.%d\n",  __GLIBC__, __GLIBC_MINOR__);
989 #       endif
990 #   else
991 printf("%d\n",  __GLIBC__);
992 #   endif
993     return 0;
994 #else
995     return 1;
996 #endif
998 EOCP
1000            $CC -o try ./try.c
1001            GLIBC_VERSION="`./try`"
1002            AC_MSG_RESULT($GLIBC_VERSION)
1003            rm -f try try.*],)
1004         ;;
1005         *)         ;;
1006 esac
1008 echo "---------------------------------------------"
1009 echo "     Checking system libraries finished."
1010 echo -e "---------------------------------------------\n"
1012 CXX_VERSION=
1013 CRYPTOPPFLAGS=
1014 echo "--------------------------------------"
1015 echo "     Checking activated networks."
1016 echo "--------------------------------------"
1018   if test "$DONKEY" = "yes"; then
1019     AC_MSG_CHECKING(eDonkey)
1020     if test -d ../src/networks/donkey; then
1021       AC_MSG_RESULT(yes)
1022       if test "$DONKEY_SUI" = "yes"; then
1023         AC_PROG_CXX
1025         AC_CHECK_TOOL(NEWCXX, [$CXX], [no])
1026         AC_MSG_CHECKING(eMule SUI)
1027         if test x"$NEWCXX" = x"no"
1028         then
1029           AC_MSG_RESULT(no)
1030           CXX=
1031           DONKEY_SUI=no
1032         else
1033           AC_MSG_RESULT(yes)
1034           ACX_CHECK_CXX_FLAGS(-fno-omit-frame-pointer,no_omit_frame_pointer, CRYPTOPPFLAGS="-fno-omit-frame-pointer")
1035           ACX_CHECK_CXX_FLAGS(-mno-omit-leaf-frame-pointer,no_omit_leaf_frame_pointer, CRYPTOPPFLAGS="$CRYPTOPPFLAGS -mno-omit-leaf-frame-pointer")
1036           CXX=$NEWCXX
1037           CXX_VERSION=`$CXX -dumpversion`
1038           DONKEY_SUI_FILE=DonkeySui1
1039           AC_DEFINE(HAVE_CRYPTOPP, 1,)
1040         fi
1041       fi
1042 #      AC_MSG_CHECKING(eDonkey server)
1043 #      if test -d ../src/networks/server; then
1044 #        AC_MSG_RESULT(no)
1045 #        DONKEY_SERVER=no
1046 #      else
1047 #        AC_MSG_RESULT(no)
1048 #        DONKEY_SERVER=no
1049 #      fi
1050     else
1051       DONKEY=no
1052       DONKEY_SUI=no
1053       AC_MSG_RESULT(no)
1054     fi
1055   else
1056     DONKEY_SUI=no
1057   fi
1059   if test "$BITTORRENT" = "yes"; then
1060     AC_MSG_CHECKING(BitTorrent)
1061     if test -d ../src/networks/bittorrent; then
1062       AC_MSG_RESULT(yes)
1063     else
1064       BITTORRENT=no
1065       AC_MSG_RESULT(no)
1066     fi
1067   fi
1069   if test "$FILETP" = "yes"; then
1070     AC_MSG_CHECKING(FileTP)
1071     if test -d ../src/networks/fileTP; then
1072       AC_MSG_RESULT(yes)
1073     else
1074       FILETP=no
1075       AC_MSG_RESULT(no)
1076     fi
1077   fi
1079   if test "$GNUTELLA" = "yes"; then
1080     AC_MSG_CHECKING(Gnutella)
1081     if test -d ../src/networks/gnutella; then
1082       AC_MSG_RESULT(yes)
1083     else
1084       GNUTELLA=no
1085       AC_MSG_RESULT(no)
1086     fi
1087   fi
1089   if test "$GNUTELLA2" = "yes"; then
1090     AC_MSG_CHECKING(G2)
1091     if test -d ../src/networks/gnutella2; then
1092       AC_MSG_RESULT(yes)
1093     else
1094       GNUTELLA2=no
1095       AC_MSG_RESULT(no)
1096     fi
1097   fi
1099   if test "$FASTTRACK" = "yes"; then
1100     AC_MSG_CHECKING(Fasttrack)
1101     if test -d ../src/networks/fasttrack; then
1102       AC_MSG_RESULT(yes)
1103     else
1104       FASTTRACK=no
1105       AC_MSG_RESULT(no)
1106     fi
1107   fi
1109   if test "$DIRECT_CONNECT" = "yes"; then
1110     AC_MSG_CHECKING(DirectConnect)
1111     if test "$BZIP2" = "yes"; then
1112       if test -d ../src/networks/direct_connect; then
1113         AC_MSG_RESULT(yes)
1114       else
1115         DIRECT_CONNECT=no
1116         AC_MSG_RESULT(no)
1117       fi
1118     else
1119       DIRECT_CONNECT=no
1120       AC_MSG_RESULT(no - bzip2 support missing)
1121     fi
1122   fi
1124   if test "$SOULSEEK" = "yes"; then
1125     AC_MSG_CHECKING(Soulseek)
1126     if test -d ../src/networks/soulseek; then
1127       AC_MSG_RESULT(yes)
1128     else
1129       SOULSEEK=no
1130       AC_MSG_RESULT(no)
1131     fi
1132   fi
1134   if test "$OPEN_NAPSTER" = "yes"; then
1135     AC_MSG_CHECKING(OpenNapster)
1136     if test -d ../src/networks/opennap; then
1137       AC_MSG_RESULT(yes)
1138     else
1139       OPEN_NAPSTER=no
1140       AC_MSG_RESULT(no)
1141     fi
1142   fi
1144   if test "$OPENFT" = "yes"; then
1145     AC_MSG_CHECKING(OpenFT)
1146     if test -d ../src/networks/openFT; then
1147       AC_MSG_RESULT(yes)
1148     else
1149       OPENFT=no
1150       AC_MSG_RESULT(no)
1151     fi
1152   fi
1153 echo "-----------------------------------------------"
1154 echo "     Checking activated networks finished."
1155 echo "-----------------------------------------------"
1157 OCAMLLIB=`$OCAMLC -where`
1159 if test -f $OCAMLLIB/lablgl.cma; then
1160   LABLGL_CMA=lablgl.cma
1163 if test -f $OCAMLLIB/lablgl.$OCAMLLIB_EXT; then
1164   LABLGL_CMXA=lablgl.$OCAMLLIB_EXT
1167 # Check for GTK only if we want to build the GUI
1168 if test ! "$GUI" = "no"; then
1169   echo "---------------------------------------------------------"
1170   echo "Checking the libraries required to build the GTK GUI."
1171   echo "---------------------------------------------------------"
1172   if test "$GUI" = "newgui2"; then
1173       REQUIRED_GTK=2.4.0
1174       PKG_GTK=gtk+-2.0
1175       AC_MSG_CHECKING(for GTK+ - version >= $REQUIRED_GTK)
1176       if pkg-config --atleast-version $REQUIRED_GTK $PKG_GTK; then
1177         AC_MSG_RESULT(yes)
1178         REQUIRED_RSVG=2.4.0
1179         PKG_RSVG=librsvg-2.0
1180         AC_MSG_CHECKING(for librsvg - version >= $REQUIRED_RSVG)
1181         if pkg-config --atleast-version $REQUIRED_RSVG $PKG_RSVG; then
1182           GTK_CONFIG="pkg-config $PKG_GTK $PKG_RSVG"
1183           REQUIRED_LABLGTK=2.10.1
1184           LABLGTK_NAME=lablgtk2
1185           AC_MSG_RESULT(yes)
1186         else
1187           GTK_CONFIG=no
1188           AC_MSG_RESULT(no)
1189         fi
1190       else
1191         GTK_CONFIG=no
1192         AC_MSG_RESULT(no)
1193       fi
1194   else
1195     if test "$OS_FILES2" = "mingw"; then
1196       REQUIRED_GTK=1.3.0
1197       PKG_GTK=gtk+-1.3-win32-production
1198       AC_MSG_CHECKING(for GTK+ - version >= $REQUIRED_GTK)
1199       if pkg-config --atleast-version $REQUIRED_GTK $PKG_GTK; then
1200         GTK_CONFIG="pkg-config $PKG_GTK"
1201         AC_MSG_RESULT(yes)
1202       else
1203         GTK_CONFIG=no
1204         AC_MSG_RESULT(no)
1205       fi
1206     else
1207       AC_CHECK_PROG(GTK_CONFIG, gtk-config, gtk-config, no)
1208       if test "$GTK_CONFIG" = "no"; then
1209         AC_MSG_RESULT(no)
1210       else
1211         AC_MSG_RESULT(yes)
1212       fi
1213     fi
1214   fi
1215 else
1216   GTK_CONFIG=no
1218 if test "$GTK_CONFIG" = "no"; then
1219      LABLGTK_CONFIG=no
1220 else
1221   AC_MSG_CHECKING(for native code $LABLGTK_NAME)
1222   if test -f `$OCAMLC -where`/$LABLGTK_NAME/lablgtk.$OCAMLLIB_EXT; then
1223      if test "$GUI" = "newgui2"; then
1224        if test -f `$OCAMLC -where`/$LABLGTK_NAME/lablrsvg.$OCAMLLIB_EXT; then
1225          AC_MSG_RESULT(yes)
1226          LABLGTK_CONFIG=yes
1227        else
1228          AC_MSG_RESULT(no)
1229          LABLGTK_CONFIG=no
1230          if test -f `$OCAMLC -where`/$LABLGTK_NAME/lablrsvg.cma; then
1231            echo "---------------------------------------------------------"
1232            echo "lablrsvg is not installed properly. See the INSTALL.txt"
1233            echo "file of mldonkey to see how to compile $LABLGTK_NAME. You"
1234            echo "probably forgot to call 'make opt' before 'make install'."
1235            echo "---------------------------------------------------------"
1236          else
1237            echo "---------------------------------------------------------"
1238            echo "lablrsvg is not installed. See the INSTALL.txt file of"
1239            echo "mldonkey to see how to compile $LABLGTK_NAME. Librsvg"
1240            echo "may not be installed when you compiled $LABLGTK_NAME."
1241            echo "---------------------------------------------------------"
1242          fi
1243        fi
1244      else
1245        AC_MSG_RESULT(yes)
1246        LABLGTK_CONFIG=yes
1247      fi
1248   else
1249      AC_MSG_RESULT(no)
1250      LABLGTK_CONFIG=no
1251      if test -f `$OCAMLC -where`/$LABLGTK_NAME/lablgtk.cma; then
1252        echo "-------------------------------------------------------------"
1253        echo "$LABLGTK_NAME is not installed properly. See the INSTALL.txt"
1254        echo "file of mldonkey to see how to compile $LABLGTK_NAME. You"
1255        echo "probably forgot to call 'make opt' before 'make install'."
1256        echo "-------------------------------------------------------------"
1257      else
1258        echo "Do you want this script to try to download and install $LABLGTK_NAME"
1259        echo "LOCALLY in mldonkey directory ?"
1260        if test "$BATCH" = "no"; then read i <&1; else i=yes; fi
1261        case "$i" in
1262         y* | Y*)
1264          cd $PATCH_DIR
1265          rm -rf lablgtk-"$REQUIRED_LABLGTK"
1266          if test ! -f lablgtk-"$REQUIRED_LABLGTK".tar.gz; then
1267            echo Downloading ...
1268            $WGET http://wwwfun.kurims.kyoto-u.ac.jp/soft/lsl/dist/lablgtk-"$REQUIRED_LABLGTK".tar.gz
1269          fi
1270          if test ! -f lablgtk-"$REQUIRED_LABLGTK".tar.gz; then exit 1; fi
1272          mkdir -p $BUILD_DIR
1273          cd $BUILD_DIR
1274          echo Uncompressing ...
1275          gzip -cd $PATCH_DIR/lablgtk-"$REQUIRED_LABLGTK".tar.gz | tar xf -
1276          (cd lablgtk-"$REQUIRED_LABLGTK"
1277           if test -f $PATCH_DIR/lablgtk-"$REQUIRED_LABLGTK".patch; then
1278             echo Patching ...
1279             patch -p0 < $PATCH_DIR/lablgtk-"$REQUIRED_LABLGTK".patch
1280           fi
1281           PATH=$OCAML_PATH:$PATH
1282           export PATH
1283           echo $PATH
1285           if test "$GUI" = "newgui2"; then
1286             ./configure --prefix=$LOCAL_DIR
1287             $GNU_MAKE world
1288             $GNU_MAKE install
1289           else
1290             $GNU_MAKE configure
1291             $GNU_MAKE
1292             $GNU_MAKE opt
1293             $GNU_MAKE install
1294           fi
1296           cd ..
1297           rm -rf lablgtk-"$REQUIRED_LABLGTK"
1298          )
1299          cd $CONFIG_DIR
1300          if test -f `$OCAMLC -where`/$LABLGTK_NAME/lablgtk.$OCAMLLIB_EXT; then
1301             LABLGTK_CONFIG=yes
1302          else
1303             echo "Installation of $LABLGTK_NAME failed"
1304             LABLGTK_CONFIG=no
1305          fi
1306          ;;
1307         *);;
1308       esac
1309      fi
1310   fi
1313 if test "$GUI" = "newgui2" ; then
1314   GUIS="mldonkey_gui\$(EXE)"
1315   GTKCFLAGS="`pkg-config --cflags-only-I gtk+-2.0`"
1316   GTKLLIBS="`pkg-config --libs-only-L gtk+-2.0`"
1317   GTKLFLAGS="`pkg-config --libs-only-l gtk+-2.0`"
1318 else
1319   GUIS="mldonkey_gui\$(EXE) mldonkey_gui2\$(EXE)"
1322 if test "$LABLGTK_CONFIG" = "no"; then
1323   GUI="no"
1324 else
1325   MORE_TARGETS="$MORE_TARGETS $GUIS"
1326   AC_MSG_CHECKING(GToolbox.popup_menu args)
1327   OCAML_LIB_DIR="`$OCAMLC -where`"
1328   GTOOLBOX="$OCAML_LIB_DIR/$LABLGTK_NAME/gToolbox.mli"
1329   grep popup $GTOOLBOX | grep -i button 2> /dev/null && GTOOLBOX_ARGS=new
1330   if test "$GTOOLBOX_ARGS" = "new"; then
1331     GTOOLBOX_POPUPMENU=' ~button: button ~time: time '
1332     AC_MSG_RESULT(new)
1333   else
1334     GTOOLBOX_POPUPMENU=' ~x: button ~y: time '
1335     AC_MSG_RESULT(old)
1336   fi
1337   echo "---------------------------------------------------------"
1338   echo "End of GTK GUI configuration."
1339   echo "---------------------------------------------------------"
1342 if test "$OS_FILES" = "mingw"; then
1343    OCAMLDEP_OPTIONS="-slash"
1346 AC_SUBST(LIBS)
1347 AC_SUBST(CFLAGS)
1348 AC_SUBST(CPPFLAGS)
1349 AC_SUBST(CXXFLAGS)
1350 AC_SUBST(LDFLAGS)
1351 AC_SUBST(CC)
1352 AC_SUBST(CPP)
1353 AC_SUBST(CXX)
1354 AC_SUBST(FIX_BROKEN_CPP)
1355 AC_SUBST(CONFIG_INCLUDES)
1356 AC_SUBST(OCAMLC)
1357 AC_SUBST(OCAMLLIB)
1358 AC_SUBST(OCAMLOPT)
1359 AC_SUBST(OCAMLLEX)
1360 AC_SUBST(OCAMLYACC)
1361 AC_SUBST(OCAMLDEP)
1362 AC_SUBST(OCAMLDEP_OPTIONS)
1363 AC_SUBST(CAMLP4)
1364 AC_SUBST(PERL)
1365 AC_SUBST(OCAMLDOC)
1366 AC_SUBST(OCAMLMKTOP)
1367 AC_SUBST(SYSTEM)
1368 AC_SUBST(MORE_TARGETS)
1369 AC_SUBST(MORE_SUBDIRS)
1370 AC_SUBST(LABLGL_CMA)
1371 AC_SUBST(LABLGL_CMXA)
1372 AC_SUBST(MD4ARCH)
1373 AC_SUBST(MD4COMP)
1374 AC_SUBST(ICONV)
1375 AC_SUBST(OPEN_NAPSTER)
1376 AC_SUBST(DIRECT_CONNECT)
1377 AC_SUBST(GNUTELLA)
1378 AC_SUBST(GNUTELLA2)
1379 AC_SUBST(BITTORRENT)
1380 AC_SUBST(FILETP)
1381 AC_SUBST(SOULSEEK)
1382 AC_SUBST(OPENFT)
1383 AC_SUBST(FASTTRACK)
1384 AC_SUBST(DONKEY)
1385 AC_SUBST(DONKEY_SUI)
1386 AC_SUBST(CRYPTOPPFLAGS)
1387 AC_SUBST(DONKEY_SUI_FILE)
1388 AC_SUBST(DONKEY_SERVER)
1389 AC_SUBST(GUI)
1390 AC_SUBST(REQUIRED_OCAML)
1391 AC_SUBST(REQUIRED_LABLGTK)
1392 AC_SUBST(ARCH)
1393 AC_SUBST(COMPRESS)
1394 AC_SUBST(COMPRESS_EXT)
1395 AC_SUBST(CHECKBOUNDS)
1396 AC_SUBST(MLDONKEY_VERSION)
1397 AC_SUBST(SCM_VERSION)
1398 AC_SUBST(MAJOR_VERSION)
1399 AC_SUBST(MINOR_VERSION)
1400 AC_SUBST(SUB_VERSION)
1401 AC_SUBST(GTOOLBOX_POPUPMENU)
1402 AC_SUBST(OS_FILES)
1403 AC_SUBST(OS_FILES2)
1404 AC_SUBST(TARGET_TYPE)
1405 AC_SUBST(RPMBUILD)
1406 AC_SUBST(GTKCFLAGS)
1407 AC_SUBST(GTKLLIBS)
1408 AC_SUBST(GTKLFLAGS)
1409 AC_SUBST(GD)
1410 AC_SUBST(GD_JPG)
1411 AC_SUBST(GD_PNG)
1412 AC_SUBST(GDGRAPHICS)
1413 AC_SUBST(GD_LIBS)
1414 AC_SUBST(GD_STATIC_LIBS)
1415 AC_SUBST(GD_CFLAGS)
1416 AC_SUBST(GD_LDFLAGS)
1417 AC_SUBST(BZIP2)
1418 AC_SUBST(MAGIC)
1419 AC_SUBST(MAGICLIB)
1420 BUILD_SYSTEM="`uname -s` `uname -m` `uname -r`"
1421 AC_SUBST(BUILD_SYSTEM)
1422 AC_SUBST(GLIBC_VERSION)
1423 AC_SUBST(CC_VERSION)
1424 AC_SUBST(CXX_VERSION)
1425 AC_SUBST(CONFIGURE_ARGUMENTS)
1426 AC_SUBST(CONFIGURE_RUN)
1428 AUTOCONF=../src/utils/lib/autoconf.ml
1429 GTK_AUTOCONF=../src/utils/lib/gAutoconf.ml
1430 AC_OUTPUT(\
1431   Makefile.config \
1432   mldonkey.rc \
1433   $AUTOCONF.new $GTK_AUTOCONF.new \
1434    ../src/utils/lib/magic.ml \
1435    ../src/networks/donkey/donkeySui.ml \
1436    ../src/daemon/driver/driverGraphics.ml \
1437    ../packages/rpm/mldonkey.spec \
1438    ../packages/rpm/Makefile \
1439    ../packages/slackware/mldonkey.options)
1440 diff $AUTOCONF.new $AUTOCONF 2> /dev/null > /dev/null || cp -f $AUTOCONF.new $AUTOCONF
1441 diff $GTK_AUTOCONF.new $GTK_AUTOCONF 2> /dev/null > /dev/null || cp -f $GTK_AUTOCONF.new $GTK_AUTOCONF
1443 cd ..
1445 echo -e "\nBuilding dependencies (if it blocks, try '$GNU_MAKE depend' to see the problem)"
1446 $GNU_MAKE depend 2> /dev/null > /dev/null || echo "Building dependencies fails: try: '$GNU_MAKE depend'"
1448 echo -e -n "\nConfiguring MLDonkey" $MLDONKEY_VERSION
1449 if test ! -z "$SCM_VERSION"; then
1450   echo -n " - SCM: $SCM_VERSION"
1452 echo " completed."
1454 echo -e "\nNetwork modules:"
1455 echo -n " - eDonkey           "
1456 if test "$DONKEY" = "yes"; then
1457   if test "$DONKEY_SUI" = "yes"; then
1458     echo "enabled (eMule SUI enabled)"
1459   else
1460     echo "enabled (eMule SUI disabled)"
1461   fi
1462 else
1463   echo "        disabled"
1466 echo -n " - BitTorrent        "
1467 if test "$BITTORRENT" = "yes"; then
1468   echo "enabled"
1469 else
1470   echo "        disabled"
1473 echo -n " - FileTP (aka wget) "
1474 if test "$FILETP" = "yes"; then
1475   echo "enabled"
1476 else
1477   echo "        disabled"
1480 echo -n " - Fasttrack         "
1481 if test "$FASTTRACK" = "yes"; then
1482   echo "enabled"
1483 else
1484   echo "        disabled"
1487 echo -n " - Gnutella          "
1488 if test "$GNUTELLA" = "yes"; then
1489   echo "enabled (warning: this network module is unmaintained)"
1490 else
1491   echo "        disabled - unmaintained"
1494 echo -n " - Gnutella2         "
1495 if test "$GNUTELLA2" = "yes"; then
1496   echo "enabled (warning: this network module is unmaintained)"
1497 else
1498   echo "        disabled - unmaintained"
1501 echo -n " - Direct Connect    "
1502 if test "$DIRECT_CONNECT" = "yes"; then
1503   echo "enabled"
1504 else
1505   echo "        disabled"
1508 echo -n " - Open Napster      "
1509 if test "$OPEN_NAPSTER" = "yes"; then
1510   echo "enabled          - currently not usable"
1511 else
1512   echo "        disabled - currently not usable"
1515 echo -n " - Soulseek          "
1516 if test "$SOULSEEK" = "yes"; then
1517   echo "enabled          - currently not usable"
1518 else
1519   echo "        disabled - currently not usable"
1522 echo -n " - OpenFT            "
1523 if test "$OPENFT" = "yes"; then
1524   echo "enabled          - currently not usable"
1525 else
1526   echo "        disabled - currently not usable"
1529 echo -e "\nCore features:"
1531 echo " - zlib (required)   enabled"
1533 echo -n " - threads           "
1534 if test "$USE_PTHREAD" = "yes"; then
1535   echo "enabled"
1536 else
1537   echo "        disabled"
1540 echo -n " - bzip2             "
1541 if test "$BZIP2" = "yes"; then
1542   echo "enabled"
1543 else
1544   echo "        disabled"
1547 echo -n " - iconv             "
1548 if test "$ICONV" = "yes"; then
1549   echo "enabled"
1550 else
1551   echo "        disabled"
1554 echo -n " - libmagic          "
1555 if test "$MAGIC" = "yes"; then
1556   echo "enabled"
1557 else
1558   echo "        disabled"
1561 echo -n " - graphical stats   "
1562 if test "$GD" = "yes"; then
1563   echo "enabled"
1564   echo -n "   - png support     "
1565   if test "$GD_PNG" = "yes"; then
1566     echo "enabled"
1567   else
1568     echo "        disabled"
1569   fi
1571   echo -n "   - jpg support     "
1572   if test "$GD_JPG" = "yes"; then
1573     echo "enabled"
1574   else
1575     echo "        disabled"
1576   fi
1577 else
1578   echo "        disabled"
1581 if test "$LABLGTK_CONFIG" = "yes"; then
1582   echo -n -e "\n - GUI support       "
1583   if test "$GUI" = "newgui1"; then
1584     echo "GTK1 newgui"
1585   else
1586     if test "$GUI" = "newgui2"; then
1587       echo "GTK2 GUI"
1588     else
1589       echo "GTK1 oldgui"
1590     fi
1591   fi
1594 if test "$OLDGUI_NO_310" = "yes"; then
1595   echo " - GUI support       GTK1 oldgui does not work with Ocaml 3.10/3.11, disabled"
1598 if test "$TARGET_TYPE" = "byte"; then
1599   OCAML_TYPE="- byte code"
1600   COMPILE_TARGET=".byte"
1602 echo -e "\nCompilers:"
1603 echo -e " - Ocaml version     $OCAMLVERSION $OCAML_TYPE"
1604 echo -e " - $CC version       $CC_VERSION"
1605 if test "x$CXX" != "x"; then
1606   echo -e " - $CXX version       $CXX_VERSION"
1608 echo -e "\nNow execute '$GNU_MAKE' to start compiling. Good luck!"
1610 echo -e "\nTo compile a static code execute:     $GNU_MAKE mlnet$COMPILE_TARGET.static"
1611 echo      "To produce a release tarball execute: $GNU_MAKE release.mlnet.static"
1612 echo      "To clean the build directory execute: $GNU_MAKE maintainerclean"
1613 if test "$DONKEY_SUI" = "yes"; then
1614   echo -e "\nCompiling CryptoPP.cc can take several minutes, on slow machines up to half an hour."