Patchwork [3/5] Makefile: test before search for kernel modules

login
register
mail settings
Submitter Thomas Petazzoni
Date Aug. 20, 2013, 11:03 a.m.
Message ID <1376996584-4462-4-git-send-email-thomas.petazzoni@free-electrons.com>
Download mbox | patch
Permalink /patch/268494/
State Accepted
Headers show

Comments

Thomas Petazzoni - Aug. 20, 2013, 11:03 a.m.
The 'find $(TARGET_DIR)/lib/modules' used to find and strip kernel
modules fails when no kernel modules have been installed. While the
'|| true' prevents the entire build from failing, there are still some
error messages displayed, which is not nice.

Instead, test if the directory exists before doing the find. We also
remove the '|| true' in order to really abort the build if a
problematic error occurs.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Luca Ceresoli - Aug. 21, 2013, 7:08 a.m.
Thomas Petazzoni wrote:
> The 'find $(TARGET_DIR)/lib/modules' used to find and strip kernel
> modules fails when no kernel modules have been installed. While the
> '|| true' prevents the entire build from failing, there are still some
> error messages displayed, which is not nice.
>
> Instead, test if the directory exists before doing the find. We also
> remove the '|| true' in order to really abort the build if a
> problematic error occurs.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

Acked-by: Luca Ceresoli <luca@lucaceresoli.net>

Patch

diff --git a/Makefile b/Makefile
index 794d217..5d40126 100644
--- a/Makefile
+++ b/Makefile
@@ -476,8 +476,9 @@  ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY),y)
 	find $(TARGET_DIR)/usr/lib/ -name '*.py' -print0 | xargs -0 rm -f
 endif
 	$(STRIP_FIND_CMD) | xargs $(STRIPCMD) 2>/dev/null || true
-	find $(TARGET_DIR)/lib/modules -type f -name '*.ko' | \
-		xargs -r $(KSTRIPCMD) || true
+	test -d $(TARGET_DIR)/lib/modules && \
+		find $(TARGET_DIR)/lib/modules -type f -name '*.ko' | \
+		xargs -r $(KSTRIPCMD)
 
 # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
 # besides the one in which crash occurred; or SIGTRAP kills my program when