/* * Important: The below generated source_foo.o and deps_foo.o variable * assignments are parsed not only by make, but also by the rather simple * parser in scripts/mod/sumversion.c. */ static void parse_dep_file(void *map, size_t len) { char *m = map; char *end = m + len; char *p; char s[PATH_MAX]; int first; p = strchr(m, ':'); if (!p) { fprintf(stderr, "fixdep: parse error\n"); exit(1); } memcpy(s, m, p-m); s[p-m] = 0; m = p+1; clear_config(); first = 1; while (m < end) { while (m < end && (*m == ' ' || *m == '\\' || *m == '\n')) m++; p = m; while (p < end && *p != ' ') p++; if (p == end) { do p--; while (!isalnum(*p)); p++; } memcpy(s, m, p-m); s[p-m] = 0; if (strrcmp(s, "include/generated/autoconf.h") && strrcmp(s, "arch/um/include/uml-config.h") && strrcmp(s, "include/linux/kconfig.h") && strrcmp(s, ".ver")) { /* * Do not list the source file as dependency, so that * kbuild is not confused if a .c file is rewritten * into .S or vice versa. Storing it in source_* is * needed for modpost to compute srcversions. */ if (first) { printf("source_%s := %s\n\n", target, s); printf("deps_%s := \\\n", target); } else printf(" %s \\\n", s); do_config_file(s); } first = 0; m = p + 1; } printf("\n%s: $(deps_%s)\n\n", target, target); printf("$(deps_%s):\n", target); }
void parse_dep_file(void *map, size_t len) { char *m = map; char *end = m + len; char *p; char s[PATH_MAX]; p = strchr(m, ':'); if (!p) { fprintf(stderr, "fixdep: parse error\n"); exit(1); } memcpy(s, m, p-m); s[p-m] = 0; printf("deps_%s := \\\n", target); m = p+1; clear_config(); while (m < end) { while (m < end && (*m == ' ' || *m == '\\' || *m == '\n')) m++; p = m; while (p < end && *p != ' ') p++; if (p == end) { do p--; while (!isalnum(*p)); p++; } memcpy(s, m, p-m); s[p-m] = 0; if (strrcmp(s, "include/linux/autoconf.h") && strrcmp(s, "arch/um/include/uml-config.h") && strrcmp(s, ".ver")) { printf(" %s \\\n", s); do_config_file(s); } m = p + 1; } printf("\n%s: $(deps_%s)\n\n", target, target); printf("$(deps_%s):\n", target); }
/* * Important: The below generated source_foo.o and deps_foo.o variable * assignments are parsed not only by make, but also by the rather simple * parser in scripts/mod/sumversion.c. */ static void parse_dep_file(void *map, size_t len) { char *m = map; char *end = m + len; char *p; char s[PATH_MAX]; int is_target; int saw_any_target = 0; int is_first_dep = 0; clear_config(); while (m < end) { /* Skip any "white space" */ while (m < end && (*m == ' ' || *m == '\\' || *m == '\n')) m++; /* Find next "white space" */ p = m; while (p < end && *p != ' ' && *p != '\\' && *p != '\n') p++; /* Is the token we found a target name? */ is_target = (*(p-1) == ':'); /* Don't write any target names into the dependency file */ if (is_target) { /* The /next/ file is the first dependency */ is_first_dep = 1; } else { /* Save this token/filename */ memcpy(s, m, p-m); s[p - m] = 0; /* Ignore certain dependencies */ if (strrcmp(s, "include/generated/autoconf.h") && strrcmp(s, "arch/um/include/uml-config.h") && strrcmp(s, "include/linux/kconfig.h") && strrcmp(s, ".ver")) { /* * Do not list the source file as dependency, * so that kbuild is not confused if a .c file * is rewritten into .S or vice versa. Storing * it in source_* is needed for modpost to * compute srcversions. */ if (is_first_dep) { /* * If processing the concatenation of * multiple dependency files, only * process the first target name, which * will be the original source name, * and ignore any other target names, * which will be intermediate temporary * files. */ if (!saw_any_target) { saw_any_target = 1; printf("source_%s := %s\n\n", target, s); printf("deps_%s := \\\n", target); } is_first_dep = 0; } else printf(" %s \\\n", s); do_config_file(s); } } /* * Start searching for next token immediately after the first * "whitespace" character that follows this token. */ m = p + 1; } if (!saw_any_target) { fprintf(stderr, "fixdep: parse error; no targets found\n"); exit(1); } printf("\n%s: $(deps_%s)\n\n", target, target); printf("$(deps_%s):\n", target); }