Merged from silc_1_0_branch.
[silc.git] / configure.in.pre
index ac6548de6f3b3b53822ac7425015c636c497cc5e..671dac894b0f2fabe6e7c1f8ce2c30b203f3873e 100644 (file)
@@ -60,11 +60,54 @@ if test "$GCC"; then
   CFLAGS="-Wall -finline-functions $CFLAGS"
 fi
 
+#
+# Library versioning.
+#
+# Do the releases and library versioning according to following rules:
+#
+#  - If any code has changed in library, increment [LIB]_REVISION
+#  - If functions were added, set [LIB]_REVISION to 0
+#  - If functions were added, removed or changed, increment [LIB]_CURRENT
+#  - If functions were added, increment [LIB]_AGE
+#  - If functions were removed, set [LIB]_AGE to 0
+#
+# where [LIB] is LIBSILC and LIBSILCCLIENT, and where "functions" means
+# functions public interfaces.
+#
+# The LIB_BASE_VERSION defines the SILC software major.minor version and 
+# it is increment only when these version numbers actually change.
+#
+
+# Base version for libraries.  Do not change this unless SILC version
+# changes too.
+LIB_BASE_VERSION=1.0
+
+# libsilc versions
+LIBSILC_CURRENT=1
+LIBSILC_REVISION=0
+LIBSILC_AGE=1
+
+# libsilcclient versions
+LIBSILCCLIENT_CURRENT=1
+LIBSILCCLIENT_REVISION=1
+LIBSILCCLIENT_AGE=0
+
+# Substitute the version numbers
+AC_SUBST(LIB_BASE_VERSION)
+AC_SUBST(LIBSILC_CURRENT)
+AC_SUBST(LIBSILC_REVISION)
+AC_SUBST(LIBSILC_AGE)
+AC_SUBST(LIBSILCCLIENT_CURRENT)
+AC_SUBST(LIBSILCCLIENT_REVISION)
+AC_SUBST(LIBSILCCLIENT_AGE)
+
+#
 # Program checking
 #
 AC_PROG_INSTALL
 AC_PROG_RANLIB
 AC_PROG_MAKE_SET
+AC_DISABLE_SHARED
 AC_PROG_LIBTOOL
 AC_PATH_PROG(sedpath, sed)
 
@@ -92,17 +135,17 @@ AC_TYPE_UID_T
 AC_TYPE_PID_T
 
 AC_CHECK_SIZEOF(long long, 0)
-AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
+AC_SUBST(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
 AC_CHECK_SIZEOF(long, 0)
-AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
+AC_SUBST(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
 AC_CHECK_SIZEOF(int, 0)
-AC_DEFINE_UNQUOTED(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
+AC_SUBST(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
 AC_CHECK_SIZEOF(short, 0)
-AC_DEFINE_UNQUOTED(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
+AC_SUBST(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
 AC_CHECK_SIZEOF(char, 0)
-AC_DEFINE_UNQUOTED(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
+AC_SUBST(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
 AC_CHECK_SIZEOF(void *, 0)
-AC_DEFINE_UNQUOTED(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
+AC_SUBST(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
 
 # Function and library checking
 #
@@ -132,20 +175,21 @@ sim_support=false
 AC_MSG_CHECKING(for SIM support)
 AC_MSG_RESULT()
 AC_CHECK_HEADERS(dlfcn.h,
-  AC_CHECK_LIB(dl, dlopen,
-    [
-      AC_DEFINE(SILC_SIM)
-      sim_support=true
-      LIBS="$LIBS -ldl"
-    ],
-    [
-      AC_CHECK_LIB(c, dlopen,
-        [
-          AC_DEFINE(SILC_SIM)
-          sim_support=true
-        ])
-    ])
-  )
+  [
+    AC_CHECK_LIB(dl, dlopen,
+      [
+        AC_DEFINE(SILC_SIM)
+        sim_support=true
+        LIBS="$LIBS -ldl"
+      ],
+      [
+        AC_CHECK_LIB(c, dlopen,
+          [
+            AC_DEFINE(SILC_SIM)
+            sim_support=true
+          ])
+      ])
+   ])
 
 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
 if test x$sim_support = xtrue; then
@@ -195,6 +239,9 @@ if test x$check_ipv6 = xtrue; then
   summary_ipv6="no"
   AC_TRY_COMPILE(
     [
+      #ifdef HAVE_SYS_TYPES_H
+      #include <sys/types.h>
+      #endif
       #ifdef HAVE_NETINET_TCP_H
       #include <netinet/tcp.h>
       #endif
@@ -202,7 +249,7 @@ if test x$check_ipv6 = xtrue; then
       #include <netdb.h>
       #endif
       #include <sys/socket.h>
-      #ifdef HAVE_NETDB_IN_H
+      #ifdef HAVE_NETINET_IN_H
       #include <netinet/in.h>
       #endif
     ],
@@ -213,7 +260,7 @@ if test x$check_ipv6 = xtrue; then
     [
       AC_DEFINE(HAVE_IPV6)
       AC_MSG_RESULT(yes)
-      summary_ipv6="ues"
+      summary_ipv6="yes"
     ],
       AC_MSG_RESULT(no)
     )
@@ -305,7 +352,7 @@ AC_ARG_WITH(etcdir,
   [[  --with-etcdir=DIR       directory for system files [/etc/silc]]],
   [
     case "$withval" in
-      no)
+      no|yes)
         ;;
       *)
         ETCDIR="$withval"
@@ -322,7 +369,7 @@ AC_ARG_WITH(helpdir,
   [[  --with-helpdir=DIR      directory for SILC help files [PREFIX/help]]],
   [
     case "$withval" in
-      no)
+      no|yes)
         ;;
       *)
        HELPDIR="$withval"
@@ -339,7 +386,7 @@ AC_ARG_WITH(docdir,
   [[  --with-docdir=DIR       directory for SILC documentation [PREFIX/doc]]],
   [
     case "$withval" in
-      no)
+      no|yes)
         ;;
       *)
         DOCDIR="$withval"
@@ -356,7 +403,7 @@ AC_ARG_WITH(simdir,
   [[  --with-simdir=DIR       directory for SIM modules [PREFIX/modules]]],
   [
     case "$withval" in
-      no)
+      no|yes)
         ;;
       *)
         MODULESDIR="$withval"
@@ -373,7 +420,7 @@ AC_ARG_WITH(logsdir,
   [[  --with-logsdir=DIR      directory for SILC Server logs [PREFIX/logs]]],
   [
     case "$withval" in
-      no)
+      no|yes)
         ;;
       *)
         LOGSDIR="$withval"
@@ -406,7 +453,7 @@ AC_ARG_WITH(silcd-pid-file,
                                  Server [/var/run/silcd.pid]]],
   [
     case "$withval" in
-      no)
+      no|yes)
         ;;
       *)
         PIDFILE="$withval"
@@ -422,6 +469,9 @@ AC_SUBST(PIDFILE)
 
 # SOCKS4 support checking
 #
+SAVE_LIBS="$LIBS"
+SAVE_CFLAGS="$CFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
 AC_MSG_CHECKING(whether to support SOCKS4)
 AC_ARG_WITH(socks4,
   [[  --with-socks4[=DIR]     with SOCKS4 support [search in DIR/lib and DIR/include]]],
@@ -436,31 +486,34 @@ AC_ARG_WITH(socks4,
     
         if test -d "$withval/include"; then
           CFLAGS="$CFLAGS -I$withval/include"
-        else
-          CFLAGS="$CFLAGS -I$withval"
         fi
         if test -d "$withval/lib"; then
-          withval="-L$withval/lib -lsocks"
-        else
-          withval="-L$withval -lsocks"
+          LDFLAGS="$LDFLAGS -L$withval/lib"
         fi
     
-        LIBS="$withval $LIBS"
-        AC_TRY_LINK([],
-          [
-            Rconnect();
-          ], [],
-          [
-            AC_MSG_ERROR(Could not find SOCKS4 library.)
-          ])
+        LIBS="-lsocks $LIBS"
         ;;
     esac
+
+    AC_TRY_LINK([],
+      [
+        Rconnect();
+      ], [],
+      [
+        AC_MSG_ERROR(Could not find SOCKS4 library.)
+        LIBS="$SAVE_LIBS"
+        CFLAGS="$SAVE_CFLAGS"
+        LDFLAGS="$SAVE_LDFLAGS"
+      ])
   ],
     AC_MSG_RESULT(no)
   )
 
 # SOCKS5 support checking
 #
+SAVE_LIBS="$LIBS"
+SAVE_CFLAGS="$CFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
 AC_MSG_CHECKING(whether to support SOCKS5)
 AC_ARG_WITH(socks5,
   [[  --with-socks5[=DIR]     with SOCKS5 support [search in DIR/lib and DIR/include]]],
@@ -475,25 +528,25 @@ AC_ARG_WITH(socks5,
 
         if test -d "$withval/include"; then
           CFLAGS="$CFLAGS -I$withval/include"
-        else
-          CFLAGS="$CFLAGS -I$withval"
         fi
         if test -d "$withval/lib"; then
-          withval="-L$withval/lib -lsocks5"
-        else
-          withval="-L$withval -lsocks5"
+          LDFLAGS="$LDFLAGS -L$withval/lib"
         fi
 
-        LIBS="$withval $LIBS"
-        AC_TRY_LINK([],
-          [
-            SOCKSconnect();
-          ], [],
-          [
-            AC_MSG_ERROR(Could not find SOCKS5 library.)
-          ])
+        LIBS="-lsocks5 $LIBS"
         ;;
     esac
+
+    AC_TRY_LINK([],
+      [
+        SOCKSconnect();
+      ], [],
+      [
+        AC_MSG_ERROR(Could not find SOCKS5 library.)
+        LIBS="$SAVE_LIBS"
+        CFLAGS="$SAVE_CFLAGS"
+        LDFLAGS="$SAVE_LDFLAGS"
+      ])
   ],
     AC_MSG_RESULT(no)
   )
@@ -534,6 +587,9 @@ fi
 # source tree.
 #
 mp_gmp=false
+SAVE_LIBS="$LIBS"
+SAVE_CFLAGS="$CFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
 AC_MSG_CHECKING(whether to search for GMP)
 AC_ARG_WITH(gmp,
   [[  --with-gmp[=DIR]        use GMP instead of MPI [search in DIR/lib and DIR/include]]],
@@ -547,24 +603,26 @@ AC_ARG_WITH(gmp,
     
         if test -d "$withval/include"; then
           CFLAGS="$CFLAGS -I$withval/include"
-        else
-          CFLAGS="$CFLAGS -I$withval"
         fi
         if test -d "$withval/lib"; then
-          withval="-L$withval/lib -lgmp"
-        else
-          withval="-L$withval -lgmp"
+          LDFLAGS="$LDFLAGS -L$withval/lib"
         fi
     
-        LIBS="$withval $LIBS"
-        AC_CHECK_LIB(gmp, __gmpz_init,
-          [
-            mp_gmp=true
-            AC_DEFINE(SILC_MP_GMP)
-            AC_MSG_RESULT(Using GMP as a MP library.)
-          ])
+        LIBS="-lgmp $LIBS"
         ;;
     esac
+
+    AC_CHECK_LIB(gmp, __gmpz_init,
+      [
+        mp_gmp=true
+        AC_DEFINE(SILC_MP_GMP)
+        AC_MSG_RESULT(Using GMP as a MP library.)
+      ],
+      [
+        LIBS="$SAVE_LIBS"
+        CFLAGS="$SAVE_CFLAGS"
+        LDFLAGS="$SAVE_LDFLAGS"
+      ])
   ],
     AC_MSG_RESULT(no)
   )
@@ -580,6 +638,10 @@ fi
 #
 check_iconv=true
 has_iconv=false
+SAVE_LIBS="$LIBS"
+SAVE_CFLAGS="$CFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+SAVE_CPPFLAGS="$CPPFLAGS"
 AC_MSG_CHECKING(whether to implicit search for libiconv)
 AC_ARG_WITH(iconv,
   [[  --with-iconv[=DIR]      use libiconv [search in DIR/include and DIR/lib]]],
@@ -587,13 +649,14 @@ AC_ARG_WITH(iconv,
     case "${withval}" in
       no)
         AC_MSG_RESULT(no)
-
-        AC_CHECK_HEADERS(iconv.h, AC_CHECK_FUNC(iconv, has_iconv=true))
+        AC_CHECK_HEADERS(iconv.h,
+          [
+            AC_CHECK_FUNC(iconv, has_iconv=true)
+          ])
         check_iconv=false
         ;;
       *)
         AC_MSG_RESULT(yes)
-
         if test -d $withval/include; then
           CPPFLAGS="$CPPFLAGS -I$withval/include"
           CFLAGS="$CFLAGS -I$withval/include"
@@ -601,16 +664,19 @@ AC_ARG_WITH(iconv,
         if test -d $withval/lib; then
           LDFLAGS="$LDFLAGS -L$withval/lib"
         fi
+        ;;
     esac
   ],
   [
     AC_MSG_RESULT(no)
-
-    AC_CHECK_HEADERS(iconv.h, AC_CHECK_FUNCS(iconv,
-                                [
-                                  has_iconv=true
-                                  check_iconv=false
-                                 ]))
+    AC_CHECK_HEADERS(iconv.h,
+      [
+        AC_CHECK_FUNCS(iconv,
+          [
+            has_iconv=true
+            check_iconv=false
+          ])
+      ])
   ])
 
 if test x$check_iconv = xtrue; then
