/* ************************************************** */ int main(int argc, char *argv[]) { if (do_parse(argc, argv) || /* parse arguments */ do_init() || /* initialization */ do_configuration() || /* configuration */ do_bootstrap()) { /* bootstrap */ goto end; } do_observe(); /* observe */ do_end(); /* end */ goto end; end: do_clean(); /* clean */ return 0; }
/* * Build the makefile from the skeleton */ void makefile(void) { FILE *ifp, *ofp; char line[BUFSIZ]; struct opt *op; int versreq; read_files(); snprintf(line, sizeof(line), "../platform/%s/conf/Makefile", platformname); ifp = fopen(line, "r"); if (ifp == NULL) { snprintf(line, sizeof(line), "Makefile.%s", platformname); ifp = fopen(line, "r"); } if (ifp == NULL) err(1, "%s", line); ofp = fopen(path("Makefile.new"), "w"); if (ofp == NULL) err(1, "%s", path("Makefile.new")); fprintf(ofp, "KERN_IDENT=%s\n", raisestr(ident)); fprintf(ofp, "MACHINE_PLATFORM=%s\n", platformname); fprintf(ofp, "MACHINE=%s\n", machinename); fprintf(ofp, "MACHINE_ARCH=%s\n", machinearchname); fprintf(ofp, ".makeenv MACHINE_PLATFORM\n"); fprintf(ofp, ".makeenv MACHINE\n"); fprintf(ofp, ".makeenv MACHINE_ARCH\n"); fprintf(ofp, "IDENT="); if (profiling) fprintf(ofp, " -DGPROF"); if (cputype == 0) { printf("cpu type must be specified\n"); exit(1); } fprintf(ofp, "\n"); for (op = mkopt; op != NULL; op = op->op_next) fprintf(ofp, "%s=%s\n", op->op_name, op->op_value); if (debugging) fprintf(ofp, "DEBUG=-g\n"); if (profiling) { 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); continue; } if (strcmp(line, "%BEFORE_DEPEND\n") == 0) do_before_depend(ofp); else if (strcmp(line, "%OBJS\n") == 0) do_objs(ofp); else if (strcmp(line, "%MFILES\n") == 0) do_mfiles(ofp); else if (strcmp(line, "%CFILES\n") == 0) do_cfiles(ofp); else if (strcmp(line, "%SFILES\n") == 0) do_sfiles(ofp); else if (strcmp(line, "%RULES\n") == 0) do_rules(ofp); else if (strcmp(line, "%CLEAN\n") == 0) do_clean(ofp); else if (strncmp(line, "%VERSREQ=", sizeof("%VERSREQ=") - 1) == 0) { versreq = atoi(line + sizeof("%VERSREQ=") - 1); if (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 fprintf(stderr, "Unknown %% construct in generic makefile: %s", line); } fclose(ifp); fclose(ofp); moveifchanged(path("Makefile.new"), path("Makefile")); }