summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2005-12-30 15:29:50 +0000
committerru <ru@FreeBSD.org>2005-12-30 15:29:50 +0000
commit9d1801a10554429dd1cfce2268b2f14d02e25509 (patch)
tree89491ff57608e5c7f7419acbfdb5462531473285
parente1d71bf7ffd9ed8d01e36055fb6e58ec68e88197 (diff)
downloadFreeBSD-src-9d1801a10554429dd1cfce2268b2f14d02e25509.zip
FreeBSD-src-9d1801a10554429dd1cfce2268b2f14d02e25509.tar.gz
Clean up most of the "XXX"-tagged items:
- The code that creates hints.c and env.c from the skeleton files moved into separate functions. - Sanity checks for missing "ident" and "cputype" directives moved into main(), alongside the existing check for "machine". PR: bin/90310 Submitted by: Matt Emmerton <matt@gsicomp.on.ca>
-rw-r--r--usr.sbin/config/config.h2
-rw-r--r--usr.sbin/config/main.c15
-rw-r--r--usr.sbin/config/mkmakefile.c35
-rw-r--r--usr.sbin/config/mkoptions.c4
4 files changed, 39 insertions, 17 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h
index d1ba1ed..31d3375 100644
--- a/usr.sbin/config/config.h
+++ b/usr.sbin/config/config.h
@@ -144,6 +144,8 @@ int yyparse(void);
int yylex(void);
void options(void);
void makefile(void);
+void makeenv(void);
+void makehints(void);
void headers(void);
extern STAILQ_HEAD(device_head, device) dtab;
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index e7f270e..d485e91 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -162,10 +162,23 @@ main(int argc, char **argv)
STAILQ_INIT(&ftab);
if (yyparse())
exit(3);
+
+ /*
+ * Ensure that required elements (machine, cpu, ident) are present.
+ */
if (machinename == NULL) {
printf("Specify machine type, e.g. ``machine i386''\n");
exit(1);
}
+ if (ident == NULL) {
+ printf("no ident line specified\n");
+ exit(1);
+ }
+ if (SLIST_EMPTY(&cputype)) {
+ printf("cpu type must be specified\n");
+ exit(1);
+ }
+
/*
* make symbolic links in compilation directory
* for "sys" (to make genassym.c work along with #include <sys/xxx>)
@@ -194,6 +207,8 @@ main(int argc, char **argv)
}
options(); /* make options .h files */
makefile(); /* build Makefile */
+ makeenv(); /* build env.c */
+ makehints(); /* build hints.c */
headers(); /* make a lot of .h files */
configfile(); /* put config file into kernel*/
cleanheaders(p);
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index 9ef2adf..157cff6 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -113,7 +113,6 @@ makefile(void)
char line[BUFSIZ];
struct opt *op;
int versreq;
- char *s;
read_files();
snprintf(line, sizeof(line), "../../conf/Makefile.%s", machinename);
@@ -125,12 +124,6 @@ makefile(void)
if (ifp == 0)
err(1, "%s", line);
- /* XXX this check seems to be misplaced. */
- if (SLIST_EMPTY(&cputype)) {
- printf("cpu type must be specified\n");
- exit(1);
- }
-
ofp = fopen(path("Makefile.new"), "w");
if (ofp == 0)
err(1, "%s", path("Makefile.new"));
@@ -181,8 +174,18 @@ makefile(void)
(void) fclose(ifp);
(void) fclose(ofp);
moveifchanged(path("Makefile.new"), path("Makefile"));
+}
+
+/*
+ * Build hints.c from the skeleton
+ */
+void
+makehints(void)
+{
+ FILE *ifp, *ofp;
+ char line[BUFSIZ];
+ char *s;
- /* XXX makefile() should make the Makefile, not hints.c. */
if (hints) {
ifp = fopen(hints, "r");
if (ifp == NULL)
@@ -234,8 +237,18 @@ makefile(void)
fclose(ifp);
fclose(ofp);
moveifchanged(path("hints.c.new"), path("hints.c"));
+}
+
+/*
+ * Build env.c from the skeleton
+ */
+void
+makeenv(void)
+{
+ FILE *ifp, *ofp;
+ char line[BUFSIZ];
+ char *s;
- /* XXX makefile() should make the Makefile, not env.c. */
if (env) {
ifp = fopen(env, "r");
if (ifp == NULL)
@@ -518,10 +531,6 @@ read_files(void)
char fname[MAXPATHLEN];
struct files_name *nl, *tnl;
- if (ident == NULL) {
- printf("no ident line specified\n");
- exit(1);
- }
(void) snprintf(fname, sizeof(fname), "../../conf/files");
read_file(fname);
(void) snprintf(fname, sizeof(fname),
diff --git a/usr.sbin/config/mkoptions.c b/usr.sbin/config/mkoptions.c
index 3e2dcf7..d757815 100644
--- a/usr.sbin/config/mkoptions.c
+++ b/usr.sbin/config/mkoptions.c
@@ -290,10 +290,6 @@ read_options(void)
char genopt[MAXPATHLEN];
SLIST_INIT(&otab);
- if (ident == NULL) {
- printf("no ident line specified\n");
- exit(1);
- }
(void) snprintf(fname, sizeof(fname), "../../conf/options");
openit:
fp = fopen(fname, "r");
OpenPOWER on IntegriCloud