Add option "-d destdir" which instructs config to use another output

directory than the default one. If the option is not given, then the
output of config is exactly as before. Only when an alternate output
directory has been specified will config modify its behavior.

Additional changed:
o  Remove the now conflicting and unused NODEV define. It
   conflicts with NODEV in sys/param.h.
o  Rename the now conflicting MACHINE token to ARCH. It
   conflicts with MACHINE in sys/param.h.
o  Fix some easy style bugs.
o  Fix some easy grammar bugs in the manpage.

Approved by: peter, archie
This commit is contained in:
Marcel Moolenaar 1999-10-30 10:55:48 +00:00
parent 3f5bbb089a
commit c1454d67ec
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=52653
6 changed files with 79 additions and 19 deletions

View File

@ -41,6 +41,7 @@
.Sh SYNOPSIS
.Nm config
.Op Fl gpr
.Op Fl d Ar destdir
.Ar SYSTEM_NAME
.Sh DESCRIPTION
This is the old version of the
@ -73,6 +74,13 @@ section below).
Available options and operands:
.Pp
.Bl -tag -width SYSTEM_NAME
.It Fl d Ar destdir
Use
.Ar destdir
as the output directory, instead of the default one. Note
that config does not append
.Ar SYSTEM_NAME
to the directory given.
.It Fl g
Configure a system for debugging.
.It Fl p
@ -104,8 +112,11 @@ represents one of the architectures supported by FreeBSD.
.Nm Config
creates the directory
.Pa ../../compile/SYSTEM_NAME
as necessary and place all output files there.
If the directory already exists and the
or the one given with the
.Fl d
option
as necessary and places all output files there.
If the output directory already exists and the
.Fl r
flag was specified, it will be removed first.
The output of
@ -222,7 +233,7 @@ list of files specific to
.Em ERNIE
system
.It Pa /sys/compile/SYSTEM_NAME
kernel build directory for system
default kernel build directory for system
.Pa SYSTEM_NAME .
.El
.Sh SEE ALSO

View File

@ -41,8 +41,6 @@
#include <stdlib.h>
#include <string.h>
#define NODEV ((dev_t)-1)
struct file_list {
struct file_list *f_next;
char *f_fn; /* the name */
@ -177,6 +175,7 @@ extern int maxusers;
extern int old_config_present; /* Old config/build directory still there */
extern char *PREFIX; /* Config file name - for error messages */
extern char srcdir[]; /* root of the kernel source tree */
#define eq(a,b) (!strcmp(a,b))
#define ns(s) strdup(s)

View File

@ -5,6 +5,7 @@
}
%token ANY
%token ARCH
%token AT
%token BUS
%token COMMA
@ -23,7 +24,6 @@
%token IOMEM
%token IOSIZ
%token IRQ
%token MACHINE
%token MAXUSERS
%token MINUS
%token NEXUS
@ -133,7 +133,7 @@ Spec:
;
Config_spec:
MACHINE Save_id
ARCH Save_id
= {
if (!strcmp($2, "i386")) {
machine = MACHINE_I386;

View File

@ -66,7 +66,7 @@ struct kt {
{ "iomem", IOMEM },
{ "iosiz", IOSIZ },
{ "irq", IRQ },
{ "machine", MACHINE },
{ "machine", ARCH }, /* MACHINE is defined in /sys/param.h */
{ "makeoptions", MAKEOPTIONS },
{ "maxusers", MAXUSERS },
{ "nexus", NEXUS },

View File

@ -49,6 +49,7 @@ static const char rcsid[] =
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <ctype.h>
#include <err.h>
#include <stdio.h>
@ -65,14 +66,20 @@ static const char rcsid[] =
#define FALSE (0)
#endif
#define CDIR "../../compile/"
char * PREFIX;
char destdir[MAXPATHLEN];
char srcdir[MAXPATHLEN];
static int no_config_clobber = TRUE;
int old_config_present;
int debugging;
int profiling;
static void usage __P((void));
static void configfile __P((void));
static void get_srcdir __P((void));
static void usage __P((void));
/*
* Config builds a set of files for building a UNIX
@ -85,11 +92,17 @@ main(argc, argv)
{
struct stat buf;
int ch;
int ch, len;
char *p;
while ((ch = getopt(argc, argv, "gprn")) != -1)
while ((ch = getopt(argc, argv, "d:gprn")) != -1)
switch (ch) {
case 'd':
if (*destdir == '\0')
strcpy(destdir, optarg);
else
errx(2, "directory already set");
break;
case 'g':
debugging++;
break;
@ -117,6 +130,16 @@ main(argc, argv)
if (freopen(PREFIX = *argv, "r", stdin) == NULL)
err(2, "%s", PREFIX);
if (*destdir != '\0') {
len = strlen(destdir);
while (len > 1 && destdir[len - 1] == '/')
destdir[--len] = '\0';
get_srcdir();
} else {
strcpy(destdir, CDIR);
strcat(destdir, PREFIX);
}
p = path((char *)NULL);
if (stat(p, &buf)) {
if (mkdir(p, 0777))
@ -164,8 +187,12 @@ main(argc, argv)
*/
{
char xxx[80];
(void) snprintf(xxx, sizeof(xxx), "../../%s/include", machinename);
if (*srcdir == '\0')
(void)snprintf(xxx, sizeof(xxx), "../../%s/include",
machinename);
else
(void)snprintf(xxx, sizeof(xxx), "%s/%s/include",
srcdir, machinename);
(void) symlink(xxx, path("machine"));
}
options(); /* make options .h files */
@ -176,10 +203,34 @@ main(argc, argv)
exit(0);
}
/*
* get_srcdir
* determine the root of the kernel source tree
* and save that in srcdir.
*/
static void
get_srcdir()
{
int i;
char *p;
(void)getcwd(srcdir, sizeof(srcdir));
for (i = 0; i < 2; i++) {
p = strrchr(srcdir, '/');
if (p != NULL)
*p = '\0';
}
/* Sanity check */
p = strrchr(srcdir, '/');
if (p == NULL || strcmp(p + 1, "sys"))
errx(2, "non-standard kernel source tree");
}
static void
usage()
{
fprintf(stderr, "usage: config [-gpr] sysname\n");
fprintf(stderr, "usage: config [-gpr] [-d destdir] sysname\n");
exit(1);
}
@ -302,11 +353,8 @@ path(file)
{
register char *cp;
#define CDIR "../../compile/"
cp = malloc((unsigned int)(sizeof(CDIR) + strlen(PREFIX) +
(file ? strlen(file) : 0) + 2));
(void) strcpy(cp, CDIR);
(void) strcat(cp, PREFIX);
cp = malloc((size_t)(strlen(destdir) + (file ? strlen(file) : 0) + 2));
(void) strcpy(cp, destdir);
if (file) {
(void) strcat(cp, "/");
(void) strcat(cp, file);

View File

@ -181,6 +181,8 @@ makefile()
fprintf(ofp, "PROF=-pg\n");
fprintf(ofp, "PROFLEVEL=%d\n", profiling);
}
if (*srcdir != '\0')
fprintf(ofp,"S=%s\n", srcdir);
while (fgets(line, BUFSIZ, ifp) != 0) {
if (*line != '%') {
fprintf(ofp, "%s", line);