release-2-9-0
[mldonkey.git] / config / configure.in
blob0dd115c169782c85abed1ff4517cc7f05c5584fd
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=0   # 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.0
283 DOWNLOAD_OCAML_MAJOR=3.10
284 DOWNLOAD_OCAML=3.10.0
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.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.08/ocaml-"$REQUIRED_OCAML".tar.gz
539         fi
540         if test ! -f ocaml-"$REQUIRED_OCAML".tar.gz; then
541           echo "********        download Ocaml $REQUIRED_OCAML not successful, try do download it manually       *********" 1>&2;
542           echo "********        from http://caml.inria.fr/pub/distrib/                                   *********" 1>&2;
543           echo "********        and copy the tar.gz into $PATCH_DIR              *********" 1>&2;
544           exit 1
545         fi
547         echo Uncompressing ...
548         mkdir -p $BUILD_DIR
549         cd $BUILD_DIR
550         rm -rf ocaml-"$REQUIRED_OCAML"
551         gzip -cd $PATCH_DIR/ocaml-"$REQUIRED_OCAML".tar.gz | tar vxf -
552         cd ocaml-"$REQUIRED_OCAML"
553         if test -f $PATCH_DIR/ocaml-"$REQUIRED_OCAML".patch; then
554           echo Patching ...
555           patch -p1 < $PATCH_DIR/ocaml-"$REQUIRED_OCAML".patch
556         fi
557       fi
558       echo Configuring ...
559       ./configure -prefix $LOCAL_DIR -host $host -cc $CC
560       cd config
561       cp -f Makefile Makefile.old
562       sed "s/OTHERLIBRARIES=.*/OTHERLIBRARIES=unix dynlink num str bigarray threads/" Makefile.old > Makefile
563       cd ..
564       cp -f $PATCH_DIR/Makefile.ocamldoc ocamldoc/Makefile
565       echo Compiling ...
566       $GNU_MAKE world opt opt.opt
567       echo Installing ...
568       $GNU_MAKE install
569       if ! test -f $LOCAL_DIR/lib/ocaml/threads; then
570         if ! test -f $LOCAL_DIR/lib/ocaml/vmthreads; then
571           ln -s vmthreads  $LOCAL_DIR/lib/ocaml/threads
572         fi
573       fi
574       cd $BUILD_DIR
575       if [ test "$REQUIRED_OCAML" = "CVS" ]; then
576         rm -rf ocaml
577       else
578         rm -rf ocaml-"$REQUIRED_OCAML"
579       fi
580       cd $CONFIG_DIR
581       echo Ocaml locally installed for mldonkey
583       if test -f "$LOCAL_OCAML"/ocamlc.opt; then
584          OCAMLC=$LOCAL_OCAML/ocamlc.opt
585          ac_cv_prog_OCAMLC=$LOCAL_OCAML/ocamlc.opt
586       else
587       if test -f "$LOCAL_OCAML"/ocamlc; then
588          OCAMLC=$LOCAL_OCAML/ocamlc
589          ac_cv_prog_OCAMLC=$LOCAL_OCAML/ocamlc
590       else
591         echo "Ocaml installation failed"; exit 1
592       fi
593       fi
594       ;;
595    *)  exit 1;;
596   esac
597   fi
600 if test "$OCAMLC" = "$LOCAL_OCAML"/ocamlc.opt ; then
601   OCAML_PATH="$LOCAL_OCAML"/
602   OCAMLOPT=$LOCAL_OCAML/ocamlopt.opt
603   OCAMLDOC=$LOCAL_OCAML/ocamldoc
604   OCAMLMKTOP=$LOCAL_OCAML/ocamlmktop
605   OCAMLDEP=$LOCAL_OCAML/ocamldep
606   OCAMLLEX=$LOCAL_OCAML/ocamllex.opt
607   OCAMLYACC=$LOCAL_OCAML/ocamlyacc
608   CAMLP4=$LOCAL_OCAML/camlp4
609 else
610   if test "$OCAMLC" = "$LOCAL_OCAML"/ocamlc ; then
611   OCAML_PATH="$LOCAL_OCAML"/
612   if test -f "$LOCAL_OCAML/ocamlopt"; then
613     OCAMLOPT=$LOCAL_OCAML/ocamlopt
614   else
615     OCAMLOPT=no
616   fi
617   OCAMLDOC=$LOCAL_OCAML/ocamldoc
618   OCAMLMKTOP=$LOCAL_OCAML/ocamlmktop
619   OCAMLDEP=$LOCAL_OCAML/ocamldep
620   OCAMLLEX=$LOCAL_OCAML/ocamllex
621   OCAMLYACC=$LOCAL_OCAML/ocamlyacc
622   CAMLP4=$LOCAL_OCAML/camlp4
623   else
624   AC_CHECK_PROG(OCAMLOPT, ocamlopt.opt, ocamlopt.opt)
625   AC_CHECK_PROG(OCAMLOPT, ocamlopt, ocamlopt, no)
626   AC_CHECK_PROG(OCAMLDEP, ocamldep, ocamldep)
627   AC_CHECK_PROG(OCAMLLEX, ocamllex.opt, ocamllex.opt)
628   AC_CHECK_PROG(OCAMLLEX, ocamllex, ocamllex)
629   AC_CHECK_PROG(OCAMLYACC, ocamlyacc, ocamlyacc)
630   AC_CHECK_PROG(OCAMLDOC, ocamldoc, ocamldoc)
631   AC_CHECK_PROG(OCAMLMKTOP, ocamlmktop, ocamlmktop)
632   AC_CHECK_PROG(CAMLP4, camlp4, camlp4)
636 OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
637 OCAMLLIB=`$OCAMLC -where`
638 REBUILD_OCAML=no
639 case "$OCAMLVERSION" in
640     3.10*|3.11*)
641       if test "$GUI" = "oldgui"; then
642         OLDGUI_NO_310=yes
643         GUI=no
644       fi
645       ;;
646     "$REQUIRED_OCAML"*|3.09.*|3.08.4*|3.08.3*) ;;
647     *)
648       if [ test "$REQUIRED_OCAML" != "CVS" ]; then
649         REBUILD_OCAML=yes
650       fi
651       ;;
652 esac
653 if test "$REBUILD_OCAML" = "yes"; then
654   echo "********  Version $REQUIRED_OCAML of Objective-Caml is required  *********" 1>&2;
655   echo "*******  Check http://caml.inria.fr/  ********" 1>&2;
656   exit 1;
659 if test "$OCAMLOPT" = "no"; then
660   TARGET_TYPE=byte
661   OCAMLLIB_EXT=cma
662 else
663   TARGET_TYPE=opt
664   OCAMLLIB_EXT=cmxa
666   OCAMLOPTVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
668   test "$OCAMLOPTVERSION" = "$OCAMLVERSION" || {
669     echo "********  Version $REQUIRED_OCAML of ocamlopt is required  *********" 1>&2;
670     echo "*******  Check http://caml.inria.fr/  ********" 1>&2;
671     exit 1; }
675 echo "-------------------------------------------"
676 echo "     Checking Ocaml $OCAMLVERSION finished."
677 echo "-------------------------------------------"
680 if test "$PROFILE" = "yes"; then
681    OCAMLOPT="$OCAMLOPT -p"
682    CFLAGS="$CFLAGS -pg"
684 if test "$FORCE_MINGW" = "yes"; then
685     OCAMLC="$OCAMLC -ccopt -mno-cygwin"
686     OCAMLOPT="$OCAMLOPT -ccopt -mno-cygwin"
687     OCAMLMKTOP="$OCAMLMKTOP -ccopt -mno-cygwin"
689 if test "$DEBUG" = "yes"; then
690     OCAMLC="$OCAMLC -g"
693 echo -e "\n----------------------------------"
694 echo "     Checking system headers."
695 echo "----------------------------------"
697 ifelse(AC_ACVERSION, [2.13], [],
698 [dnl Large file enabled
699    AC_SYS_LARGEFILE
703 # Sizes of various common basic types
704 AC_CHECK_SIZEOF(int)
705 AC_CHECK_SIZEOF(long)
706 AC_CHECK_SIZEOF(void *)
707 AC_CHECK_SIZEOF(char)
708 AC_CHECK_SIZEOF(short)
709 AC_CHECK_SIZEOF(float)
710 AC_CHECK_SIZEOF(double)
711 AC_CHECK_FUNCS(setrlimit getrlimit strerror_r strerror)
712 AC_CHECK_HEADERS(byteswap.h,,)
714 # various header files
715 AC_CHECK_HEADERS([sys/utsname.h])
716 AC_CHECK_HEADERS(arpa/inet.h,,)
717 AC_CHECK_HEADERS([sys/types.h sys/time.h sys/resource.h netinet/in_systm.h netinet/in.h netinet/ip.h],,,
718 [#ifdef HAVE_SYS_TYPES_H
719 #include <sys/types.h>
720 #endif
721 #ifdef HAVE_SYS_TIME_H
722 #include <sys/time.h>
723 #endif
724 #ifdef HAVE_NETINET_IN_SYSTM_H
725 #include <netinet/in_systm.h>
726 #endif
727 #ifdef HAVE_NETINET_IN_H
728 #include <netinet/in.h>
729 #endif
732 # poll if possible
733 AC_CHECK_HEADERS(sys/poll.h,,)
734 AC_CHECK_FUNCS(poll,,)
736 AC_CHECK_HEADERS(sys/vfs.h,,)
737 AC_CHECK_HEADERS([sys/param.h sys/mount.h],,,
738 [#if HAVE_SYS_PARAM_H
739 #include <sys/param.h>
740 #endif
742 echo "-------------------------------------------"
743 echo "     Checking system headers finished."
744 echo -e "-------------------------------------------\n"
745 echo "-----------------------------------"
746 echo "     Checking system libraries."
747 echo "-----------------------------------"
748 echo "----- checking zlib (required)"
749 AC_CHECK_LIB(z,inflate,,[echo "Zlib missing, did you install zlib and zlib-developer packages?"; exit 1])
750 AC_CHECK_HEADERS(zlib.h,,[echo "Zlib missing, did you install zlib and zlib-developer packages?"; exit 1])
751 AC_CHECK_LIB(z,zlibVersion,[AC_DEFINE(HAVE_ZLIBVERSION, 1,)])
753 if test "$BZIP2" != "no"; then
754   echo "----- checking bzlib (optional)"
755   AC_CHECK_HEADERS(bzlib.h,[AC_CHECK_LIB(bz2,BZ2_bzReadOpen,[BZIP2=yes],[BZIP2=no])],[BZIP2=no])
758 if test "$BZIP2" = "yes"; then
759   AC_CHECK_LIB(bz2,BZ2_bzlibVersion,[AC_DEFINE(HAVE_BZLIBVERSION, 1,)])
760   AC_DEFINE(USE_BZIP2, 1, [Define to 1 if you have bzip2 support.])
761 else
762   AC_MSG_NOTICE(bzlib not available)
765 if test "$MAGIC" != "no"; then
766   echo "----- checking libmagic (GNU file) (optional)"
767   AC_CHECK_HEADERS(magic.h,
768     [AC_CHECK_LIB(magic,magic_file,
769       [AC_CHECK_DECL([MAGIC_ERROR], [MAGIC=yes], [MAGIC=no],[#include <magic.h>])],
770       [MAGIC=no])],
771     [MAGIC=no])
774 if test "$MAGIC" = "yes"; then
775   MAGICLIB=Magic_magic
776 else
777   MAGICLIB=Magic_nomagic
778   AC_MSG_NOTICE(libmagic not available)
781 GD_JPG=no
782 GD_PNG=no
783 if test "$GD" != "no"; then
784   echo "----- checking gd (optional)"
785   GD=no
786   LIBGD=no
787   SAVE_LIBS=$LIBS
788   SAVE_CFLAGS=$CFLAGS
789   SAVE_LDFLAGS=$LDFLAGS
790   AC_CHECK_PROG(GDLIBCONFIG, gdlib-config, gdlib-config)
791   if test "$ac_cv_prog_GDLIBCONFIG" = "gdlib-config"; then
792     GD_LIBS=`$GDLIBCONFIG --libs`
793     $GDLIBCONFIG --static-libs > /dev/null 2>&1
794     if test "$?" = "0"; then
795       GD_STATIC_LIBS=`$GDLIBCONFIG --static-libs`
796     fi
797     GD_LIBS2="$LIBS -lgd $GD_LIBS"
798     LIBS=$GD_LIBS2
799     GD_CFLAGS=`$GDLIBCONFIG --cflags`
800     CFLAGS="$CFLAGS $GD_CFLAGS"
801     GD_LDFLAGS=`$GDLIBCONFIG --ldflags`
802     LDFLAGS="$LDFLAGS $GD_LDFLAGS"
803     AC_MSG_CHECKING(for libgd > 2.0.14)
804     GDVERSION=`$GDLIBCONFIG --version`
805     GDMAJORVERSION=`$GDLIBCONFIG --majorversion`
806     GDMINORVERSION=`$GDLIBCONFIG --minorversion`
807     GDREVISION=`$GDLIBCONFIG --revision`
808     if [ [ $GDMAJORVERSION = 2 ] && [ $GDMINORVERSION = 0 ] && [ $GDREVISION -gt 14 ]]; then
809         AC_MSG_RESULT($GDVERSION)
810         LIBGD=yes
811     else
812         AC_MSG_RESULT(no (found $GDVERSION))
813         LIBGD=no
814     fi
815   else
816     LIBGD=yes
817   fi
819   if test "$LIBGD" = "yes"; then
820     AC_CHECK_HEADERS(gd.h,[LIBGD=yes],[LIBGD=no])
821   fi
823   if test "$LIBGD" = "yes"; then
824     AC_MSG_CHECKING(for gdImageCreate in -lgd)
825     AC_TRY_LINK([#include <gd.h>],
826     [gdImageCreate (0,0);],
827     [LIBGD=yes], [LIBGD=no])
828     AC_MSG_RESULT($LIBGD)
829     LIBS=$SAVE_LIBS
831     if test "$LIBGD" = "no"; then
832       AC_MSG_NOTICE([not found, trying another method])
833       AC_CHECK_LIB(gd, gdImageCreate, [LIBGD=yes], [LIBGD=no])
834     fi
835   fi
837   if test "$LIBGD" = "yes"; then
838     LIBPNG=no
839 # saving current variables
840     SAVE_LIBS_PNG=$LIBS
841     SAVE_CFLAGS_PNG=$CFLAGS
842     SAVE_LDFLAGS_PNG=$LDFLAGS
843     AC_CHECK_PROG(PNGLIBCONFIG, libpng-config, libpng-config)
844     if test "$ac_cv_prog_PNGLIBCONFIG" = "libpng-config"; then
845 # check libpng-config contents and update system variables
846       PNG_LIBS=`$PNGLIBCONFIG --libs`
847       LIBS="$LIBS $PNG_LIBS"
848       PNG_CFLAGS=`$PNGLIBCONFIG --cflags`
849       CFLAGS="$CFLAGS $PNG_CFLAGS"
850       PNG_LDFLAGS=`$PNGLIBCONFIG --ldflags`
851       LDFLAGS="$LDFLAGS $PNG_LDFLAGS"
852     fi
853     AC_CHECK_LIB(png, png_create_read_struct , [LIBPNG=yes])
854 # restore variables
855     LIBS=$SAVE_LIBS_PNG
856     CFLAGS=$SAVE_CFLAGS_PNG
857     LDFLAGS=$SAVE_LDFLAGS_PNG
859     if test "$LIBPNG" = "no"; then
860       AC_MSG_NOTICE(png support not available)
861     else
862       LIBGD_PNG=no
863       LIBS=$GD_LIBS2
864       AC_MSG_CHECKING(for gdImagePng in -lgd)
865       AC_TRY_LINK([#include <gd.h>],
866       [gdImagePng (0,0);],
867       [LIBGD_PNG=yes], [LIBGD_PNG=no])
868       AC_MSG_RESULT($LIBGD_PNG)
869       LIBS=$SAVE_LIBS
871       if test "$LIBGD_PNG" = "no"; then
872         AC_MSG_NOTICE([not found, trying another method])
873         AC_CHECK_LIB(gd, gdImagePng, [LIBGD_PNG=yes], [LIBGD_PNG=no])
874       fi
876       AC_MSG_CHECKING(for png support in libgd)
877       if test "$LIBGD_PNG" = "yes"; then
878         GD=yes
879         GD_PNG=yes
880         AC_MSG_RESULT(yes)
881         AC_CHECK_LIB(png, png_access_version_number,[AC_DEFINE(HAVE_PNGVERSION, 1,)])
882         AC_DEFINE(HAVE_GD_PNG, 1, [Define to 1 if you have png support in libgd.])
883       else
884         AC_MSG_RESULT(no)
885       fi
886     fi
888     LIBJPEG=no
889     AC_CHECK_LIB(jpeg, jpeg_CreateCompress, [LIBJPEG=yes])
891     if test "$LIBJPEG" = "no"; then
892       AC_MSG_NOTICE(jpeg support not available)
893     else
894       LIBGD_JPG=no
895       LIBS=$GD_LIBS2
896       AC_MSG_CHECKING(for gdImageJpeg in -lgd)
897       AC_TRY_LINK([#include <gd.h>],
898       [gdImageJpeg (0,0,0);],
899       [LIBGD_JPG=yes], [LIBGD_JPG=no])
900       AC_MSG_RESULT($LIBGD_JPG)
901       LIBS=$SAVE_LIBS
903       if test "$LIBGD_JPG" = "no"; then
904         AC_MSG_NOTICE([not found, trying another method])
905         AC_CHECK_LIB(gd, gdImageJpeg, [LIBGD_JPG=yes], [LIBGD_JPG=no])
906       fi
908       AC_MSG_CHECKING(for jpeg support in libgd)
909       if test "$LIBGD_JPG" = "yes"; then
910         GD=yes
911         GD_JPG=yes
912         AC_DEFINE(HAVE_GD_JPG, 1, [Define to 1 if you have jpg support in libgd.])
913         AC_MSG_RESULT(yes)
914       else
915         AC_MSG_RESULT(no)
916       fi
917     fi
918   else
919     AC_MSG_NOTICE(libgd not available)
920   fi
921   LIBS=$SAVE_LIBS
922   CFLAGS=$SAVE_CFLAGS
923   LDFLAGS=$SAVE_LDFLAGS
926 if test "$GD" != "no"; then
927   GDGRAPHICS=DriverGraphics_gd
928 else
929   GDGRAPHICS=DriverGraphics_nogd
932 if test "$ICONV" = "yes"; then
933   echo "----- checking iconv (optional)"
934   AM_ICONV
935   if test "$am_cv_func_iconv" != "yes"; then
936     AC_DEFINE(DISABLE_ICONV, 1, [Define to 1 if you want to replace iconv and related with stubs.])
937     ICONV=no
938   else
939   LIBS="$LIBS $LIBICONV"
940   AC_CHECK_FUNCS([locale_charset],,
941   AC_TRY_LINK([#include <langinfo.h>],
942   [char* cs = nl_langinfo(CODESET);],
943   AC_MSG_NOTICE(found nl_langinfo(CODESET)),
944   [echo "Your iconv implementation is incomplete"; exit 1]))
945   AC_CHECK_LIB(charset,locale_charset)
946   AC_CHECK_HEADERS([libcharset.h])
947   AC_CHECK_HEADERS([langinfo.h])
948   AC_CHECK_HEADERS([locale.h])
949   fi
950 else
951   AC_DEFINE(DISABLE_ICONV, 1, [Define to 1 if you want to replace iconv and related with stubs.])
952   ICONV=no
955 if test "$USE_PTHREAD" = "no"; then
956  PTHREAD_LIBS=""
957  echo "You disabled thread support, this will hurt MLDonkey performance!"
958 else
959   echo "----- checking thread support (optional, strongly advised)"
960   ACX_PTHREAD
963 # On linux plaforms, we will have to check that includes from kernel are
964 # available. glibc version test was shamelessly taken from
965 # http://public.activestate.com/gsar/APC/perl-5.8.x/Configure
966 GLIBC_VERSION=""
967 case $host in
968         *linux*)
969            echo "----- GNU C Library version"
970            AC_CHECK_HEADERS(linux/limits.h,, [
971              OLD_CPPFLAGS=$CPPFLAGS
972              CPPFLAGS="-I /usr/src/linux/include"
973              AC_CHECK_HEADER(linux/types.h,[CONFIG_INCLUDES="-I /usr/src/linux/include"])
974              CPPFLAGS=$OLD_CPPFLAGS]
975            )
976            AC_CHECK_HEADERS(gnu/libc-version.h,[AC_MSG_CHECKING(for GNU C Library version)
978 cat >try.c <<'EOCP'
979 /* Find out version of GNU C library.  __GLIBC__ and __GLIBC_MINOR__
980    alone are insufficient to distinguish different versions, such as
981    2.0.6 and 2.0.7.  The function gnu_get_libc_version() appeared in
982    libc version 2.1.0.      A. Dougherty,  June 3, 2002.
984 #include <stdio.h>
985 int main(void)
987 #ifdef __GLIBC__
988 #   ifdef __GLIBC_MINOR__
989 #       if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
990 #           include <gnu/libc-version.h>
991     printf("%s\n",  gnu_get_libc_version());
992 #       else
993     printf("%d.%d\n",  __GLIBC__, __GLIBC_MINOR__);
994 #       endif
995 #   else
996 printf("%d\n",  __GLIBC__);
997 #   endif
998     return 0;
999 #else
1000     return 1;
1001 #endif
1003 EOCP
1005            $CC -o try ./try.c
1006            GLIBC_VERSION="`./try`"
1007            AC_MSG_RESULT($GLIBC_VERSION)
1008            rm -f try try.*],)
1009         ;;
1010         *)         ;;
1011 esac
1013 echo "---------------------------------------------"
1014 echo "     Checking system libraries finished."
1015 echo -e "---------------------------------------------\n"
1017 CXX_VERSION=
1018 CRYPTOPPFLAGS=
1019 echo "--------------------------------------"
1020 echo "     Checking activated networks."
1021 echo "--------------------------------------"
1023   if test "$DONKEY" = "yes"; then
1024     AC_MSG_CHECKING(eDonkey)
1025     if test -d ../src/networks/donkey; then
1026       AC_MSG_RESULT(yes)
1027       if test "$DONKEY_SUI" = "yes"; then
1028         AC_PROG_CXX
1030         AC_CHECK_TOOL(NEWCXX, [$CXX], [no])
1031         AC_MSG_CHECKING(eMule SUI)
1032         if test x"$NEWCXX" = x"no"
1033         then
1034           AC_MSG_RESULT(no)
1035           CXX=
1036           DONKEY_SUI=no
1037         else
1038           AC_MSG_RESULT(yes)
1039           ACX_CHECK_CXX_FLAGS(-fno-omit-frame-pointer,no_omit_frame_pointer, CRYPTOPPFLAGS="-fno-omit-frame-pointer")
1040           ACX_CHECK_CXX_FLAGS(-mno-omit-leaf-frame-pointer,no_omit_leaf_frame_pointer, CRYPTOPPFLAGS="$CRYPTOPPFLAGS -mno-omit-leaf-frame-pointer")
1041           CXX=$NEWCXX
1042           CXX_VERSION=`$CXX -dumpversion`
1043           DONKEY_SUI_FILE=DonkeySui1
1044           AC_DEFINE(HAVE_CRYPTOPP, 1,)
1045         fi
1046       fi
1047 #      AC_MSG_CHECKING(eDonkey server)
1048 #      if test -d ../src/networks/server; then
1049 #        AC_MSG_RESULT(no)
1050 #        DONKEY_SERVER=no
1051 #      else
1052 #        AC_MSG_RESULT(no)
1053 #        DONKEY_SERVER=no
1054 #      fi
1055     else
1056       DONKEY=no
1057       DONKEY_SUI=no
1058       AC_MSG_RESULT(no)
1059     fi
1060   else
1061     DONKEY_SUI=no
1062   fi
1064   if test "$BITTORRENT" = "yes"; then
1065     AC_MSG_CHECKING(BitTorrent)
1066     if test -d ../src/networks/bittorrent; then
1067       AC_MSG_RESULT(yes)
1068     else
1069       BITTORRENT=no
1070       AC_MSG_RESULT(no)
1071     fi
1072   fi
1074   if test "$FILETP" = "yes"; then
1075     AC_MSG_CHECKING(FileTP)
1076     if test -d ../src/networks/fileTP; then
1077       AC_MSG_RESULT(yes)
1078     else
1079       FILETP=no
1080       AC_MSG_RESULT(no)
1081     fi
1082   fi
1084   if test "$GNUTELLA" = "yes"; then
1085     AC_MSG_CHECKING(Gnutella)
1086     if test -d ../src/networks/gnutella; then
1087       AC_MSG_RESULT(yes)
1088     else
1089       GNUTELLA=no
1090       AC_MSG_RESULT(no)
1091     fi
1092   fi
1094   if test "$GNUTELLA2" = "yes"; then
1095     AC_MSG_CHECKING(G2)
1096     if test -d ../src/networks/gnutella2; then
1097       AC_MSG_RESULT(yes)
1098     else
1099       GNUTELLA2=no
1100       AC_MSG_RESULT(no)
1101     fi
1102   fi
1104   if test "$FASTTRACK" = "yes"; then
1105     AC_MSG_CHECKING(Fasttrack)
1106     if test -d ../src/networks/fasttrack; then
1107       AC_MSG_RESULT(yes)
1108     else
1109       FASTTRACK=no
1110       AC_MSG_RESULT(no)
1111     fi
1112   fi
1114   if test "$DIRECT_CONNECT" = "yes"; then
1115     AC_MSG_CHECKING(DirectConnect)
1116     if test "$BZIP2" = "yes"; then
1117       if test -d ../src/networks/direct_connect; then
1118         AC_MSG_RESULT(yes)
1119       else
1120         DIRECT_CONNECT=no
1121         AC_MSG_RESULT(no)
1122       fi
1123     else
1124       DIRECT_CONNECT=no
1125       AC_MSG_RESULT(no - bzip2 support missing)
1126     fi
1127   fi
1129   if test "$SOULSEEK" = "yes"; then
1130     AC_MSG_CHECKING(Soulseek)
1131     if test -d ../src/networks/soulseek; then
1132       AC_MSG_RESULT(yes)
1133     else
1134       SOULSEEK=no
1135       AC_MSG_RESULT(no)
1136     fi
1137   fi
1139   if test "$OPEN_NAPSTER" = "yes"; then
1140     AC_MSG_CHECKING(OpenNapster)
1141     if test -d ../src/networks/opennap; then
1142       AC_MSG_RESULT(yes)
1143     else
1144       OPEN_NAPSTER=no
1145       AC_MSG_RESULT(no)
1146     fi
1147   fi
1149   if test "$OPENFT" = "yes"; then
1150     AC_MSG_CHECKING(OpenFT)
1151     if test -d ../src/networks/openFT; then
1152       AC_MSG_RESULT(yes)
1153     else
1154       OPENFT=no
1155       AC_MSG_RESULT(no)
1156     fi
1157   fi
1158 echo "-----------------------------------------------"
1159 echo "     Checking activated networks finished."
1160 echo "-----------------------------------------------"
1162 OCAMLLIB=`$OCAMLC -where`
1164 if test -f $OCAMLLIB/lablgl.cma; then
1165   LABLGL_CMA=lablgl.cma
1168 if test -f $OCAMLLIB/lablgl.$OCAMLLIB_EXT; then
1169   LABLGL_CMXA=lablgl.$OCAMLLIB_EXT
1172 # Check for GTK only if we want to build the GUI
1173 if test ! "$GUI" = "no"; then
1174   echo "---------------------------------------------------------"
1175   echo "Checking the libraries required to build the GTK GUI."
1176   echo "---------------------------------------------------------"
1177   if test "$GUI" = "newgui2"; then
1178       REQUIRED_GTK=2.4.0
1179       PKG_GTK=gtk+-2.0
1180       AC_MSG_CHECKING(for GTK+ - version >= $REQUIRED_GTK)
1181       if pkg-config --atleast-version $REQUIRED_GTK $PKG_GTK; then
1182         AC_MSG_RESULT(yes)
1183         REQUIRED_RSVG=2.4.0
1184         PKG_RSVG=librsvg-2.0
1185         AC_MSG_CHECKING(for librsvg - version >= $REQUIRED_RSVG)
1186         if pkg-config --atleast-version $REQUIRED_RSVG $PKG_RSVG; then
1187           GTK_CONFIG="pkg-config $PKG_GTK $PKG_RSVG"
1188           REQUIRED_LABLGTK=2.6.0
1189           LABLGTK_NAME=lablgtk2
1190           AC_MSG_RESULT(yes)
1191         else
1192           GTK_CONFIG=no
1193           AC_MSG_RESULT(no)
1194         fi
1195       else
1196         GTK_CONFIG=no
1197         AC_MSG_RESULT(no)
1198       fi
1199   else
1200     if test "$OS_FILES2" = "mingw"; then
1201       REQUIRED_GTK=1.3.0
1202       PKG_GTK=gtk+-1.3-win32-production
1203       AC_MSG_CHECKING(for GTK+ - version >= $REQUIRED_GTK)
1204       if pkg-config --atleast-version $REQUIRED_GTK $PKG_GTK; then
1205         GTK_CONFIG="pkg-config $PKG_GTK"
1206         AC_MSG_RESULT(yes)
1207       else
1208         GTK_CONFIG=no
1209         AC_MSG_RESULT(no)
1210       fi
1211     else
1212       AC_CHECK_PROG(GTK_CONFIG, gtk-config, gtk-config, no)
1213       if test "$GTK_CONFIG" = "no"; then
1214         AC_MSG_RESULT(no)
1215       else
1216         AC_MSG_RESULT(yes)
1217       fi
1218     fi
1219   fi
1220 else
1221   GTK_CONFIG=no
1223 if test "$GTK_CONFIG" = "no"; then
1224      LABLGTK_CONFIG=no
1225 else
1226   AC_MSG_CHECKING(for native code $LABLGTK_NAME)
1227   if test -f `$OCAMLC -where`/$LABLGTK_NAME/lablgtk.$OCAMLLIB_EXT; then
1228      if test "$GUI" = "newgui2"; then
1229        if test -f `$OCAMLC -where`/$LABLGTK_NAME/lablrsvg.$OCAMLLIB_EXT; then
1230          AC_MSG_RESULT(yes)
1231          LABLGTK_CONFIG=yes
1232        else
1233          AC_MSG_RESULT(no)
1234          LABLGTK_CONFIG=no
1235          if test -f `$OCAMLC -where`/$LABLGTK_NAME/lablrsvg.cma; then
1236            echo "---------------------------------------------------------"
1237            echo "lablrsvg is not installed properly. See the INSTALL.txt"
1238            echo "file of mldonkey to see how to compile $LABLGTK_NAME. You"
1239            echo "probably forgot to call 'make opt' before 'make install'."
1240            echo "---------------------------------------------------------"
1241          else
1242            echo "---------------------------------------------------------"
1243            echo "lablrsvg is not installed. See the INSTALL.txt file of"
1244            echo "mldonkey to see how to compile $LABLGTK_NAME. Librsvg"
1245            echo "may not be installed when you compiled $LABLGTK_NAME."
1246            echo "---------------------------------------------------------"
1247          fi
1248        fi
1249      else
1250        AC_MSG_RESULT(yes)
1251        LABLGTK_CONFIG=yes
1252      fi
1253   else
1254      AC_MSG_RESULT(no)
1255      LABLGTK_CONFIG=no
1256      if test -f `$OCAMLC -where`/$LABLGTK_NAME/lablgtk.cma; then
1257        echo "-------------------------------------------------------------"
1258        echo "$LABLGTK_NAME is not installed properly. See the INSTALL.txt"
1259        echo "file of mldonkey to see how to compile $LABLGTK_NAME. You"
1260        echo "probably forgot to call 'make opt' before 'make install'."
1261        echo "-------------------------------------------------------------"
1262      else
1263        echo "Do you want this script to try to download and install $LABLGTK_NAME"
1264        echo "LOCALLY in mldonkey directory ?"
1265        if test "$BATCH" = "no"; then read i <&1; else i=yes; fi
1266        case "$i" in
1267         y* | Y*)
1269          cd $PATCH_DIR
1270          rm -rf lablgtk-"$REQUIRED_LABLGTK"
1271          if test ! -f lablgtk-"$REQUIRED_LABLGTK".tar.gz; then
1272            echo Downloading ...
1273            $WGET http://wwwfun.kurims.kyoto-u.ac.jp/soft/olabl/dist/lablgtk-"$REQUIRED_LABLGTK".tar.gz
1274          fi
1275          if test ! -f lablgtk-"$REQUIRED_LABLGTK".tar.gz; then exit 1; fi
1277          mkdir -p $BUILD_DIR
1278          cd $BUILD_DIR
1279         echo Uncompressing ...
1280          gzip -cd $PATCH_DIR/lablgtk-"$REQUIRED_LABLGTK".tar.gz | tar xf -
1281          (cd lablgtk-"$REQUIRED_LABLGTK"
1282           PATH=$OCAML_PATH:$PATH
1283           export PATH
1284           echo $PATH
1286           if test "$GUI" = "newgui2"; then
1287             ./configure --prefix=$LOCAL_DIR
1288             $GNU_MAKE world
1289             $GNU_MAKE install
1290           else
1291             $GNU_MAKE configure
1292             $GNU_MAKE
1293             $GNU_MAKE opt
1294             $GNU_MAKE install
1295           fi
1297           cd ..
1298           rm -rf lablgtk-"$REQUIRED_LABLGTK"
1299          )
1300          cd $CONFIG_DIR
1301          if test -f `$OCAMLC -where`/$LABLGTK_NAME/lablgtk.$OCAMLLIB_EXT; then
1302             LABLGTK_CONFIG=yes
1303          else
1304             echo "Installation of $LABLGTK_NAME failed"
1305             LABLGTK_CONFIG=no
1306          fi
1307          ;;
1308         *);;
1309       esac
1310      fi
1311   fi
1314 if test "$GUI" = "newgui2" ; then
1315   GUIS="mldonkey_gui\$(EXE)"
1316   GTKCFLAGS="`pkg-config --cflags-only-I gtk+-2.0`"
1317   GTKLLIBS="`pkg-config --libs-only-L gtk+-2.0`"
1318   GTKLFLAGS="`pkg-config --libs-only-l gtk+-2.0`"
1319 else
1320   GUIS="mldonkey_gui\$(EXE) mldonkey_gui2\$(EXE)"
1323 if test "$LABLGTK_CONFIG" = "no"; then
1324   GUI="no"
1325 else
1326   MORE_TARGETS="$MORE_TARGETS $GUIS"
1327   AC_MSG_CHECKING(GToolbox.popup_menu args)
1328   OCAML_LIB_DIR="`$OCAMLC -where`"
1329   GTOOLBOX="$OCAML_LIB_DIR/$LABLGTK_NAME/gToolbox.mli"
1330   grep popup $GTOOLBOX | grep -i button 2> /dev/null && GTOOLBOX_ARGS=new
1331   if test "$GTOOLBOX_ARGS" = "new"; then
1332     GTOOLBOX_POPUPMENU=' ~button: button ~time: time '
1333     AC_MSG_RESULT(new)
1334   else
1335     GTOOLBOX_POPUPMENU=' ~x: button ~y: time '
1336     AC_MSG_RESULT(old)
1337   fi
1338   echo "---------------------------------------------------------"
1339   echo "End of GTK GUI configuration."
1340   echo "---------------------------------------------------------"
1343 if test "$OS_FILES" = "mingw"; then
1344    OCAMLDEP_OPTIONS="-slash"
1347 TMK=no
1349 AC_SUBST(LIBS)
1350 AC_SUBST(CFLAGS)
1351 AC_SUBST(CPPFLAGS)
1352 AC_SUBST(CXXFLAGS)
1353 AC_SUBST(LDFLAGS)
1354 AC_SUBST(CC)
1355 AC_SUBST(CPP)
1356 AC_SUBST(CXX)
1357 AC_SUBST(FIX_BROKEN_CPP)
1358 AC_SUBST(CONFIG_INCLUDES)
1359 AC_SUBST(OCAMLC)
1360 AC_SUBST(OCAMLLIB)
1361 AC_SUBST(OCAMLOPT)
1362 AC_SUBST(OCAMLLEX)
1363 AC_SUBST(OCAMLYACC)
1364 AC_SUBST(OCAMLDEP)
1365 AC_SUBST(OCAMLDEP_OPTIONS)
1366 AC_SUBST(CAMLP4)
1367 AC_SUBST(PERL)
1368 AC_SUBST(OCAMLDOC)
1369 AC_SUBST(OCAMLMKTOP)
1370 AC_SUBST(SYSTEM)
1371 AC_SUBST(MORE_TARGETS)
1372 AC_SUBST(MORE_SUBDIRS)
1373 AC_SUBST(LABLGL_CMA)
1374 AC_SUBST(LABLGL_CMXA)
1375 AC_SUBST(MD4ARCH)
1376 AC_SUBST(MD4COMP)
1377 AC_SUBST(ICONV)
1378 AC_SUBST(OPEN_NAPSTER)
1379 AC_SUBST(DIRECT_CONNECT)
1380 AC_SUBST(GNUTELLA)
1381 AC_SUBST(GNUTELLA2)
1382 AC_SUBST(BITTORRENT)
1383 AC_SUBST(FILETP)
1384 AC_SUBST(SOULSEEK)
1385 AC_SUBST(OPENFT)
1386 AC_SUBST(FASTTRACK)
1387 AC_SUBST(DONKEY)
1388 AC_SUBST(DONKEY_SUI)
1389 AC_SUBST(CRYPTOPPFLAGS)
1390 AC_SUBST(DONKEY_SUI_FILE)
1391 AC_SUBST(DONKEY_SERVER)
1392 AC_SUBST(GUI)
1393 AC_SUBST(REQUIRED_OCAML)
1394 AC_SUBST(REQUIRED_LABLGTK)
1395 AC_SUBST(ARCH)
1396 AC_SUBST(COMPRESS)
1397 AC_SUBST(COMPRESS_EXT)
1398 AC_SUBST(CHECKBOUNDS)
1399 AC_SUBST(MLDONKEY_VERSION)
1400 AC_SUBST(SCM_VERSION)
1401 AC_SUBST(MAJOR_VERSION)
1402 AC_SUBST(MINOR_VERSION)
1403 AC_SUBST(SUB_VERSION)
1404 AC_SUBST(GTOOLBOX_POPUPMENU)
1405 AC_SUBST(OS_FILES)
1406 AC_SUBST(OS_FILES2)
1407 AC_SUBST(TARGET_TYPE)
1408 AC_SUBST(RPMBUILD)
1409 AC_SUBST(TMK)
1410 AC_SUBST(GTKCFLAGS)
1411 AC_SUBST(GTKLLIBS)
1412 AC_SUBST(GTKLFLAGS)
1413 AC_SUBST(GD)
1414 AC_SUBST(GD_JPG)
1415 AC_SUBST(GD_PNG)
1416 AC_SUBST(GDGRAPHICS)
1417 AC_SUBST(GD_LIBS)
1418 AC_SUBST(GD_STATIC_LIBS)
1419 AC_SUBST(GD_CFLAGS)
1420 AC_SUBST(GD_LDFLAGS)
1421 AC_SUBST(BZIP2)
1422 AC_SUBST(MAGIC)
1423 AC_SUBST(MAGICLIB)
1424 BUILD_SYSTEM="`uname -s` `uname -m` `uname -r`"
1425 AC_SUBST(BUILD_SYSTEM)
1426 AC_SUBST(GLIBC_VERSION)
1427 AC_SUBST(CC_VERSION)
1428 AC_SUBST(CXX_VERSION)
1429 AC_SUBST(CONFIGURE_ARGUMENTS)
1430 AC_SUBST(CONFIGURE_RUN)
1432 AUTOCONF=../src/utils/lib/autoconf.ml
1433 GTK_AUTOCONF=../src/utils/lib/gAutoconf.ml
1434 AC_OUTPUT(\
1435   Makefile.config \
1436   mldonkey.rc \
1437   $AUTOCONF.new $GTK_AUTOCONF.new \
1438    ../src/utils/lib/magic.ml \
1439    ../src/networks/donkey/donkeySui.ml \
1440    ../src/daemon/driver/driverGraphics.ml \
1441    ../packages/rpm/mldonkey.spec \
1442    ../packages/rpm/Makefile \
1443    ../packages/slackware/mldonkey.options)
1444 diff $AUTOCONF.new $AUTOCONF 2> /dev/null > /dev/null || cp -f $AUTOCONF.new $AUTOCONF
1445 diff $GTK_AUTOCONF.new $GTK_AUTOCONF 2> /dev/null > /dev/null || cp -f $GTK_AUTOCONF.new $GTK_AUTOCONF
1447 cd ..
1449 echo -e "\nBuilding dependencies (if it blocks, try '$GNU_MAKE depend' to see the problem)"
1450 $GNU_MAKE depend 2> /dev/null > /dev/null || echo "Building dependencies fails: try: '$GNU_MAKE depend'"
1452 echo -e -n "\nConfiguring MLDonkey" $MLDONKEY_VERSION
1453 if test ! -z "$SCM_VERSION"; then
1454   echo -n " - SCM: $SCM_VERSION"
1456 echo " completed."
1458 echo -e "\nNetwork modules:"
1459 echo -n " - eDonkey           "
1460 if test "$DONKEY" = "yes"; then
1461   if test "$DONKEY_SUI" = "yes"; then
1462     echo "enabled (eMule SUI enabled)"
1463   else
1464     echo "enabled (eMule SUI disabled)"
1465   fi
1466 else
1467   echo "        disabled"
1470 echo -n " - BitTorrent        "
1471 if test "$BITTORRENT" = "yes"; then
1472   echo "enabled"
1473 else
1474   echo "        disabled"
1477 echo -n " - FileTP (aka wget) "
1478 if test "$FILETP" = "yes"; then
1479   echo "enabled"
1480 else
1481   echo "        disabled"
1484 echo -n " - Fasttrack         "
1485 if test "$FASTTRACK" = "yes"; then
1486   echo "enabled"
1487 else
1488   echo "        disabled"
1491 echo -n " - Gnutella          "
1492 if test "$GNUTELLA" = "yes"; then
1493   echo "enabled (warning: default hostcache URLs out-of-date)"
1494 else
1495   echo "        disabled - unmaintained"
1498 echo -n " - Gnutella2         "
1499 if test "$GNUTELLA2" = "yes"; then
1500   echo "enabled (warning: default hostcache URLs out-of-date)"
1501 else
1502   echo "        disabled - unmaintained"
1505 echo -n " - Direct Connect    "
1506 if test "$DIRECT_CONNECT" = "yes"; then
1507   echo "enabled"
1508 else
1509   echo "        disabled"
1512 echo -n " - Open Napster      "
1513 if test "$OPEN_NAPSTER" = "yes"; then
1514   echo "enabled          - currently not usable"
1515 else
1516   echo "        disabled - currently not usable"
1519 echo -n " - Soulseek          "
1520 if test "$SOULSEEK" = "yes"; then
1521   echo "enabled          - currently not usable"
1522 else
1523   echo "        disabled - currently not usable"
1526 echo -n " - OpenFT            "
1527 if test "$OPENFT" = "yes"; then
1528   echo "enabled          - currently not usable"
1529 else
1530   echo "        disabled - currently not usable"
1533 echo -e "\nCore features:"
1535 echo " - zlib (required)   enabled"
1537 echo -n " - threads           "
1538 if test "$USE_PTHREAD" = "yes"; then
1539   echo "enabled"
1540 else
1541   echo "        disabled"
1544 echo -n " - bzip2             "
1545 if test "$BZIP2" = "yes"; then
1546   echo "enabled"
1547 else
1548   echo "        disabled"
1551 echo -n " - iconv             "
1552 if test "$ICONV" = "yes"; then
1553   echo "enabled"
1554 else
1555   echo "        disabled"
1558 echo -n " - libmagic          "
1559 if test "$MAGIC" = "yes"; then
1560   echo "enabled"
1561 else
1562   echo "        disabled"
1565 echo -n " - graphical stats   "
1566 if test "$GD" = "yes"; then
1567   echo "enabled"
1568   echo -n "   - png support     "
1569   if test "$GD_PNG" = "yes"; then
1570     echo "enabled"
1571   else
1572     echo "        disabled"
1573   fi
1575   echo -n "   - jpg support     "
1576   if test "$GD_JPG" = "yes"; then
1577     echo "enabled"
1578   else
1579     echo "        disabled"
1580   fi
1581 else
1582   echo "        disabled"
1585 if test "$LABLGTK_CONFIG" = "yes"; then
1586   echo -n -e "\n - GUI support       "
1587   if test "$GUI" = "newgui1"; then
1588     echo "GTK1 newgui"
1589   else
1590     if test "$GUI" = "newgui2"; then
1591       echo "GTK2 GUI"
1592     else
1593       echo "GTK1 oldgui"
1594     fi
1595   fi
1598 if test "$OLDGUI_NO_310" = "yes"; then
1599   echo " - GUI support       GTK1 oldgui does not work with Ocaml 3.10/3.11, disabled"
1602 if test "$TARGET_TYPE" = "byte"; then
1603   OCAML_TYPE="- byte code"
1604   COMPILE_TARGET=".byte"
1606 echo -e "\nCompilers:"
1607 echo -e " - Ocaml version     $OCAMLVERSION $OCAML_TYPE"
1608 echo -e " - $CC version       $CC_VERSION"
1609 if test "x$CXX" != "x"; then
1610   echo -e " - $CXX version       $CXX_VERSION"
1612 echo -e "\nNow execute '$GNU_MAKE' to start compiling. Good luck!"
1614 echo -e "\nTo compile a static code execute:     $GNU_MAKE mlnet$COMPILE_TARGET.static"
1615 echo      "To produce a release tarball execute: $GNU_MAKE release.mlnet.static"
1616 echo      "To clean the build directory execute: $GNU_MAKE maintainerclean"
1617 if test "$DONKEY_SUI" = "yes"; then
1618   echo -e "\nCompiling CryptoPP.cc can take several minutes, on slow machines up to half an hour."