@@ -636,26 +702,30 @@ if test x$check_iconv = xtrue; then
         [
           echo "yes"
           AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
-          has_iconv=true 
-          check_iconv=true 
+          has_iconv=true
+          check_iconv=false
+        ],
+        [
+          echo "no"
+          LIBS="$SAVE_LIBS"
+          CFLAGS="$SAVE_CFLAGS"
+          LDFLAGS="$SAVE_LDFLAGS"
+          CPPFLAGS="$SAVE_CPPFLAGS"
         ])
      ])
 fi
 
 if test x$check_iconv = xtrue; then
   # search for iconv library..
-  SAVE_CPPFLAGS="$CPPFLAGS"
+  SAVE_LIBS="$LIBS"
   SAVE_CFLAGS="$CFLAGS"
   SAVE_LDFLAGS="$LDFLAGS"
+  SAVE_CPPFLAGS="$CPPFLAGS"
     
   for dir in `echo "/usr/local /usr/pkg /usr/contrib"`; do
     if test x$has_iconv = xfalse; then
       AC_MSG_RESULT(searching in $dir...)
-    
-      CPPFLAGS="$SAVE_CPPFLAGS"
-      CFLAGS="$SAVE_CFLAGS"
-      LDFLAGS="$SAVE_LDFLAGS"
-      
+     
       if test -d $dir/include; then
         CPPFLAGS="$CPPFLAGS -I$dir/include"
         CFLAGS="$CFLAGS -I$dir/include"
