[kernel] r13233 - dists/trunk/linux-kbuild-2.6/scripts/mod

Bastian Blank waldi at alioth.debian.org
Tue Mar 24 09:23:32 UTC 2009


Author: waldi
Date: Tue Mar 24 09:23:30 2009
New Revision: 13233

Log:
* scripts/mod/Makefile: Generate modpost.h.
* scripts/mod/gendef.py: Extract getopt definitions from upstream tool.
* scripts/mod/modpost.c: Use extracted getopt definitions.


Added:
   dists/trunk/linux-kbuild-2.6/scripts/mod/gendef.py   (contents, props changed)
Modified:
   dists/trunk/linux-kbuild-2.6/scripts/mod/Makefile
   dists/trunk/linux-kbuild-2.6/scripts/mod/modpost.c

Modified: dists/trunk/linux-kbuild-2.6/scripts/mod/Makefile
==============================================================================
--- dists/trunk/linux-kbuild-2.6/scripts/mod/Makefile	(original)
+++ dists/trunk/linux-kbuild-2.6/scripts/mod/Makefile	Tue Mar 24 09:23:30 2009
@@ -7,14 +7,21 @@
 
 OUTDIR = scripts/mod
 
+top_srcdir = ../..
+
+include $(top_srcdir)/Makefile.inc
+
 modpost.real-%:
 	$(MAKE) -f Makefile.real TYPE=$* SOURCEDIR=$(top_srcdir)/kbuild/scripts/mod
 
 %: %.o
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
 
-include $(top_srcdir)/Makefile.inc
+modpost.h: $(top_srcdir)/kbuild/scripts/mod/modpost.c
+	./gendef.py $< > $@
+
+modpost.o: modpost.c modpost.h
 
 clean:
-	rm $(PROGS) *.o
+	rm $(PROGS) modpost.h *.o
 

Added: dists/trunk/linux-kbuild-2.6/scripts/mod/gendef.py
==============================================================================
--- (empty file)
+++ dists/trunk/linux-kbuild-2.6/scripts/mod/gendef.py	Tue Mar 24 09:23:30 2009
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+import re
+import sys
+
+for line in open(sys.argv[1]):
+    match = re.search('getopt\(argc, argv, "([\w:]*?)"\)', line)
+    if match:
+        options = match.group(1)
+        break
+else:
+    raise RuntimeError
+
+print '#define GETOPT_OPTIONS "%s"' % options
+
+print '#define GETOPT_CASE',
+for c in options:
+    if c == ':':
+        continue
+    print "case '%c':" % c,
+print

Modified: dists/trunk/linux-kbuild-2.6/scripts/mod/modpost.c
==============================================================================
--- dists/trunk/linux-kbuild-2.6/scripts/mod/modpost.c	(original)
+++ dists/trunk/linux-kbuild-2.6/scripts/mod/modpost.c	Tue Mar 24 09:23:30 2009
@@ -5,6 +5,8 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "modpost.h"
+
 int main (int argc, char *argv[])
 {
   char const *data, *class;
@@ -13,22 +15,11 @@
   int opt;
   FILE *file;
 
-  while ((opt = getopt (argc, argv, "acei:I:K:mM:o:sSw")) != -1)
+  while ((opt = getopt (argc, argv, GETOPT_OPTIONS)) != -1)
   { 
     switch(opt)
     {
-      case 'a':
-      case 'e':
-      case 'i':
-      case 'c':
-      case 'I':
-      case 'K':
-      case 'm':
-      case 'M':
-      case 'o':
-      case 's':
-      case 'S':
-      case 'w':
+      GETOPT_CASE
         break;
       default:
         return EXIT_FAILURE;



More information about the Kernel-svn-changes mailing list