This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: need to define _ISOC99_SOURCE


Well, this issue is somewhat too complex for me, I'd really like some
help at coding this into Autoconf.

Here is what I have done up to now.  I'd be happy if we could
regularly commit the improvements, instead of having a growing patch.

Here is a satisfying starting point?  OK to commit?

Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.55
diff -u -r1.55 aclang.m4
--- aclang.m4	2000/08/01 13:14:42	1.55
+++ aclang.m4	2000/08/01 14:13:22
@@ -508,6 +508,72 @@
 ])# AC_LANG_COMPILER_WORKS
 
 
+# _AC_COMPILER_ENABLE_EXTENSIONS
+# ------------------------------
+# Define all the symbols that might give access to useful features.
+# AIX needs _ALL_SOURCE.
+# GNU needs _GNU_SOURCE.
+# We use AC_DEFINE to set these symbols in confdefs.h too.
+define([_AC_COMPILER_ENABLE_EXTENSIONS],
+[AH_TEMPLATE([_GNU_SOURCE],
+             [Define to enable extensions from the GNU libc.])dnl
+AH_TEMPLATE([_ALL_SOURCE],
+            [Define where running AIX 3, where system headers sometimes
+             need this to enable some additional features.])dnl
+AH_TEMPLATE([__EXTENSIONS__],
+            [Solaris uses that symbol to define all extensions that are
+             not incompatible with whatever standard is in use.
+             __EXTENSIONS__ normally doesn't come into play, but
+             occasionally people mistakenly compile with gcc -ansi or
+             something like that, and this makes us immune to these
+             glitches.])dnl
+AH_TEMPLATE([_HPUX_SOURCE],
+            [FIXME: what's the documentation?])dnl
+AH_TEMPLATE([_XOPEN_SOURCE],
+            [If <stdio.h> declares ftello when _XOPEN_SOURCE is defined
+             to 500, but does not declare ftello otherwise, then you
+             should define _XOPEN_SOURCE.  This is needed for glibc
+             2.1.3; see the source code to AC_SYS_LARGEFILE.])dnl
+ac_found=false
+ac_save_CFLAGS=$CFLAGS
+for ac_flag in "" \
+               -D_GNU_SOURCE=1 \
+               -D_ALL_SOURCE=1 \
+               -D__EXTENSIONS__=1 \
+               -D_HPUX_SOURCE=1 \
+               -D_XOPEN_SOURCE=500; do
+  CFLAGS="$ac_save_CFLAGS $ac_flags"
+  AC_LINK_IFELSE([AC_LANG_SOURCE([#include <stdio.h>
+
+int
+main ()
+{
+  /* Check that fileno is properly declared.  This fileno test must
+     come first, as the other tests declare fileno as a side effect
+     if the compiler is pre-C99.  */
+  int i1 = !fileno;
+
+  /* Check that ordinary fileno works.  */
+  int i2 = fileno (stdin);
+
+  /* Check again with the fileno function, to make sure it gets linked in.  */
+#undef fileno
+  int i3 = fileno (stdin);
+
+  /* Make sure all the test values get used, so that references to
+     functions don't get optimized away.  */
+  return i1+i2+i3;
+}])],
+                 [ac_found=:; break])
+done
+if $ac_found && test -n "$ac_flag"; then
+  set X `IFS==; echo $ac_flag`; shift
+  AC_DEFINE_UNQUOTED($[1], $[2])
+fi
+CFLAGS=$ac_save_CFLAGS
+])
+
+
 # -------------------- #
 # 3b. The C compiler.  #
 # -------------------- #
@@ -579,6 +645,7 @@
 _AC_PROG_CC_G
 AC_EXPAND_ONCE([_AC_EXEEXT])
 AC_EXPAND_ONCE([_AC_OBJEXT])
+AC_EXPAND_ONCE([_AC_COMPILER_ENABLE_EXTENSIONS])
 AC_LANG_POP
 ])# AC_PROG_CC
 
@@ -771,6 +838,7 @@
 _AC_PROG_CXX_G
 AC_EXPAND_ONCE([_AC_EXEEXT])
 AC_EXPAND_ONCE([_AC_OBJEXT])
+AC_EXPAND_ONCE([_AC_COMPILER_ENABLE_EXTENSIONS])
 AC_LANG_POP
 ])# AC_PROG_CXX
 
@@ -868,9 +936,9 @@
 _AC_LANG_COMPILER_WORKS
 _AC_PROG_F77_GNU
 _AC_PROG_F77_G
-
 AC_EXPAND_ONCE([_AC_EXEEXT])
 AC_EXPAND_ONCE([_AC_OBJEXT])
+AC_EXPAND_ONCE([_AC_COMPILER_ENABLE_EXTENSIONS])
 AC_LANG_POP
 ])# AC_PROG_F77
 
Index: acspecific.m4
===================================================================
RCS file: /cvs/autoconf/acspecific.m4,v
retrieving revision 1.291
diff -u -r1.291 acspecific.m4
--- acspecific.m4	2000/08/01 11:14:48	1.291
+++ acspecific.m4	2000/08/01 14:13:36
@@ -1545,26 +1545,7 @@
 
 # AC_AIX
 # ------
-AC_DEFUN([AC_AIX],
-[AH_VERBATIM([_ALL_SOURCE],
-[/* Define if on AIX 3.
-   System headers sometimes define this.
-   We just want to avoid a redefinition error message.  */
-#ifndef _ALL_SOURCE
-# undef _ALL_SOURCE
-#endif])dnl
-AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
-AC_BEFORE([$0], [AC_TRY_RUN])dnl
-AC_MSG_CHECKING(for AIX)
-AC_EGREP_CPP(yes,
-[#ifdef _AIX
-  yes
-#endif
-],
-[AC_MSG_RESULT(yes)
-AC_DEFINE(_ALL_SOURCE)],
-AC_MSG_RESULT(no))
-])# AC_AIX
+AU_DEFUN([AC_AIX], [])
 
 
 # AC_MINIX

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]