This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gas configure cleanup


While I was removing BFD_NEED_DECLARATION, Jim Wilson mentioned that it
would also be good to also get rid of GAS_CHECK_DECL_NEEDED and replace
it with AC_CHECK_DECLS.  This patch is removes GAS_CHECK_DECL_NEEDED.

There were a couple of complications with this, one involving errno and
one involving string.h/strings.h/ffs().  In both cases I made changes to
make gas/configure and gas/as.h look more like bfd/configure and
bfd/sysdep.h under the assumption that what compiles for bfd should be
OK for gas as well.

For errno.h, bdf/sysdep.h includes this header with no check for
existence and then has an extern for errno if errno is not defined or if
both _MSC_VER and _INC_ERRNO are not defined.  I changed as.h to do the
same and removed all errno checking from gas/configure.in.

For string.h/strings.h, bfd uses the macro ACX_HEADER_STRING to see if
it can include both and I made gas do the same.  This was needed for
HP-UX because we have strings.h but ffs() is only defined by string.h
and with the AC_CHECK_HEADERS test we were finding the ffs() declaration
in string.h but not including string.h because we included strings.h
instead.  This change allows us to include both when it is safe.

I also removed a redundent include of errno.h from messages.c (which
already got it from as.h).

Tested on HP-PA HP-UX and IA64 Linux.

Ok for checkin?



gas/ChangeLog

2005-07-14  Steve Ellcey  <sje@cup.hp.com>

	* acinclude.m4: Include ../config/acx.m4.
	* configure.in: Replace GAS_CHECK_DECL_NEEDED with AC_CHECK_DECLS.
	Call ACX_HEADER_STRING.
	(gas_test_headers): Remove.
	* configure: Regenerate.
	* config.in: Regenerate.
	* as.h: Change includes (string.h, strings.h , errno.h)
	Replace NEED_DECLARATION_* with HAVE_DECL_*.
	* messages.c: Remove include of errno.h.

*** src.orig/gas/acinclude.m4	Thu Jul 14 10:54:45 2005
--- src/gas/acinclude.m4	Thu Jul 14 10:54:26 2005
***************
*** 1,3 ****
--- 1,4 ----
+ sinclude(../config/acx.m4)
  sinclude(../bfd/warning.m4)
  
  dnl GAS_CHECK_DECL_NEEDED(name, typedefname, typedef, headers)
*** src.orig/gas/configure.in	Thu Jul 14 10:54:45 2005
--- src/gas/configure.in	Thu Jul 14 10:54:26 2005
*************** CY_GNU_GETTEXT
*** 621,627 ****
  AM_MAINTAINER_MODE
  AC_EXEEXT
  
! AC_CHECK_HEADERS(string.h stdlib.h memory.h strings.h unistd.h stdarg.h varargs.h errno.h sys/types.h)
  
  # Put this here so that autoconf's "cross-compiling" message doesn't confuse
  # people who are not cross-compiling but are compiling cross-assemblers.
--- 621,628 ----
  AM_MAINTAINER_MODE
  AC_EXEEXT
  
! AC_CHECK_HEADERS(string.h stdlib.h memory.h strings.h unistd.h stdarg.h varargs.h sys/types.h)
! ACX_HEADER_STRING
  
  # Put this here so that autoconf's "cross-compiling" message doesn't confuse
  # people who are not cross-compiling but are compiling cross-assemblers.
*************** esac
*** 658,693 ****
  # working properly!
  GAS_WORKING_ASSERT
  
