History

kbuild: allow docproc invocation from external

- 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

Jiri Slaby committed 17 years ago

Commit 2d510051 parent cefdff41 file · +9 −4Browse files

Showing the changes to scripts/basic (1 of 1 file). Show all

Unified · Split

scripts/basic/docproc.c+9−4
@@ -69,7 +69,7 @@ FILELINE * docsection; · 68 unmodified lines
6969 #define NOFUNCTION "-nofunction"
7070 #define NODOCSECTIONS "-no-doc-sections"
7171
72−char *srctree;
72+static char *srctree, *kernsrctree;
7373
7474 void usage (void)
7575 {
@@ -77,7 +77,8 @@ void usage (void) · 1 unmodified line
7777 fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n");
7878 fprintf(stderr, "doc: frontend when generating kernel documentation\n");
7979 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");
8182 }
8283
8384 /*
@@ -96,8 +97,8 @@ void exec_kernel_doc(char **svec) · 12 unmodified lines
9697 exit(1);
9798 case 0:
9899 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,
101102 PATH_MAX - strlen(real_filename));
102103 execvp(real_filename, svec);
103104 fprintf(stderr, "exec ");
@@ -178,6 +179,7 @@ void find_export_symbols(char * filename) · 74 unmodified lines
178179 char real_filename[PATH_MAX + 1];
179180 memset(real_filename, 0, sizeof(real_filename));
180181 strncat(real_filename, srctree, PATH_MAX);
182+ strncat(real_filename, "/", PATH_MAX - strlen(real_filename));
181183 strncat(real_filename, filename,
182184 PATH_MAX - strlen(real_filename));
183185 sym = add_new_file(filename);
@@ -382,6 +384,9 @@ int main(int argc, char *argv[]) · 198 unmodified lines
382384 srctree = getenv("SRCTREE");
383385 if (!srctree)
384386 srctree = getcwd(NULL, 0);
387+ kernsrctree = getenv("KBUILD_SRC");
388+ if (!kernsrctree)
389+ kernsrctree = srctree;
385390 if (argc != 3) {
386391 usage();
387392 exit(1);