Upstream-Status: Backport

Patch addressing a parallel make race in Busybox

  http://git.busybox.net/busybox/commit/?id=d8e61bbf13d0cf38d477255cfd5dc71c5d51d575

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>

From d8e61bbf13d0cf38d477255cfd5dc71c5d51d575 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <vda.linux@googlemail.com>
Date: Sun, 21 Aug 2016 22:00:20 +0200
Subject: build system: different fix for
 include/applet_tables.h/include/NUM_APPLETS.h

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

diff --git a/applets/Kbuild.src b/applets/Kbuild.src
index 5cc1827..3aedbbf 100644
--- a/applets/Kbuild.src
+++ b/applets/Kbuild.src
@@ -29,7 +29,7 @@ applets/applets.o: include/usage_compressed.h include/applet_tables.h
 
 applets/applet_tables: .config include/applets.h
 applets/usage:         .config include/applets.h
-applets/usage_pod:     .config include/applets.h include/applet_tables.h include/NUM_APPLETS.h
+applets/usage_pod:     .config include/applets.h include/applet_tables.h
 
 quiet_cmd_gen_usage_compressed = GEN     include/usage_compressed.h
       cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets
@@ -37,8 +37,21 @@ quiet_cmd_gen_usage_compressed = GEN     include/usage_compressed.h
 include/usage_compressed.h: applets/usage $(srctree_slash)applets/usage_compressed
 	$(call cmd,gen_usage_compressed)
 
-quiet_cmd_gen_applet_tables = GEN     include/applet_tables.h
+quiet_cmd_gen_applet_tables = GEN     include/applet_tables.h include/NUM_APPLETS.h
       cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h include/NUM_APPLETS.h
 
-include/applet_tables.h include/NUM_APPLETS.h: applets/applet_tables
+include/NUM_APPLETS.h: applets/applet_tables
+	$(call cmd,gen_applet_tables)
+
+# In fact, include/applet_tables.h depends only on applets/applet_tables,
+# and is generated by it. But specifying only it can run
+# applets/applet_tables twice, possibly in parallel.
+# We say that it also needs NUM_APPLETS.h
+#
+# Unfortunately, we need to list the same command,
+# and it can be executed twice (sequentially).
+# The alternative is to not list any command,
+# and then if include/applet_tables.h is deleted, it won't be rebuilt.
+#
+include/applet_tables.h: include/NUM_APPLETS.h applets/applet_tables
 	$(call cmd,gen_applet_tables)
