Patch installed for autoconf cleanup (part 4)
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Tue Apr 25 17:32:00 GMT 2000
WRT http://gcc.gnu.org/ml/gcc-patches/2000-04/msg00948.html , I have
installed the following patch which improves the
gcc_AC_NEED_DECLARATION{S} macros. It does the following:
1. Modify the gcc_AC_NEED_DECLARATION{S} macros to more closely
follow the style of AC_CHECK_FUNC{S} WRT optional ACTION parameters
2. Require the caller to pass the particular INCLUDES to search when
checking whether a decl exists. In this case I pass in system.h so
the configure check conditions exactly match the bootstrap conditions.
3. Add a small hack into the macro so we don't have to manually
insert entries into acconfig.h for each decl we check.
4. Minor cleanup.
2000-04-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* aclocal.m4 (gcc_AC_NEED_DECLARATION): This macro now requires
INCLUDES to search and does not provide any of its own. Also it
now accepts optional ACTION-IF-NEEDED and ACTION-IF-NOT-NEEDED
parameters. Also it does not call AC_DEFINE.
(gcc_AC_NEED_DECLARATIONS): Likewise. Also this macro now calls
AC_DEFINE and provides for automatic entries for autoheader.
(gcc_AC_FUNC_PRINTF_PTR): Cleanup C code in test.
* configure.in (gcc_AC_NEED_DECLARATIONS): Save and restore CFLAGS
so we can pass -I flags and include gansidecl.h/system.h in this
test.
* acconfig.h: Delete all NEED_DECLARATION_* entries.
diff -rup orig/egcs-CVS20000425/gcc/aclocal.m4 egcs-CVS20000425/gcc/aclocal.m4
--- orig/egcs-CVS20000425/gcc/aclocal.m4 Mon Apr 24 17:14:24 2000
+++ egcs-CVS20000425/gcc/aclocal.m4 Tue Apr 25 13:27:39 2000
@@ -10,59 +10,44 @@ fi
])
dnl See whether we need a declaration for a function.
-dnl gcc_AC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
+dnl The result is highly dependent on the INCLUDES passed in, so make sure
+dnl to use a different cache variable name in this macro if it is invoked
+dnl in a different context somewhere else.
+dnl gcc_AC_NEED_DECLARATION(FUNCTION, INCLUDES,
+dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED]])
AC_DEFUN(gcc_AC_NEED_DECLARATION,
[AC_MSG_CHECKING([whether $1 must be declared])
AC_CACHE_VAL(gcc_cv_decl_needed_$1,
-[AC_TRY_COMPILE([
-#include <stdio.h>
-#ifdef STRING_WITH_STRINGS
-# include <string.h>
-# include <strings.h>
-#else
-# ifdef HAVE_STRING_H
-# include <string.h>
-# else
-# ifdef HAVE_STRINGS_H
-# include <strings.h>
-# endif
-# endif
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifndef HAVE_RINDEX
-#ifndef rindex
-#define rindex strrchr
-#endif
-#endif
-#ifndef HAVE_INDEX
-#ifndef index
-#define index strchr
-#endif
-#endif
-$2],
-[char *(*pfn) = (char *(*)) $1],
-eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
+[AC_TRY_COMPILE([$2],
+[#ifndef $1
+char *(*pfn) = (char *(*)) $1 ;
+#endif], eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then
- AC_MSG_RESULT(yes)
- gcc_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- AC_DEFINE_UNQUOTED($gcc_tr_decl)
+ AC_MSG_RESULT(yes) ; ifelse([$3], , :, [$3])
else
- AC_MSG_RESULT(no)
+ AC_MSG_RESULT(no) ; ifelse([$4], , :, [$4])
fi
])dnl
dnl Check multiple functions to see whether each needs a declaration.
-dnl gcc_AC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
+dnl Arrange to define NEED_DECLARATION_<FUNCTION> if appropriate.
+dnl gcc_AC_NEED_DECLARATIONS(FUNCTION... , INCLUDES,
+dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED]])
AC_DEFUN(gcc_AC_NEED_DECLARATIONS,
[for ac_func in $1
do
-gcc_AC_NEED_DECLARATION($ac_func, $2)
+gcc_AC_NEED_DECLARATION($ac_func, [$2],
+[changequote(, )dnl
+ ac_tr_decl=NEED_DECLARATION_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+changequote([, ])dnl
+ AC_DEFINE_UNQUOTED($ac_tr_decl) $3], $4)
done
+dnl Automatically generate config.h entries via autoheader.
+if test x = y ; then
+ patsubst(translit([$1], [a-z], [A-Z]), [\w+],
+ AC_DEFINE([NEED_DECLARATION_\&], 1,
+ [Define if you need to provide a declaration for this function.]))dnl
+fi
])
dnl Check if we have vprintf and possibly _doprnt.
@@ -87,13 +72,13 @@ AC_DEFUN(gcc_AC_FUNC_PRINTF_PTR,
gcc_cv_func_printf_ptr,
[AC_TRY_RUN([#include <stdio.h>
-main()
+int main()
{
char buf[64];
char *p = buf, *q = NULL;
sprintf(buf, "%p", p);
sscanf(buf, "%p", &q);
- exit (p != q);
+ return (p != q);
}], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
gcc_cv_func_printf_ptr=no)
rm -f core core.* *.core])
diff -rup orig/egcs-CVS20000425/gcc/configure.in egcs-CVS20000425/gcc/configure.in
--- orig/egcs-CVS20000425/gcc/configure.in Tue Apr 25 16:25:24 2000
+++ egcs-CVS20000425/gcc/configure.in Tue Apr 25 13:44:10 2000
@@ -446,22 +446,26 @@ AC_FUNC_VFORK
AC_FUNC_MMAP_ANYWHERE
AC_FUNC_MMAP_FILE
+# We will need to find libiberty.h and ansidecl.h
+saved_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include"
gcc_AC_NEED_DECLARATIONS(bcopy bzero bcmp \
index rindex getenv atol sbrk abort atof getcwd getwd \
- strsignal putc_unlocked fputs_unlocked strstr environ)
-
-gcc_AC_NEED_DECLARATIONS(malloc realloc calloc free, [
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-])
+ strsignal putc_unlocked fputs_unlocked strstr environ \
+ malloc realloc calloc free, [
+#include "gansidecl.h"
+#include "system.h"])
gcc_AC_NEED_DECLARATIONS(getrlimit setrlimit getrusage, [
-#include <sys/types.h>
+#include "gansidecl.h"
+#include "system.h"
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
])
+
+# Restore CFLAGS from before the gcc_AC_NEED_DECLARATIONS tests.
+CFLAGS="$saved_CFLAGS"
# mkdir takes a single argument on some systems.
gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG
diff -rup orig/egcs-CVS20000425/gcc/acconfig.h egcs-CVS20000425/gcc/acconfig.h
--- orig/egcs-CVS20000425/gcc/acconfig.h Tue Apr 25 16:25:24 2000
+++ egcs-CVS20000425/gcc/acconfig.h Tue Apr 25 13:26:08 2000
@@ -7,6 +7,12 @@
/* Define as 1 if you have gettext and don't want to use GNU gettext. */
#undef HAVE_GETTEXT
+/* Define if your locale.h file contains LC_MESSAGES. */
+#undef HAVE_LC_MESSAGES
+
+/* Define as 1 if you have the stpcpy function. */
+#undef HAVE_STPCPY
+
/* Define if your assembler supports specifying the maximum number
of bytes to skip when using the GAS .p2align command. */
#undef HAVE_GAS_MAX_SKIP_P2ALIGN
@@ -16,83 +22,5 @@
/* Define if your assembler uses the old HImode fild and fist notation. */
#undef HAVE_GAS_FILDS_FISTS
-
-/* Define if your locale.h file contains LC_MESSAGES. */
-#undef HAVE_LC_MESSAGES
-
-/* Define as 1 if you have the stpcpy function. */
-#undef HAVE_STPCPY
-
-/* Whether malloc must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_MALLOC
-
-/* Whether realloc must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_REALLOC
-
-/* Whether calloc must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_CALLOC
-
-/* Whether free must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_FREE
-
-/* Whether bcopy must be declared even if <string.h> is included. */
-#undef NEED_DECLARATION_BCOPY
-
-/* Whether bcmp must be declared even if <string.h> is included. */
-#undef NEED_DECLARATION_BCMP
-
-/* Whether bzero must be declared even if <string.h> is included. */
-#undef NEED_DECLARATION_BZERO
-
-/* Whether index must be declared even if <string.h> is included. */
-#undef NEED_DECLARATION_INDEX
-
-/* Whether rindex must be declared even if <string.h> is included. */
-#undef NEED_DECLARATION_RINDEX
-
-/* Whether getenv must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_GETENV
-
-/* Whether atol must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_ATOL
-
-/* Whether atof must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_ATOF
-
-/* Whether sbrk must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_SBRK
-
-/* Whether abort must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_ABORT
-
-/* Whether strsignal must be declared even if <string.h> is included. */
-#undef NEED_DECLARATION_STRSIGNAL
-
-/* Whether strstr must be declared even if <string.h> is included. */
-#undef NEED_DECLARATION_STRSTR
-
-/* Whether getcwd must be declared even if <unistd.h> is included. */
-#undef NEED_DECLARATION_GETCWD
-
-/* Whether getwd must be declared even if <unistd.h> is included. */
-#undef NEED_DECLARATION_GETWD
-
-/* Whether getrlimit must be declared even if <sys/resource.h> is included. */
-#undef NEED_DECLARATION_GETRLIMIT
-
-/* Whether setrlimit must be declared even if <sys/resource.h> is included. */
-#undef NEED_DECLARATION_SETRLIMIT
-
-/* Whether getrusage must be declared even if <sys/resource.h> is included. */
-#undef NEED_DECLARATION_GETRUSAGE
-
-/* Whether putc_unlocked must be declared even if <stdio.h> is included. */
-#undef NEED_DECLARATION_PUTC_UNLOCKED
-
-/* Whether fputs_unlocked must be declared even if <stdio.h> is included. */
-#undef NEED_DECLARATION_FPUTS_UNLOCKED
-
-/* Whether environ must be declared. */
-#undef NEED_DECLARATION_ENVIRON
@TOP@
More information about the Gcc-patches
mailing list