- getcwd returns path without a slash at the end, add the slash - add KBUILD_SRC env support, so that we can specify path for kernel (to know where scripts/kernel-doc resides) and SRCTREE (for searching files referenced in .tmpl) separately [v2] - use KBUILD_SRC instead of a newly introduced environment variable
Showing the changes to scripts/basic (1 of 1 file). Show all
Unified · Split
| @@ -69,7 +69,7 @@ FILELINE * docsection; · 68 unmodified lines | ||
| 69 | 69 | #define NOFUNCTION "-nofunction" |
| 70 | 70 | #define NODOCSECTIONS "-no-doc-sections" |
| 71 | 71 | |
| 72 | −char *srctree; | |
| 72 | +static char *srctree, *kernsrctree; | |
| 73 | 73 | |
| 74 | 74 | void usage (void) |
| 75 | 75 | { |
| @@ -77,7 +77,8 @@ void usage (void) · 1 unmodified line | ||
| 77 | 77 | fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n"); |
| 78 | 78 | fprintf(stderr, "doc: frontend when generating kernel documentation\n"); |
| 79 | 79 | fprintf(stderr, "depend: generate list of files referenced within file\n"); |
| 80 | − fprintf(stderr, "Environment variable SRCTREE: absolute path to kernel source tree.\n"); | |
| 80 | + fprintf(stderr, "Environment variable SRCTREE: absolute path to sources.\n"); | |
| 81 | + fprintf(stderr, " KBUILD_SRC: absolute path to kernel source tree.\n"); | |
| 81 | 82 | } |
| 82 | 83 | |
| 83 | 84 | /* |
| @@ -96,8 +97,8 @@ void exec_kernel_doc(char **svec) · 12 unmodified lines | ||
| 96 | 97 | exit(1); |
| 97 | 98 | case 0: |
| 98 | 99 | memset(real_filename, 0, sizeof(real_filename)); |
| 99 | − strncat(real_filename, srctree, PATH_MAX); | |
| 100 | − strncat(real_filename, KERNELDOCPATH KERNELDOC, | |
| 100 | + strncat(real_filename, kernsrctree, PATH_MAX); | |
| 101 | + strncat(real_filename, "/" KERNELDOCPATH KERNELDOC, | |
| 101 | 102 | PATH_MAX - strlen(real_filename)); |
| 102 | 103 | execvp(real_filename, svec); |
| 103 | 104 | fprintf(stderr, "exec "); |
| @@ -178,6 +179,7 @@ void find_export_symbols(char * filename) · 74 unmodified lines | ||
| 178 | 179 | char real_filename[PATH_MAX + 1]; |
| 179 | 180 | memset(real_filename, 0, sizeof(real_filename)); |
| 180 | 181 | strncat(real_filename, srctree, PATH_MAX); |
| 182 | + strncat(real_filename, "/", PATH_MAX - strlen(real_filename)); | |
| 181 | 183 | strncat(real_filename, filename, |
| 182 | 184 | PATH_MAX - strlen(real_filename)); |
| 183 | 185 | sym = add_new_file(filename); |
| @@ -382,6 +384,9 @@ int main(int argc, char *argv[]) · 198 unmodified lines | ||
| 382 | 384 | srctree = getenv("SRCTREE"); |
| 383 | 385 | if (!srctree) |
| 384 | 386 | srctree = getcwd(NULL, 0); |
| 387 | + kernsrctree = getenv("KBUILD_SRC"); | |
| 388 | + if (!kernsrctree) | |
| 389 | + kernsrctree = srctree; | |
| 385 | 390 | if (argc != 3) { |
| 386 | 391 | usage(); |
| 387 | 392 | exit(1); |