Added support for checking timezone and tm_gmtoff. Fixed
[silc.git] / configure.ad
index 5f0141834d31316f5557e74661a21a7768fe0d3c..5bd10618dee4039f3cd4e6a8cbcda134f4cae371 100644 (file)
@@ -36,6 +36,9 @@ case "$target" in
   *-*-freebsd*)
     check_threads=true
     ;;
+  *-*-netbsd*)
+    check_threads=true
+    ;;
   *-*-*bsd*)
     check_threads=false
     ;;
@@ -135,6 +138,8 @@ AC_CHECK_SIZEOF(char, 0)
 AC_SUBST(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
 AC_CHECK_SIZEOF(void *, 0)
 AC_SUBST(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
+AC_CHECK_TYPES(long long)
+AC_CHECK_TYPES(long double)
 
 # Function to check if compiler flag works
 # Usage: SILC_ADD_CFLAGS(FLAGS, [ACTION-IF-FAILED])
@@ -176,44 +181,10 @@ AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
 AC_CHECK_FUNCS(poll select listen bind shutdown close connect setsockopt)
 AC_CHECK_FUNCS(setrlimit time ctime utime gettimeofday getrusage)
 AC_CHECK_FUNCS(chmod fcntl stat fstat getenv putenv strerror)
-AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
-AC_CHECK_FUNCS(setgroups initgroups nl_langinfo epoll_wait)
+AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid sched_yield)
+AC_CHECK_FUNCS(setgroups initgroups nl_langinfo nanosleep gmtime)
 AC_CHECK_FUNCS(strchr snprintf strstr strcpy strncpy memcpy memset memmove)
 
-#ifdef SILC_DIST_SIM
-# SIM support checking
-# XXX These needs to be changed as more supported platforms appear.
-# XXX This probably needs to be made platform dependant check.
-#
-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], [], [HAVE_SIM])
-        sim_support=true
-        LIBS="$LIBS -ldl"
-      ],
-      [
-        AC_CHECK_LIB(c, dlopen,
-          [
-            AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
-            sim_support=true
-          ])
-      ])
-   ])
-
-AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
-if test x$sim_support = xtrue; then
-  AC_MSG_RESULT(Enabled SIM support.)
-  __SILC_HAVE_SIM="#define __SILC_HAVE_SIM 1"
-else
-  AC_MSG_RESULT(No SIM support found.)
-fi
-#endif SILC_DIST_SIM
-
 # lib/contrib conditionals
 #
 AC_CHECK_HEADER(regex.h,
@@ -607,7 +578,9 @@ if test -n "$with_silc_includes" || test -n "$with_silc_libs"; then
   if test "$ac_silc_libs" != "no"; then
     compile_libs=false
     LIBSUBDIR=
-    LIBS="$LIBS -L$ac_silc_libs"
+    LDFLAGS="-L$ac_silc_libs $LDFLAGS"
+  else
+    LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
   fi
 
   # Check libs to link against
@@ -624,9 +597,9 @@ if test -n "$with_silc_includes" || test -n "$with_silc_libs"; then
 
 else
   # pkg-config check
-  PKG_CHECK_MODULES(SILC, silc, compile_libs=false, compile_libs=true)
+  PKG_CHECK_MODULES(SILC, [silc >= 1.1], compile_libs=false, compile_libs=true)
 #ifdef SILC_DIST_CLIENTLIB
-  PKG_CHECK_MODULES(SILCCLIENT, silcclient, compile_libs=false, compile_libs=true)
+  PKG_CHECK_MODULES(SILCCLIENT, [silcclient >= 1.1], compile_libs=false, compile_libs=true)
 #endif SILC_DIST_CLIENTLIB
 #ifdef SILC_DIST_SERVERLIB
   PKG_CHECK_MODULES(SILCSERVER, silcserver, compile_libs=false, compile_libs=true)
@@ -634,21 +607,57 @@ else
 
   if test x$compile_libs = xfalse; then
     LIBSUBDIR=
-    LIBS="$LIBS $SILC_LIBS"
+    LIBS="$SILC_LIBS $LIBS"
     CFLAGS="$CFLAGS $SILC_CFLAGS"
 #ifdef SILC_DIST_CLIENTLIB
-    LIBS="$LIBS $SILCCLIENT_LIBS"
+    LIBS="$SILCCLIENT_LIBS $LIBS"
     CFLAGS="$CFLAGS $SILCCLIENT_CFLAGS"
 #endif SILC_DIST_CLIENTLIB
 #ifdef SILC_DIST_SERVERLIB
     LIBS="$LIBS $SILCSERVER_LIBS"
     CFLAGS="$CFLAGS $SILCSERVER_CFLAGS"
 #endif SILC_DIST_SERVERLIB
+  else
+    LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
   fi
 fi
+#else SILC_DIST_TOOLKIT
+LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
 #endif SILC_DIST_TOOLKIT
 
-AC_SUBST(LIBSUBDIR)
+#ifdef SILC_DIST_SIM
+# SIM support checking
+# XXX These needs to be changed as more supported platforms appear.
+# XXX This probably needs to be made platform dependant check.
+#
+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], [], [HAVE_SIM])
+        sim_support=true
+        LIBS="$LIBS -ldl"
+      ],
+      [
+        AC_CHECK_LIB(c, dlopen,
+          [
+            AC_DEFINE([SILC_SIM], [], [HAVE_SIM])
+            sim_support=true
+          ])
+      ])
+   ])
+
+AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
+if test x$sim_support = xtrue; then
+  AC_MSG_RESULT(Enabled SIM support.)
+  __SILC_HAVE_SIM="#define __SILC_HAVE_SIM 1"
+else
+  AC_MSG_RESULT(No SIM support found.)
+fi
+#endif SILC_DIST_SIM
 
 # SOCKS4 support checking
 #
