build system: do not rebuild ash and hush on any change to any .c file
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 26 Jun 2010 00:40:08 +0000 (02:40 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 26 Jun 2010 00:40:08 +0000 (02:40 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
applets/Kbuild.src
applets/applet_tables.c
libbb/appletlib.c
shell/ash.c
shell/hush.c

index e3bac968102108bfc4eb8795b7ec328c39deb08b..31fee8d1e31321b5d3de248eba6bcdebd5ee4df6 100644 (file)
@@ -38,7 +38,7 @@ include/usage_compressed.h: applets/usage $(srctree_slash)applets/usage_compress
        $(call cmd,gen_usage_compressed)
 
 quiet_cmd_gen_applet_tables = GEN     include/applet_tables.h
-      cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h
+      cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h include/NUM_APPLETS.h
 
 include/applet_tables.h: applets/applet_tables
        $(call cmd,gen_applet_tables)
index e48be46821e7ffe3a07cd33dcc4ca50a44371652..338dc20f9514b2065604f64dea4b0b683bd87ed9 100644 (file)
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
        }
        printf("\n");
 
-       printf("#ifndef SKIP_definitions\n");
+       //printf("#ifndef SKIP_definitions\n");
        printf("const char applet_names[] ALIGN1 = \"\"\n");
        for (i = 0; i < NUM_APPLETS; i++) {
                printf("\"%s\" \"\\0\"\n", applets[i].name);
@@ -123,9 +123,29 @@ int main(int argc, char **argv)
        }
        printf("};\n");
 #endif
-       printf("#endif /* SKIP_definitions */\n");
+       //printf("#endif /* SKIP_definitions */\n");
        printf("\n");
        printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
 
+       if (argv[2]) {
+               char line_old[80];
+               char line_new[80];
+               FILE *fp;
+
+               line_old[0] = 0;
+               fp = fopen(argv[2], "r");
+               if (fp) {
+                       fgets(line_old, sizeof(line_old), fp);
+                       fclose(fp);
+               }
+               sprintf(line_new, "#define NUM_APPLETS %u\n", NUM_APPLETS);
+               if (strcmp(line_old, line_new) != 0) {
+                       fp = fopen(argv[2], "w");
+                       if (!fp)
+                               return 1;
+                       fputs(line_new, fp);
+               }
+       }
+
        return 0;
 }
index f3d5301846dd1a94a06bfeb790af23aff449e667..58f1a9490bd9fd51d7d64921cdc6f8a050b11b60 100644 (file)
@@ -61,7 +61,7 @@
 static const char usage_messages[] ALIGN1 = UNPACKED_USAGE;
 #else
 # define usage_messages 0
-#endif /* SHOW_USAGE */
+#endif
 
 #if ENABLE_FEATURE_COMPRESS_USAGE
 
index 1f8f90a091f9f432d171240994f24ea4176d2a3c..cfd8154ef8e8abd9a2baa3b2ac4c2b1daef169b3 100644 (file)
@@ -50,9 +50,7 @@
 # define CLEAR_RANDOM_T(rnd) ((void)0)
 #endif
 
-#define SKIP_definitions 1
-#include "applet_tables.h"
-#undef SKIP_definitions
+#include "NUM_APPLETS.h"
 #if NUM_APPLETS == 1
 /* STANDALONE does not make sense, and won't compile */
 # undef CONFIG_FEATURE_SH_STANDALONE
index e64c923b48319896ba4c71109f5244d710cc1c8e..29ff3c44290e865347d25fcf57bc4b71d12bb420 100644 (file)
 # define USE_FOR_MMU(...)
 #endif
 
-#define SKIP_definitions 1
-#include "applet_tables.h"
-#undef SKIP_definitions
+#include "NUM_APPLETS.h"
 #if NUM_APPLETS == 1
 /* STANDALONE does not make sense, and won't compile */
 # undef CONFIG_FEATURE_SH_STANDALONE