@@ -687,8 +757,19 @@ if test x$check_iconv = xtrue; then
               AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
             ],
             [
+              echo "no"
               has_iconv=false
+              LIBS="$SAVE_LIBS"    
+              CFLAGS="$SAVE_CFLAGS"
+              LDFLAGS="$SAVE_LDFLAGS"
+              CPPFLAGS="$SAVE_CPPFLAGS"
             ])
+         ],
+         [
+           CFLAGS="$SAVE_CFLAGS"
+           LDFLAGS="$SAVE_LDFLAGS"
+           CPPFLAGS="$SAVE_CPPFLAGS"
          ])
       fi
     done
@@ -729,7 +810,7 @@ if test x$has_iconv = xtrue; then
     )
 
   if test x$ac_iconv_good = xno; then
-    AC_MSG_ERROR(Try using libiconv instead.)
+    AC_MSG_RESULT(Try using libiconv instead.)
   fi
 fi
 
@@ -759,10 +840,14 @@ AC_ARG_WITH(pthreads,
   ])
 
 if test x$check_threads = xtrue; then
+  SAVE_LIBS="$LIBS"
+  SAVE_CFLAGS="$CFLAGS"
+  SAVE_LDFLAGS="$LDFLAGS"
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  
   AC_MSG_RESULT(yes)
   AC_CHECK_HEADERS(pthread.h,
     [
-      SAVE_LIBS="$LIBS"
       LIBS="$LIBS -lpthread"
       AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
         [
@@ -770,25 +855,20 @@ if test x$check_threads = xtrue; then
           case "${target}" in
             *-*-freebsd*)
               LIBS="$SAVE_LIBS -pthread"
-              AC_CHECK_LIB(c_r, pthread_attr_init, has_threads=true)
+              AC_CHECK_LIB(c_r, pthread_attr_init, has_threads=true, LIBS="$SAVE_LIBS")
+              ;;
+            *)
+              LIBS="$SAVE_LIBS"
               ;;
           esac
         ])
     ],
     [
       # search for pthread library..
-      SAVE_CPPFLAGS="$CPPFLAGS"
-      SAVE_CFLAGS="$CFLAGS"
-      SAVE_LDFLAGS="$LDFLAGS"
-
       for dir in `echo "/usr/local /usr/pkg /usr/contrib /usr/pkg/pthreads /usr/local/pthreads"`; do
         if test x$has_threads = xfalse; then
           AC_MSG_RESULT(searching in $dir...)
   
-          CPPFLAGS="$SAVE_CPPFLAGS"
-          CFLAGS="$SAVE_CFLAGS"
-          LDFLAGS="$SAVE_LDFLAGS"
-  
           if test -d $dir/include; then
             CPPFLAGS="$CPPFLAGS -I$dir/include"
             CFLAGS="$CFLAGS -I$dir/include"
@@ -804,7 +884,19 @@ if test x$check_threads = xtrue; then
             [ 
               LIBS="$LIBS -lpthread"
               AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
-                                                       has_threads=false)
+                [
+                  has_threads=false
+
+                  LIBS="$SAVE_LIBS"
+                  CFLAGS="$SAVE_CFLAGS"
+                  LDFLAGS="$SAVE_LDFLAGS"
+                  CPPFLAGS="$SAVE_CPPFLAGS"
+                ])
+            ],
+            [
+              CFLAGS="$SAVE_CFLAGS"
+              LDFLAGS="$SAVE_LDFLAGS"
+              CPPFLAGS="$SAVE_CPPFLAGS"
             ])
         fi
       done
