This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Patch to cleanup various autoconf macro issues


	This patch cleans up various autoconf macro issues:

1.  Rename various macros to AC_GCC_* because autoconf does a check on
anything starting with AC_*.

2.  Call AC_DEFINE with 3 arguments so that we don't have to add
entries by hand into acconfig.h.

3.  Fix the NEED_DECLARATION macros to more closely follow the
CHECK_FUNCS style of allowing actions if needed or not-needed.  Also
don't have these macros provide include directories to search.  Pass
in system.h instead so that the include dirs searched exactly match
those used during compilation.  Finally, provide a machanism for
automatically creating entries via autoheader instead of adding them
by hand in acconfig.h.

4.  Other minor cleanups...


Bootstrapped on OSF4 and Irix6, okay to install?

		Thanks,
		--Kaveh



1999-09-23  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* aclocal.m4 (AC_GCC_HEADER_STRING): Renamed from GCC_HEADER_STRING.
	Supply AC_DEFINE with 3 arguments.
	
	(AC_GCC_NEED_DECLARATION): Renamed from GCC_NEED_DECLARATION.
	Macro now requires include files to search and does not provide
	any of its own.  Also newly accepts optional ACTION-IF-NEEDED and
	ACTION-IF-NOT-NEEDED parameters.  Also does not call AC_DEFINE.
	
	(AC_GCC_NEED_DECLARATIONS): Renamed from GCC_NEED_DECLARATIONS.
	Macro now requires include files to search and does not provide
	any of its own.  Also newly accepts optional ACTION-IF-NEEDED and
	ACTION-IF-NOT-NEEDED parameters.  Also now calls AC_DEFINE and
	provides for automatic entries for autoheader.

	(AC_GCC_FUNC_VFPRINTF_DOPRNT): Renamed from GCC_FUNC_VFPRINTF_DOPRNT.

	(AC_GCC_FUNC_PRINTF_PTR): Renamed from GCC_FUNC_PRINTF_PTR.
	Declare main returns int, call return not exit from main in test.
	Supply AC_DEFINE with 3 arguments.

	(AC_GCC_PROG_LN): Renamed from GCC_PROG_LN.

	(AC_GCC_C_VOLATILE): Renamed from GCC_C_VOLATILE.
	Supply AC_DEFINE with 3 arguments.
	
	(AC_GCC_FUNC_MKDIR_TAKES_ONE_ARG): Renamed from
	GCC_FUNC_MKDIR_TAKES_ONE_ARG.  Supply AC_DEFINE with 3 arguments.

	(AC_GCC_PROG_INSTALL): Renamed from EGCS_PROG_INSTALL.

	
	* configure.in: Supply AC_DEFINE with 3 arguments.
	Call the new AC_GCC_* names of autoconf macros.
	Update invocation of AC_GCC_NEED_DECLARATIONS to pass in system.h
	during checks so that the headers searched in the autoconf test
	exactly match the headers used during complation.
	
	
	* acconfig.h: Remove entries now obsoleted by 3 argument calls to
	AC_DEFINE.


	
diff -rup orig/egcs-CVS19990919/gcc/aclocal.m4 egcs-CVS19990919/gcc/aclocal.m4
--- orig/egcs-CVS19990919/gcc/aclocal.m4	Wed Sep 15 09:46:01 1999
+++ egcs-CVS19990919/gcc/aclocal.m4	Sun Sep 19 16:27:31 1999
@@ -1,69 +1,53 @@
 dnl See whether we can include both string.h and strings.h.
