[ccan] [PATCH 2/4] Clean up use of 'rm' in Makefiles

David Gibson david at gibson.dropbear.id.au
Sat Apr 30 18:01:47 AEST 2016


Most of the ccan Makefiles use $(RM) to remove files.  However, 'rm' is
traditionally considered one of the few shell tools which can be used in
Makefiles without indirecting via a variable.

rm is also typically invoked with -f in Makefiles, so that it doesn't cause
errors if the files don't exist (because they haven't been built).  A
number of instances in ccan were missing this.

This corrects these warts.

Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
 Makefile                               | 6 +++---
 ccan/cdump/tools/Makefile              | 2 +-
 ccan/crypto/sha256/benchmarks/Makefile | 2 +-
 ccan/io/benchmarks/Makefile            | 2 +-
 ccan/timer/benchmarks/Makefile         | 2 +-
 tools/Makefile                         | 2 +-
 tools/ccanlint/Makefile                | 2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index 856baa9..5d4b701 100644
--- a/Makefile
+++ b/Makefile
@@ -64,9 +64,9 @@ ccan/%/info: ccan/%/_info
 	$(CC) $(CCAN_CFLAGS) -o $@ -x c $<
 
 clean: tools-clean
-	$(RM) `find * -name '*.o'` `find * -name '.depends'` `find * -name '*.a'`  `find * -name info` `find * -name '*.d'` `find ccan -name '*-Makefile'`
-	$(RM) config.h
-	$(RM) inter-depends lib-depends test-depends
+	rm -f `find * -name '*.o'` `find * -name '.depends'` `find * -name '*.a'`  `find * -name info` `find * -name '*.d'` `find ccan -name '*-Makefile'`
+	rm -f config.h
+	rm -f inter-depends lib-depends test-depends
 
 # Creates a dependency from the tests to the object files which it needs.
 inter-depends: $(ALL_DEPENDS) Makefile
diff --git a/ccan/cdump/tools/Makefile b/ccan/cdump/tools/Makefile
index 3b30d66..8b01284 100644
--- a/ccan/cdump/tools/Makefile
+++ b/ccan/cdump/tools/Makefile
@@ -5,7 +5,7 @@ CFLAGS := -I$(CCANDIR) -Wall
 cdump-enumstr: cdump-enumstr.o $(CCAN_OBJS)
 
 clean:
-	$(RM) cdump-enumstr.o $(CCAN_OBJS)
+	rm -f cdump-enumstr.o $(CCAN_OBJS)
 
 ccan-tal.o: $(CCANDIR)/ccan/tal/tal.c
 	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/ccan/crypto/sha256/benchmarks/Makefile b/ccan/crypto/sha256/benchmarks/Makefile
index a9f1b29..f1749ab 100644
--- a/ccan/crypto/sha256/benchmarks/Makefile
+++ b/ccan/crypto/sha256/benchmarks/Makefile
@@ -12,7 +12,7 @@ $(INTEL_OBJS): %.o : %.asm
 	yasm -f x64 -f elf64 -X gnu -g dwarf2 -D LINUX -o $@ $<
 
 clean:
-	$(RM) -f *.o
+	rm -f *.o
 
 ccan-crypto-sha256.o: $(CCANDIR)/ccan/crypto/sha256/sha256.c
 	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/ccan/io/benchmarks/Makefile b/ccan/io/benchmarks/Makefile
index 0068400..7dcf9be 100644
--- a/ccan/io/benchmarks/Makefile
+++ b/ccan/io/benchmarks/Makefile
@@ -26,4 +26,4 @@ err.o: $(CCANDIR)/ccan/err/err.c
 	$(CC) $(CFLAGS) -c -o $@ $<
 
 clean:
-	$(RM) -f *.o $(ALL)
+	rm -f *.o $(ALL)
diff --git a/ccan/timer/benchmarks/Makefile b/ccan/timer/benchmarks/Makefile
index 7e0653a..a3cbbd1 100644
--- a/ccan/timer/benchmarks/Makefile
+++ b/ccan/timer/benchmarks/Makefile
@@ -32,4 +32,4 @@ list.o: $(CCANDIR)/ccan/list/list.c
 	$(CC) $(CFLAGS) -c -o $@ $<
 
 clean:
-	$(RM) *.o $(ALL)
+	rm -f *.o $(ALL)
diff --git a/tools/Makefile b/tools/Makefile
index 338befc..6e4833a 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -45,6 +45,6 @@ tools/configurator/configurator: tools/configurator/configurator.c
 tools/modfiles: tools/modfiles.o tools/manifest.o $(DEP_OBJS)
 
 tools-clean: ccanlint-clean
-	$(RM) $(ALL_TOOLS)
+	rm -f $(ALL_TOOLS)
 
 include tools/ccanlint/Makefile
diff --git a/tools/ccanlint/Makefile b/tools/ccanlint/Makefile
index 691f270..5a26679 100644
--- a/tools/ccanlint/Makefile
+++ b/tools/ccanlint/Makefile
@@ -47,4 +47,4 @@ $(CORE_OBJS): config.h
 tools/ccanlint/ccanlint: $(OBJS)
 
 ccanlint-clean:
-	$(RM) tools/ccanlint/ccanlint
+	rm -f tools/ccanlint/ccanlint
-- 
2.5.5



More information about the ccan mailing list