- # On some systems, the system header files may not declare malloc, realloc,
- # and free.  There are places where gas needs these functions to have been
- # declared -- such as when taking their addresses.
- gas_test_headers="
- #ifdef HAVE_MEMORY_H
- #include <memory.h>
- #endif
- #ifdef HAVE_STRING_H
- #include <string.h>
- #else
- #ifdef HAVE_STRINGS_H
- #include <strings.h>
- #endif
- #endif
- #ifdef HAVE_STDLIB_H
- #include <stdlib.h>
- #endif
- #ifdef HAVE_UNISTD_H
- #include <unistd.h>
- #endif
- "
- 
- # Does errno.h declare errno, or do we have to add a separate declaration
- # for it?
- GAS_CHECK_DECL_NEEDED(errno, f, int f, [
- #ifdef HAVE_ERRNO_H
- #include <errno.h>
- #endif
- ])
- 
  AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
  AC_CACHE_VAL(gas_cv_decl_getopt_unistd_h,
  [AC_TRY_COMPILE([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);],
--- 659,664 ----
*************** if test $gas_cv_decl_getopt_unistd_h = y
*** 698,709 ****
  	    [Is the prototype for getopt in <unistd.h> in the expected format?])
  fi
  
! GAS_CHECK_DECL_NEEDED(environ, f, char **f, $gas_test_headers)
! GAS_CHECK_DECL_NEEDED(ffs, f, int (*f)(int), $gas_test_headers)
! GAS_CHECK_DECL_NEEDED(free, f, void (*f)(), $gas_test_headers)
! GAS_CHECK_DECL_NEEDED(malloc, f, char *(*f)(), $gas_test_headers)
! GAS_CHECK_DECL_NEEDED(sbrk, f, char *(*f)(), $gas_test_headers)
! GAS_CHECK_DECL_NEEDED(strstr, f, char *(*f)(), $gas_test_headers)
  
  dnl This must come last.
  
--- 669,675 ----
  	    [Is the prototype for getopt in <unistd.h> in the expected format?])
  fi
  
! AC_CHECK_DECLS([environ, ffs, free, malloc, realloc, sbrk, strstr])
  
  dnl This must come last.
  
*** src.orig/gas/as.h	Thu Jul 14 10:54:45 2005
--- src/gas/as.h	Thu Jul 14 10:54:26 2005
*************** extern void *alloca ();
*** 72,77 ****
--- 72,82 ----
  
  /* System include files first...  */
  #include <stdio.h>
+ 
+ #ifdef STRING_WITH_STRINGS
+ #include <string.h>
+ #include <strings.h>
+ #else
  #ifdef HAVE_STRING_H
  #include <string.h>
  #else
*************** extern void *alloca ();
*** 79,84 ****
--- 84,91 ----
  #include <strings.h>
  #endif
  #endif
+ #endif
+ 
  #ifdef HAVE_STDLIB_H
  #include <stdlib.h>
  #endif
*************** extern void *alloca ();
*** 126,149 ****
  #endif
  #endif /* !__MWERKS__ */
  
  /* Other stuff from config.h.  */
! #ifdef NEED_DECLARATION_ENVIRON
  extern char **environ;
  #endif
! #ifdef NEED_DECLARATION_ERRNO
! extern int errno;
! #endif
! #ifdef NEED_DECLARATION_FFS
  extern int ffs (int);
  #endif
! #ifdef NEED_DECLARATION_FREE
  extern void free ();
  #endif
! #ifdef NEED_DECLARATION_MALLOC
  extern PTR malloc ();
  extern PTR realloc ();
  #endif
! #ifdef NEED_DECLARATION_STRSTR
  extern char *strstr ();
  #endif
  
--- 133,160 ----
  #endif
  #endif /* !__MWERKS__ */
  
+ #include <errno.h>
+ #if !(defined(errno) || defined(_MSC_VER) && defined(_INC_ERRNO))
+ extern int errno;
+ #endif
+ 
  /* Other stuff from config.h.  */
! #if !HAVE_DECL_ENVIRON
  extern char **environ;
  #endif
! #if !HAVE_DECL_FFS
  extern int ffs (int);
  #endif
! #if !HAVE_DECL_FREE
  extern void free ();
  #endif
! #if !HAVE_DECL_MALLOC
  extern PTR malloc ();
+ #endif
+ #if !HAVE_DECL_REALLOC
  extern PTR realloc ();
  #endif
! #if !HAVE_DECL_STRSTR
  extern char *strstr ();
  #endif
  
*** src.orig/gas/messages.c	Thu Jul 14 10:54:45 2005
--- src/gas/messages.c	Thu Jul 14 10:54:26 2005
***************
*** 22,30 ****
  #include "as.h"
  
  #include <stdio.h>
- #ifdef HAVE_ERRNO_H
- #include <errno.h>
- #endif
  
  #ifdef USE_STDARG
  #include <stdarg.h>
--- 22,27 ----


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