Commit 2d51005c authored by Jiri Slaby's avatar Jiri Slaby Committed by Sam Ravnborg

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
Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
Acked-by: default avatarRandy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
parent cefdff4b
...@@ -69,7 +69,7 @@ FILELINE * docsection; ...@@ -69,7 +69,7 @@ FILELINE * docsection;
#define NOFUNCTION "-nofunction" #define NOFUNCTION "-nofunction"
#define NODOCSECTIONS "-no-doc-sections" #define NODOCSECTIONS "-no-doc-sections"
char *srctree; static char *srctree, *kernsrctree;
void usage (void) void usage (void)
{ {
...@@ -77,7 +77,8 @@ void usage (void) ...@@ -77,7 +77,8 @@ void usage (void)
fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n"); fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n");
fprintf(stderr, "doc: frontend when generating kernel documentation\n"); fprintf(stderr, "doc: frontend when generating kernel documentation\n");
fprintf(stderr, "depend: generate list of files referenced within file\n"); fprintf(stderr, "depend: generate list of files referenced within file\n");
fprintf(stderr, "Environment variable SRCTREE: absolute path to kernel source tree.\n"); fprintf(stderr, "Environment variable SRCTREE: absolute path to sources.\n");
fprintf(stderr, " KBUILD_SRC: absolute path to kernel source tree.\n");
} }
/* /*
...@@ -96,8 +97,8 @@ void exec_kernel_doc(char **svec) ...@@ -96,8 +97,8 @@ void exec_kernel_doc(char **svec)
exit(1); exit(1);
case 0: case 0:
memset(real_filename, 0, sizeof(real_filename)); memset(real_filename, 0, sizeof(real_filename));
strncat(real_filename, srctree, PATH_MAX); strncat(real_filename, kernsrctree, PATH_MAX);
strncat(real_filename, KERNELDOCPATH KERNELDOC, strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
PATH_MAX - strlen(real_filename)); PATH_MAX - strlen(real_filename));
execvp(real_filename, svec); execvp(real_filename, svec);
fprintf(stderr, "exec "); fprintf(stderr, "exec ");
...@@ -178,6 +179,7 @@ void find_export_symbols(char * filename) ...@@ -178,6 +179,7 @@ void find_export_symbols(char * filename)
char real_filename[PATH_MAX + 1]; char real_filename[PATH_MAX + 1];
memset(real_filename, 0, sizeof(real_filename)); memset(real_filename, 0, sizeof(real_filename));
strncat(real_filename, srctree, PATH_MAX); strncat(real_filename, srctree, PATH_MAX);
strncat(real_filename, "/", PATH_MAX - strlen(real_filename));
strncat(real_filename, filename, strncat(real_filename, filename,
PATH_MAX - strlen(real_filename)); PATH_MAX - strlen(real_filename));
sym = add_new_file(filename); sym = add_new_file(filename);
...@@ -382,6 +384,9 @@ int main(int argc, char *argv[]) ...@@ -382,6 +384,9 @@ int main(int argc, char *argv[])
srctree = getenv("SRCTREE"); srctree = getenv("SRCTREE");
if (!srctree) if (!srctree)
srctree = getcwd(NULL, 0); srctree = getcwd(NULL, 0);
kernsrctree = getenv("KBUILD_SRC");
if (!kernsrctree)
kernsrctree = srctree;
if (argc != 3) { if (argc != 3) {
usage(); usage();
exit(1); exit(1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment