summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config/mkmakefile.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2010-04-27 05:04:32 +0000
committerimp <imp@FreeBSD.org>2010-04-27 05:04:32 +0000
commit1b05a112d4cbea67db29b7df286106b4cde94e93 (patch)
treea2652595ec783ee7d8e499e3947ba8000e7f2d54 /usr.sbin/config/mkmakefile.c
parentbba9d9c06c699a401091f437b2dced6938a6accc (diff)
downloadFreeBSD-src-1b05a112d4cbea67db29b7df286106b4cde94e93.zip
FreeBSD-src-1b05a112d4cbea67db29b7df286106b4cde94e93.tar.gz
Move checking the version up from Makefile generation to just after
we've parsed the config file. Makefile generation is too late if we've introduce changes to the syntax of the metafiles to warn about version skew, since we have to try to parse them and we get an parse error that's rather baffling to the user rather than a 'your config is too old, upgrade' which we should get. We have to defer doing it until after we've read the user's config file because we define machinename there. The version required to compile the kernel is encoded in Makefile.machinename. There's no real reason for this to be the case, but changing it now would introduce some logistical issues that I'd rather avoid for the moment. I intend to revisit this if we're still using config in FreeBSD 10. This also means that we cannot introduce any config metafile changes that result in a syntax error or other error for the user until 9.0 is released. Otherwise, we break the upgrade path, or at least reduce the usefulness of the error messages we generate. # This implies that the config file option mapping will need to be redone. MFC after: 3 days
Diffstat (limited to 'usr.sbin/config/mkmakefile.c')
-rw-r--r--usr.sbin/config/mkmakefile.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index 7845089..b5a0e35 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -105,17 +105,14 @@ new_fent(void)
}
/*
- * Build the makefile from the skeleton
+ * Open the correct Makefile and return it, or error out.
*/
-void
-makefile(void)
+FILE *
+open_makefile_template(void)
{
- FILE *ifp, *ofp;
+ FILE *ifp;
char line[BUFSIZ];
- struct opt *op, *t;
- int versreq;
- read_files();
snprintf(line, sizeof(line), "../../conf/Makefile.%s", machinename);
ifp = fopen(line, "r");
if (ifp == 0) {
@@ -124,7 +121,21 @@ makefile(void)
}
if (ifp == 0)
err(1, "%s", line);
+ return (ifp);
+}
+/*
+ * Build the makefile from the skeleton
+ */
+void
+makefile(void)
+{
+ FILE *ifp, *ofp;
+ char line[BUFSIZ];
+ struct opt *op, *t;
+
+ read_files();
+ ifp = open_makefile_template();
ofp = fopen(path("Makefile.new"), "w");
if (ofp == 0)
err(1, "%s", path("Makefile.new"));
@@ -156,23 +167,9 @@ makefile(void)
do_rules(ofp);
else if (eq(line, "%CLEAN\n"))
do_clean(ofp);
- else if (strncmp(line, "%VERSREQ=", sizeof("%VERSREQ=") - 1) == 0) {
- versreq = atoi(line + sizeof("%VERSREQ=") - 1);
- if (MAJOR_VERS(versreq) != MAJOR_VERS(CONFIGVERS) ||
- versreq > CONFIGVERS) {
- fprintf(stderr, "ERROR: version of config(8) does not match kernel!\n");
- fprintf(stderr, "config version = %d, ", CONFIGVERS);
- fprintf(stderr, "version required = %d\n\n", versreq);
- fprintf(stderr, "Make sure that /usr/src/usr.sbin/config is in sync\n");
- fprintf(stderr, "with your /usr/src/sys and install a new config binary\n");
- fprintf(stderr, "before trying this again.\n\n");
- fprintf(stderr, "If running the new config fails check your config\n");
- fprintf(stderr, "file against the GENERIC or LINT config files for\n");
- fprintf(stderr, "changes in config syntax, or option/device naming\n");
- fprintf(stderr, "conventions\n\n");
- exit(1);
- }
- } else
+ else if (strncmp(line, "%VERSREQ=", 9) == 0)
+ line[0] = '\0'; /* handled elsewhere */
+ else
fprintf(stderr,
"Unknown %% construct in generic makefile: %s",
line);
OpenPOWER on IntegriCloud