[patch] mkdep.c

From: Andrew Morton (andrewm@uow.edu.au)
Date: Wed Mar 22 2000 - 10:25:46 EST


If you build a kernel and then remove some source files, the next kernel
build will silently succeed, using the existing .o files.

bix:/usr/src/linux> make bzImage
bix:/usr/src/linux> rm kernel/sched.c kernel/dma.c kernel/fork.c ...
bix:/usr/src/linux> make bzImage # This works!

The attached patch teaches mkdep.c to make 'filename.o' dependent upon
'filename.[Sc]'

-akpm-

--- linux-2.3.99-pre1/scripts/mkdep.c Fri Jan 14 13:03:58 2000
+++ linux.akpm/scripts/mkdep.c Thu Mar 23 02:15:33 2000
@@ -18,6 +18,10 @@
  * the definition is inactivated, but I still used it. It turns out this
  * actually happens a few times in the kernel source. The simple way to
  * fix this problem is to remove this particular optimization.
+ *
+ * 2.3.99-pre1, Andrew Morton <andrewm@uow.edu.au>
+ * - Changed so that 'filename.o' depends upon 'filename.[cS]'. This is so that
+ * missing source files are noticed, rather than silently ignored.
  */
 
 #include <ctype.h>
@@ -47,6 +51,8 @@
 };
 
 
+/* Current input file */
+static const char *g_filename;
 
 /*
  * This records all the configuration options seen.
@@ -58,7 +64,16 @@
 int size_config = 0;
 int len_config = 0;
 
-
+static void
+do_depname(void)
+{
+ if (!hasdep) {
+ hasdep = 1;
+ printf("%s:", depname);
+ if (g_filename)
+ printf(" \\\n %s", g_filename);
+ }
+}
 
 /*
  * Grow the configuration string to a desired length.
@@ -193,10 +208,7 @@
         if (access(path->buffer, F_OK) != 0)
                 return;
 
- if (!hasdep) {
- hasdep = 1;
- printf("%s:", depname);
- }
+ do_depname();
         printf(" \\\n %s", path->buffer);
 }
 
@@ -227,10 +239,7 @@
 
         define_config(pc, len);
 
- if (!hasdep) {
- hasdep = 1;
- printf("%s: ", depname);
- }
+ do_depname();
         printf(" \\\n $(wildcard %s.h)", path_array[0].buffer);
 }
 
@@ -513,7 +522,8 @@
         hasdep = 0;
         clear_config();
         state_machine(map, map+st.st_size);
- if (hasdep) {
+ if (hasdep)
+ {
                 puts(command);
                 if (*command)
                         define_precious(filename);
@@ -549,11 +559,13 @@
         while (--argc > 0) {
                 const char * filename = *++argv;
                 const char * command = __depname;
+ g_filename = 0;
                 len = strlen(filename);
                 memcpy(depname, filename, len+1);
                 if (len > 2 && filename[len-2] == '.') {
                         if (filename[len-1] == 'c' || filename[len-1] == 'S') {
                             depname[len-1] = 'o';
+ g_filename = filename;
                             command = "";
                         }
                 }

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:36 EST