From 34875e6487738a81c2b09979b804556bc8ea885b Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 4 Apr 2005 11:27:16 +0000 Subject: [PATCH] Add a check for providing a prototype for getopt() which is compatible with the one in include/getopt.h. If so then define HAVE_DECL_GETOPT. --- gprof/ChangeLog | 8 +++++ gprof/configure | 62 ++++++++++++++++++++++++++++++++++++++ gprof/configure.in | 10 +++++++ gprof/gconfig.in | 2 ++ ld/ChangeLog | 11 +++++++ ld/config.in | 2 ++ ld/configure | 69 ++++++++++++++++++++++++++++++++----------- ld/configure.in | 10 +++++++ ld/emultempl/elf32.em | 1 + ld/ldemul.c | 1 + ld/lexsup.c | 1 + 11 files changed, 159 insertions(+), 18 deletions(-) diff --git a/gprof/ChangeLog b/gprof/ChangeLog index 623d00c46bf..7df630e9796 100644 --- a/gprof/ChangeLog +++ b/gprof/ChangeLog @@ -1,3 +1,11 @@ +2005-04-04 Nick Clifton + + * configure.in: Add a check for providing a prototype + for getopt() which is compatible with the one in + include/getopt.h. If so then define HAVE_DECL_GETOPT. + * configure: Regenerate. + * gconfig.in (HAVE_DECL_GETOPT): Add. + 2005-03-29 Nick Clifton * po/de.po: Updated German translation. diff --git a/gprof/configure b/gprof/configure index e637b930fa9..76a1312dbe1 100755 --- a/gprof/configure +++ b/gprof/configure @@ -8287,6 +8287,68 @@ fi done +echo "$as_me:$LINENO: checking for a known getopt prototype in unistd.h" >&5 +echo $ECHO_N "checking for a known getopt prototype in unistd.h... $ECHO_C" >&6 +if test "${gprof_cv_decl_getopt_unistd_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +extern int getopt (int, char *const*, const char *); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + gprof_cv_decl_getopt_unistd_h=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gprof_cv_decl_getopt_unistd_h=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +echo "$as_me:$LINENO: result: $gprof_cv_decl_getopt_unistd_h" >&5 +echo "${ECHO_T}$gprof_cv_decl_getopt_unistd_h" >&6 +if test $gprof_cv_decl_getopt_unistd_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DECL_GETOPT 1 +_ACEOF + +fi + build_warnings="-W -Wall -Wstrict-prototypes -Wmissing-prototypes" # Check whether --enable-werror or --disable-werror was given. diff --git a/gprof/configure.in b/gprof/configure.in index 01dd81fefaa..e130b0d2ae0 100644 --- a/gprof/configure.in +++ b/gprof/configure.in @@ -32,6 +32,16 @@ AC_EXEEXT AC_CHECK_HEADERS(sys/gmon_out.h) +AC_MSG_CHECKING(for a known getopt prototype in unistd.h) +AC_CACHE_VAL(gprof_cv_decl_getopt_unistd_h, +[AC_TRY_COMPILE([#include ], [extern int getopt (int, char *const*, const char *);], +gprof_cv_decl_getopt_unistd_h=yes, gprof_cv_decl_getopt_unistd_h=no)]) +AC_MSG_RESULT($gprof_cv_decl_getopt_unistd_h) +if test $gprof_cv_decl_getopt_unistd_h = yes; then + AC_DEFINE([HAVE_DECL_GETOPT], 1, + [Is the prototype for getopt in in the expected format?]) +fi + build_warnings="-W -Wall -Wstrict-prototypes -Wmissing-prototypes" AC_ARG_ENABLE(werror, diff --git a/gprof/gconfig.in b/gprof/gconfig.in index d57b25834e1..1495bfeb39f 100644 --- a/gprof/gconfig.in +++ b/gprof/gconfig.in @@ -139,3 +139,5 @@ /* Define as 1 if you have gettext and don't want to use GNU gettext. */ #undef HAVE_GETTEXT +/* Is the prototype for getopt in in the expected format? */ +#undef HAVE_DECL_GETOPT diff --git a/ld/ChangeLog b/ld/ChangeLog index 4066d1e83ac..1455a1c65d2 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,14 @@ +2005-04-04 Nick Clifton + + * configure.in: Add a check for providing a prototype + for getopt() which is compatible with the one in + include/getopt.h. If so then define HAVE_DECL_GETOPT. + * configure: Regenerate. + * config.in (HAVE_DECL_GETOPT): Add. + * ldemul.c: Include config.h + * lexsup.c: Likewise. + * emultempl/elf32.sc: Likewise. + 2005-03-29 Alan Modra * emultempl/elf32.em (gld${EMULATION_NAME}_layout_sections_again): diff --git a/ld/config.in b/ld/config.in index 01ec4ff020d..a905962a2ed 100644 --- a/ld/config.in +++ b/ld/config.in @@ -175,3 +175,5 @@ /* Additional extension a shared object might have. */ #undef EXTRA_SHLIB_EXTENSION +/* Is the prototype for getopt in in the expected format? */ +#undef HAVE_DECL_GETOPT diff --git a/ld/configure b/ld/configure index bc7db6faeba..4cbd0114ccb 100755 --- a/ld/configure +++ b/ld/configure @@ -4824,6 +4824,39 @@ fi fi +echo $ac_n "checking for a known getopt prototype in unistd.h""... $ac_c" 1>&6 +echo "configure:4829: checking for a known getopt prototype in unistd.h" >&5 +if eval "test \"`echo '$''{'ld_cv_decl_getopt_unistd_h'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int main() { +extern int getopt (int, char *const*, const char *); +; return 0; } +EOF +if { (eval echo configure:4841: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ld_cv_decl_getopt_unistd_h=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ld_cv_decl_getopt_unistd_h=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ld_cv_decl_getopt_unistd_h" 1>&6 +if test $ld_cv_decl_getopt_unistd_h = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_DECL_GETOPT 1 +EOF + +fi + case "${host}" in *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*) @@ -4834,12 +4867,12 @@ EOF esac echo $ac_n "checking whether strstr must be declared""... $ac_c" 1>&6 -echo "configure:4838: checking whether strstr must be declared" >&5 +echo "configure:4871: checking whether strstr must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_strstr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4860,7 +4893,7 @@ int main() { char *(*pfn) = (char *(*)) strstr ; return 0; } EOF -if { (eval echo configure:4864: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4897: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_strstr=no else @@ -4881,12 +4914,12 @@ EOF fi echo $ac_n "checking whether free must be declared""... $ac_c" 1>&6 -echo "configure:4885: checking whether free must be declared" >&5 +echo "configure:4918: checking whether free must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_free'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4907,7 +4940,7 @@ int main() { char *(*pfn) = (char *(*)) free ; return 0; } EOF -if { (eval echo configure:4911: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4944: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_free=no else @@ -4928,12 +4961,12 @@ EOF fi echo $ac_n "checking whether sbrk must be declared""... $ac_c" 1>&6 -echo "configure:4932: checking whether sbrk must be declared" >&5 +echo "configure:4965: checking whether sbrk must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_sbrk'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4954,7 +4987,7 @@ int main() { char *(*pfn) = (char *(*)) sbrk ; return 0; } EOF -if { (eval echo configure:4958: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4991: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_sbrk=no else @@ -4975,12 +5008,12 @@ EOF fi echo $ac_n "checking whether getenv must be declared""... $ac_c" 1>&6 -echo "configure:4979: checking whether getenv must be declared" >&5 +echo "configure:5012: checking whether getenv must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_getenv'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -5001,7 +5034,7 @@ int main() { char *(*pfn) = (char *(*)) getenv ; return 0; } EOF -if { (eval echo configure:5005: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5038: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_getenv=no else @@ -5022,12 +5055,12 @@ EOF fi echo $ac_n "checking whether environ must be declared""... $ac_c" 1>&6 -echo "configure:5026: checking whether environ must be declared" >&5 +echo "configure:5059: checking whether environ must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_environ'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -5048,7 +5081,7 @@ int main() { char *(*pfn) = (char *(*)) environ ; return 0; } EOF -if { (eval echo configure:5052: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5085: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_environ=no else @@ -5076,19 +5109,19 @@ fi # constants, while still supporting pre-ANSI compilers which do not # support string concatenation. echo $ac_n "checking whether ANSI C string concatenation works""... $ac_c" 1>&6 -echo "configure:5080: checking whether ANSI C string concatenation works" >&5 +echo "configure:5113: checking whether ANSI C string concatenation works" >&5 if eval "test \"`echo '$''{'ld_cv_string_concatenation'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5125: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ld_cv_string_concatenation=yes else diff --git a/ld/configure.in b/ld/configure.in index 39d4d1277a6..db8861c8f86 100644 --- a/ld/configure.in +++ b/ld/configure.in @@ -138,6 +138,16 @@ AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h) AC_CHECK_FUNCS(sbrk realpath glob) AC_HEADER_DIRENT +AC_MSG_CHECKING(for a known getopt prototype in unistd.h) +AC_CACHE_VAL(ld_cv_decl_getopt_unistd_h, +[AC_TRY_COMPILE([#include ], [extern int getopt (int, char *const*, const char *);], +ld_cv_decl_getopt_unistd_h=yes, ld_cv_decl_getopt_unistd_h=no)]) +AC_MSG_RESULT($ld_cv_decl_getopt_unistd_h) +if test $ld_cv_decl_getopt_unistd_h = yes; then + AC_DEFINE([HAVE_DECL_GETOPT], 1, + [Is the prototype for getopt in in the expected format?]) +fi + BFD_BINARY_FOPEN BFD_NEED_DECLARATION(strstr) diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 3b9cdd78569..16464b54af0 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -35,6 +35,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define TARGET_IS_${EMULATION_NAME} +#include "config.h" #include "bfd.h" #include "sysdep.h" #include "libiberty.h" diff --git a/ld/ldemul.c b/ld/ldemul.c index b935e0a053d..45869d87709 100644 --- a/ld/ldemul.c +++ b/ld/ldemul.c @@ -20,6 +20,7 @@ along with GLD; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" #include "bfd.h" #include "sysdep.h" #include "getopt.h" diff --git a/ld/lexsup.c b/ld/lexsup.c index c3fb81e68b4..cf5f07ba4b8 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -20,6 +20,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" #include "bfd.h" #include "sysdep.h" #include "libiberty.h" -- 2.30.2