aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2005-12-05 14:22:12 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2005-12-05 14:22:12 +0000
commit8c7a62275a61304c16a51877eb730e3508f2fe9b (patch)
tree40d79d56305386356866f6c99a9547c2d0b01395
parent1c36ac6bc6cca3d41f29ec094b14bc3b4613ca96 (diff)
downloadsrc-8c7a62275a61304c16a51877eb730e3508f2fe9b.tar.gz
src-8c7a62275a61304c16a51877eb730e3508f2fe9b.zip
Prepare for MACHINE and hw.machine switching to "pc98" on FreeBSD/pc98.
Reviewed by: nyan
Notes
Notes: svn path=/head/; revision=153115
-rw-r--r--gnu/usr.bin/man/man/man.c37
-rw-r--r--gnu/usr.bin/man/man/man.man41
-rw-r--r--sys/i386/i386/identcpu.c2
-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
8 files changed, 125 insertions, 37 deletions
diff --git a/gnu/usr.bin/man/man/man.c b/gnu/usr.bin/man/man/man.c
index 18005dfc036d..e6ce0184878d 100644
--- a/gnu/usr.bin/man/man/man.c
+++ b/gnu/usr.bin/man/man/man.c
@@ -24,6 +24,7 @@ static const char rcsid[] =
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/param.h>
+#include <sys/utsname.h>
#include <ctype.h>
#include <errno.h>
#ifdef __FreeBSD__
@@ -73,6 +74,7 @@ extern int do_system_command ();
char *prognam;
static char *pager;
+static char *machine_arch;
static char *machine;
static char *manp;
static char *manpathlist[MAXDIRS];
@@ -362,7 +364,11 @@ man_getopt (argc, argv)
apropos++;
break;
case 'm':
- machine = optarg;
+ machine_arch = optarg;
+ if ((machine = strchr(optarg, ':')) != NULL)
+ *machine++ = '\0';
+ else
+ machine = optarg;
break;
#ifdef __FreeBSD__
case 'o':
@@ -468,11 +474,23 @@ man_getopt (argc, argv)
if (debug)
fprintf (stderr, "\nusing %s as pager\n", pager);
+ if (machine_arch == NULL && (machine_arch = getenv ("MACHINE_ARCH")) == NULL)
+ machine_arch = MACHINE_ARCH;
+
if (machine == NULL && (machine = getenv ("MACHINE")) == NULL)
- machine = MACHINE;
+ {
+ static struct utsname utsname;
+
+ if (uname(&utsname) == -1)
+ {
+ perror ("uname");
+ exit (1);
+ }
+ machine = utsname.machine;
+ }
if (debug)
- fprintf (stderr, "\nusing %s architecture\n", machine);
+ fprintf (stderr, "\nusing %s:%s architecture\n", machine_arch, machine);
if (manp == NULL)
{
@@ -1498,6 +1516,19 @@ try_section (path, section, longsec, name, glob)
if (found && !findall) /* only do this architecture... */
return found;
}
+ if (strcmp(machine_arch, machine) != 0)
+ {
+ snprintf(buf, sizeof(buf), "%s/man%s/%s", path, section, machine_arch);
+ if (is_directory (buf) == 1)
+ {
+ snprintf(buf, sizeof(buf), "%s/%s", machine_arch, name);
+ arch_search++;
+ found = try_section (path, section, longsec, buf, glob);
+ arch_search--;
+ if (found && !findall) /* only do this architecture... */
+ return found;
+ }
+ }
}
if (debug)
diff --git a/gnu/usr.bin/man/man/man.man b/gnu/usr.bin/man/man/man.man
index 9f808bf4148f..963d001072e3 100644
--- a/gnu/usr.bin/man/man/man.man
+++ b/gnu/usr.bin/man/man/man.man
@@ -14,7 +14,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 5, 1991
+.Dd December 3, 2005
.Dt MAN 1
.Os
.Sh NAME
@@ -23,7 +23,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl adfhkotw
-.Op Fl m Ar machine
+.Op Fl m Ar arch Ns Op : Ns Ar machine
.Op Fl p Ar string
.Op Fl M Ar path
.Op Fl P Ar pager
@@ -103,20 +103,40 @@ Print a help message and exit.
.It Fl k
Equivalent to
.Nm apropos .
-.It Fl m Ar machine
-As some manual pages are intended only for specific architectures,
+.It Fl m Ar arch Ns Op : Ns Ar machine
+As some manual pages are intended only for specific
+architectures and machine types,
.Nm
searches any subdirectories,
-with the same name as the current architecture,
+with the same name as the current machine type and architecture,
in every directory which it searches.
-Machine specific areas are checked before general areas.
+Machine specific areas are checked before architecture specific areas,
+and architecture specific areas are checked before general areas.
+For example, for
+.Dq Li i386:pc98 ,
+the following subdirectories will be searched for section 8
+manpages, in order:
+.Pa man8/pc98, man8/i386 ,
+and
+.Pa man8 .
+.Pp
The current machine type may be overridden using this option
or by setting the environment variable
.Ev MACHINE
+to the name of a specific machine.
+The current architecture may be overridden using this option
+or by setting the environment variable
+.Ev MACHINE_ARCH
to the name of a specific architecture.
This option overrides the
.Ev MACHINE
-environment variable.
+and
+.Ev MACHINE_ARCH
+environment variables.
+A
+.Ar machine
+component, if omitted, defaults to
+.Ar arch .
.It Fl o
Look for original, non-localized manpages only.
.Pp
@@ -201,7 +221,7 @@ Do not actually display the man pages, but do print the location(s) of
the files that would be formatted or displayed.
.El
.Sh ENVIRONMENT
-.Bl -tag -width MANROFFSEQ
+.Bl -tag -width ".Ev MACHINE_ARCH"
.It Ev LC_ALL , LC_CTYPE , LANG
These variables specify the preferred language for manual pages.
(See the
@@ -212,6 +232,11 @@ If
.Ev MACHINE
is set, its value is used to override the current machine type
when searching machine specific subdirectories.
+.It Ev MACHINE_ARCH
+If
+.Ev MACHINE_ARCH
+is set, its value is used to override the current architecture
+when searching architecture specific subdirectories.
.It Ev MANPATH
If
.Ev MANPATH
diff --git a/sys/i386/i386/identcpu.c b/sys/i386/i386/identcpu.c
index e328a20a76d9..6f2162bb518e 100644
--- a/sys/i386/i386/identcpu.c
+++ b/sys/i386/i386/identcpu.c
@@ -81,7 +81,7 @@ static void print_transmeta_info(void);
int cpu_class;
u_int cpu_exthigh; /* Highest arg to extended CPUID */
u_int cyrix_did; /* Device ID of Cyrix CPU */
-char machine[] = "i386";
+char machine[] = MACHINE;
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
machine, 0, "Machine class");
diff --git a/usr.bin/catman/catman.1 b/usr.bin/catman/catman.1
index 8fc77803a772..fe855872fd54 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 6fcd9758d33a..ced6ae6bbc55 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 d3170f5e5eea..73302bc755bb 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 4e20cebf8d93..1928c8470113 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 30f2da8d0ba7..ea089fec963c 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);