string: factorize skip_spaces and export it to be generally available
[safe/jmp/linux-2.6] / scripts / mod / sumversion.c
index 5c07545..ecf9c7d 100644 (file)
@@ -7,6 +7,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <string.h>
+#include <limits.h>
 #include "modpost.h"
 
 /*
@@ -289,6 +290,15 @@ static int parse_file(const char *fname, struct md4_ctx *md)
        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. */
@@ -324,8 +334,6 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
                deps_drivers/net/dummy.o := \
                  drivers/net/dummy.c \
                    $(wildcard include/config/net/fastroute.h) \
-                 include/linux/config.h \
-                   $(wildcard include/config/h.h) \
                  include/linux/module.h \
 
           Sum all files in the same dir or subdirs.
@@ -381,8 +389,11 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
        struct md4_ctx md;
        char *sources, *end, *fname;
        const char *basename;
-       char filelist[strlen(getenv("MODVERDIR")) + strlen("/") +
-                     strlen(modname) - strlen(".o") + strlen(".mod") + 1 ];
+       char filelist[PATH_MAX + 1];
+       char *modverdir = getenv("MODVERDIR");
+
+       if (!modverdir)
+               modverdir = ".";
 
        /* Source files for module are in .tmp_versions/modname.mod,
           after the first line. */
@@ -390,14 +401,13 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
                basename = strrchr(modname, '/') + 1;
        else
                basename = modname;
-       sprintf(filelist, "%s/%.*s.mod", getenv("MODVERDIR"),
+       sprintf(filelist, "%s/%.*s.mod", modverdir,
                (int) strlen(basename) - 2, basename);
 
        file = grab_file(filelist, &len);
-       if (!file) {
-               warn("could not find versions for %s\n", filelist);
+       if (!file)
+               /* not a module or .mod file missing - ignore */
                return;
-       }
 
        sources = strchr(file, '\n');
        if (!sources) {
@@ -417,7 +427,8 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
        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;
        }