Subject: toolchain/22504: problems cross-building from Debian GNU/Linux
To: None <gnats-bugs@gnats.netbsd.org>
From: None <chris@pin.lu>
List: netbsd-bugs
Date: 08/16/2003 18:50:52
>Number:         22504
>Category:       toolchain
>Synopsis:       problems cross-building from Debian GNU/Linux
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 16 16:51:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Christian Limpach <chris@pin.lu>
>Release:        current as of 030816
>Organization:
	
>Environment:
	
	
	Debian GNU/Linux
>Description:
	The following problems exist when cross-building from Debian GNU/Linux
	(and possibly other non-NetBSD hosts):
	- bin/sh/mkinit.c: mkinit is built for and run on the build host and
	  Linux doesn't have strlcpy. (fix in bin/sh/mkinit.c, partially revert
	  changes from 1.21->1.22)
	- bin/cat/cat.c: SIZE_T_MAX is not defined on Linux, SIZE_MAX is defined.
	  (fix in tools/compat/compat_defs.h, unless SIZE_MAX is the correct name)
	- usr.bin/stat/stat.c: Linux doesn't have st_[acm]timespec or st_[acm]tim.
	  Linux has st_[acm]time.  (fix in usr.bin/stat/stat.c,
	  tools/compat/configure.ac, tools/compat/configure (regen only),
	  tools/compat/config.h.in)
>How-To-Repeat:
	build.sh on Debian GNU/Linux
>Fix:
	
Index: bin/sh/mkinit.c
===================================================================
RCS file: /cvs/netbsd/src/bin/sh/mkinit.c,v
retrieving revision 1.23
diff -u -r1.23 mkinit.c
--- bin/sh/mkinit.c	7 Aug 2003 09:05:35 -0000	1.23
+++ bin/sh/mkinit.c	15 Aug 2003 16:03:42 -0000
@@ -216,7 +216,7 @@
 			char line2[1024];
 			static const char undef[] = "#undef ";
 
-			strlcpy(line2, line, sizeof(line2));
+			strcpy(line2, line);
 			memcpy(line2, undef, sizeof(undef) - 1);
 			cp = line2 + sizeof(undef) - 1;
 			while(*cp && (*cp == ' ' || *cp == '\t'))
Index: tools/compat/compat_defs.h
===================================================================
RCS file: /cvs/netbsd/src/tools/compat/compat_defs.h,v
retrieving revision 1.29
diff -u -r1.29 compat_defs.h
--- tools/compat/compat_defs.h	27 Jul 2003 07:56:37 -0000	1.29
+++ tools/compat/compat_defs.h	16 Aug 2003 15:42:36 -0000
@@ -410,6 +410,10 @@
 #define UINT32_MAX 0xffffffffU
 #endif
 
+#if !defined(SIZE_T_MAX) && defined(SIZE_MAX)
+#define SIZE_T_MAX SIZE_MAX
+#endif
+
 /* <stdlib.h> */
 
 #ifndef __GNUC__
Index: tools/compat/config.h.in
===================================================================
RCS file: /cvs/netbsd/src/tools/compat/config.h.in,v
retrieving revision 1.30
diff -u -r1.30 config.h.in
--- tools/compat/config.h.in	25 Jul 2003 03:21:16 -0000	1.30
+++ tools/compat/config.h.in	15 Aug 2003 12:40:20 -0000
@@ -43,6 +43,7 @@
 #undef HAVE_STRUCT_STAT_ST_BIRTHTIME
 #undef HAVE_STRUCT_STAT_ST_ATIM
 #undef HAVE_STRUCT_STAT_ST_MTIMENSEC
+#undef HAVE_STRUCT_STAT_ST_ATIME
 #undef HAVE_STRUCT_STATFS_F_IOSIZE
 
 #undef HAVE_DECL_OPTIND
