summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-02-03 20:45:45 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-02-03 20:45:45 +0000
commit242a685bbe8387eac874059ec9de2cbbe38353d1 (patch)
treeb81684f239dc694a82b4c93e729b63119e377362 /usr.bin
parent30e1e9b675692c897c5a565e2e386b3c7b72329a (diff)
Add a new default variable in Makefile context, MACHINE_CPU. Its value is
decided at compile-time and is either MACHINE_CPU from <machine/param.h> if it is defined, or the same value as MACHINE_ARCH otherwise. This will be used to allow ports with suffixes to their canonical MACHINE_ARCH to provide this canonical name as MACHINE_CPU, and in turn to let Makefiles do TRT. ok kettenis@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/Makefile.boot8
-rw-r--r--usr.bin/make/arch.c6
-rw-r--r--usr.bin/make/main.c24
-rw-r--r--usr.bin/make/make.113
4 files changed, 43 insertions, 8 deletions
diff --git a/usr.bin/make/Makefile.boot b/usr.bin/make/Makefile.boot
index 7a8c745e589..0a77ef8ec75 100644
--- a/usr.bin/make/Makefile.boot
+++ b/usr.bin/make/Makefile.boot
@@ -1,11 +1,12 @@
# $OpenPackages: Makefile.boot,v 1.5 2001/04/06 00:09:55 will Exp $
-# $OpenBSD: Makefile.boot,v 1.8 2001/05/29 12:41:18 espie Exp $
+# $OpenBSD: Makefile.boot,v 1.9 2010/02/03 20:45:44 miod Exp $
#
# a very simple makefile...
#
# You only want to use this if you aren't running OpenBSD.
#
-# modify MACHINE and MACHINE_ARCH as appropriate for your target architecture
+# modify MACHINE, MACHINE_ARCH and MACHINE_CPU as appropriate
+# for your target architecture
#
.c.o:
@@ -13,7 +14,8 @@
MACHINE=sun
MACHINE_ARCH=sparc
-CFLAGS= -Iohash -I. -DTARGET_MACHINE=\"${MACHINE}\" -DTARGET_MACHINE_ARCH=\"${MACHINE_ARCH}\" -DMACHINE=\"${MACHINE}\" \
+MACHINE_CPU=sparc
+CFLAGS= -Iohash -I. -DTARGET_MACHINE=\"${MACHINE}\" -DTARGET_MACHINE_ARCH=\"${MACHINE_ARCH}\" -DTARGET_MACHINE_CPU=\"${MACHINE_CPU}\" -DMACHINE=\"${MACHINE}\" \
-DMAKE_BOOTSTRAP -DNEED_FGETLN
LIBS= ohash/libohash.a
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c
index 00548407aec..138a9729a21 100644
--- a/usr.bin/make/arch.c
+++ b/usr.bin/make/arch.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: arch.c,v 1.76 2009/08/16 09:53:43 espie Exp $ */
+/* $OpenBSD: arch.c,v 1.77 2010/02/03 20:45:44 miod Exp $ */
/* $NetBSD: arch.c,v 1.17 1996/11/06 17:58:59 christos Exp $ */
/*
@@ -113,6 +113,10 @@
#undef MACHINE_ARCH
#define MACHINE_ARCH TARGET_MACHINE_ARCH
#endif
+#ifdef TARGET_MACHINE_CPU
+#undef MACHINE_CPU
+#define MACHINE_CPU TARGET_MACHINE_CPU
+#endif
static struct ohash archives; /* Archives we've already examined. */
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index be58856340e..f1c8cf8200e 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: main.c,v 1.92 2008/11/04 07:22:35 espie Exp $ */
+/* $OpenBSD: main.c,v 1.93 2010/02/03 20:45:44 miod Exp $ */
/* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */
/*
@@ -109,6 +109,7 @@ static void record_option(int, const char *);
static char *figure_out_MACHINE(void);
static char *figure_out_MACHINE_ARCH(void);
+static char *figure_out_MACHINE_CPU(void);
static void no_fd_limits(void);
static char *chdir_verify_path(const char *, struct dirs *);
@@ -406,7 +407,7 @@ add_dirpath(Lst l, const char *n)
* 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
+ * Note that MACHINE, MACHINE_ARCH and MACHINE_CPU are decided at
* run-time.
*/
static char *
@@ -442,6 +443,23 @@ figure_out_MACHINE_ARCH()
}
return r;
}
+static char *
+figure_out_MACHINE_CPU()
+{
+ char *r = getenv("MACHINE_CPU");
+ if (r == NULL) {
+#if !defined(MACHINE_CPU) && ! defined(MACHINE_ARCH)
+ r = "unknown"; /* XXX: no uname -p yet */
+#else
+#if defined(MACHINE_CPU)
+ r = MACHINE_CPU;
+#else
+ r = MACHINE_ARCH;
+#endif
+#endif
+ }
+ return r;
+}
/* get rid of resource limit on file descriptors */
static void
@@ -653,6 +671,7 @@ main(int argc, char **argv)
bool outOfDate = true; /* false if all targets up to date */
char *machine = figure_out_MACHINE();
char *machine_arch = figure_out_MACHINE_ARCH();
+ char *machine_cpu = figure_out_MACHINE_CPU();
const char *syspath = _PATH_DEFSYSPATH;
char *p;
static struct dirs d;
@@ -706,6 +725,7 @@ main(int argc, char **argv)
Var_Set("MFLAGS", "");
Var_Set("MACHINE", machine);
Var_Set("MACHINE_ARCH", machine_arch);
+ Var_Set("MACHINE_CPU", machine_cpu);
/*
* First snag any flags out of the MAKEFLAGS environment variable.
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index 78c56f3c32f..91d092f98b2 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: make.1,v 1.84 2009/02/10 19:24:17 jmc Exp $
+.\" $OpenBSD: make.1,v 1.85 2010/02/03 20:45:44 miod Exp $
.\" $OpenPackages$
.\" $NetBSD: make.1,v 1.18 1997/03/10 21:19:53 christos Exp $
.\"
@@ -31,7 +31,7 @@
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd $Mdocdate: February 10 2009 $
+.Dd $Mdocdate: February 3 2010 $
.Dt MAKE 1
.Os
.Sh NAME
@@ -667,6 +667,15 @@ Name of the machine architecture
was compiled for, obtained from the
.Ev MACHINE_ARCH
environment variable, or defined at compilation time.
+.It Va MACHINE_CPU
+Name of the machine processor
+.Nm
+was compiled for, obtained from the
+.Ev MACHINE_CPU
+environment variable, or defined at compilation time.
+On processors where only one endianness is possible, the value of this
+variable is always the same as
+.Ev MACHINE_ARCH .
.It Va MAKEFILE
Possibly the file name of the last makefile that has been read.
It should not be used; see the