diff options
author | kaiw <kaiw@FreeBSD.org> | 2014-01-28 19:12:31 +0000 |
---|---|---|
committer | kaiw <kaiw@FreeBSD.org> | 2014-01-28 19:12:31 +0000 |
commit | 9c3c6fdae0b43f1bbd5486754c20e403fc83c3b6 (patch) | |
tree | c000f1bf7a21df619e5cc1ac52b3edc991b884d0 /contrib/bmake/main.c | |
parent | 0fb1cfad9518e33fe20de1d9d694d0d5c2044fa2 (diff) | |
parent | 17e24564634134c9b7145fcf8d1c7d51b93c3182 (diff) | |
download | FreeBSD-src-9c3c6fdae0b43f1bbd5486754c20e403fc83c3b6.zip FreeBSD-src-9c3c6fdae0b43f1bbd5486754c20e403fc83c3b6.tar.gz |
MFH@261240.
Diffstat (limited to 'contrib/bmake/main.c')
-rw-r--r-- | contrib/bmake/main.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c index 45a45e0..78fbf41 100644 --- a/contrib/bmake/main.c +++ b/contrib/bmake/main.c @@ -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, 1989, 1990, 1993\ #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/04 15:38:26 sjg Exp $"); #include <sys/param.h> #include <sys/resource.h> #include <sys/stat.h> +#if defined(MAKE_NATIVE) && defined(HAVE_SYSCTL) +#include <sys/sysctl.h> +#endif #include <sys/utsname.h> #include "wait.h" @@ -145,6 +148,10 @@ __RCSID("$NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $"); #define DEFMAXLOCAL DEFMAXJOBS #endif /* DEFMAXLOCAL */ +#ifndef __arraycount +# define __arraycount(__x) (sizeof(__x) / sizeof(__x[0])) +#endif + Lst create; /* Targets to be made */ time_t now; /* Time at start of make */ GNode *DEFAULT; /* .DEFAULT node */ @@ -910,6 +917,20 @@ main(int argc, char **argv) } if (!machine_arch) { +#if defined(MAKE_NATIVE) && defined(HAVE_SYSCTL) && defined(CTL_HW) && defined(HW_MACHINE_ARCH) + static char machine_arch_buf[sizeof(utsname.machine)]; + 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; @@ -919,6 +940,7 @@ main(int argc, char **argv) #else machine_arch = MACHINE_ARCH; #endif +#endif } myPid = getpid(); /* remember this for vFork() */ |