mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-29 12:03:03 +00:00
Prepare for MACHINE and hw.machine switching to "pc98" on FreeBSD/pc98.
Reviewed by: nyan
This commit is contained in:
parent
1c36ac6bc6
commit
8c7a62275a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=153115
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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");
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user