{"thread":{"id":"9037","subject":"[PATCH v2] Use $(RM) in makefiles instead of 'rm -f'","startedAt":"2007-07-14T17:51:44Z","lastAt":"2007-07-14T17:51:44Z","messageCount":1,"participants":["Emil Medve"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"47361","messageId":"1184435504937-git-send-email-Emilian.Medve@Freescale.com","threadId":"9037","inReplyTo":null,"subject":"[PATCH v2] Use $(RM) in makefiles instead of 'rm -f'","fromName":"Emil Medve","fromEmail":"emilian.medve@freescale.com","sentAt":"2007-07-14T17:51:44Z","receivedAt":"2007-07-14T17:51:44Z","isPatch":true,"sender":{"key":"emilian.medve@freescale.com","avatar":null},"body":"Use $(RM) in makefiles instead of 'rm -f'\n\nSigned-off-by: Emil Medve <Emilian.Medve@Freescale.com>\n---\n Documentation/Makefile |   16 ++++++-----\n Makefile               |   68 ++++++++++++++++++++++++------------------------\n contrib/emacs/Makefile |    3 +-\n git-gui/Makefile       |   16 ++++++-----\n t/Makefile             |    3 +-\n templates/Makefile     |    3 +-\n 6 files changed, 58 insertions(+), 51 deletions(-)\n\ndiff --git a/Documentation/Makefile b/Documentation/Makefile\nindex f3a6c73..3ddc9ca 100644\n--- a/Documentation/Makefile\n+++ b/Documentation/Makefile\n@@ -43,6 +43,8 @@ endif\n INSTALL?=install\n DOC_REF = origin/man\n \n+RM ?= rm -f\n+\n -include ../config.mak.autogen\n -include ../config.mak\n \n@@ -84,7 +86,7 @@ install: man\n # Determine \"include::\" file references in asciidoc files.\n #\n doc.dep : $(wildcard *.txt) build-docdep.perl\n-\trm -f $@+ $@\n+\t$(RM) $@+ $@\n \tperl ./build-docdep.perl >$@+\n \tmv $@+ $@\n \n@@ -109,11 +111,11 @@ cmd-list.made: cmd-list.perl $(MAN1_TXT)\n git.7 git.html: git.txt core-intro.txt\n \n clean:\n-\trm -f *.xml *.xml+ *.html *.html+ *.1 *.5 *.7 howto-index.txt howto/*.html doc.dep\n-\trm -f $(cmds_txt) *.made\n+\t$(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7 howto-index.txt howto/*.html doc.dep\n+\t$(RM) $(cmds_txt) *.made\n \n %.html : %.txt\n-\trm -f $@+ $@\n+\t$(RM) $@+ $@\n \t$(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \\\n \t\t$(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $<\n \tmv $@+ $@\n@@ -122,7 +124,7 @@ clean:\n \txmlto -m callouts.xsl man $<\n \n %.xml : %.txt\n-\trm -f $@+ $@\n+\t$(RM) $@+ $@\n \t$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \\\n \t\t$(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $<\n \tmv $@+ $@\n@@ -137,7 +139,7 @@ user-manual.html: user-manual.xml\n \txsltproc $(XSLTOPTS) -o $@ $(XSLT) $<\n \n howto-index.txt: howto-index.sh $(wildcard howto/*.txt)\n-\trm -f $@+ $@\n+\t$(RM) $@+ $@\n \tsh ./howto-index.sh $(wildcard howto/*.txt) >$@+\n \tmv $@+ $@\n \n@@ -147,7 +149,7 @@ $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt\n WEBDOC_DEST = /pub/software/scm/git/docs\n \n $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt\n-\trm -f $@+ $@\n+\t$(RM) $@+ $@\n \tsed -e '1,/^$$/d' $< | $(ASCIIDOC) -b xhtml11 - >$@+\n \tmv $@+ $@\n \ndiff --git a/Makefile b/Makefile\nindex d7541b4..5f8d177 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -188,7 +188,7 @@ export TCL_PATH TCLTK_PATH\n # explicitly what architecture to check for. Fix this up for yours..\n SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__\n \n-\n+RM ?= rm -f\n \n ### --- END CONFIGURATION SECTION ---\n \n@@ -729,7 +729,7 @@ export TAR INSTALL DESTDIR SHELL_PATH\n \n all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS)\n ifneq (,$X)\n-\t$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), rm -f '$p';)\n+\t$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$p';)\n endif\n \n all::\n@@ -743,7 +743,7 @@ strip: $(PROGRAMS) git$X\n \t$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X\n \n gitk-wish: gitk GIT-GUI-VARS\n-\t$(QUIET_GEN)rm -f $@ $@+ && \\\n+\t$(QUIET_GEN)$(RM) $@ $@+ && \\\n \tsed -e '1,3s|^exec .* \"$$0\"|exec $(subst |,'\\|',$(TCLTK_PATH_SQ)) \"$$0\"|' <gitk >$@+ && \\\n \tchmod +x $@+ && \\\n \tmv -f $@+ $@\n@@ -759,10 +759,10 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)\n help.o: common-cmds.h\n \n git-merge-subtree$X: git-merge-recursive$X\n-\t$(QUIET_BUILT_IN)rm -f $@ && ln git-merge-recursive$X $@\n+\t$(QUIET_BUILT_IN)$(RM) $@ && ln git-merge-recursive$X $@\n \n $(BUILT_INS): git$X\n-\t$(QUIET_BUILT_IN)rm -f $@ && ln git$X $@\n+\t$(QUIET_BUILT_IN)$(RM) $@ && ln git$X $@\n \n common-cmds.h: ./generate-cmdlist.sh\n \n@@ -770,7 +770,7 @@ common-cmds.h: $(wildcard Documentation/git-*.txt)\n \t$(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@\n \n $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh\n-\t$(QUIET_GEN)rm -f $@ $@+ && \\\n+\t$(QUIET_GEN)$(RM) $@ $@+ && \\\n \tsed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \\\n \t    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \\\n \t    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n@@ -782,7 +782,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh\n $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak\n \n $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py\n-\trm -f $@ $@+\n+\t$(RM) $@ $@+\n \tsed -e '1s|#!.*/python|#!$(PYTHON_PATH_SQ)|' \\\n \t    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n \t    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \\\n@@ -794,7 +794,7 @@ perl/perl.mak: GIT-CFLAGS\n \t$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)\n \n $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl\n-\t$(QUIET_GEN)rm -f $@ $@+ && \\\n+\t$(QUIET_GEN)$(RM) $@ $@+ && \\\n \tINSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \\\n \tsed -e '1{' \\\n \t    -e '\ts|#!.*perl|#!$(PERL_PATH_SQ)|' \\\n@@ -813,7 +813,7 @@ git-status: git-commit\n \t$(QUIET_GEN)cp $< $@+ && mv $@+ $@\n \n gitweb/gitweb.cgi: gitweb/gitweb.perl\n-\t$(QUIET_GEN)rm -f $@ $@+ && \\\n+\t$(QUIET_GEN)$(RM) $@ $@+ && \\\n \tsed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \\\n \t    -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \\\n \t    -e 's|++GIT_BINDIR++|$(bindir)|g' \\\n@@ -836,7 +836,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl\n \tmv $@+ $@\n \n git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css\n-\t$(QUIET_GEN)rm -f $@ $@+ && \\\n+\t$(QUIET_GEN)$(RM) $@ $@+ && \\\n \tsed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \\\n \t    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n \t    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \\\n@@ -849,11 +849,11 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css\n \tmv $@+ $@\n \n configure: configure.ac\n-\t$(QUIET_GEN)rm -f $@ $<+ && \\\n+\t$(QUIET_GEN)$(RM) $@ $<+ && \\\n \tsed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n \t    $< > $<+ && \\\n \tautoconf -o $@ $<+ && \\\n-\trm -f $<+\n+\t$(RM) $<+\n \n # These can record GIT_VERSION\n git.o git.spec \\\n@@ -908,7 +908,7 @@ $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)\n $(DIFF_OBJS): diffcore.h\n \n $(LIB_FILE): $(LIB_OBJS)\n-\t$(QUIET_AR)rm -f $@ && $(AR) rcs $@ $(LIB_OBJS)\n+\t$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)\n \n XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \\\n \txdiff/xmerge.o\n@@ -916,7 +916,7 @@ $(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \\\n \txdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h\n \n $(XDIFF_LIB): $(XDIFF_OBJS)\n-\t$(QUIET_AR)rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)\n+\t$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)\n \n \n perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS\n@@ -927,11 +927,11 @@ doc:\n \t$(MAKE) -C Documentation all\n \n TAGS:\n-\trm -f TAGS\n+\t$(RM) TAGS\n \tfind . -name '*.[hcS]' -print | xargs etags -a\n \n tags:\n-\trm -f tags\n+\t$(RM) tags\n \tfind . -name '*.[hcS]' -print | xargs ctags -a\n \n ### Detect prefix changes\n@@ -1010,9 +1010,9 @@ endif\n \t\tcp '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \\\n \t\t\t'$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \\\n \tfi\n-\t$(foreach p,$(BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)\n+\t$(foreach p,$(BUILT_INS), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)\n ifneq (,$X)\n-\t$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p';)\n+\t$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p';)\n endif\n \n install-doc:\n@@ -1042,7 +1042,7 @@ dist: git.spec git-archive configure\n \t\t$(GIT_TARNAME)/configure \\\n \t\t$(GIT_TARNAME)/version \\\n \t\t$(GIT_TARNAME)/git-gui/version\n-\t@rm -rf $(GIT_TARNAME)\n+\t@$(RM) -r $(GIT_TARNAME)\n \tgzip -f -9 $(GIT_TARNAME).tar\n \n rpm: dist\n@@ -1051,13 +1051,13 @@ rpm: dist\n htmldocs = git-htmldocs-$(GIT_VERSION)\n manpages = git-manpages-$(GIT_VERSION)\n dist-doc:\n-\trm -fr .doc-tmp-dir\n+\t$(RM) -r .doc-tmp-dir\n \tmkdir .doc-tmp-dir\n \t$(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc\n \tcd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .\n \tgzip -n -9 -f $(htmldocs).tar\n \t:\n-\trm -fr .doc-tmp-dir\n+\t$(RM) -r .doc-tmp-dir\n \tmkdir -p .doc-tmp-dir/man1 .doc-tmp-dir/man5 .doc-tmp-dir/man7\n \t$(MAKE) -C Documentation DESTDIR=./ \\\n \t\tman1dir=../.doc-tmp-dir/man1 \\\n@@ -1066,31 +1066,31 @@ dist-doc:\n \t\tinstall\n \tcd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .\n \tgzip -n -9 -f $(manpages).tar\n-\trm -fr .doc-tmp-dir\n+\t$(RM) -r .doc-tmp-dir\n \n ### Cleaning rules\n \n clean:\n-\trm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \\\n+\t$(RM) *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \\\n \t\t$(LIB_FILE) $(XDIFF_LIB)\n-\trm -f $(ALL_PROGRAMS) $(BUILT_INS) git$X\n-\trm -f $(TEST_PROGRAMS)\n-\trm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags\n-\trm -rf autom4te.cache\n-\trm -f configure config.log config.mak.autogen config.mak.append config.status config.cache\n-\trm -rf $(GIT_TARNAME) .doc-tmp-dir\n-\trm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz\n-\trm -f $(htmldocs).tar.gz $(manpages).tar.gz\n-\trm -f gitweb/gitweb.cgi\n+\t$(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X\n+\t$(RM) $(TEST_PROGRAMS)\n+\t$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags\n+\t$(RM) -r autom4te.cache\n+\t$(RM) configure config.log config.mak.autogen config.mak.append config.status config.cache\n+\t$(RM) -r $(GIT_TARNAME) .doc-tmp-dir\n+\t$(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz\n+\t$(RM) $(htmldocs).tar.gz $(manpages).tar.gz\n+\t$(RM) gitweb/gitweb.cgi\n \t$(MAKE) -C Documentation/ clean\n \t$(MAKE) -C perl clean\n \t$(MAKE) -C templates/ clean\n \t$(MAKE) -C t/ clean\n ifndef NO_TCLTK\n-\trm -f gitk-wish\n+\t$(RM) gitk-wish\n \t$(MAKE) -C git-gui clean\n endif\n-\trm -f GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS\n+\t$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS\n \n .PHONY: all install clean strip\n .PHONY: .FORCE-GIT-VERSION-FILE TAGS tags .FORCE-GIT-CFLAGS\ndiff --git a/contrib/emacs/Makefile b/contrib/emacs/Makefile\nindex 98aa0aa..5e94d6f 100644\n--- a/contrib/emacs/Makefile\n+++ b/contrib/emacs/Makefile\n@@ -7,6 +7,7 @@ INSTALL ?= install\n INSTALL_ELC = $(INSTALL) -m 644\n prefix ?= $(HOME)\n emacsdir = $(prefix)/share/emacs/site-lisp\n+RM ?= rm -f\n \n all: $(ELC)\n \n@@ -17,4 +18,4 @@ install: all\n %.elc: %.el\n \t$(EMACS) -batch -f batch-byte-compile $<\n \n-clean:; rm -f $(ELC)\n+clean:; $(RM) $(ELC)\ndiff --git a/git-gui/Makefile b/git-gui/Makefile\nindex 1bac6fe..e98df9d 100644\n--- a/git-gui/Makefile\n+++ b/git-gui/Makefile\n@@ -31,13 +31,15 @@ ifndef INSTALL\n \tINSTALL = install\n endif\n \n+RM ?= rm -f\n+\n INSTALL_D0 = $(INSTALL) -d -m755 # space is required here\n INSTALL_D1 =\n INSTALL_R0 = $(INSTALL) -m644 # space is required here\n INSTALL_R1 =\n INSTALL_X0 = $(INSTALL) -m755 # space is required here\n INSTALL_X1 =\n-INSTALL_L0 = rm -f # space is required here\n+INSTALL_L0 = $(RM) # space is required here\n INSTALL_L1 = && ln # space is required here\n INSTALL_L2 =\n INSTALL_L3 =\n@@ -59,7 +61,7 @@ ifndef V\n \tINSTALL_L0 = dst=\n \tINSTALL_L1 = && src=\n \tINSTALL_L2 = && dst=\n-\tINSTALL_L3 = && echo '   ' 'LINK       ' `basename \"$$dst\"` '->' `basename \"$$src\"` && rm -f \"$$dst\" && ln \"$$src\" \"$$dst\"\n+\tINSTALL_L3 = && echo '   ' 'LINK       ' `basename \"$$dst\"` '->' `basename \"$$src\"` && $(RM) \"$$dst\" && ln \"$$src\" \"$$dst\"\n endif\n \n TCL_PATH   ?= tclsh\n@@ -83,7 +85,7 @@ exedir    = $(dir $(gitexecdir))share/git-gui/lib\n exedir_SQ = $(subst ','\\'',$(exedir))\n \n $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh\n-\t$(QUIET_GEN)rm -f $@ $@+ && \\\n+\t$(QUIET_GEN)$(RM) $@ $@+ && \\\n \tGITGUI_RELATIVE= && \\\n \tif test '$(exedir_SQ)' = '$(libdir_SQ)'; then \\\n \t\tif test \"$(uname_O)\" = Cygwin; \\\n@@ -101,7 +103,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh\n \tmv $@+ $@\n \n $(GITGUI_BUILT_INS): git-gui\n-\t$(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@\n+\t$(QUIET_BUILT_IN)$(RM) $@ && ln git-gui $@\n \n lib/tclIndex: $(ALL_LIBFILES)\n \t$(QUIET_INDEX)if echo \\\n@@ -110,7 +112,7 @@ lib/tclIndex: $(ALL_LIBFILES)\n \t| $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \\\n \telse \\\n \t echo 1>&2 \"    * $(TCL_PATH) failed; using unoptimized loading\"; \\\n-\t rm -f $@ ; \\\n+\t $(RM) $@ ; \\\n \t echo '# Autogenerated by git-gui Makefile' >$@ && \\\n \t echo >>$@ && \\\n \t $(foreach p,$(PRELOAD_FILES) $(ALL_LIBFILES),echo '$(subst lib/,,$p)' >>$@ &&) \\\n@@ -151,8 +153,8 @@ dist-version:\n \t@echo $(GITGUI_VERSION) > $(TARDIR)/version\n \n clean::\n-\trm -f $(ALL_PROGRAMS) lib/tclIndex\n-\trm -f GIT-VERSION-FILE GIT-GUI-VARS\n+\t$(RM) $(ALL_PROGRAMS) lib/tclIndex\n+\t$(RM) GIT-VERSION-FILE GIT-GUI-VARS\n \n .PHONY: all install dist-version clean\n .PHONY: .FORCE-GIT-VERSION-FILE\ndiff --git a/t/Makefile b/t/Makefile\nindex b25caca..72d7884 100644\n--- a/t/Makefile\n+++ b/t/Makefile\n@@ -6,6 +6,7 @@\n #GIT_TEST_OPTS=--verbose --debug\n SHELL_PATH ?= $(SHELL)\n TAR ?= $(TAR)\n+RM ?= rm -f\n \n # Shell quote;\n SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n@@ -19,7 +20,7 @@ $(T):\n \t@echo \"*** $@ ***\"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)\n \n clean:\n-\trm -fr trash\n+\t$(RM) -r trash\n \n # we can test NO_OPTIMIZE_COMMITS independently of LC_ALL\n full-svn-test:\ndiff --git a/templates/Makefile b/templates/Makefile\nindex aaa39d3..6273ae2 100644\n--- a/templates/Makefile\n+++ b/templates/Makefile\n@@ -8,6 +8,7 @@ INSTALL ?= install\n TAR ?= tar\n prefix ?= $(HOME)\n template_dir ?= $(prefix)/share/git-core/templates\n+RM ?= rm -f\n # DESTDIR=\n \n # Shell quote (do not use $(call) to accommodate ancient setups);\n@@ -42,7 +43,7 @@ custom:\n \t$(QUIET): no custom templates yet\n \n clean:\n-\trm -rf blt boilerplates.made\n+\t$(RM) -r blt boilerplates.made\n \n install: all\n \t$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(template_dir_SQ)'\n-- \n1.5.2.2.277.g4d9b5\n"}]}