Index: tools/compat/configure
===================================================================
RCS file: /cvs/netbsd/src/tools/compat/configure,v
retrieving revision 1.41
diff -u -r1.41 configure
--- tools/compat/configure	26 Jul 2003 20:23:59 -0000	1.41
+++ tools/compat/configure	15 Aug 2003 12:38:42 -0000
@@ -2087,8 +2087,7 @@
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   for ac_declaration in \
-   ''\
-   '#include <stdlib.h>' \
+   '' \
    'extern "C" void std::exit (int) throw (); using std::exit;' \
    'extern "C" void std::exit (int); using std::exit;' \
    'extern "C" void exit (int) throw ();' \
@@ -2102,8 +2101,8 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <stdlib.h>
 $ac_declaration
+#include <stdlib.h>
 int
 main ()
 {
@@ -5892,6 +5891,99 @@
 
 
 fi
+echo "$as_me:$LINENO: checking for struct stat.st_atime" >&5
+echo $ECHO_N "checking for struct stat.st_atime... $ECHO_C" >&6
+if test "${ac_cv_member_struct_stat_st_atime+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/stat.h>
+
+int
+main ()
+{
+static struct stat ac_aggr;
+if (ac_aggr.st_atime)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 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
+  ac_cv_member_struct_stat_st_atime=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/stat.h>
+
+int
+main ()
+{
+static struct stat ac_aggr;
+if (sizeof ac_aggr.st_atime)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 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
+  ac_cv_member_struct_stat_st_atime=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_member_struct_stat_st_atime=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_member_struct_stat_st_atime" >&5
+echo "${ECHO_T}$ac_cv_member_struct_stat_st_atime" >&6
+if test $ac_cv_member_struct_stat_st_atime = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_STAT_ST_ATIME 1
+_ACEOF
+
+
+fi
 
 echo "$as_me:$LINENO: checking for struct statfs.f_iosize" >&5
 echo $ECHO_N "checking for struct statfs.f_iosize... $ECHO_C" >&6
Index: tools/compat/configure.ac
===================================================================
RCS file: /cvs/netbsd/src/tools/compat/configure.ac,v
retrieving revision 1.40
diff -u -r1.40 configure.ac
--- tools/compat/configure.ac	26 Jul 2003 20:24:00 -0000	1.40
+++ tools/compat/configure.ac	15 Aug 2003 12:38:07 -0000
@@ -84,7 +84,7 @@
 #include <dirent.h>])
 AC_CHECK_MEMBERS([struct stat.st_flags, struct stat.st_gen,
 	struct stat.st_birthtime, struct stat.st_atim,
-	struct stat.st_mtimensec],,, [#include <sys/stat.h>])
+	struct stat.st_mtimensec, struct stat.st_atime],,, [#include <sys/stat.h>])
 AC_CHECK_MEMBERS(struct statfs.f_iosize,,, [#include <sys/mount.h>])
 
 # Global variable decls.
Index: usr.bin/stat/stat.c
===================================================================
RCS file: /cvs/netbsd/src/usr.bin/stat/stat.c,v
retrieving revision 1.13
diff -u -r1.13 stat.c
--- usr.bin/stat/stat.c	25 Jul 2003 03:21:17 -0000	1.13
+++ usr.bin/stat/stat.c	15 Aug 2003 12:39:47 -0000
@@ -91,6 +91,12 @@
 #define st_mtimespec st_mtim
 #endif /* HAVE_STRUCT_STAT_ST_ATIM */
 
+#if HAVE_STRUCT_STAT_ST_ATIME
+#define st_atimespec st_atime
+#define st_ctimespec st_ctime
+#define st_mtimespec st_mtime
+#endif /* HAVE_STRUCT_STAT_ST_ATIM */
+
 #define DEF_FORMAT \
 	"%d %i %Sp %l %Su %Sg %r %z \"%Sa\" \"%Sm\" \"%Sc\" " DEF_B \
 	"%k %b " DEF_F "%N"

-- 
Christian Limpach <chris@pin.lu>
>Release-Note:
>Audit-Trail:
>Unformatted: