aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2005-04-04 11:27:16 +0000
committerNick Clifton <nickc@redhat.com>2005-04-04 11:27:16 +0000
commit34875e6487738a81c2b09979b804556bc8ea885b (patch)
tree35f8536360eb5884dbf3706d1a550ee0f933acdf /ld
parent661f7c357e34dee7936489da7a385c29a1343d02 (diff)
downloadfsf-binutils-gdb-34875e6487738a81c2b09979b804556bc8ea885b.zip
fsf-binutils-gdb-34875e6487738a81c2b09979b804556bc8ea885b.tar.gz
fsf-binutils-gdb-34875e6487738a81c2b09979b804556bc8ea885b.tar.bz2
Add a check for <unistd.h> providing a prototype for getopt() which is compatible
with the one in include/getopt.h. If so then define HAVE_DECL_GETOPT.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog11
-rw-r--r--ld/config.in2
-rwxr-xr-xld/configure69
-rw-r--r--ld/configure.in10
-rw-r--r--ld/emultempl/elf32.em1
-rw-r--r--ld/ldemul.c1
-rw-r--r--ld/lexsup.c1
7 files changed, 77 insertions, 18 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 4066d1e..1455a1c 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,14 @@
+2005-04-04 Nick Clifton <nickc@redhat.com>
+
+ * configure.in: Add a check for <unistd.h> 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 <amodra@bigpond.net.au>
* emultempl/elf32.em (gld${EMULATION_NAME}_layout_sections_again):
diff --git a/ld/config.in b/ld/config.in
index 01ec4ff..a905962 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 <unistd.h> in the expected format? */
+#undef HAVE_DECL_GETOPT
diff --git a/ld/configure b/ld/configure
index bc7db6f..4cbd011 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 <<EOF
+#line 4834 "configure"
+#include "confdefs.h"
+#include <unistd.h>
+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 <<EOF
-#line 4843 "configure"
+#line 4876 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -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 <<EOF
-#line 4890 "configure"
+#line 4923 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -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 <<EOF
-#line 4937 "configure"
+#line 4970 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -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 <<EOF
-#line 4984 "configure"
+#line 5017 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -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 <<EOF
-#line 5031 "configure"
+#line 5064 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -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 <<EOF
-#line 5085 "configure"
+#line 5118 "configure"
#include "confdefs.h"
int main() {
char *a = "a" "a";
; return 0; }
EOF
-if { (eval echo configure:5092: \"$ac_compile\") 1>&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 39d4d12..db8861c 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 <unistd.h>], [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 <unistd.h> 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 3b9cdd7..16464b5 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 b935e0a..45869d8 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 c3fb81e..cf5f07b 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"