summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2005-12-05 14:22:12 +0000
committerru <ru@FreeBSD.org>2005-12-05 14:22:12 +0000
commit6e96e6259d287eca55fb509febe1122cd1742e16 (patch)
tree40d79d56305386356866f6c99a9547c2d0b01395 /usr.bin
parent92cbca9c0a7ad409d87bff6fa6943c6b016bfc94 (diff)
downloadFreeBSD-src-6e96e6259d287eca55fb509febe1122cd1742e16.zip
FreeBSD-src-6e96e6259d287eca55fb509febe1122cd1742e16.tar.gz
Prepare for MACHINE and hw.machine switching to "pc98" on FreeBSD/pc98.
Reviewed by: nyan
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/catman/catman.15
-rw-r--r--usr.bin/catman/catman.c24
-rw-r--r--usr.bin/make/main.c27
-rw-r--r--usr.bin/makewhatis/makewhatis.15
-rw-r--r--usr.bin/makewhatis/makewhatis.c21
5 files changed, 57 insertions, 25 deletions
diff --git a/usr.bin/catman/catman.1 b/usr.bin/catman/catman.1
index 8fc7780..fe85587 100644
--- a/usr.bin/catman/catman.1
+++ b/usr.bin/catman/catman.1
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 22, 2004
+.Dd December 3, 2005
.Dt CATMAN 1
.Os
.Sh NAME
@@ -80,6 +80,9 @@ option is used.
.It Ev MACHINE
If set, overrides the current machine type when searching for
machine specific man page subdirectories.
+.It Ev MACHINE_ARCH
+If set, overrides the current architecture when searching for
+architecture specific man page subdirectories.
.It Ev MANPATH
Determines the set of directories to be processed if none are given on
the command line.
diff --git a/usr.bin/catman/catman.c b/usr.bin/catman/catman.c
index 6fcd975..ced6ae6 100644
--- a/usr.bin/catman/catman.c
+++ b/usr.bin/catman/catman.c
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
+#include <sys/utsname.h>
#include <ctype.h>
#include <dirent.h>
@@ -65,7 +66,7 @@ static int force; /* -f flag: force overwriting all cat pages */
static int rm_junk; /* -r flag: remove garbage pages */
static char *locale; /* user's locale if -L is used */
static char *lang_locale; /* short form of locale */
-static const char *machine;
+static const char *machine, *machine_arch;
static int exit_code; /* exit code to use when finished */
/*
@@ -634,7 +635,7 @@ process_mandir(char *dir_name, char *section)
process_section(dir_name, section);
} else {
struct dirent **entries;
- char *machine_dir;
+ char *machine_dir, *arch_dir;
int nsections;
int i;
@@ -651,6 +652,13 @@ process_mandir(char *dir_name, char *section)
if (test_path(machine_dir, NULL) & TEST_DIR)
process_section(dir_name, machine_dir);
free(machine_dir);
+ if (strcmp(machine_arch, machine) != 0) {
+ asprintf(&arch_dir, "%s/%s", entries[i]->d_name,
+ machine_arch);
+ if (test_path(arch_dir, NULL) & TEST_DIR)
+ process_section(dir_name, arch_dir);
+ free(arch_dir);
+ }
free(entries[i]);
}
free(entries);
@@ -791,8 +799,16 @@ main(int argc, char **argv)
signal(SIGQUIT, trap_signal);
signal(SIGTERM, trap_signal);
- if ((machine = getenv("MACHINE")) == NULL)
- machine = MACHINE;
+ if ((machine = getenv("MACHINE")) == NULL) {
+ static struct utsname utsname;
+
+ if (uname(&utsname) == -1)
+ err(1, "uname");
+ machine = utsname.machine;
+ }
+
+ if ((machine_arch = getenv("MACHINE_ARCH")) == NULL)
+ machine_arch = MACHINE_ARCH;
if (optind == argc) {
const char *manpath = getenv("MANPATH");
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index d3170f5..73302bc 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -61,15 +61,13 @@ __FBSDID("$FreeBSD$");
* the .MFLAGS target.
*/
-#ifndef MACHINE
-#include <sys/utsname.h>
-#endif
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/queue.h>
#include <sys/resource.h>
+#include <sys/utsname.h>
#include <sys/wait.h>
#include <err.h>
#include <errno.h>
@@ -717,13 +715,14 @@ main(int argc, char **argv)
#endif
/*
- * PC-98 kernel sets the `i386' string to the utsname.machine and
- * it cannot be distinguished from IBM-PC by uname(3). Therefore,
- * we check machine.ispc98 and adjust the machine variable before
- * using usname(3) below.
- * NOTE: machdep.ispc98 was defined on 1998/8/31. At that time,
- * __FreeBSD_version was defined as 300003. So, this check can
- * safely be done with any kernel with version > 300003.
+ * 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.
*/
if ((machine = getenv("MACHINE")) == NULL) {
int ispc98;
@@ -741,19 +740,15 @@ main(int argc, char **argv)
* so we can share an executable for similar machines.
* (i.e. m68k: amiga hp300, mac68k, sun3, ...)
*
- * Note that while MACHINE is decided at run-time,
- * MACHINE_ARCH is always known at compile time.
+ * Note that both MACHINE and MACHINE_ARCH are decided at
+ * run-time.
*/
if (machine == NULL) {
-#ifdef MACHINE
- machine = MACHINE;
-#else
static struct utsname utsname;
if (uname(&utsname) == -1)
err(2, "uname");
machine = utsname.machine;
-#endif
}
if ((machine_arch = getenv("MACHINE_ARCH")) == NULL) {
diff --git a/usr.bin/makewhatis/makewhatis.1 b/usr.bin/makewhatis/makewhatis.1
index 4e20ceb..1928c84 100644
--- a/usr.bin/makewhatis/makewhatis.1
+++ b/usr.bin/makewhatis/makewhatis.1
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 12, 2002
+.Dd December 3, 2005
.Dt MAKEWHATIS 1
.Os
.Sh NAME
@@ -98,6 +98,9 @@ option is used.
.It Ev MACHINE
If set, its value is used to override the current
machine type when searching machine specific subdirectories.
+.It Ev MACHINE_ARCH
+If set, its value is used to override the current
+architecture when searching architecture specific subdirectories.
.It Ev MANPATH
Determines the set of directories to be processed if none are given on
the command line.
diff --git a/usr.bin/makewhatis/makewhatis.c b/usr.bin/makewhatis/makewhatis.c
index 30f2da8..ea089fe 100644
--- a/usr.bin/makewhatis/makewhatis.c
+++ b/usr.bin/makewhatis/makewhatis.c
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/queue.h>
+#include <sys/utsname.h>
#include <ctype.h>
#include <dirent.h>
@@ -98,7 +99,7 @@ static const char *whatis_name="whatis";/* -n option: the name */
static char *common_output; /* -o option: the single output file */
static char *locale; /* user's locale if -L is used */
static char *lang_locale; /* short form of locale */
-static const char *machine;
+static const char *machine, *machine_arch;
static int exit_code; /* exit code to use when finished */
static SLIST_HEAD(, visited_dir) visited_dirs =
@@ -921,6 +922,12 @@ process_mandir(char *dir_name)
entries[i]->d_name, machine);
if (stat(section_dir, &st) == 0 && S_ISDIR(st.st_mode))
process_section(section_dir);
+ if (strcmp(machine_arch, machine) != 0) {
+ snprintf(section_dir, sizeof section_dir, "%s/%s/%s",
+ dir_name, entries[i]->d_name, machine_arch);
+ if (stat(section_dir, &st) == 0 && S_ISDIR(st.st_mode))
+ process_section(section_dir);
+ }
free(entries[i]);
}
free(entries);
@@ -1011,8 +1018,16 @@ main(int argc, char **argv)
whatis_proto = new_sbuf();
whatis_final = new_sbuf();
- if ((machine = getenv("MACHINE")) == NULL)
- machine = MACHINE;
+ if ((machine = getenv("MACHINE")) == NULL) {
+ static struct utsname utsname;
+
+ if (uname(&utsname) == -1)
+ err(1, "uname");
+ machine = utsname.machine;
+ }
+
+ if ((machine_arch = getenv("MACHINE_ARCH")) == NULL)
+ machine_arch = MACHINE_ARCH;
if (common_output != NULL && (fp = open_output(common_output)) == NULL)
err(1, "%s", common_output);
OpenPOWER on IntegriCloud