From owner-freebsd-arch@FreeBSD.ORG Tue Apr 6 05:18:26 2010 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F0411065670 for ; Tue, 6 Apr 2010 05:18:26 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 0E87F8FC2B for ; Tue, 6 Apr 2010 05:18:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o365DxWJ004184 for ; Mon, 5 Apr 2010 23:13:59 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Mon, 05 Apr 2010 23:09:35 -0600 (MDT) Message-Id: <20100405.230935.131509470607402730.imp@bsdimp.com> To: arch@freebsd.org From: "M. Warner Losh" X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: Subject: Minor make cleanup X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2010 05:18:26 -0000 Greetings, I'd like to simplify how make gets its MACHINE and MACHINE_ARCH settings a little. Right now we have some special case code for pc98 that's not been needed for a while (it is to cope on running on FreeBSD/pc98 6.x kernels). Also, the MACHINE and MACHINE_ARCH is a little to complex, and can be simplified. It is now trivial to determine machine_arch at run-time, so we do that rather than relying on a hard-coded default value. I've also removed the MACHINE_CPU setting. I don't think it is needed since we always set it via sys.mk's includsion of bsd.cpu.mk and have for a very long time. It doesn't default to anything sensible anyway. Comments? Warner Index: main.c =================================================================== --- main.c (revision 206241) +++ main.c (working copy) @@ -872,7 +872,6 @@ { const char *machine; const char *machine_arch; - const char *machine_cpu; Boolean outOfDate = TRUE; /* FALSE if all targets up to date */ const char *p; const char *pathp; @@ -881,6 +880,8 @@ char obpath[MAXPATHLEN]; char cdpath[MAXPATHLEN]; char found_dir[MAXPATHLEN + 1]; /* for searching for sys.mk */ + char machine_[40]; + char machine_arch_[40]; char *cp = NULL, *start; save_argv = argv; @@ -933,61 +934,30 @@ #endif /* - * Prior to 7.0, FreeBSD/pc98 kernel used to set the - * utsname.machine to "i386", and MACHINE was defined as - * "i386", so it could not be distinguished from FreeBSD/i386. - * Therefore, we had to check machine.ispc98 and adjust the - * MACHINE variable. NOTE: The code is still here to be able - * to compile new make binary on old FreeBSD/pc98 systems, and - * have the MACHINE variable set properly. + * MACHINE is the specific type of machine that is build from + * MACHINE_ARCH processors. Often they are the same, but can + * be different in a number of circumstances. The kernel for + * this MACHINE is buils from sys/MACHINE/conf/BLAH. The cpu + * support for libc, comes from lib/libc/MACHINE_ARCH/blah. + * + * Some ports support muliple disparate types of hardware with + * a single MACHINE type (eg mips and powerpc support all + * their differnet kernels under the mips or powerpc umbrella + * respectively). */ if ((machine = getenv("MACHINE")) == NULL) { - int ispc98; - size_t len; - - len = sizeof(ispc98); - if (!sysctlbyname("machdep.ispc98", &ispc98, &len, NULL, 0)) { - if (ispc98) - machine = "pc98"; - } + size_t len = sizeof(machine_); + if (sysctlbyname("hw.machine", machine_, &len, NULL, 0) == 0) + machine = machine_; } - - /* - * Get the name of this type of MACHINE from utsname - * so we can share an executable for similar machines. - * (i.e. m68k: amiga hp300, mac68k, sun3, ...) - * - * Note that both MACHINE and MACHINE_ARCH are decided at - * run-time. - */ - if (machine == NULL) { - static struct utsname utsname; - - if (uname(&utsname) == -1) - err(2, "uname"); - machine = utsname.machine; - } - if ((machine_arch = getenv("MACHINE_ARCH")) == NULL) { -#ifdef MACHINE_ARCH - machine_arch = MACHINE_ARCH; -#else - machine_arch = "unknown"; -#endif + size_t len = sizeof(machine_arch_); + if (sysctlbyname("hw.machine_arch", machine_arch_, &len, + NULL, 0) == 0) + machine_arch = machine_arch_; } /* - * Set machine_cpu to the minumum supported CPU revision based - * on the target architecture, if not already set. - */ - if ((machine_cpu = getenv("MACHINE_CPU")) == NULL) { - if (!strcmp(machine_arch, "i386")) - machine_cpu = "i386"; - else - machine_cpu = "unknown"; - } - - /* * Initialize the parsing, directory and variable modules to prepare * for the reading of inclusion paths and variable settings on the * command line @@ -1016,7 +986,6 @@ Var_SetGlobal("MFLAGS", ""); Var_SetGlobal("MACHINE", machine); Var_SetGlobal("MACHINE_ARCH", machine_arch); - Var_SetGlobal("MACHINE_CPU", machine_cpu); #ifdef MAKE_VERSION Var_SetGlobal("MAKE_VERSION", MAKE_VERSION); #endif