- FILE *ifp, *ofp;
- char line[BUFSIZ];
- struct cputype *cp;
- struct opt *op;
-
- read_files(); /* Read in the "files" file */
- ifp = fopen("../conf/makefile", "r");
- if (ifp == NULL) {
- perror("../conf/makefile");
- exit(1);
- }
- ofp = fopen(path("makefile"), "w");
- if (ofp == NULL) {
- perror(path("makefile"));
- exit(1);
- }
- fprintf(ofp, "IDENT=-D%s", raise(ident));
- if (profiling)
- fprintf(ofp, " -DGPROF");
- if (cputype == NULL) {
- printf("cpu type must be specified\n");
- exit(1);
- }
- 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 (hz == 0) {
-#ifdef notdef
- printf("hz not specified; 50hz assumed\n");
-#endif
- hz = 60;
- }
- if (hadtz == 0)
- printf("timezone not specified; gmt assumed\n");
- if (maxusers == 0) {
- printf("maxusers not specified; 24 assumed\n");
- maxusers = 24;
- } else if (maxusers < 8) {
- printf("minimum of 8 maxusers assumed\n");
- maxusers = 8;
- } else if (maxusers > 128) {
- printf("maxusers truncated to 128\n");
- maxusers = 128;
- }
- fprintf(ofp, "PARAM=-DHZ=%d -DTIMEZONE=%d -DDST=%d -DMAXUSERS=%d\n",
- hz, timezone, dst, maxusers);
- while(fgets(line, BUFSIZ, ifp) != NULL)
- {
- if (*line != '%')
- {
- register char *cp;
-
- if (profiling && strncmp(line, "COPTS=", 6) == 0) {
- fprintf(ofp, "CRT0.EX=/usr/src/libc/csu/crt0.ex\n");
- cp = index(line, '\n');
- if (cp)
- *cp = '\0';
- cp = line + 6;
- while (*cp && (*cp == ' ' || *cp == '\t'))
- cp++;
- COPTS = malloc(strlen(cp) + 1);
- if (COPTS == 0) {
- fprintf(stderr, "config: out of memory\n");
- exit(1);
+ FILE *ifp, *ofp;
+ char line[BUFSIZ];
+ struct opt *op;
+ struct users *up;
+
+ read_files();
+ strcpy(line, "Makefile.");
+ (void) strcat(line, machinename);
+ ifp = fopen(line, "r");
+ if (ifp == 0) {
+ perror(line);
+ exit(1);
+ }
+ 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",
+ zone, dst, maxusers);
+ if (hz > 0)
+ fprintf(ofp, " -DHZ=%d", hz);
+ fprintf(ofp, "\n");
+ for (op = mkopt; op; 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");
+ while (fgets(line, BUFSIZ, ifp) != 0) {
+ if (*line != '%') {
+ fprintf(ofp, "%s", line);
+ continue;