/* * Read in the information about files used in making the system. * Store it in the ftab linked list. */ void read_files(void) { FILE *fp; register struct file_list *tp, *pf; register struct device *dp; register struct opt *op; const char *wd; char *this, *needs; const char *devorprof; int options; int not_option; char pname[BUFSIZ]; char fname[1024]; char *rest = (char *) 0; int nreqs, first = 1, isdup; ftab = 0; (void) sprintf(fname, "%s/files", config_directory); openit: fp = fopenp(VPATH, fname, pname, "r"); if (fp == 0) { perror(fname); exit(1); } next: options = 0; rest = (char *) 0; /* * filename [ standard | optional ] * [ dev* | profiling-routine ] [ device-driver] */ wd = get_word(fp); if (wd == (char *)EOF) { (void) fclose(fp); if (first == 1) { (void) sprintf(fname, "%s/files.%s", config_directory, machinename); first++; goto openit; } return; } if (wd == 0) goto next; /* * Allow comment lines beginning witha '#' character. */ if (*wd == '#') { while ((wd=get_word(fp)) && wd != (char *)EOF) ; goto next; } this = ns(wd); next_word(fp, wd); if (wd == 0) { printf("%s: No type for %s.\n", fname, this); exit(1); } if ((pf = fl_lookup(this)) && (pf->f_type != INVISIBLE || pf->f_flags)) isdup = 1; else isdup = 0; tp = 0; nreqs = 0; devorprof = ""; needs = 0; if (eq(wd, "standard")) goto checkdev; if (!eq(wd, "optional")) { printf("%s: %s must be optional or standard\n", fname, this); exit(1); } if (strncmp(this, "OPTIONS/", 8) == 0) options++; not_option = 0; nextopt: next_word(fp, wd); if (wd == 0) goto doneopt; if (eq(wd, "not")) { not_option = !not_option; goto nextopt; } devorprof = wd; if (eq(wd, "device-driver") || eq(wd, "profiling-routine")) { next_word(fp, wd); goto save; } nreqs++; if (needs == 0 && nreqs == 1) needs = ns(wd); if (isdup) goto invis; if (options) { struct opt *lop = 0; struct device tdev; /* * Allocate a pseudo-device entry which we will insert into * the device list below. The flags field is set non-zero to * indicate an internal entry rather than one generated from * the configuration file. The slave field is set to define * the corresponding symbol as 0 should we fail to find the * option in the option list. */ init_dev(&tdev); tdev.d_name = ns(wd); tdev.d_type = PSEUDO_DEVICE; tdev.d_flags++; tdev.d_slave = 0; for (op=opt; op; lop=op, op=op->op_next) { char *od = allCaps(ns(wd)); /* * Found an option which matches the current device * dependency identifier. Set the slave field to * define the option in the header file. */ if (strcmp(op->op_name, od) == 0) { tdev.d_slave = 1; if (lop == 0) opt = op->op_next; else lop->op_next = op->op_next; free(op); op = 0; } free(od); if (op == 0) break; } newdev(&tdev); } for (dp = dtab; dp != 0; dp = dp->d_next) { if (eq(dp->d_name, wd) && (dp->d_type != PSEUDO_DEVICE || dp->d_slave)) { if (not_option) goto invis; /* dont want file if option present */ else goto nextopt; } } if (not_option) goto nextopt; /* want file if option missing */ for (op = opt; op != 0; op = op->op_next) if (op->op_value == 0 && opteq(op->op_name, wd)) { if (nreqs == 1) { free(needs); needs = 0; } goto nextopt; } invis: while ((wd = get_word(fp)) != 0) ; if (tp == 0) tp = new_fent(); tp->f_fn = this; tp->f_type = INVISIBLE; tp->f_needs = needs; tp->f_flags = isdup; goto next; doneopt: if (nreqs == 0) { printf("%s: what is %s optional on?\n", fname, this); exit(1); } checkdev: if (wd) { if (*wd == '|') goto getrest; next_word(fp, wd); if (wd) { devorprof = wd; next_word(fp, wd); } } save: getrest: if (wd) { if (*wd == '|') { rest = ns(get_rest(fp)); } else { printf("%s: syntax error describing %s\n", fname, this); exit(1); } } if (eq(devorprof, "profiling-routine") && profiling == 0) goto next; if (tp == 0) tp = new_fent(); tp->f_fn = this; tp->f_extra = rest; if (options) tp->f_type = INVISIBLE; else if (eq(devorprof, "device-driver")) tp->f_type = DRIVER; else if (eq(devorprof, "profiling-routine")) tp->f_type = PROFILING; else tp->f_type = NORMAL; tp->f_flags = 0; tp->f_needs = needs; if (pf && pf->f_type == INVISIBLE) pf->f_flags = 1; /* mark as duplicate */ goto next; }
/* * Read in the information about files used in making the system. * Store it in the ftab linked list. */ static void read_files(void) { FILE *fp; struct file_list *tp, *pf; struct device *dp; struct device *save_dp; struct opt *op; char *wd, *this, *needs, *special, *depends, *clean, *warning; char fname[MAXPATHLEN]; int nonoptional; int nreqs, first = 1, configdep, isdup, std, filetype, imp_rule, no_obj, before_depend, nowerror, mandatory; ftab = 0; save_dp = NULL; if (ident == NULL) { printf("no ident line specified\n"); exit(1); } snprintf(fname, sizeof(fname), "../conf/files"); openit: fp = fopen(fname, "r"); if (fp == NULL) err(1, "%s", fname); next: /* * filename [ standard | mandatory | optional ] [ config-dependent ] * [ dev* | profiling-routine ] [ no-obj ] * [ compile-with "compile rule" [no-implicit-rule] ] * [ dependency "dependency-list"] [ before-depend ] * [ clean "file-list"] [ warning "text warning" ] */ wd = get_word(fp); if (wd == (char *)EOF) { fclose(fp); if (first == 1) { first++; snprintf(fname, sizeof(fname), "../platform/%s/conf/files", platformname); fp = fopen(fname, "r"); if (fp != NULL) goto next; snprintf(fname, sizeof(fname), "files.%s", platformname); goto openit; } if (first == 2) { first++; snprintf(fname, sizeof(fname), "files.%s", raisestr(ident)); fp = fopen(fname, "r"); if (fp != NULL) goto next; } return; } if (wd == 0) goto next; if (wd[0] == '#') { while (((wd = get_word(fp)) != (char *)EOF) && wd) ; goto next; } this = strdup(wd); next_word(fp, wd); if (wd == 0) { printf("%s: No type for %s.\n", fname, this); exit(1); } if ((pf = fl_lookup(this)) && (pf->f_type != INVISIBLE || pf->f_flags)) isdup = 1; else isdup = 0; tp = 0; if (first == 3 && pf == NULL && (tp = fltail_lookup(this)) != NULL) { if (tp->f_type != INVISIBLE || tp->f_flags) printf("%s: Local file %s overrides %s.\n", fname, this, tp->f_fn); else printf("%s: Local file %s could override %s" " with a different kernel configuration.\n", fname, this, tp->f_fn); } nreqs = 0; special = NULL; depends = NULL; clean = NULL; warning = NULL; configdep = 0; needs = NULL; std = mandatory = nonoptional = 0; imp_rule = 0; no_obj = 0; before_depend = 0; nowerror = 0; filetype = NORMAL; if (strcmp(wd, "standard") == 0) { std = 1; } else if (strcmp(wd, "mandatory") == 0) { /* * If an entry is marked "mandatory", config will abort if * it's not called by a configuration line in the config * file. Apart from this, the device is handled like one * marked "optional". */ mandatory = 1; } else if (strcmp(wd, "nonoptional") == 0) { nonoptional = 1; } else if (strcmp(wd, "optional") == 0) { /* don't need to do anything */ } else { printf("%s: %s must be optional, mandatory or standard\n", fname, this); printf("Alternatively, your version of config(8) may be out of sync with your\nkernel source.\n"); exit(1); } nextparam: next_word(fp, wd); if (wd == NULL) goto doneparam; if (strcmp(wd, "config-dependent") == 0) { configdep++; goto nextparam; } if (strcmp(wd, "no-obj") == 0) { no_obj++; goto nextparam; } if (strcmp(wd, "no-implicit-rule") == 0) { if (special == NULL) { printf("%s: alternate rule required when " "\"no-implicit-rule\" is specified.\n", fname); } imp_rule++; goto nextparam; } if (strcmp(wd, "before-depend") == 0) { before_depend++; goto nextparam; } if (strcmp(wd, "dependency") == 0) { next_quoted_word(fp, wd); if (wd == NULL) { printf("%s: %s missing compile command string.\n", fname, this); exit(1); } depends = strdup(wd); goto nextparam; } if (strcmp(wd, "clean") == 0) { next_quoted_word(fp, wd); if (wd == NULL) { printf("%s: %s missing clean file list.\n", fname, this); exit(1); } clean = strdup(wd); goto nextparam; } if (strcmp(wd, "compile-with") == 0) { next_quoted_word(fp, wd); if (wd == NULL) { printf("%s: %s missing compile command string.\n", fname, this); exit(1); } special = strdup(wd); goto nextparam; } if (strcmp(wd, "nowerror") == 0) { nowerror++; goto nextparam; } if (strcmp(wd, "warning") == 0) { next_quoted_word(fp, wd); if (wd == NULL) { printf("%s: %s missing warning text string.\n", fname, this); exit(1); } warning = strdup(wd); goto nextparam; } nreqs++; if (strcmp(wd, "local") == 0) { filetype = LOCAL; goto nextparam; } if (strcmp(wd, "no-depend") == 0) { filetype = NODEPEND; goto nextparam; } if (strcmp(wd, "device-driver") == 0) { printf("%s: `device-driver' flag obsolete.\n", fname); exit(1); } if (strcmp(wd, "profiling-routine") == 0) { filetype = PROFILING; goto nextparam; } if (needs == 0 && nreqs == 1) needs = strdup(wd); if (isdup) goto invis; for (dp = dtab; dp != NULL; save_dp = dp, dp = dp->d_next) if (strcmp(dp->d_name, wd) == 0) { if (std && dp->d_type == PSEUDO_DEVICE && dp->d_count <= 0) dp->d_count = 1; goto nextparam; } if (mandatory) { printf("%s: mandatory device \"%s\" not found\n", fname, wd); exit(1); } if (std) { dp = malloc(sizeof(*dp)); bzero(dp, sizeof(*dp)); init_dev(dp); dp->d_name = strdup(wd); dp->d_type = PSEUDO_DEVICE; dp->d_count = 1; save_dp->d_next = dp; goto nextparam; } for (op = opt; op != NULL; op = op->op_next) { if (op->op_value == 0 && opteq(op->op_name, wd)) { if (nreqs == 1) { free(needs); needs = NULL; } goto nextparam; } } if (nonoptional) { printf("%s: the option \"%s\" MUST be specified\n", fname, wd); exit(1); } invis: while ((wd = get_word(fp)) != 0) ; if (tp == NULL) tp = new_fent(); tp->f_fn = this; tp->f_type = INVISIBLE; tp->f_needs = needs; tp->f_flags = isdup; tp->f_special = special; tp->f_depends = depends; tp->f_clean = clean; tp->f_warn = warning; goto next; doneparam: if (std == 0 && nreqs == 0) { printf("%s: what is %s optional on?\n", fname, this); exit(1); } if (wd != NULL) { printf("%s: syntax error describing %s\n", fname, this); exit(1); } if (filetype == PROFILING && profiling == 0) goto next; if (tp == NULL) tp = new_fent(); tp->f_fn = this; tp->f_type = filetype; tp->f_flags = 0; if (configdep) tp->f_flags |= CONFIGDEP; if (imp_rule) tp->f_flags |= NO_IMPLCT_RULE; if (no_obj) tp->f_flags |= NO_OBJ; if (before_depend) tp->f_flags |= BEFORE_DEPEND; if (nowerror) tp->f_flags |= NOWERROR; if (imp_rule) tp->f_flags |= NO_IMPLCT_RULE; if (no_obj) tp->f_flags |= NO_OBJ; tp->f_needs = needs; tp->f_special = special; tp->f_depends = depends; tp->f_clean = clean; tp->f_warn = warning; if (pf && pf->f_type == INVISIBLE) pf->f_flags = 1; /* mark as duplicate */ goto next; }