aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/basic/fixdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/basic/fixdep.c')
-rw-r--r--scripts/basic/fixdep.c61
1 files changed, 46 insertions, 15 deletions
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index caef815d1743..746ec1ece614 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -120,13 +120,15 @@
120#define INT_NFIG ntohl(0x4e464947) 120#define INT_NFIG ntohl(0x4e464947)
121#define INT_FIG_ ntohl(0x4649475f) 121#define INT_FIG_ ntohl(0x4649475f)
122 122
123int insert_extra_deps;
123char *target; 124char *target;
124char *depfile; 125char *depfile;
125char *cmdline; 126char *cmdline;
126 127
127static void usage(void) 128static void usage(void)
128{ 129{
129 fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n"); 130 fprintf(stderr, "Usage: fixdep [-e] <depfile> <target> <cmdline>\n");
131 fprintf(stderr, " -e insert extra dependencies given on stdin\n");
130 exit(1); 132 exit(1);
131} 133}
132 134
@@ -138,6 +140,40 @@ static void print_cmdline(void)
138 printf("cmd_%s := %s\n\n", target, cmdline); 140 printf("cmd_%s := %s\n\n", target, cmdline);
139} 141}
140 142
143/*
144 * Print out a dependency path from a symbol name
145 */
146static void print_config(const char *m, int slen)
147{
148 int c, i;
149
150 printf(" $(wildcard include/config/");
151 for (i = 0; i < slen; i++) {
152 c = m[i];
153 if (c == '_')
154 c = '/';
155 else
156 c = tolower(c);
157 putchar(c);
158 }
159 printf(".h) \\\n");
160}
161
162static void do_extra_deps(void)
163{
164 if (insert_extra_deps) {
165 char buf[80];
166 while(fgets(buf, sizeof(buf), stdin)) {
167 int len = strlen(buf);
168 if (len < 2 || buf[len-1] != '\n') {
169 fprintf(stderr, "fixdep: bad data on stdin\n");
170 exit(1);
171 }
172 print_config(buf, len-1);
173 }
174 }
175}
176
141struct item { 177struct item {
142 struct item *next; 178 struct item *next;
143 unsigned int len; 179 unsigned int len;
@@ -197,23 +233,12 @@ static void define_config(const char *name, int len, unsigned int hash)
197static void use_config(const char *m, int slen) 233static void use_config(const char *m, int slen)
198{ 234{
199 unsigned int hash = strhash(m, slen); 235 unsigned int hash = strhash(m, slen);
200 int c, i;
201 236
202 if (is_defined_config(m, slen, hash)) 237 if (is_defined_config(m, slen, hash))
203 return; 238 return;
204 239
205 define_config(m, slen, hash); 240 define_config(m, slen, hash);
206 241 print_config(m, slen);
207 printf(" $(wildcard include/config/");
208 for (i = 0; i < slen; i++) {
209 c = m[i];
210 if (c == '_')
211 c = '/';
212 else
213 c = tolower(c);
214 putchar(c);
215 }
216 printf(".h) \\\n");
217} 242}
218 243
219static void parse_config_file(const char *map, size_t len) 244static void parse_config_file(const char *map, size_t len)
@@ -250,7 +275,7 @@ static void parse_config_file(const char *map, size_t len)
250 } 275 }
251} 276}
252 277
253/* test is s ends in sub */ 278/* test if s ends in sub */
254static int strrcmp(const char *s, const char *sub) 279static int strrcmp(const char *s, const char *sub)
255{ 280{
256 int slen = strlen(s); 281 int slen = strlen(s);
@@ -333,6 +358,7 @@ static void parse_dep_file(void *map, size_t len)
333 358
334 /* Ignore certain dependencies */ 359 /* Ignore certain dependencies */
335 if (strrcmp(s, "include/generated/autoconf.h") && 360 if (strrcmp(s, "include/generated/autoconf.h") &&
361 strrcmp(s, "include/generated/autoksyms.h") &&
336 strrcmp(s, "arch/um/include/uml-config.h") && 362 strrcmp(s, "arch/um/include/uml-config.h") &&
337 strrcmp(s, "include/linux/kconfig.h") && 363 strrcmp(s, "include/linux/kconfig.h") &&
338 strrcmp(s, ".ver")) { 364 strrcmp(s, ".ver")) {
@@ -378,6 +404,8 @@ static void parse_dep_file(void *map, size_t len)
378 exit(1); 404 exit(1);
379 } 405 }
380 406
407 do_extra_deps();
408
381 printf("\n%s: $(deps_%s)\n\n", target, target); 409 printf("\n%s: $(deps_%s)\n\n", target, target);
382 printf("$(deps_%s):\n", target); 410 printf("$(deps_%s):\n", target);
383} 411}
@@ -434,7 +462,10 @@ int main(int argc, char *argv[])
434{ 462{
435 traps(); 463 traps();
436 464
437 if (argc != 4) 465 if (argc == 5 && !strcmp(argv[1], "-e")) {
466 insert_extra_deps = 1;
467 argv++;
468 } else if (argc != 4)
438 usage(); 469 usage();
439 470
440 depfile = argv[1]; 471 depfile = argv[1];