-AC_DEFUN(GCC_HEADER_STRING,
+AC_DEFUN(AC_GCC_HEADER_STRING,
 [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
   gcc_cv_header_string,
 [AC_TRY_COMPILE([#include <string.h>
 #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
 if test $gcc_cv_header_string = yes; then
-  AC_DEFINE(STRING_WITH_STRINGS)
+  AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
 fi
 ])
 
 dnl See whether we need a declaration for a function.
-dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
-AC_DEFUN(GCC_NEED_DECLARATION,
+dnl Note, we write this as "need" not "have" on purpose.
+dnl Also we don't cache the result since its highly dependent on the
+dnl INCLUDES passed in, which may not be the same from another invocation.
+dnl AC_GCC_NEED_DECLARATION(FUNCTION , INCLUDES,
+dnl     [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED]])
+AC_DEFUN(AC_GCC_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
-#define rindex strrchr
-#endif
-#ifndef HAVE_INDEX
-#define index strchr
-#endif
-$2],
-[char *(*pfn) = (char *(*)) $1],
-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)
-else
-  AC_MSG_RESULT(no)
-fi
-])dnl
+AC_TRY_COMPILE([$2],
+[#ifndef $1
+char *(*pfn) = (char *(*)) $1
+#endif], AC_MSG_RESULT(no) ; ifelse([$4], , :, [$4]),
+  AC_MSG_RESULT(yes) ; ifelse([$3], , :, [$3])
+)])dnl
 
 dnl Check multiple functions to see whether each needs a declaration.
-dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
-AC_DEFUN(GCC_NEED_DECLARATIONS,
+dnl Define NEED_DECLARATION_<FUNCTION> as appropriate.
+dnl AC_GCC_NEED_DECLARATIONS(FUNCTION... , INCLUDES,
+dnl     [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED]])
+AC_DEFUN(AC_GCC_NEED_DECLARATIONS,
 [for ac_func in $1
 do
-GCC_NEED_DECLARATION($ac_func, $2)
+AC_GCC_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.
 dnl Note autoconf checks for vprintf even though we care about vfprintf.
-AC_DEFUN(GCC_FUNC_VFPRINTF_DOPRNT,
+AC_DEFUN(AC_GCC_FUNC_VFPRINTF_DOPRNT,
 [AC_FUNC_VPRINTF
 vfprintf=
 doprint=
@@ -78,28 +62,28 @@ AC_SUBST(doprint)
 ])    
 
 dnl See if the printf functions in libc support %p in format strings.
-AC_DEFUN(GCC_FUNC_PRINTF_PTR,
+AC_DEFUN(AC_GCC_FUNC_PRINTF_PTR,
 [AC_CACHE_CHECK(whether the printf functions support %p,
   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])
 if test $gcc_cv_func_printf_ptr = yes ; then
-  AC_DEFINE(HAVE_PRINTF_PTR)
+  AC_DEFINE(HAVE_PRINTF_PTR, 1, [Define if printf supports "%p".])
 fi
 ])
 
 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
-AC_DEFUN(GCC_PROG_LN_S,
+AC_DEFUN(AC_GCC_PROG_LN_S,
 [AC_MSG_CHECKING(whether ln -s works)
 AC_CACHE_VAL(gcc_cv_prog_LN_S,
 [rm -f conftestdata_t
@@ -131,7 +115,7 @@ AC_SUBST(LN_S)dnl
 ])
 
 dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
-AC_DEFUN(GCC_PROG_LN,
+AC_DEFUN(AC_GCC_PROG_LN,
 [AC_MSG_CHECKING(whether ln works)
 AC_CACHE_VAL(gcc_cv_prog_LN,
 [rm -f conftestdata_t
@@ -163,12 +147,12 @@ AC_SUBST(LN)dnl
 ])
 
 dnl See whether the stage1 host compiler accepts the volatile keyword.
-AC_DEFUN(GCC_C_VOLATILE,
+AC_DEFUN(AC_GCC_C_VOLATILE,
 [AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile,
 [AC_TRY_COMPILE(, [volatile int foo;],
         gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)])
 if test $gcc_cv_c_volatile = yes ; then
-  AC_DEFINE(HAVE_VOLATILE)
+  AC_DEFINE(HAVE_VOLATILE, 1, [Define if your compiler understands volatile.])
 fi
 ])
 
@@ -193,7 +177,7 @@ fi
 
 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
 dnl of the usual 2.
-AC_DEFUN(GCC_FUNC_MKDIR_TAKES_ONE_ARG,
+AC_DEFUN(AC_GCC_FUNC_MKDIR_TAKES_ONE_ARG,
 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
 [AC_TRY_COMPILE([
 #include <sys/types.h>
@@ -208,11 +192,11 @@ AC_DEFUN(GCC_FUNC_MKDIR_TAKES_ONE_ARG,
 #endif], [mkdir ("foo", 0);], 
         gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
-  AC_DEFINE(MKDIR_TAKES_ONE_ARG)
+  AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
 fi
 ])
 
-AC_DEFUN(EGCS_PROG_INSTALL,
+AC_DEFUN(AC_GCC_PROG_INSTALL,
 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
diff -rup orig/egcs-CVS19990919/gcc/configure.in egcs-CVS19990919/gcc/configure.in
--- orig/egcs-CVS19990919/gcc/configure.in	Sun Sep 19 16:22:07 1999
+++ egcs-CVS19990919/gcc/configure.in	Sun Sep 19 16:27:35 1999
@@ -101,7 +101,7 @@ if test x"${DEFAULT_LINKER+set}" = x"set
   elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
     gnu_ld_flag=yes
   fi
-  AC_DEFINE_UNQUOTED(DEFAULT_LINKER,"$DEFAULT_LINKER")
+  AC_DEFINE_UNQUOTED(DEFAULT_LINKER,"$DEFAULT_LINKER", [Define to enable the use of a default linker.])
 fi
 
 # With GNU as
@@ -119,7 +119,7 @@ if test x"${DEFAULT_ASSEMBLER+set}" = x"
   elif $DEFAULT_ASSEMBLER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
     gas_flag=yes
   fi
-  AC_DEFINE_UNQUOTED(DEFAULT_ASSEMBLER,"$DEFAULT_ASSEMBLER")
+  AC_DEFINE_UNQUOTED(DEFAULT_ASSEMBLER,"$DEFAULT_ASSEMBLER", [Define to enable the use of a default assembler.])
 fi
 
 # With stabs
@@ -178,7 +178,7 @@ fi
 AC_ARG_ENABLE(checking,
 [  --enable-checking       enable expensive run-time checks.],
 [case "${enableval}" in
-yes)	AC_DEFINE(ENABLE_CHECKING) ;;
+yes)	AC_DEFINE(ENABLE_CHECKING, 1, [Define if you want expensive run-time checks.]) ;;
 no)	;;
 *)	AC_MSG_ERROR(bad value ${enableval} given for checking option) ;;
 esac])
@@ -323,16 +323,16 @@ fi
 # Find some useful tools
 AC_PROG_AWK
 AC_PROG_LEX
-GCC_PROG_LN
-GCC_PROG_LN_S
-GCC_C_VOLATILE
+AC_GCC_PROG_LN
+AC_GCC_PROG_LN_S
+AC_GCC_C_VOLATILE
 AC_PROG_RANLIB
 AC_PROG_YACC
-EGCS_PROG_INSTALL
+AC_GCC_PROG_INSTALL
 
 AC_HEADER_STDC
 AC_HEADER_TIME
-GCC_HEADER_STRING
+AC_GCC_HEADER_STRING
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h \
 		 fcntl.h unistd.h stab.h sys/file.h sys/time.h \
@@ -362,7 +362,7 @@ AC_CACHE_VAL(gcc_cv_header_inttypes_h,
   gcc_cv_header_inttypes_h=no)])
 AC_MSG_RESULT($gcc_cv_header_inttypes_h)
 if test $gcc_cv_header_inttypes_h = yes; then
-  AC_DEFINE(HAVE_INTTYPES_H)
+  AC_DEFINE(HAVE_INTTYPES_H, 1, [Define if you have a working <inttypes.h> header file.])
 fi
 
 AC_CHECK_FUNCS(strtoul bsearch strerror putenv popen bcopy bzero bcmp \
@@ -373,8 +373,8 @@ AC_CHECK_FUNCS(strtoul bsearch strerror 
 # Make sure wchar_t is available
 #AC_CHECK_TYPE(wchar_t, unsigned int)
 
-GCC_FUNC_VFPRINTF_DOPRNT
-GCC_FUNC_PRINTF_PTR
+AC_GCC_FUNC_VFPRINTF_DOPRNT
+AC_GCC_FUNC_PRINTF_PTR
 
 case "${host}" in
 *-*-uwin*)
@@ -386,27 +386,28 @@ case "${host}" in
 esac
 AC_FUNC_VFORK
 
-GCC_NEED_DECLARATIONS(bcopy bzero bcmp \
-	index rindex getenv atol sbrk abort atof strerror getcwd getwd \
-	strsignal putc_unlocked fputs_unlocked strstr)
-
-GCC_NEED_DECLARATIONS(malloc realloc calloc free, [
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-])
+# System.h will need to find libiberty.h and ansidecl.h
+saved_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -I${srcdir}/../include"
+AC_GCC_NEED_DECLARATIONS(bcopy bzero bcmp index rindex getenv atol sbrk abort \
+	atof strerror getcwd getwd strsignal putc_unlocked fputs_unlocked \
+	strstr malloc realloc calloc free,
+[#include "system.h"])
 
-GCC_NEED_DECLARATIONS(getrlimit setrlimit getrusage, [
-#include <sys/types.h>
+AC_GCC_NEED_DECLARATIONS(getrlimit setrlimit getrusage, [
+#include "system.h"
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
 ])
 
+# Restore CFLAGS from before the AC_GCC_NEED_DECLARATIONS tests.
+CFLAGS="$saved_CFLAGS"
+
 AC_DECL_SYS_SIGLIST
 
 # mkdir takes a single argument on some systems. 
-GCC_FUNC_MKDIR_TAKES_ONE_ARG
+AC_GCC_FUNC_MKDIR_TAKES_ONE_ARG
 
 # File extensions
 manext='.1'
diff -rup orig/egcs-CVS19990919/gcc/acconfig.h egcs-CVS19990919/gcc/acconfig.h
--- orig/egcs-CVS19990919/gcc/acconfig.h	Sun Sep 19 15:54:15 1999
+++ egcs-CVS19990919/gcc/acconfig.h	Sun Sep 19 15:53:39 1999
@@ -1,12 +1,3 @@
-/* Define if you can safely include both <string.h> and <strings.h>.  */
-#undef STRING_WITH_STRINGS
-
-/* Define if printf supports "%p".  */
-#undef HAVE_PRINTF_PTR
-
-/* Define if you want expensive run-time checks. */
-#undef ENABLE_CHECKING
-
 /* Define to 1 if NLS is requested.  */
 #undef ENABLE_NLS
 
@@ -23,9 +14,6 @@
 /* Define as 1 if you have gettext and don't want to use GNU gettext.  */
 #undef HAVE_GETTEXT
 
-/* Define if your compiler understands volatile.  */
-#undef HAVE_VOLATILE
-
 /* 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
@@ -46,95 +34,11 @@
 /* Define if your assembler uses the old HImode fild and fist notation.  */
 #undef HAVE_GAS_FILDS_FISTS
 
-/* Define if you have a working <inttypes.h> header file.  */
-#undef HAVE_INTTYPES_H
-
 /* 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 strerror must be declared even if <string.h> is included.  */
-#undef NEED_DECLARATION_STRERROR
-
-/* 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
-
-/* Define to enable the use of a default assembler. */
-#undef DEFAULT_ASSEMBLER
-
-/* Define to enable the use of a default linker. */
-#undef DEFAULT_LINKER
-
-/* Define if host mkdir takes a single argument. */
-#undef MKDIR_TAKES_ONE_ARG
 
 /* Define to the name of the distribution.  */
 #undef PACKAGE


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