summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/Makefile38
-rw-r--r--usr.bin/arch/Makefile4
-rw-r--r--usr.bin/arch/arch.139
-rw-r--r--usr.bin/arch/arch.c37
-rw-r--r--usr.bin/machine/Makefile5
-rw-r--r--usr.bin/machine/machine.153
-rw-r--r--usr.bin/machine/machine.c53
7 files changed, 82 insertions, 147 deletions
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index a35683703ce..f6844db2812 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -1,26 +1,24 @@
-# $OpenBSD: Makefile,v 1.59 1999/05/24 01:29:27 angelos Exp $
+# $OpenBSD: Makefile,v 1.60 1999/08/19 22:17:37 niklas Exp $
.include <bsd.own.mk>
-SUBDIR= apply apropos arch asa at aucat audioctl awk banner basename bdes biff \
- cal calendar cap_mkdb cdio checknr chflags chpass cksum cmp col colcrt \
- colrm column comm compile_et compress cpp crontab ctags cut dirname \
- du elf2olf encrypt env error expand false file file2c find finger fmt \
- fold from fsplit fstat ftp gencat getconf getopt gprof head hexdump \
- id indent infocmp ipcrm ipcs join jot kdump keynote ktrace lam last \
- lastcomm leave less lex lndir locate lock logger login logname look \
- lorder m4 machine mail make man mesg midiplay mixerctl mkdep mkstr \
- mktemp modstat msgs nc netstat newsyslog \
- nfsstat nice nohup oldrdist pagesize passwd paste patch pr printenv \
- printf quota rdist rdistd readlink renice rev rlogin rpcgen rpcinfo rs \
- rsh rup ruptime rusers rwall rwho \
- script sed shar showmount skey skeyaudit skeyinfo skeyinit sort \
- split su sup systat tail talk tcopy tee telnet tftp tic time \
- tip tn3270 top touch tput tr true tset tsort tty ul uname unexpand \
- unifdef uniq units unvis users uudecode uuencode \
- vacation vgrind vi vis vmstat w wall wc what whatis \
- which who whois window write \
- xargs xinstall xlint xstr yacc yes
+SUBDIR= apply apropos arch asa at aucat audioctl awk banner basename bdes \
+ biff cal calendar cap_mkdb cdio checknr chflags chpass cksum cmp col \
+ colcrt colrm column comm compile_et compress cpp crontab ctags cut \
+ dirname du elf2olf encrypt env error expand false file file2c find \
+ finger fmt fold from fsplit fstat ftp gencat getconf getopt gprof \
+ head hexdump id indent infocmp ipcrm ipcs join jot kdump keynote \
+ ktrace lam last lastcomm leave less lex lndir locate lock logger \
+ login logname look lorder m4 mail make man mesg midiplay mixerctl \
+ mkdep mkstr mktemp modstat msgs nc netstat newsyslog nfsstat nice \
+ nohup oldrdist pagesize passwd paste patch pr printenv printf quota \
+ rdist rdistd readlink renice rev rlogin rpcgen rpcinfo rs rsh rup \
+ ruptime rusers rwall rwho script sed shar showmount skey skeyaudit \
+ skeyinfo skeyinit sort split su sup systat tail talk tcopy tee telnet \
+ tftp tic time tip tn3270 top touch tput tr true tset tsort tty ul \
+ uname unexpand unifdef uniq units unvis users uudecode uuencode \
+ vacation vgrind vi vis vmstat w wall wc what whatis which who whois \
+ window write xargs xinstall xlint xstr yacc yes
.if (${YP} == "yes")
SUBDIR+=ypcat ypmatch ypwhich
diff --git a/usr.bin/arch/Makefile b/usr.bin/arch/Makefile
index 9894397842d..c44dedde2e8 100644
--- a/usr.bin/arch/Makefile
+++ b/usr.bin/arch/Makefile
@@ -1,5 +1,7 @@
-# $OpenBSD: Makefile,v 1.1 1996/06/23 04:22:36 tholo Exp $
+# $OpenBSD: Makefile,v 1.2 1999/08/19 22:17:38 niklas Exp $
PROG= arch
+LINKS= ${BINDIR}/arch ${BINDIR}/machine
+MLINKS= arch.1 machine.1
.include <bsd.prog.mk>
diff --git a/usr.bin/arch/arch.1 b/usr.bin/arch/arch.1
index 4e3e2b34490..892cf112e59 100644
--- a/usr.bin/arch/arch.1
+++ b/usr.bin/arch/arch.1
@@ -26,30 +26,57 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $OpenBSD: arch.1,v 1.3 1999/07/04 11:53:50 aaron Exp $
+.\" $OpenBSD: arch.1,v 1.4 1999/08/19 22:17:38 niklas Exp $
.\"
.Dd June 22, 1996
.Dt ARCH 1
.Os
.Sh NAME
-.Nm arch
+.Nm arch ,
+.Nm machine
.Nd print architecture type
.Sh SYNOPSIS
.Nm arch
-.Op Fl k
+.Op Fl ks
+.Nm machine
+.Op Fl a
.Sh DESCRIPTION
The
.Nm
-command displays the machine's architecture type.
+and
+.Nm machine
+command displays the machine's architecture in slightly different ways.
+.Nm
+by default displays the application architecture, defined by both the
+operating system and the instruction set architecture, while
+.Nm machine
+displays the kernel architecture (without the operating system part).
+Note that both commands output the target architecture as opposed to
+.Xr uname 1
+which describes the host. This is useful for dynamic discovery
+of the target architecture in build or configuration scripts
+needing to work in cross-compilation environments.
.Pp
-The following options are available:
+The following options are available to
+.Nm arch :
.Bl -tag -width indent
.It Fl k
Display the kernel architecture instead of application
architecture.
+.It Fl s
+Display the chosen architecture in a short form, i.e. without the
+operating system prefixed.
+.El
+.Pp
+The
+.Nm machine
+command accepts this option:
+.Bl -tag -width indent
+.It Fl a
+Display the application architecture instead of the kernel architecture.
.El
.Sh SEE ALSO
-.Xr machine 1
+.Xr uname 1
.Sh HISTORY
The
.Nm
diff --git a/usr.bin/arch/arch.c b/usr.bin/arch/arch.c
index 39b028863ca..208de220b8a 100644
--- a/usr.bin/arch/arch.c
+++ b/usr.bin/arch/arch.c
@@ -29,7 +29,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: arch.c,v 1.2 1996/06/29 20:29:34 tholo Exp $";
+static char rcsid[] = "$OpenBSD: arch.c,v 1.3 1999/08/19 22:17:38 niklas Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -41,6 +41,8 @@ static char rcsid[] = "$OpenBSD: arch.c,v 1.2 1996/06/29 20:29:34 tholo Exp $";
static void usage __P((void));
+static int machine;
+
int
main(argc, argv)
int argc;
@@ -48,16 +50,32 @@ main(argc, argv)
{
struct utsname uts;
char *arch;
+ char *opts;
int c;
+ int short_form = 0;
setlocale(LC_ALL, "");
- arch = MACHINE_ARCH;
- while ((c = getopt(argc, argv, "k")) != -1)
+ machine = strcmp (argv[0], "machine") == 0;
+ if (machine) {
+ arch = MACHINE;
+ opts = "a";
+ short_form++;
+ } else {
+ arch = MACHINE_ARCH;
+ opts = "ks";
+ }
+ while ((c = getopt(argc, argv, opts)) != -1)
switch (c) {
+ case 'a':
+ arch = MACHINE_ARCH;
+ break;
case 'k':
arch = MACHINE;
break;
+ case 's':
+ short_form++;
+ break;
default:
usage();
/* NOTREASCHED */
@@ -66,12 +84,10 @@ main(argc, argv)
usage();
/* NOTREACHED */
}
- if (uname(&uts)) {
- err(1, NULL);
- /* NOTREACHED */
+ if (!short_form) {
+ fputs("OpenBSD", stdout);
+ fputc('.', stdout);
}
- fputs(uts.sysname, stdout);
- fputc('.', stdout);
fputs(arch, stdout);
fputc('\n', stdout);
exit(0);
@@ -80,6 +96,9 @@ main(argc, argv)
static void
usage()
{
- fprintf(stderr, "usage: arch [-k]\n");
+ if (machine)
+ fprintf(stderr, "usage: machine [-a]\n");
+ else
+ fprintf(stderr, "usage: arch [-ks]\n");
exit(1);
}
diff --git a/usr.bin/machine/Makefile b/usr.bin/machine/Makefile
deleted file mode 100644
index 905353f2dfe..00000000000
--- a/usr.bin/machine/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# $OpenBSD: Makefile,v 1.2 1996/06/26 05:36:22 deraadt Exp $
-
-PROG= machine
-
-.include <bsd.prog.mk>
diff --git a/usr.bin/machine/machine.1 b/usr.bin/machine/machine.1
deleted file mode 100644
index 5c130aa0603..00000000000
--- a/usr.bin/machine/machine.1
+++ /dev/null
@@ -1,53 +0,0 @@
-.\" $OpenBSD: machine.1,v 1.2 1996/06/26 05:36:23 deraadt Exp $
-.\" Copyright (c) 1980, 1990 The Regents of the University of California.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" from: @(#)machine.1 5.5 (Berkeley) 7/26/91
-.\"
-.Dd July 26, 1991
-.Dt MACHINE 1
-.Os
-.Sh NAME
-.Nm machine
-.Nd print machine type
-.Sh SYNOPSIS
-.Nm machine
-.Sh DESCRIPTION
-The
-.Nm machine
-command displays the machine type.
-.Sh SEE ALSO
-.Xr make 1
-.Sh HISTORY
-The
-.Nm machine
-command is
-.Ud .
diff --git a/usr.bin/machine/machine.c b/usr.bin/machine/machine.c
deleted file mode 100644
index 0f5aa2f1fc8..00000000000
--- a/usr.bin/machine/machine.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* $OpenBSD: machine.c,v 1.2 1996/06/26 05:36:23 deraadt Exp $ */
-
-/*
- * Copyright (c) 1986 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1986 Regents of the University of California.\n\
- All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-/*static char sccsid[] = "from: @(#)machine.c 5.5 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$OpenBSD: machine.c,v 1.2 1996/06/26 05:36:23 deraadt Exp $";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-main()
-{
- puts(MACHINE);
- exit(0);
-}