Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/config/mkmakefile.c
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
static void do_before_depend(FILE *); | static void do_before_depend(FILE *); | ||||
static void read_files(void); | static void read_files(void); | ||||
static void sanitize_envline(char *result, const char *src); | static void sanitize_envline(char *result, const char *src); | ||||
static bool preprocess(char *line, char *result); | static bool preprocess(char *line, char *result); | ||||
static void process_into_file(char *line, FILE *ofp); | static void process_into_file(char *line, FILE *ofp); | ||||
static void process_into_nvlist(char *line, nvlist_t *nvl); | static void process_into_nvlist(char *line, nvlist_t *nvl); | ||||
static void dump_nvlist(nvlist_t *nvl, FILE *ofp); | static void dump_nvlist(nvlist_t *nvl, FILE *ofp); | ||||
static const char keywords[] = { "!|" }; | |||||
static void errout(const char *fmt, ...) | static void errout(const char *fmt, ...) | ||||
{ | { | ||||
va_list ap; | va_list ap; | ||||
va_start(ap, fmt); | va_start(ap, fmt); | ||||
vfprintf(stderr, fmt, ap); | vfprintf(stderr, fmt, ap); | ||||
va_end(ap); | va_end(ap); | ||||
exit(1); | exit(1); | ||||
Show All 12 Lines | if (eq(fp->f_fn, file)) | ||||
return (fp); | return (fp); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Make a new file list entry | * Make a new file list entry | ||||
*/ | */ | ||||
static struct file_list * | struct file_list * | ||||
new_fent(void) | new_fent(void) | ||||
{ | { | ||||
struct file_list *fp; | struct file_list *fp; | ||||
fp = (struct file_list *) calloc(1, sizeof *fp); | fp = (struct file_list *) calloc(1, sizeof *fp); | ||||
if (fp == NULL) | if (fp == NULL) | ||||
err(EXIT_FAILURE, "calloc"); | err(EXIT_FAILURE, "calloc"); | ||||
STAILQ_INSERT_TAIL(&ftab, fp, f_next); | STAILQ_INSERT_TAIL(&ftab, fp, f_next); | ||||
▲ Show 20 Lines • Show All 297 Lines • ▼ Show 20 Lines | next: | ||||
* filename [ standard | optional ] | * filename [ standard | optional ] | ||||
* [ dev* [ | dev* ... ] | [ no-obj ] | * [ dev* [ | dev* ... ] | [ no-obj ] | ||||
* [ compile-with "compile rule" [no-implicit-rule] ] | * [ compile-with "compile rule" [no-implicit-rule] ] | ||||
* [ dependency "dependency-list"] [ before-depend ] | * [ dependency "dependency-list"] [ before-depend ] | ||||
* [ clean "file-list"] [ warning "text warning" ] | * [ clean "file-list"] [ warning "text warning" ] | ||||
* [ obj-prefix "file prefix"] | * [ obj-prefix "file prefix"] | ||||
* [ nowerror ] [ local ] | * [ nowerror ] [ local ] | ||||
*/ | */ | ||||
wd = get_word(fp); | wd = get_word(fp, NULL); | ||||
if (wd == (char *)EOF) { | if (wd == (char *)EOF) { | ||||
(void) fclose(fp); | (void) fclose(fp); | ||||
return; | return; | ||||
} | } | ||||
if (wd == NULL) | if (wd == NULL) | ||||
goto next; | goto next; | ||||
if (wd[0] == '#') | if (wd[0] == '#') | ||||
{ | { | ||||
while (((wd = get_word(fp)) != (char *)EOF) && wd) | while (((wd = get_word(fp, NULL)) != (char *)EOF) && wd) | ||||
; | ; | ||||
goto next; | goto next; | ||||
} | } | ||||
if (eq(wd, "include")) { | if (eq(wd, "include")) { | ||||
wd = get_quoted_word(fp); | wd = get_quoted_word(fp); | ||||
if (wd == (char *)EOF || wd == NULL) | if (wd == (char *)EOF || wd == NULL) | ||||
errout("%s: missing include filename.\n", fname); | errout("%s: missing include filename.\n", fname); | ||||
(void) snprintf(ifname, sizeof(ifname), "../../%s", wd); | (void) snprintf(ifname, sizeof(ifname), "../../%s", wd); | ||||
read_file(ifname); | read_file(ifname); | ||||
while (((wd = get_word(fp)) != (char *)EOF) && wd) | while (((wd = get_word(fp, NULL)) != (char *)EOF) && wd) | ||||
; | ; | ||||
goto next; | goto next; | ||||
} | } | ||||
this = ns(wd); | this = ns(wd); | ||||
wd = get_word(fp); | wd = get_word(fp, NULL); | ||||
if (wd == (char *)EOF) | if (wd == (char *)EOF) | ||||
return; | return; | ||||
if (wd == NULL) | if (wd == NULL) | ||||
errout("%s: No type for %s.\n", fname, this); | errout("%s: No type for %s.\n", fname, this); | ||||
tp = fl_lookup(this); | tp = fl_lookup(this); | ||||
compile = 0; | compile = 0; | ||||
match = 1; | match = 1; | ||||
nreqs = 0; | nreqs = 0; | ||||
Show All 10 Lines | next: | ||||
not = 0; | not = 0; | ||||
filetype = NORMAL; | filetype = NORMAL; | ||||
objprefix = ""; | objprefix = ""; | ||||
if (eq(wd, "standard")) | if (eq(wd, "standard")) | ||||
std = 1; | std = 1; | ||||
else if (!eq(wd, "optional")) | else if (!eq(wd, "optional")) | ||||
errout("%s: \"%s\" %s must be optional or standard\n", | errout("%s: \"%s\" %s must be optional or standard\n", | ||||
fname, wd, this); | fname, wd, this); | ||||
for (wd = get_word(fp); wd; wd = get_word(fp)) { | for (wd = get_word(fp, keywords); wd; wd = get_word(fp, keywords)) { | ||||
if (wd == (char *)EOF) | if (wd == (char *)EOF) | ||||
return; | return; | ||||
if (eq(wd, "!")) { | if (eq(wd, "!")) { | ||||
not = 1; | not = 1; | ||||
continue; | continue; | ||||
} | } | ||||
if (eq(wd, "|")) { | if (eq(wd, "|")) { | ||||
if (nreqs == 0) | if (nreqs == 0) | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | |||||
* Read in the information about files used in making the system. | * Read in the information about files used in making the system. | ||||
* Store it in the ftab linked list. | * Store it in the ftab linked list. | ||||
*/ | */ | ||||
static void | static void | ||||
read_files(void) | read_files(void) | ||||
{ | { | ||||
char fname[MAXPATHLEN]; | char fname[MAXPATHLEN]; | ||||
struct files_name *nl, *tnl; | struct files_name *nl, *tnl; | ||||
void (*read_fn)(char *); | |||||
if (versreq < CONFIGVERS_FORMAT_V2) | |||||
read_fn = &read_file; | |||||
else | |||||
read_fn = &read_file_v2; | |||||
(void) snprintf(fname, sizeof(fname), "../../conf/files"); | (void) snprintf(fname, sizeof(fname), "../../conf/files"); | ||||
read_file(fname); | read_fn(fname); | ||||
(void) snprintf(fname, sizeof(fname), | (void) snprintf(fname, sizeof(fname), | ||||
"../../conf/files.%s", machinename); | "../../conf/files.%s", machinename); | ||||
read_file(fname); | read_fn(fname); | ||||
for (nl = STAILQ_FIRST(&fntab); nl != NULL; nl = tnl) { | for (nl = STAILQ_FIRST(&fntab); nl != NULL; nl = tnl) { | ||||
read_file(nl->f_name); | read_fn(nl->f_name); | ||||
tnl = STAILQ_NEXT(nl, f_next); | tnl = STAILQ_NEXT(nl, f_next); | ||||
free(nl->f_name); | free(nl->f_name); | ||||
free(nl); | free(nl); | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
do_before_depend(FILE *fp) | do_before_depend(FILE *fp) | ||||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |