Skip to contentSkip to conversation

kbuild: prevent modpost from looking for a .cmd file for a static library linked into a module

PATCH In review [email protected] 1 participant 1 message Oct 29, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 10/13 kbuild: prevent modpost from looking for a .cmd file for a static library linked into a module

From: "Ashutosh Naik" <[email protected]>

This fixes a compile time warning which occurs whenever a static library is linked into a kernel module. MODPOST tries to look for a ".<modulename>.cmd" file to look for its dependencies, but that file doesn't exist or get generated for static libraries.

This patch prevents modpost from looking for a .cmd file when a module is linked with a static library

[[email protected]: coding-style fixes]
Cc Sam Ravnborg <[email protected]>
Cc Rusty Russell <[email protected]>

---

 scripts/mod/sumversion.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
scripts/mod/sumversion.c renamed from scripts/mod/sumversion.c~kbuild-prevent-modpost-from-looking-for-a-cmd-file-for-a-static-library-linked-into-a-module +11 -1
diff -puN scripts/mod/sumversion.c~kbuild-prevent-modpost-from-looking-for-a-cmd-file-for-a-static-library-linked-into-a-module scripts/mod/sumversion.c
@@ -290,6 +290,15 @@ static int parse_file(const char *fname,
 	release_file(file, len);
 	return 1;
 }
+/* Check whether the file is a static library or not */
+static int is_static_library(const char *objfile)
+{
+	int len = strlen(objfile);
+	if (objfile[len - 2] == '.' && objfile[len - 1] == 'a')
+		return 1;
+	else
+		return 0;
+}
 
 /* We have dir/file.o.  Open dir/.file.o.cmd, look for deps_ line to
  * figure out source file. */
@@ -420,7 +429,8 @@ void get_src_version(const char *modname
 	while ((fname = strsep(&sources, " ")) != NULL) {
 		if (!*fname)
 			continue;
-		if (!parse_source_files(fname, &md))
+		if (!(is_static_library(fname)) &&
+				!parse_source_files(fname, &md))
 			goto release;
 	}
 

_