configure/genstamp: check for struct tm.tm_gmtoff
authorNathan Bryant <loanshark@uncensored.citadel.org>
Fri, 4 Jan 2002 20:43:26 +0000 (20:43 +0000)
committerNathan Bryant <loanshark@uncensored.citadel.org>
Fri, 4 Jan 2002 20:43:26 +0000 (20:43 +0000)
citadel/ChangeLog
citadel/Makefile.in
citadel/acinclude.m4 [new file with mode: 0644]
citadel/configure.ac
citadel/genstamp.c

index ef338a2416bff4402dc0b77b43ebe5aeedd9ca87..2b1d8bad6198f174e1a00892b8bb1db027772977 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 590.34  2002/01/04 20:43:26  nbryant
+ configure/genstamp: check for struct tm.tm_gmtoff
+
  Revision 590.33  2002/01/03 22:01:17  ajc
  * Fixed mail to "sysop"
 
@@ -3061,3 +3064,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
+
index d80c7d447d8eef56e0ad5f0ddfcd0709400049ef..e27d5475b5a0bec7bcd442c29ce34100e26cecbc 100644 (file)
@@ -68,6 +68,7 @@ INSTALL=@INSTALL@
 INSTALL_DATA=@INSTALL_DATA@
 SHELL=/bin/sh
 AUTOCONF=@AUTOCONF@
+ACLOCAL=@ACLOCAL@
 YACC=@YACC@
 DATABASE=@DATABASE@
 
@@ -324,6 +325,9 @@ config.status: $(srcdir)/configure
 $(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/aclocal.m4
        cd $(srcdir) && $(AUTOCONF)
 
+$(srcdir)/aclocal.m4: $(srcdir)/acinclude.m4
+       cd $(srcdir) && $(ACLOCAL)
+
 weekly: $(srcdir)/weekly.in config.status
        CONFIG_FILES=weekly CONFIG_HEADERS= $(SHELL) ./config.status
 
diff --git a/citadel/acinclude.m4 b/citadel/acinclude.m4
new file mode 100644 (file)
index 0000000..ae541a6
--- /dev/null
@@ -0,0 +1,22 @@
+# CIT_STRUCT_TM
+# ------------------
+# Figure out how to get the current GMT offset.  If `struct tm' has a
+# `tm_gmtoff' member, define `HAVE_STRUCT_TM_TM_GMTOFF'.  Otherwise, if the
+# external variable `timezone' is found, define `HAVE_TIMEZONE'.
+AC_DEFUN([CIT_STRUCT_TM],
+[AC_REQUIRE([AC_STRUCT_TM])dnl
+AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <sys/types.h>
+#include <$ac_cv_struct_tm>
+])
+if test "$ac_cv_member_struct_tm_tm_gmtoff" != yes; then
+  AC_CACHE_CHECK(for timezone, ac_cv_var_timezone,
+[AC_TRY_LINK(
+[#include <time.h>],
+[printf("%ld", (long)timezone);], ac_cv_var_timezone=yes, ac_cv_var_timezone=no)])
+  if test $ac_cv_var_timezone = yes; then
+    AC_DEFINE(HAVE_TIMEZONE, 1,
+              [Define if you don't have `tm_gmtoff' but do have the external
+               variable `timezone'.])
+  fi
+fi
+])# CIT_STRUCT_TM
index 1f3cf24b0e6a145ff89581218a4510c5af658ea1..df039663cd1fd6b02145b28d65a6cc8962a16cd0 100644 (file)
@@ -116,6 +116,7 @@ AC_PROG_INSTALL
 AC_PROG_YACC
 missing_dir=`cd $ac_aux_dir && pwd`
 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
+AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
 
 dnl Checks for system services.
 
@@ -366,7 +367,9 @@ AC_C_CONST
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
 AC_HEADER_TIME
-AC_STRUCT_TM
+
+dnl defined in acinclude.m4:
+CIT_STRUCT_TM
 
 dnl Check the size of various builtin types; see typesize.h (error)
 AC_CHECK_SIZEOF(char, 0)
index 8915afa88ee6e5befa9845053915a6de3767a751..5048ca6706f5764301d5c787a5e4cea07308da78 100644 (file)
@@ -51,7 +51,11 @@ void datestring(char *buf, time_t xtime, int which_format) {
        t = localtime(&xtime);
 
        /* Convert "seconds west of GMT" to "hours/minutes offset" */
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
        offset = t->tm_gmtoff;
+#else
+       offset = timezone;
+#endif
        if (offset > 0) {
                offsign = '-';
        }