+ ofp = fopen(path("Makefile"), "w");
+ if (ofp == 0) {
+ perror(path("Makefile"));
+ exit(1);
+ }
+ fprintf(ofp, "IDENT=-D%s", raise(ident));
+ if (profiling)
+ fprintf(ofp, " -DGPROF");
+ if (cputype == 0) {
+ printf("cpu type must be specified\n");
+ exit(1);
+ }
+ { struct cputype *cp;
+ for (cp = cputype; cp; cp = cp->cpu_next)
+ fprintf(ofp, " -D%s", cp->cpu_name);
+ }
+ for (op = opt; op; op = op->op_next)
+ if (op->op_value)
+ fprintf(ofp, " -D%s=\"%s\"", op->op_name, op->op_value);
+ else
+ fprintf(ofp, " -D%s", op->op_name);
+ fprintf(ofp, "\n");
+ if (hadtz == 0)
+ printf("timezone not specified; gmt assumed\n");
+ if ((unsigned)machine > NUSERS) {
+ printf("maxusers config info isn't present, using vax\n");
+ up = &users[MACHINE_VAX-1];
+ } else
+ up = &users[machine-1];
+ if (maxusers == 0) {
+ printf("maxusers not specified; %d assumed\n", up->u_default);
+ maxusers = up->u_default;
+ } else if (maxusers < up->u_min) {
+ printf("minimum of %d maxusers assumed\n", up->u_min);
+ maxusers = up->u_min;
+ } else if (maxusers > up->u_max)
+ printf("warning: maxusers > %d (%d)\n", up->u_max, maxusers);
+ fprintf(ofp, "PARAM=-DTIMEZONE=%d -DDST=%d -DMAXUSERS=%d\n",
+ timezone, dst, maxusers);
+ for (op = mkopt; op; op = op->op_next)
+ fprintf(ofp, "%s=%s\n", op->op_name, op->op_value);
+ while (fgets(line, BUFSIZ, ifp) != 0) {
+ if (*line == '%')
+ goto percent;
+ if (profiling && strncmp(line, "COPTS=", 6) == 0) {
+ register char *cp;
+
+ fprintf(ofp, _PATH_GPROF, machinename);
+ cp = index(line, '\n');
+ if (cp)
+ *cp = 0;
+ cp = line + 6;
+ while (*cp && (*cp == ' ' || *cp == '\t'))
+ cp++;
+ COPTS = malloc((unsigned)(strlen(cp) + 1));
+ if (COPTS == 0) {
+ printf("config: out of memory\n");
+ exit(1);
+ }
+ strcpy(COPTS, cp);
+ fprintf(ofp, "%s -pg\n", line);
+ continue;
+ }
+ fprintf(ofp, "%s", line);
+ continue;
+ percent:
+ if (eq(line, "%OBJS\n"))
+ do_objs(ofp);
+ else if (eq(line, "%CFILES\n"))
+ do_cfiles(ofp);
+ else if (eq(line, "%RULES\n"))
+ do_rules(ofp);
+ else if (eq(line, "%LOAD\n"))
+ do_load(ofp);
+ else
+ fprintf(stderr,
+ "Unknown %% construct in generic makefile: %s",
+ line);
+ }
+ (void) fclose(ifp);
+ (void) fclose(ofp);