blob: 4cfdc1797eb8c30d985505838eee6d754b222cbf [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * docproc is a simple preprocessor for the template files
3 * used as placeholders for the kernel internal documentation.
4 * docproc is used for documentation-frontend and
5 * dependency-generator.
6 * The two usages have in common that they require
7 * some knowledge of the .tmpl syntax, therefore they
8 * are kept together.
9 *
10 * documentation-frontend
11 * Scans the template file and call kernel-doc for
12 * all occurrences of ![EIF]file
Randy Dunlap6dd16f42007-09-04 21:23:22 -070013 * Beforehand each referenced file is scanned for
14 * any symbols that are exported via these macros:
15 * EXPORT_SYMBOL(), EXPORT_SYMBOL_GPL(), &
16 * EXPORT_SYMBOL_GPL_FUTURE()
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 * This is used to create proper -function and
18 * -nofunction arguments in calls to kernel-doc.
19 * Usage: docproc doc file.tmpl
20 *
21 * dependency-generator:
22 * Scans the template file and list all files
23 * referenced in a format recognized by make.
24 * Usage: docproc depend file.tmpl
25 * Writes dependency information to stdout
26 * in the following format:
27 * file.tmpl src.c src2.c
28 * The filenames are obtained from the following constructs:
29 * !Efilename
30 * !Ifilename
31 * !Dfilename
32 * !Ffilename
Johannes Berge662af42007-10-24 15:08:48 -070033 * !Pfilename
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 *
35 */
36
Johannes Bergeda603f2010-09-11 15:55:22 -070037#define _GNU_SOURCE
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#include <stdio.h>
39#include <stdlib.h>
40#include <string.h>
41#include <ctype.h>
42#include <unistd.h>
43#include <limits.h>
Johannes Bergeda603f2010-09-11 15:55:22 -070044#include <errno.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <sys/types.h>
46#include <sys/wait.h>
47
48/* exitstatus is used to keep track of any failing calls to kernel-doc,
49 * but execution continues. */
50int exitstatus = 0;
51
52typedef void DFL(char *);
53DFL *defaultline;
54
55typedef void FILEONLY(char * file);
56FILEONLY *internalfunctions;
57FILEONLY *externalfunctions;
58FILEONLY *symbolsonly;
Johannes Bergeda603f2010-09-11 15:55:22 -070059FILEONLY *findall;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
J.A. Magallon48b9d032005-06-25 14:59:22 -070061typedef void FILELINE(char * file, char * line);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062FILELINE * singlefunctions;
63FILELINE * entity_system;
Johannes Berge662af42007-10-24 15:08:48 -070064FILELINE * docsection;
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66#define MAXLINESZ 2048
67#define MAXFILES 250
68#define KERNELDOCPATH "scripts/"
69#define KERNELDOC "kernel-doc"
70#define DOCBOOK "-docbook"
Johannes Bergeda603f2010-09-11 15:55:22 -070071#define LIST "-list"
Linus Torvalds1da177e2005-04-16 15:20:36 -070072#define FUNCTION "-function"
73#define NOFUNCTION "-nofunction"
Johannes Berg2e959722007-10-24 15:08:48 -070074#define NODOCSECTIONS "-no-doc-sections"
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Jiri Slaby2d510052009-05-31 18:05:34 +020076static char *srctree, *kernsrctree;
Rob Landleybb13be52007-10-09 01:25:18 -050077
Johannes Bergeda603f2010-09-11 15:55:22 -070078static char **all_list = NULL;
79static int all_list_len = 0;
80
81static void consume_symbol(const char *sym)
82{
83 int i;
84
85 for (i = 0; i < all_list_len; i++) {
86 if (!all_list[i])
87 continue;
88 if (strcmp(sym, all_list[i]))
89 continue;
90 all_list[i] = NULL;
91 break;
92 }
93}
94
Trevor Keith4356f482009-09-18 12:49:23 -070095static void usage (void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
97 fprintf(stderr, "Usage: docproc {doc|depend} file\n");
98 fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n");
99 fprintf(stderr, "doc: frontend when generating kernel documentation\n");
100 fprintf(stderr, "depend: generate list of files referenced within file\n");
Jiri Slaby2d510052009-05-31 18:05:34 +0200101 fprintf(stderr, "Environment variable SRCTREE: absolute path to sources.\n");
102 fprintf(stderr, " KBUILD_SRC: absolute path to kernel source tree.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103}
104
105/*
Randy Dunlap6dd16f42007-09-04 21:23:22 -0700106 * Execute kernel-doc with parameters given in svec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 */
Trevor Keith4356f482009-09-18 12:49:23 -0700108static void exec_kernel_doc(char **svec)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109{
110 pid_t pid;
111 int ret;
112 char real_filename[PATH_MAX + 1];
113 /* Make sure output generated so far are flushed */
114 fflush(stdout);
Randy Dunlap6dd16f42007-09-04 21:23:22 -0700115 switch (pid=fork()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 case -1:
117 perror("fork");
118 exit(1);
119 case 0:
120 memset(real_filename, 0, sizeof(real_filename));
Jiri Slaby2d510052009-05-31 18:05:34 +0200121 strncat(real_filename, kernsrctree, PATH_MAX);
122 strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 PATH_MAX - strlen(real_filename));
124 execvp(real_filename, svec);
125 fprintf(stderr, "exec ");
126 perror(real_filename);
127 exit(1);
128 default:
129 waitpid(pid, &ret ,0);
130 }
131 if (WIFEXITED(ret))
132 exitstatus |= WEXITSTATUS(ret);
133 else
134 exitstatus = 0xff;
135}
136
137/* Types used to create list of all exported symbols in a number of files */
138struct symbols
139{
140 char *name;
141};
142
143struct symfile
144{
145 char *filename;
146 struct symbols *symbollist;
147 int symbolcnt;
148};
149
150struct symfile symfilelist[MAXFILES];
151int symfilecnt = 0;
152
Trevor Keith4356f482009-09-18 12:49:23 -0700153static void add_new_symbol(struct symfile *sym, char * symname)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154{
155 sym->symbollist =
156 realloc(sym->symbollist, (sym->symbolcnt + 1) * sizeof(char *));
157 sym->symbollist[sym->symbolcnt++].name = strdup(symname);
158}
159
160/* Add a filename to the list */
Trevor Keith4356f482009-09-18 12:49:23 -0700161static struct symfile * add_new_file(char * filename)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162{
163 symfilelist[symfilecnt++].filename = strdup(filename);
164 return &symfilelist[symfilecnt - 1];
165}
Randy Dunlap6dd16f42007-09-04 21:23:22 -0700166
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167/* Check if file already are present in the list */
Trevor Keith4356f482009-09-18 12:49:23 -0700168static struct symfile * filename_exist(char * filename)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169{
170 int i;
171 for (i=0; i < symfilecnt; i++)
172 if (strcmp(symfilelist[i].filename, filename) == 0)
173 return &symfilelist[i];
174 return NULL;
175}
176
177/*
178 * List all files referenced within the template file.
179 * Files are separated by tabs.
180 */
Trevor Keith4356f482009-09-18 12:49:23 -0700181static void adddep(char * file) { printf("\t%s", file); }
182static void adddep2(char * file, char * line) { line = line; adddep(file); }
183static void noaction(char * line) { line = line; }
184static void noaction2(char * file, char * line) { file = file; line = line; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
186/* Echo the line without further action */
Trevor Keith4356f482009-09-18 12:49:23 -0700187static void printline(char * line) { printf("%s", line); }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189/*
Randy Dunlap6dd16f42007-09-04 21:23:22 -0700190 * Find all symbols in filename that are exported with EXPORT_SYMBOL &
191 * EXPORT_SYMBOL_GPL (& EXPORT_SYMBOL_GPL_FUTURE implicitly).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 * All symbols located are stored in symfilelist.
193 */
Trevor Keith4356f482009-09-18 12:49:23 -0700194static void find_export_symbols(char * filename)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195{
196 FILE * fp;
197 struct symfile *sym;
198 char line[MAXLINESZ];
199 if (filename_exist(filename) == NULL) {
200 char real_filename[PATH_MAX + 1];
201 memset(real_filename, 0, sizeof(real_filename));
Rob Landleybb13be52007-10-09 01:25:18 -0500202 strncat(real_filename, srctree, PATH_MAX);
Jiri Slaby2d510052009-05-31 18:05:34 +0200203 strncat(real_filename, "/", PATH_MAX - strlen(real_filename));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 strncat(real_filename, filename,
205 PATH_MAX - strlen(real_filename));
206 sym = add_new_file(filename);
207 fp = fopen(real_filename, "r");
Jesper Juhlf0f3ca82011-06-15 11:53:13 +0200208 if (fp == NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 fprintf(stderr, "docproc: ");
210 perror(real_filename);
Henrik Kretzschmar074a5dd2006-09-29 02:00:56 -0700211 exit(1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 }
Randy Dunlap6dd16f42007-09-04 21:23:22 -0700213 while (fgets(line, MAXLINESZ, fp)) {
J.A. Magallon48b9d032005-06-25 14:59:22 -0700214 char *p;
215 char *e;
Randy Dunlap6dd16f42007-09-04 21:23:22 -0700216 if (((p = strstr(line, "EXPORT_SYMBOL_GPL")) != NULL) ||
217 ((p = strstr(line, "EXPORT_SYMBOL")) != NULL)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 /* Skip EXPORT_SYMBOL{_GPL} */
219 while (isalnum(*p) || *p == '_')
220 p++;
Randy Dunlap6dd16f42007-09-04 21:23:22 -0700221 /* Remove parentheses & additional whitespace */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 while (isspace(*p))
223 p++;
224 if (*p != '(')
225 continue; /* Syntax error? */
226 else
227 p++;
228 while (isspace(*p))
229 p++;
230 e = p;
231 while (isalnum(*e) || *e == '_')
232 e++;
233 *e = '\0';
234 add_new_symbol(sym, p);
235 }
236 }
237 fclose(fp);
238 }
239}
240
241/*
242 * Document all external or internal functions in a file.
243 * Call kernel-doc with following parameters:
244 * kernel-doc -docbook -nofunction function_name1 filename
Randy Dunlap6dd16f42007-09-04 21:23:22 -0700245 * Function names are obtained from all the src files
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 * by find_export_symbols.
247 * intfunc uses -nofunction
248 * extfunc uses -function
249 */
Trevor Keith4356f482009-09-18 12:49:23 -0700250static void docfunctions(char * filename, char * type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251{
252 int i,j;
253 int symcnt = 0;
254 int idx = 0;
255 char **vec;
256
257 for (i=0; i <= symfilecnt; i++)
258 symcnt += symfilelist[i].symbolcnt;
Johannes Berg2e959722007-10-24 15:08:48 -0700259 vec = malloc((2 + 2 * symcnt + 3) * sizeof(char *));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 if (vec == NULL) {
261 perror("docproc: ");
262 exit(1);
263 }
264 vec[idx++] = KERNELDOC;
265 vec[idx++] = DOCBOOK;
Johannes Berg2e959722007-10-24 15:08:48 -0700266 vec[idx++] = NODOCSECTIONS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 for (i=0; i < symfilecnt; i++) {
268 struct symfile * sym = &symfilelist[i];
269 for (j=0; j < sym->symbolcnt; j++) {
270 vec[idx++] = type;
Johannes Bergeda603f2010-09-11 15:55:22 -0700271 consume_symbol(sym->symbollist[j].name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 vec[idx++] = sym->symbollist[j].name;
273 }
274 }
275 vec[idx++] = filename;
276 vec[idx] = NULL;
277 printf("<!-- %s -->\n", filename);
278 exec_kernel_doc(vec);
279 fflush(stdout);
280 free(vec);
281}
Trevor Keith4356f482009-09-18 12:49:23 -0700282static void intfunc(char * filename) { docfunctions(filename, NOFUNCTION); }
283static void extfunc(char * filename) { docfunctions(filename, FUNCTION); }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
285/*
Randy Dunlapc6120932006-11-02 22:07:01 -0800286 * Document specific function(s) in a file.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 * Call kernel-doc with the following parameters:
288 * kernel-doc -docbook -function function1 [-function function2]
289 */
Trevor Keith4356f482009-09-18 12:49:23 -0700290static void singfunc(char * filename, char * line)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291{
292 char *vec[200]; /* Enough for specific functions */
293 int i, idx = 0;
294 int startofsym = 1;
295 vec[idx++] = KERNELDOC;
296 vec[idx++] = DOCBOOK;
297
Randy Dunlap6dd16f42007-09-04 21:23:22 -0700298 /* Split line up in individual parameters preceded by FUNCTION */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 for (i=0; line[i]; i++) {
300 if (isspace(line[i])) {
301 line[i] = '\0';
302 startofsym = 1;
303 continue;
304 }
305 if (startofsym) {
306 startofsym = 0;
307 vec[idx++] = FUNCTION;
308 vec[idx++] = &line[i];
309 }
310 }
Johannes Bergeda603f2010-09-11 15:55:22 -0700311 for (i = 0; i < idx; i++) {
312 if (strcmp(vec[i], FUNCTION))
313 continue;
314 consume_symbol(vec[i + 1]);
315 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 vec[idx++] = filename;
317 vec[idx] = NULL;
318 exec_kernel_doc(vec);
319}
320
321/*
Johannes Berge662af42007-10-24 15:08:48 -0700322 * Insert specific documentation section from a file.
323 * Call kernel-doc with the following parameters:
324 * kernel-doc -docbook -function "doc section" filename
325 */
Trevor Keith4356f482009-09-18 12:49:23 -0700326static void docsect(char *filename, char *line)
Johannes Berge662af42007-10-24 15:08:48 -0700327{
328 char *vec[6]; /* kerneldoc -docbook -function "section" file NULL */
329 char *s;
330
331 for (s = line; *s; s++)
332 if (*s == '\n')
333 *s = '\0';
334
Namhyung Kimd0f95c72010-10-22 23:32:10 +0900335 if (asprintf(&s, "DOC: %s", line) < 0) {
336 perror("asprintf");
337 exit(1);
338 }
Johannes Bergeda603f2010-09-11 15:55:22 -0700339 consume_symbol(s);
340 free(s);
341
Johannes Berge662af42007-10-24 15:08:48 -0700342 vec[0] = KERNELDOC;
343 vec[1] = DOCBOOK;
344 vec[2] = FUNCTION;
345 vec[3] = line;
346 vec[4] = filename;
347 vec[5] = NULL;
348 exec_kernel_doc(vec);
349}
350
Johannes Bergeda603f2010-09-11 15:55:22 -0700351static void find_all_symbols(char *filename)
352{
353 char *vec[4]; /* kerneldoc -list file NULL */
354 pid_t pid;
355 int ret, i, count, start;
356 char real_filename[PATH_MAX + 1];
357 int pipefd[2];
358 char *data, *str;
359 size_t data_len = 0;
360
361 vec[0] = KERNELDOC;
362 vec[1] = LIST;
363 vec[2] = filename;
364 vec[3] = NULL;
365
366 if (pipe(pipefd)) {
367 perror("pipe");
368 exit(1);
369 }
370
371 switch (pid=fork()) {
372 case -1:
373 perror("fork");
374 exit(1);
375 case 0:
376 close(pipefd[0]);
377 dup2(pipefd[1], 1);
378 memset(real_filename, 0, sizeof(real_filename));
379 strncat(real_filename, kernsrctree, PATH_MAX);
380 strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
381 PATH_MAX - strlen(real_filename));
382 execvp(real_filename, vec);
383 fprintf(stderr, "exec ");
384 perror(real_filename);
385 exit(1);
386 default:
387 close(pipefd[1]);
388 data = malloc(4096);
389 do {
390 while ((ret = read(pipefd[0],
391 data + data_len,
392 4096)) > 0) {
393 data_len += ret;
394 data = realloc(data, data_len + 4096);
395 }
396 } while (ret == -EAGAIN);
397 if (ret != 0) {
398 perror("read");
399 exit(1);
400 }
401 waitpid(pid, &ret ,0);
402 }
403 if (WIFEXITED(ret))
404 exitstatus |= WEXITSTATUS(ret);
405 else
406 exitstatus = 0xff;
407
408 count = 0;
409 /* poor man's strtok, but with counting */
410 for (i = 0; i < data_len; i++) {
411 if (data[i] == '\n') {
412 count++;
413 data[i] = '\0';
414 }
415 }
416 start = all_list_len;
417 all_list_len += count;
418 all_list = realloc(all_list, sizeof(char *) * all_list_len);
419 str = data;
420 for (i = 0; i < data_len && start != all_list_len; i++) {
421 if (data[i] == '\0') {
422 all_list[start] = str;
423 str = data + i + 1;
424 start++;
425 }
426 }
427}
428
Johannes Berge662af42007-10-24 15:08:48 -0700429/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 * Parse file, calling action specific functions for:
431 * 1) Lines containing !E
432 * 2) Lines containing !I
433 * 3) Lines containing !D
434 * 4) Lines containing !F
Johannes Berge662af42007-10-24 15:08:48 -0700435 * 5) Lines containing !P
Johannes Bergeda603f2010-09-11 15:55:22 -0700436 * 6) Lines containing !C
437 * 7) Default lines - lines not matching the above
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 */
Trevor Keith4356f482009-09-18 12:49:23 -0700439static void parse_file(FILE *infile)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440{
441 char line[MAXLINESZ];
J.A. Magallon48b9d032005-06-25 14:59:22 -0700442 char * s;
Randy Dunlap6dd16f42007-09-04 21:23:22 -0700443 while (fgets(line, MAXLINESZ, infile)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 if (line[0] == '!') {
445 s = line + 2;
446 switch (line[1]) {
447 case 'E':
448 while (*s && !isspace(*s)) s++;
449 *s = '\0';
450 externalfunctions(line+2);
451 break;
452 case 'I':
453 while (*s && !isspace(*s)) s++;
454 *s = '\0';
455 internalfunctions(line+2);
456 break;
457 case 'D':
458 while (*s && !isspace(*s)) s++;
459 *s = '\0';
460 symbolsonly(line+2);
461 break;
462 case 'F':
463 /* filename */
464 while (*s && !isspace(*s)) s++;
465 *s++ = '\0';
466 /* function names */
467 while (isspace(*s))
468 s++;
469 singlefunctions(line +2, s);
470 break;
Johannes Berge662af42007-10-24 15:08:48 -0700471 case 'P':
472 /* filename */
473 while (*s && !isspace(*s)) s++;
474 *s++ = '\0';
475 /* DOC: section name */
476 while (isspace(*s))
477 s++;
478 docsection(line + 2, s);
479 break;
Johannes Bergeda603f2010-09-11 15:55:22 -0700480 case 'C':
481 while (*s && !isspace(*s)) s++;
482 *s = '\0';
483 if (findall)
484 findall(line+2);
485 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 default:
487 defaultline(line);
488 }
Jesper Juhlf0f3ca82011-06-15 11:53:13 +0200489 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 defaultline(line);
491 }
492 }
493 fflush(stdout);
494}
495
496
497int main(int argc, char *argv[])
498{
499 FILE * infile;
Johannes Bergeda603f2010-09-11 15:55:22 -0700500 int i;
Rob Landleybb13be52007-10-09 01:25:18 -0500501
502 srctree = getenv("SRCTREE");
503 if (!srctree)
504 srctree = getcwd(NULL, 0);
Jiri Slaby2d510052009-05-31 18:05:34 +0200505 kernsrctree = getenv("KBUILD_SRC");
Amerigo Wangb767b902009-06-19 03:06:54 -0400506 if (!kernsrctree || !*kernsrctree)
Jiri Slaby2d510052009-05-31 18:05:34 +0200507 kernsrctree = srctree;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 if (argc != 3) {
509 usage();
510 exit(1);
511 }
512 /* Open file, exit on error */
513 infile = fopen(argv[2], "r");
514 if (infile == NULL) {
515 fprintf(stderr, "docproc: ");
516 perror(argv[2]);
517 exit(2);
518 }
519
Jesper Juhlf0f3ca82011-06-15 11:53:13 +0200520 if (strcmp("doc", argv[1]) == 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 /* Need to do this in two passes.
522 * First pass is used to collect all symbols exported
Randy Dunlap6dd16f42007-09-04 21:23:22 -0700523 * in the various files;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 * Second pass generate the documentation.
Randy Dunlap6dd16f42007-09-04 21:23:22 -0700525 * This is required because some functions are declared
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 * and exported in different files :-((
527 */
528 /* Collect symbols */
529 defaultline = noaction;
530 internalfunctions = find_export_symbols;
531 externalfunctions = find_export_symbols;
532 symbolsonly = find_export_symbols;
533 singlefunctions = noaction2;
Johannes Berge662af42007-10-24 15:08:48 -0700534 docsection = noaction2;
Johannes Bergeda603f2010-09-11 15:55:22 -0700535 findall = find_all_symbols;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 parse_file(infile);
537
538 /* Rewind to start from beginning of file again */
539 fseek(infile, 0, SEEK_SET);
540 defaultline = printline;
541 internalfunctions = intfunc;
542 externalfunctions = extfunc;
543 symbolsonly = printline;
544 singlefunctions = singfunc;
Johannes Berge662af42007-10-24 15:08:48 -0700545 docsection = docsect;
Johannes Bergeda603f2010-09-11 15:55:22 -0700546 findall = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547
548 parse_file(infile);
Johannes Bergeda603f2010-09-11 15:55:22 -0700549
550 for (i = 0; i < all_list_len; i++) {
551 if (!all_list[i])
552 continue;
553 fprintf(stderr, "Warning: didn't use docs for %s\n",
554 all_list[i]);
555 }
Jesper Juhlf0f3ca82011-06-15 11:53:13 +0200556 } else if (strcmp("depend", argv[1]) == 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 /* Create first part of dependency chain
558 * file.tmpl */
559 printf("%s\t", argv[2]);
560 defaultline = noaction;
561 internalfunctions = adddep;
562 externalfunctions = adddep;
563 symbolsonly = adddep;
564 singlefunctions = adddep2;
Johannes Berge662af42007-10-24 15:08:48 -0700565 docsection = adddep2;
Johannes Bergeda603f2010-09-11 15:55:22 -0700566 findall = adddep;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 parse_file(infile);
568 printf("\n");
Jesper Juhlf0f3ca82011-06-15 11:53:13 +0200569 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 fprintf(stderr, "Unknown option: %s\n", argv[1]);
571 exit(1);
572 }
573 fclose(infile);
574 fflush(stdout);
575 return exitstatus;
576}