diff options
Diffstat (limited to 'scripts/basic')
| -rw-r--r-- | scripts/basic/.gitignore | 2 | ||||
| -rw-r--r-- | scripts/basic/Makefile | 3 | ||||
| -rw-r--r-- | scripts/basic/docproc.c | 583 |
3 files changed, 1 insertions, 587 deletions
diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore index bf8b199ec598..a776371a3502 100644 --- a/scripts/basic/.gitignore +++ b/scripts/basic/.gitignore | |||
| @@ -1,3 +1 @@ | |||
| 1 | hash | ||
| 2 | fixdep | fixdep | |
| 3 | docproc | ||
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile index 4c324a1f1e0e..4fcef87bb875 100644 --- a/scripts/basic/Makefile +++ b/scripts/basic/Makefile | |||
| @@ -7,9 +7,8 @@ | |||
| 7 | # .config is included by main Makefile. | 7 | # .config is included by main Makefile. |
| 8 | # --------------------------------------------------------------------------- | 8 | # --------------------------------------------------------------------------- |
| 9 | # fixdep: Used to generate dependency information during build process | 9 | # fixdep: Used to generate dependency information during build process |
| 10 | # docproc: Used in Documentation/DocBook | ||
| 11 | 10 | ||
| 12 | hostprogs-y := fixdep docproc | 11 | hostprogs-y := fixdep |
| 13 | always := $(hostprogs-y) | 12 | always := $(hostprogs-y) |
| 14 | 13 | ||
| 15 | # fixdep is needed to compile other host programs | 14 | # fixdep is needed to compile other host programs |
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c deleted file mode 100644 index 98dec87974d0..000000000000 --- a/scripts/basic/docproc.c +++ /dev/null | |||
| @@ -1,583 +0,0 @@ | |||
| 1 | /* | ||
| 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 | ||
| 13 | * 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() | ||
| 17 | * 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 | ||
| 33 | * !Pfilename | ||
| 34 | * | ||
| 35 | */ | ||
| 36 | |||
| 37 | #define _GNU_SOURCE | ||
| 38 | #include <stdio.h> | ||
| 39 | #include <stdlib.h> | ||
| 40 | #include <string.h> | ||
| 41 | #include <ctype.h> | ||
| 42 | #include <unistd.h> | ||
| 43 | #include <limits.h> | ||
| 44 | #include <errno.h> | ||
| 45 | #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. */ | ||
| 50 | int exitstatus = 0; | ||
| 51 | |||
| 52 | typedef void DFL(char *); | ||
| 53 | DFL *defaultline; | ||
| 54 | |||
| 55 | typedef void FILEONLY(char * file); | ||
| 56 | FILEONLY *internalfunctions; | ||
| 57 | FILEONLY *externalfunctions; | ||
| 58 | FILEONLY *symbolsonly; | ||
| 59 | FILEONLY *findall; | ||
| 60 | |||
| 61 | typedef void FILELINE(char * file, char * line); | ||
| 62 | FILELINE * singlefunctions; | ||
| 63 | FILELINE * entity_system; | ||
| 64 | FILELINE * docsection; | ||
| 65 | |||
| 66 | #define MAXLINESZ 2048 | ||
| 67 | #define MAXFILES 250 | ||
| 68 | #define KERNELDOCPATH "scripts/" | ||
| 69 | #define KERNELDOC "kernel-doc" | ||
| 70 | #define DOCBOOK "-docbook" | ||
| 71 | #define LIST "-list" | ||
| 72 | #define FUNCTION "-function" | ||
| 73 | #define NOFUNCTION "-nofunction" | ||
| 74 | #define NODOCSECTIONS "-no-doc-sections" | ||
| 75 | |||
| 76 | static char *srctree, *kernsrctree; | ||
| 77 | |||
| 78 | static char **all_list = NULL; | ||
| 79 | static int all_list_len = 0; | ||
| 80 | |||
| 81 | static 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 | |||
| 95 | static void usage (void) | ||
| 96 | { | ||
| 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"); | ||
| 101 | fprintf(stderr, "Environment variable SRCTREE: absolute path to sources.\n"); | ||
| 102 | fprintf(stderr, " KBUILD_SRC: absolute path to kernel source tree.\n"); | ||
| 103 | } | ||
| 104 | |||
| 105 | /* | ||
| 106 | * Execute kernel-doc with parameters given in svec | ||
| 107 | */ | ||
| 108 | static void exec_kernel_doc(char **svec) | ||
| 109 | { | ||
| 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); | ||
| 115 | switch (pid=fork()) { | ||
| 116 | case -1: | ||
| 117 | perror("fork"); | ||
| 118 | exit(1); | ||
| 119 | case 0: | ||
| 120 | memset(real_filename, 0, sizeof(real_filename)); | ||
| 121 | strncat(real_filename, kernsrctree, PATH_MAX); | ||
| 122 | strncat(real_filename, "/" KERNELDOCPATH KERNELDOC, | ||
| 123 | 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 */ | ||
| 138 | struct symbols | ||
| 139 | { | ||
| 140 | char *name; | ||
| 141 | }; | ||
| 142 | |||
| 143 | struct symfile | ||
| 144 | { | ||
| 145 | char *filename; | ||
| 146 | struct symbols *symbollist; | ||
| 147 | int symbolcnt; | ||
| 148 | }; | ||
| 149 | |||
| 150 | struct symfile symfilelist[MAXFILES]; | ||
| 151 | int symfilecnt = 0; | ||
| 152 | |||
| 153 | static void add_new_symbol(struct symfile *sym, char * symname) | ||
| 154 | { | ||
| 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 */ | ||
| 161 | static struct symfile * add_new_file(char * filename) | ||
| 162 | { | ||
| 163 | symfilelist[symfilecnt++].filename = strdup(filename); | ||
| 164 | return &symfilelist[symfilecnt - 1]; | ||
| 165 | } | ||
| 166 | |||
| 167 | /* Check if file already are present in the list */ | ||
| 168 | static struct symfile * filename_exist(char * filename) | ||
| 169 | { | ||
| 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 | */ | ||
| 181 | static void adddep(char * file) { printf("\t%s", file); } | ||
| 182 | static void adddep2(char * file, char * line) { line = line; | ||