@@ -1119,12 +1128,111 @@ if test x$has_threads = xtrue; then
       ;;
    esac
 
+  # Check for threads
   AC_CHECK_FUNC(pthread_create)
+
+  # Check for read/write locks
+  AC_CHECK_FUNC(pthread_rwlock_init,
+  [
+    AC_RUN_IFELSE(
+      [
+        #include <pthread.h>
+        int main()
+        {
+          pthread_rwlock_t rwlock;
+          pthread_rwlock_init(&rwlock, NULL);
+          pthread_rwlock_destroy(&rwlock);
+          return 0;
+        }
+      ],
+      [],
+      [
+       # Rwlock not defined
+        CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
+      ]
+    )
+  ],
+  [
+    # Rwlock not defined
+    CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
+  ])
+
   AC_DEFINE([SILC_HAVE_PTHREAD], [], [HAVE_PTHREAD])
   AC_DEFINE([SILC_THREADS], [], [HAVE_THREAD])
   __SILC_HAVE_PTHREAD="#define __SILC_HAVE_PTHREAD 1"
 fi
 
+#
+# Check for timezone and tm_gmtoff for timezone information
+#
+AC_MSG_CHECKING(whether system has timezone)
+AC_RUN_IFELSE(
+  [
+    #include <stdio.h>
+    #include <time.h>
+    int main()
+    {
+      timezone = 0;
+      return 0;
+    }
+  ],
+  [ AC_MSG_RESULT(yes)
+    AC_DEFINE([HAVE_TIMEZONE], [], [HAVE_TIMEZONE]) ],
+  [ AC_MSG_RESULT(no) ],
+  [ AC_MSG_RESULT(no) ]
+)
+AC_MSG_CHECKING(whether system has tm_gmtoff)
+AC_RUN_IFELSE(
+  [
+    #include <stdio.h>
+    #include <time.h>
+    int main()
+    {
+      struct tm tm;
+      tm.tm_gmtoff = 0;
+      return 0;
+    }
+  ],
+  [ AC_MSG_RESULT(yes)
+    AC_DEFINE([HAVE_TM_GMTOFF], [], [HAVE_TM_GMTOFF]) ],
+  [ AC_MSG_RESULT(no) ],
+  [ AC_MSG_RESULT(no) ]
+)
+AC_MSG_CHECKING(whether system has __tm_gmtoff)
+AC_RUN_IFELSE(
+  [
+    #include <stdio.h>
+    #include <time.h>
+    int main()
+    {
+      struct tm tm;
+      tm.__tm_gmtoff = 0;
+      return 0;
+    }
+  ],
+  [ AC_MSG_RESULT(yes)
+    AC_DEFINE([HAVE___TM_GMTOFF], [], [HAVE___TM_GMTOFF]) ],
+  [ AC_MSG_RESULT(no) ],
+  [ AC_MSG_RESULT(no) ]
+)
+AC_MSG_CHECKING(whether system has __tm_gmtoff__)
+AC_RUN_IFELSE(
+  [
+    #include <stdio.h>
+    #include <time.h>
+    int main()
+    {
+      struct tm tm;
+      tm.__tm_gmtoff__ = 0;
+      return 0;
+    }
+  ],
+  [ AC_MSG_RESULT(yes)
+    AC_DEFINE([HAVE___TM_GMTOFF__], [], [HAVE___TM_GMTOFF__]) ],
+  [ AC_MSG_RESULT(no) ],
+  [ AC_MSG_RESULT(no) ]
+)
+
 # Native WIN32 compilation under cygwin
 #
 AC_MSG_CHECKING(whether to compile native WIN32 code)