@@ -905,6 +997,22 @@ AC_ARG_WITH(silcd,
     AC_MSG_RESULT(yes)
   ])
 
+libtoolfix=true
+AC_MSG_CHECKING(whether to do libtoolfix)
+AC_ARG_WITH(libtoolfix,
+  [  --without-libtoolfix     Do not fix libtool, for package builders],
+  [
+    AC_MSG_RESULT(no)
+    libtoolfix=false
+  ],
+  [
+    AC_MSG_RESULT(yes)
+  ])
+
+AC_SUBST(ETCDIR)
+AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
+
+
 
 ##
 ##  Misc
@@ -919,7 +1027,10 @@ if test x$without_irssi = xfalse; then
   fi
 fi
 
-AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
+if test x$mp_gmp = xfalse; then
+  AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
+fi
+
 #AC_CONFIG_SUBDIRS(lib/zlib)
 
 SILC_TOP_SRCDIR=`pwd`
@@ -931,6 +1042,18 @@ INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
 AC_SUBST(INCLUDE_DEFINES_INT)
 AC_SUBST(SILC_DIST_SUBDIRS)
 
+#
+# Fix the libtool to support run-time configuration.  This allows us
+# to in run-time specify when to compile shared/static libraries without
+# need to reconfigure the entire libtool.
+#
+if test x$libtoolfix = xtrue; then
+  ./libtoolfix $SILC_TOP_SRCDIR/ltmain.sh
+fi
+AM_CONDITIONAL(SILC_LIBTOOLFIX, test x$libtoolfix = xtrue)
+
+
+#
 # Makefile outputs
 #
 AC_CONFIG_FILES(
@@ -942,7 +1065,9 @@ includes/Makefile
 lib/Makefile
 lib/contrib/Makefile
 lib/silccore/Makefile
+lib/silccore/tests/Makefile
 lib/silccrypt/Makefile
+lib/silccrypt/tests/Makefile
 lib/silcmath/Makefile
 lib/silcmath/mpi/Makefile.defines
 lib/silcmath/mpi/Makefile.defines_int
@@ -957,6 +1082,7 @@ lib/silcutil/epoc/Makefile
 lib/silcsftp/Makefile
 lib/silcsftp/tests/Makefile
 doc/example_silcd.conf
+includes/silcincludes.h
 )
 
 if test "x$silc_dist" = "xsilc-client" ||
@@ -989,6 +1115,9 @@ silc/Makefile
 win32/Makefile
 win32/libsilc/Makefile
 win32/libsilcclient/Makefile
+tutorial/Makefile
+tutorial/Makefile.defines
+tutorial/Makefile.defines_int
 )
 fi
 
@@ -1033,7 +1162,7 @@ if test "x$silc_dist" = "xsilc-server" ||
    test "x$silc_dist" = "xsilc-toolkit"; then
   silcd="yes"
   if test x$without_silcd = xtrue; then
-    without_silcd="no"
+    silcd="no"
   fi
 echo " Compile SILC Server ...........: $silcd"
 echo " Server configuration file .....: $summary_silcd_configfile"
@@ -1047,7 +1176,7 @@ else
 fi
 echo " SIM support ...................: $sim_support"
 echo " IPv6 support ..................: $summary_ipv6"
-echo " Assmebler optimizations .......: $summary_asm"
+echo " Assembler optimizations .......: $summary_asm"
 
 mp="MPI"
 if test x$mp_gmp = xtrue; then
@@ -1063,4 +1192,8 @@ echo " Multi-threads support .........: $threads"
 echo " Debugging enabled .............: $summary_debug"
 echo " Stack-trace enabled ...........: $summary_stacktrace"
 echo ""
-echo "Compile the sources with 'make' or 'gmake' command."
+if test "x$silc_dist" = "xsilc-client"; then
+  echo "Compile the sources with 'make' or 'gmake' command (GNU make is required)."
+else
+  echo "Compile the sources with 'make' or 'gmake' command."
+fi