Module Name:    src
Committed By:   matt
Date:           Sat Sep 14 15:09:34 UTC 2013

Modified Files:
        src/usr.bin/make: main.c

Log Message:
If MAKE_NATIVE, use sysctl to get MACHINE_ARCH from hw.machine_arch.


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/usr.bin/make/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.224 src/usr.bin/make/main.c:1.225
--- src/usr.bin/make/main.c:1.224	Wed Sep  4 15:38:26 2013
+++ src/usr.bin/make/main.c	Sat Sep 14 15:09:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $	*/
+/*	$NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -118,6 +118,9 @@ __RCSID("$NetBSD: main.c,v 1.224 2013/09
 #include <sys/param.h>
 #include <sys/resource.h>
 #include <sys/stat.h>
+#ifdef MAKE_NATIVE
+#include <sys/sysctl.h>
+#endif
 #include <sys/utsname.h>
 #include <sys/wait.h>
 
@@ -879,6 +882,20 @@ main(int argc, char **argv)
 	}
 
 	if (!machine_arch) {
+#ifdef MAKE_NATIVE
+	    static char machine_arch_buf[sizeof(utsname.machine)];
+	    const int mib[2] = { CTL_HW, HW_MACHINE_ARCH };
+	    size_t len = sizeof(machine_arch_buf);
+                
+	    if (sysctl(mib, __arraycount(mib), machine_arch_buf,
+		    &len, NULL, 0) < 0) {
+		(void)fprintf(stderr, "%s: sysctl failed (%s).\n", progname,
+		    strerror(errno));
+		exit(2);
+	    }
+
+	    machine_arch = machine_arch_buf;
+#else
 #ifndef MACHINE_ARCH
 #ifdef MAKE_MACHINE_ARCH
             machine_arch = MAKE_MACHINE_ARCH;
@@ -888,6 +905,7 @@ main(int argc, char **argv)
 #else
 	    machine_arch = MACHINE_ARCH;
 #endif
+#endif
 	}
 
 	myPid = getpid();		/* remember this for vFork() */

Reply via email to