a769ac6
2005-02-07  Roland McGrath  <roland@frob.com>
a769ac6
a769ac6
	* configure.ac (WEXTRA): Check for -Wextra and set this substitution.
a769ac6
a769ac6
2003-08-12  Roland McGrath  <roland@redhat.com>
a769ac6
a769ac6
	* configure.ac: Check for struct stat st_?tim members.
a769ac6
	* src/strip.c (process_file): Use st_?time if st_?tim are not there.
a769ac6
a769ac6
	* configure.ac: Check for futimes function.
a769ac6
	* src/strip.c (handle_elf) [! HAVE_FUTIMES]: Use utimes instead.
a769ac6
	(handle_ar) [! HAVE_FUTIMES]: Likewise.
a769ac6
a769ac6
--- elfutils/configure.ac
a769ac6
+++ elfutils/configure.ac
a769ac6
@@ -66,6 +66,15 @@ CFLAGS="$old_CFLAGS"])
a769ac6
 AS_IF([test "x$ac_cv_c99" != xyes],
a769ac6
       AC_MSG_ERROR([gcc with C99 support required]))
a769ac6
 
a769ac6
+AC_CACHE_CHECK([for -Wextra option to $CC], ac_cv_cc_wextra, [dnl
a769ac6
+old_CFLAGS="$CFLAGS"
a769ac6
+CFLAGS="$CFLAGS -Wextra"
a769ac6
+AC_COMPILE_IFELSE([void foo (void) { }],
a769ac6
+		  ac_cv_cc_wextra, ac_cv_cc_wextra=no)
a769ac6
+CFLAGS="$old_CFLAGS"])
a769ac6
+AC_SUBST(WEXTRA)
a769ac6
+AS_IF([test "x$ac_cv_cc_wextra" = yes], [WEXTRA=-Wextra])
a769ac6
+
a769ac6
 LOCALEDIR=$datadir
a769ac6
 AC_SUBST(LOCALEDIR)
a769ac6
 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR")
a769ac6
--- elfutils/lib/ChangeLog
a769ac6
+++ elfutils/lib/ChangeLog
a769ac6
@@ -1,3 +1,8 @@
a769ac6
+2005-02-07  Roland McGrath  <roland@redhat.com>
a769ac6
+
a769ac6
+	* Makefile.am (WEXTRA): New variable, substituted by configure.
a769ac6
+	(AM_CFLAGS): Use it in place of -Wextra.
a769ac6
+
a769ac6
 2005-02-15  Ulrich Drepper  <drepper@redhat.com>
a769ac6
 
a769ac6
 	* dynamicsizehash.c (lookup): Mark val parameter as possibly unused.
a769ac6
--- elfutils/lib/Makefile.am
a769ac6
+++ elfutils/lib/Makefile.am
a769ac6
@@ -17,12 +17,13 @@
a769ac6
 ## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
a769ac6
 ##
a769ac6
 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
a769ac6
+WEXTRA = @WEXTRA@
a769ac6
 if MUDFLAP
a769ac6
 AM_CFLAGS = -fmudflap
a769ac6
 else
a769ac6
 AM_CFLAGS =
a769ac6
 endif
a769ac6
-AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra $($(*F)_CFLAGS)
a769ac6
+AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused $(WEXTRA) $($(*F)_CFLAGS)
a769ac6
 INCLUDES = -I$(srcdir)/../libelf -I..
a769ac6
 
a769ac6
 noinst_LIBRARIES = libeu.a
a769ac6
--- elfutils/libasm/Makefile.am
a769ac6
+++ elfutils/libasm/Makefile.am
a769ac6
@@ -14,12 +14,13 @@
a769ac6
 ## 3001 King Ranch Road, Ukiah, CA 95482.
a769ac6
 ##
a769ac6
 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
a769ac6
+WEXTRA = @WEXTRA@
a769ac6
 if MUDFLAP
a769ac6
 AM_CFLAGS = -fmudflap
a769ac6
 else
a769ac6
 AM_CFLAGS =
a769ac6
 endif
a769ac6
-AM_CFLAGS += -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2
a769ac6
+AM_CFLAGS += -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2
a769ac6
 INCLUDES = -I. -I$(srcdir) -I.. -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl \
a769ac6
 	   -I$(top_srcdir)/lib
a769ac6
 GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
a769ac6
--- elfutils/libdw/Makefile.am
a769ac6
+++ elfutils/libdw/Makefile.am
a769ac6
@@ -14,12 +14,13 @@
a769ac6
 ## 3001 King Ranch Road, Ukiah, CA 95482.
a769ac6
 ##
a769ac6
 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
a769ac6
+WEXTRA = @WEXTRA@
a769ac6
 if MUDFLAP
a769ac6
 AM_CFLAGS = -fmudflap
a769ac6
 else
a769ac6
 AM_CFLAGS =
a769ac6
 endif
a769ac6
-AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99
a769ac6
+AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 $(WEXTRA) -std=gnu99
a769ac6
 INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib
a769ac6
 VERSION = 1
a769ac6
 
a769ac6
--- elfutils/libebl/Makefile.am
a769ac6
+++ elfutils/libebl/Makefile.am
a769ac6
@@ -14,12 +14,13 @@
a769ac6
 ## 3001 King Ranch Road, Ukiah, CA 95482.
a769ac6
 ##
a769ac6
 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\"
a769ac6
+WEXTRA = @WEXTRA@
a769ac6
 if MUDFLAP
a769ac6
 AM_CFLAGS = -fmudflap
a769ac6
 else
a769ac6
 AM_CFLAGS =
a769ac6
 endif
a769ac6
-AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 \
a769ac6
+AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 \
a769ac6
 	     -std=gnu99
a769ac6
 
a769ac6
 INCLUDES = -I$(srcdir) -I$(top_srcdir)/libelf -I$(top_srcdir)/lib -I..
a769ac6
--- elfutils/libelf/Makefile.am
a769ac6
+++ elfutils/libelf/Makefile.am
a769ac6
@@ -17,12 +17,13 @@
a769ac6
 ## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
a769ac6
 ##
a769ac6
 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
a769ac6
+WEXTRA = @WEXTRA@
a769ac6
 if MUDFLAP
a769ac6
 AM_CFLAGS = -fpic -fmudflap
a769ac6
 else
a769ac6
 AM_CFLAGS =
a769ac6
 endif
a769ac6
-AM_CFLAGS += -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 -std=gnu99 \
a769ac6
+AM_CFLAGS += -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 \
a769ac6
 	     $($(*F)_CFLAGS)
a769ac6
 INCLUDES = -I$(srcdir) -I$(top_srcdir)/lib -I..
a769ac6
 GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
a769ac6
--- elfutils/src/Makefile.am
a769ac6
+++ elfutils/src/Makefile.am
a769ac6
@@ -15,14 +15,15 @@
a769ac6
 ##
a769ac6
 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) \
a769ac6
        -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
a769ac6
+WEXTRA = @WEXTRA@
a769ac6
 if MUDFLAP
a769ac6
-AM_CFLAGS = -Wall -Wshadow -Wunused -Wextra -std=gnu99 -fmudflap \
a769ac6
+AM_CFLAGS = -Wall -Wshadow -Wunused $(WEXTRA) -std=gnu99 -fmudflap \
a769ac6
 	    $(native_ld_cflags) $(if $($(*F)_no_Wunused),,-Wunused) \
a769ac6
 	    $(if $($(*F)_no_Wformat),,-Wformat=2)
a769ac6
 else
a769ac6
 AM_CFLAGS = -Wall -Wshadow -std=gnu99 $(native_ld_cflags) \
a769ac6
 	    $(if $($(*F)_no_Werror),,-Werror) \
a769ac6
-	    $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
a769ac6
+	    $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \
a769ac6
 	    $(if $($(*F)_no_Wformat),,-Wformat=2)
a769ac6
 endif
a769ac6
 if MUDFLAP
a769ac6
--- elfutils/src/strip.c
a769ac6
+++ elfutils/src/strip.c
a769ac6
@@ -245,8 +245,18 @@ process_file (const char *fname)
a769ac6
 
a769ac6
       /* If we have to preserve the timestamp, we need it in the
a769ac6
 	 format utimes() understands.  */
a769ac6
+#ifdef HAVE_STRUCT_STAT_ST_ATIM
a769ac6
       TIMESPEC_TO_TIMEVAL (&tv[0], &pre_st.st_atim);
a769ac6
+#else
a769ac6
+      tv[0].tv_sec = pre_st.st_atime;
a769ac6
+      tv[0].tv_usec = 0;
a769ac6
+#endif
a769ac6
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
a769ac6
       TIMESPEC_TO_TIMEVAL (&tv[1], &pre_st.st_mtim);
a769ac6
+#else
a769ac6
+      tv[1].tv_sec = pre_st.st_atime;
a769ac6
+      tv[1].tv_usec = 0;
a769ac6
+#endif
a769ac6
     }
a769ac6
 
a769ac6
   /* Open the file.  */
a769ac6
@@ -1677,7 +1687,13 @@ handle_elf (int fd, Elf *elf, const char
a769ac6
   /* If requested, preserve the timestamp.  */
a769ac6
   if (tvp != NULL)
a769ac6
     {
a769ac6
-      if (futimes (fd, tvp) != 0)
a769ac6
+      if (
a769ac6
+#ifdef HAVE_FUTIMES
a769ac6
+	  futimes (fd, tvp) != 0
a769ac6
+#else
a769ac6
+	  utimes (output_fname, tvp) != 0
a769ac6
+#endif
a769ac6
+	  )
a769ac6
 	{
a769ac6
 	  error (0, errno, gettext ("\
a769ac6
 cannot set access and modification date of \"%s\""),
a769ac6
@@ -1734,7 +1750,13 @@ handle_ar (int fd, Elf *elf, const char 
a769ac6
 
a769ac6
   if (tvp != NULL)
a769ac6
     {
a769ac6
-      if (unlikely (futimes (fd, tvp) != 0))
a769ac6
+	  if (unlikely (
a769ac6
+#ifdef HAVE_FUTIMES
a769ac6
+			futimes (fd, tvp)
a769ac6
+#else
a769ac6
+			utimes (fname, tvp)
a769ac6
+#endif
a769ac6
+			!= 0))
a769ac6
 	{
a769ac6
 	  error (0, errno, gettext ("\
a769ac6
 cannot set access and modification date of \"%s\""), fname);