@@ -1154,38 +1262,9 @@ AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
 #
 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
 
-#ifdef SILC_DIST_TOOLKIT
-# --with-irssi
-#
-without_irssi=true
-AC_MSG_CHECKING(whether to compile Irssi SILC Client)
-AC_ARG_WITH(irssi,
-  [  --with-irssi            compile with Irssi SILC Client],
-  [
-    AC_MSG_RESULT(yes)
-    without_irssi=false
-  ],
-  [
-    AC_MSG_RESULT(no)
-    without_irssi=true
-  ])
-AM_CONDITIONAL(with_irssi, test xwithout_irssi = xfalse)
-
-# --with-silcd
-#
-without_silcd=true
-AC_MSG_CHECKING(whether to compile SILC Server)
-AC_ARG_WITH(silcd,
-  [  --with-silcd            compile with SILC Server],
-  [
-    AC_MSG_RESULT(yes)
-    without_silcd=false
-  ],
-  [
-    AC_MSG_RESULT(no)
-    without_silcd=true
-  ])
-#endif SILC_DIST_TOOLKIT
+#ifdef SILC_DIST_SERVER
+without_silcd=false
+#endif SILC_DIST_SERVER
 #ifdef SILC_DIST_CLIENT
 AM_CONDITIONAL(with_irssi, true)
 #endif SILC_DIST_CLIENT
@@ -1226,7 +1305,9 @@ AD_INCLUDE_CONFIGURE
 #
 # Substitutions
 #
+AC_SUBST(LIBSUBDIR)
 AC_SUBST(SILC_TOP_SRCDIR)
+AC_SUBST(LDFLAGS)
 AC_SUBST(LIBS)
 AC_SUBST(SILC_LIB_INCLUDES)
 AC_SUBST(__SILC_HAVE_PTHREAD)
@@ -1310,20 +1391,17 @@ echo " include directory .............: $s_includedir"
 #endif SILC_DIST_INCLUDES
 echo ""
 
-#ifdef SILC_DIST_TOOLKIT
+#ifdef SILC_DIST_CLIENT
 if test x$without_irssi = xtrue; then
   irssi="no"
 fi
-if test x$without_silcd = xtrue; then
-  silcd="no"
-fi
-#endif SILC_DIST_TOOLKIT
-
-#ifdef SILC_DIST_CLIENT
 echo " Compile SILC Client ...........: $irssi"
 #endif SILC_DIST_CLIENT
 
 #ifdef SILC_DIST_SERVER
+if test x$without_silcd = xtrue; then
+  silcd="no"
+fi
 echo " Compile SILC Server ...........: $silcd"
 #endif SILC_DIST_SERVER