summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2011-11-19 01:29:05 +0000
committerIan Lynagh <igloo@earth.li>2011-11-19 01:52:32 +0000
commit80e9070c77718b7ff0e913182e54842754726ce8 (patch)
tree12804916372a3675a7d1beb00bd41e70083c5edf
parent042841713eb6468696eeb437de994c52eb7a858e (diff)
downloadhaskell-80e9070c77718b7ff0e913182e54842754726ce8.tar.gz
Improve the way we call "rm" in the build system; fixes trac #4916
We avoid calling "rm -rf" with no file arguments; this fixes cleaning on Solaris, where that fails. We also check for suspicious arguments: anything containing "..", starting "/", or containing a "*" (you need to call $(wildcard ...) yourself now if you really want globbing). This should make things a little safer.
-rw-r--r--compiler/ghc.mk6
-rw-r--r--docs/man/ghc.mk2
-rw-r--r--driver/ghci/ghc.mk6
-rw-r--r--ghc.mk91
-rw-r--r--ghc/ghc.mk4
-rw-r--r--includes/ghc.mk2
-rw-r--r--libffi/ghc.mk16
-rw-r--r--mk/tree.mk21
-rw-r--r--rules/build-dependencies.mk6
-rw-r--r--rules/build-package-way.mk4
-rw-r--r--rules/build-package.mk4
-rw-r--r--rules/build-perl.mk2
-rw-r--r--rules/clean-target.mk2
-rw-r--r--rules/docbook.mk2
-rw-r--r--rules/manual-package-config.mk2
-rw-r--r--rules/shell-wrapper.mk4
-rw-r--r--utils/ghc-pkg/ghc.mk10
-rw-r--r--utils/mkdirhier/ghc.mk2
-rw-r--r--utils/runghc/ghc.mk2
19 files changed, 106 insertions, 82 deletions
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index d2a272ed7e..9893a5e142 100644
--- a/compiler/ghc.mk
+++ b/compiler/ghc.mk
@@ -44,7 +44,7 @@ compiler/stage3/package-data.mk : compiler/stage3/build/Config.hs
endif
compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
- "$(RM)" $(RM_OPTS) $@
+ $(call removeFiles,$@)
@echo 'Creating $@ ... '
@echo '{-# LANGUAGE CPP #-}' >> $@
@echo 'module Config where' >> $@
@@ -157,7 +157,7 @@ $(eval $(call clean-target,compiler,config_hs,compiler/main/Config.hs))
PLATFORM_H = ghc_boot_platform.h
compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
- "$(RM)" $(RM_OPTS) $@
+ $(call removeFiles,$@)
@echo "Creating $@..."
@echo "#ifndef __PLATFORM_H__" >> $@
@echo "#define __PLATFORM_H__" >> $@
@@ -203,7 +203,7 @@ endif
# the HOST platform is the TARGET of stage1. The TARGET remains the same
# (stage1 is the cross-compiler, not stage2).
compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
- "$(RM)" $(RM_OPTS) $@
+ $(call removeFiles,$@)
@echo "Creating $@..."
@echo "#ifndef __PLATFORM_H__" >> $@
@echo "#define __PLATFORM_H__" >> $@
diff --git a/docs/man/ghc.mk b/docs/man/ghc.mk
index 96fef2dbf6..0c1014b452 100644
--- a/docs/man/ghc.mk
+++ b/docs/man/ghc.mk
@@ -30,7 +30,7 @@ docs/man/flags.xsl: docs/man/gen_flags.xsl.sh
# Re-use the flags documentation from the user's guide by injecting some
# entities after the XML declaration to make it a stand-alone document.
docs/man/flags.xml: docs/users_guide/flags.xml
- "$(RM)" $(RM_OPTS) $@
+ $(call removeFiles,$@)
head -n 1 $< >> $@
echo "<!DOCTYPE sect1 [<!ENTITY ndash \"-\"> \
<!ENTITY ldquo \"\`\"> \
diff --git a/driver/ghci/ghc.mk b/driver/ghci/ghc.mk
index 31e84d6abb..51203ab4d5 100644
--- a/driver/ghci/ghc.mk
+++ b/driver/ghci/ghc.mk
@@ -18,12 +18,12 @@ install: install_driver_ghci
install_driver_ghci: WRAPPER=$(DESTDIR)$(bindir)/ghci-$(ProjectVersion)
install_driver_ghci:
$(call INSTALL_DIR,"$(DESTDIR)$(bindir)")
- "$(RM)" $(RM_OPTS) "$(WRAPPER)"
+ $(call removeFiles, "$(WRAPPER)")
$(CREATE_SCRIPT) "$(WRAPPER)"
echo '#!$(SHELL)' >> "$(WRAPPER)"
echo 'exec "$(bindir)/ghc-$(ProjectVersion)" --interactive $${1+"$$@"}' >> "$(WRAPPER)"
$(EXECUTABLE_FILE) "$(WRAPPER)"
- "$(RM)" $(RM_OPTS) "$(DESTDIR)$(bindir)/ghci"
+ $(call removeFiles,"$(DESTDIR)$(bindir)/ghci")
$(LN_S) ghci-$(ProjectVersion) "$(DESTDIR)$(bindir)/ghci"
else # Windows...
@@ -53,7 +53,7 @@ install_driver_ghcii: GHCII_SCRIPT=$(DESTDIR)$(bindir)/ghcii.sh
install_driver_ghcii: GHCII_SCRIPT_VERSIONED = $(DESTDIR)$(bindir)/ghcii-$(ProjectVersion).sh
install_driver_ghcii:
$(call INSTALL_DIR,$(DESTDIR)$(bindir))
- "$(RM)" $(RM_OPTS) $(GHCII_SCRIPT)
+ $(call removeFiles,$(GHCII_SCRIPT))
echo "#!$(SHELL)" >> $(GHCII_SCRIPT)
echo 'exec "$$0"/../ghc --interactive $${1+"$$@"}' >> $(GHCII_SCRIPT)
$(EXECUTABLE_FILE) $(GHCII_SCRIPT)
diff --git a/ghc.mk b/ghc.mk
index 2d8aaf419c..e97511c9ba 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -672,8 +672,11 @@ ifeq "$(phase)" "final"
$(eval $(call all-target,library_doc_index,libraries/index.html))
endif
INSTALL_LIBRARY_DOCS += libraries/*.html libraries/*.gif libraries/*.css libraries/*.js
-CLEAN_FILES += libraries/doc-index* libraries/haddock*.css \
- libraries/haddock*.js libraries/index*.html libraries/*.gif
+CLEAN_FILES += $(wildcard libraries/doc-index* \
+ libraries/haddock*.css \
+ libraries/haddock*.js \
+ libraries/index*.html \
+ libraries/*.gif)
endif
# -----------------------------------------------------------------------------
@@ -882,7 +885,7 @@ INSTALL_DISTDIR_compiler = stage2
install_packages: install_libexecs
install_packages: rts/package.conf.install
$(call INSTALL_DIR,"$(DESTDIR)$(topdir)")
- "$(RM)" $(RM_OPTS_REC) "$(INSTALLED_PACKAGE_CONF)"
+ $(call removeTrees,"$(INSTALLED_PACKAGE_CONF)")
$(call INSTALL_DIR,"$(INSTALLED_PACKAGE_CONF)")
"$(INSTALLED_GHC_PKG_REAL)" --force --global-conf "$(INSTALLED_PACKAGE_CONF)" update rts/package.conf.install
$(foreach p, $(INSTALLED_PKG_DIRS), \
@@ -962,7 +965,7 @@ endif
BIN_DIST_MK = $(BIN_DIST_PREP_DIR)/bindist.mk
unix-binary-dist-prep:
- "$(RM)" $(RM_OPTS_REC) bindistprep/
+ $(call removeTrees,bindistprep/)
"$(MKDIRHIER)" $(BIN_DIST_PREP_DIR)
set -e; for i in packages LICENSE compiler ghc rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh settings.in ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done
echo "HADDOCK_DOCS = $(HADDOCK_DOCS)" >> $(BIN_DIST_MK)
@@ -973,13 +976,13 @@ unix-binary-dist-prep:
echo "BUILD_MAN = $(BUILD_MAN)" >> $(BIN_DIST_MK)
echo "GHC_CABAL_INPLACE = utils/ghc-cabal/dist-install/build/tmp/ghc-cabal" >> $(BIN_DIST_MK)
cd $(BIN_DIST_PREP_DIR) && autoreconf
- "$(RM)" $(RM_OPTS) $(BIN_DIST_PREP_TAR)
+ $(call removeFiles,$(BIN_DIST_PREP_TAR))
# h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
# tree then we want to include the real file, not a symlink to it
cd bindistprep && "$(TAR_CMD)" hcf - -T ../$(BIN_DIST_LIST) | bzip2 -c > ../$(BIN_DIST_PREP_TAR_BZ2)
windows-binary-dist-prep:
- "$(RM)" $(RM_OPTS_REC) bindistprep/
+ $(call removeTrees,bindistprep/)
$(MAKE) prefix=$(TOP)/$(BIN_DIST_PREP_DIR) install
cd bindistprep && "$(TAR_CMD)" cf - $(BIN_DIST_NAME) | bzip2 -c > ../$(BIN_DIST_PREP_TAR_BZ2)
@@ -1074,8 +1077,8 @@ endef
.PHONY: sdist-prep
sdist-prep :
- "$(RM)" $(RM_OPTS_REC) $(SRC_DIST_DIR)
- "$(RM)" $(RM_OPTS) $(SRC_DIST_TARBALL)
+ $(call removeTrees,$(SRC_DIST_DIR))
+ $(call removeFiles,$(SRC_DIST_TARBALL))
mkdir $(SRC_DIST_DIR)
cd $(SRC_DIST_DIR) && for i in $(SRC_DIST_DIRS); do mkdir $$i; ( cd $$i && lndir $(TOP)/$$i ); done
cd $(SRC_DIST_DIR) && for i in $(SRC_DIST_FILES); do $(LN_S) $(TOP)/$$i .; done
@@ -1092,7 +1095,7 @@ sdist-prep :
$(call sdist_file,utils/genprimopcode,dist,,,Parser,y)
$(call sdist_file,utils/haddock,dist,src,Haddock,Lex,x)
$(call sdist_file,utils/haddock,dist,src,Haddock,Parse,y)
- cd $(SRC_DIST_DIR) && "$(RM)" $(RM_OPTS_REC) compiler/stage[123] mk/build.mk
+ cd $(SRC_DIST_DIR) && $(call removeTrees,compiler/stage[123] mk/build.mk)
cd $(SRC_DIST_DIR) && "$(FIND)" $(SRC_DIST_DIRS) \( -name _darcs -o -name SRC -o -name "autom4te*" -o -name "*~" -o -name ".cvsignore" -o -name "\#*" -o -name ".\#*" -o -name "log" -o -name "*-SAVE" -o -name "*.orig" -o -name "*.rej" -o -name "*-darcs-backup*" \) -print | "$(XARGS)" $(XARGS_OPTS) "$(RM)" $(RM_OPTS_REC)
.PHONY: sdist
@@ -1142,15 +1145,15 @@ clean : clean_files clean_libraries
.PHONY: clean_files
clean_files :
- "$(RM)" $(RM_OPTS) $(CLEAN_FILES)
+ $(call removeFiles,$(CLEAN_FILES))
.PHONY: clean_libraries
clean_libraries: $(patsubst %,clean_libraries/%_dist-install,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
clean_libraries: $(patsubst %,clean_libraries/%_dist-boot,$(PACKAGES_STAGE0))
clean_libraries:
- "$(RM)" $(RM_OPTS_REC) $(patsubst %, libraries/%/dist, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
- "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/*.buildinfo, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
+ $(call removeTrees,$(patsubst %, libraries/%/dist, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
+ $(call removeFiles,$(patsubst %, $(wildcard libraries/%/*.buildinfo), $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
# We have to define a clean target for each library manually, because the
# libraries/*/ghc.mk files are not included when we're cleaning.
@@ -1164,42 +1167,42 @@ endif
clean : clean_bindistprep
.PHONY: clean_bindistprep
clean_bindistprep:
- "$(RM)" $(RM_OPTS_REC) bindistprep/
+ $(call removeTrees,bindistprep/)
distclean : clean
- "$(RM)" $(RM_OPTS) config.cache config.status config.log mk/config.h mk/stamp-h
- "$(RM)" $(RM_OPTS) mk/config.mk mk/are-validating.mk mk/project.mk
- "$(RM)" $(RM_OPTS) mk/config.mk.old mk/project.mk.old
- "$(RM)" $(RM_OPTS) settings docs/users_guide/ug-book.xml
- "$(RM)" $(RM_OPTS) compiler/ghc.cabal compiler/ghc.cabal.old
- "$(RM)" $(RM_OPTS) ghc/ghc-bin.cabal
- "$(RM)" $(RM_OPTS) libraries/base/include/HsBaseConfig.h
- "$(RM)" $(RM_OPTS) libraries/directory/include/HsDirectoryConfig.h
- "$(RM)" $(RM_OPTS) libraries/process/include/HsProcessConfig.h
- "$(RM)" $(RM_OPTS) libraries/unix/include/HsUnixConfig.h
- "$(RM)" $(RM_OPTS) libraries/old-time/include/HsTimeConfig.h
- "$(RM)" $(RM_OPTS_REC) utils/ghc-pwd/dist
- "$(RM)" $(RM_OPTS_REC) inplace
-
- "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/config.log, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
- "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/config.status, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
- "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/include/Hs*Config.h, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
- "$(RM)" $(RM_OPTS_REC) $(patsubst %, libraries/%/autom4te.cache, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
+ $(call removeFiles,config.cache config.status config.log mk/config.h mk/stamp-h)
+ $(call removeFiles,mk/config.mk mk/are-validating.mk mk/project.mk)
+ $(call removeFiles,mk/config.mk.old mk/project.mk.old)
+ $(call removeFiles,settings docs/users_guide/ug-book.xml)
+ $(call removeFiles,compiler/ghc.cabal compiler/ghc.cabal.old)
+ $(call removeFiles,ghc/ghc-bin.cabal)
+ $(call removeFiles,libraries/base/include/HsBaseConfig.h)
+ $(call removeFiles,libraries/directory/include/HsDirectoryConfig.h)
+ $(call removeFiles,libraries/process/include/HsProcessConfig.h)
+ $(call removeFiles,libraries/unix/include/HsUnixConfig.h)
+ $(call removeFiles,libraries/old-time/include/HsTimeConfig.h)
+ $(call removeTrees,utils/ghc-pwd/dist)
+ $(call removeTrees,inplace)
+
+ $(call removeFiles,$(patsubst %, libraries/%/config.log, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
+ $(call removeFiles,$(patsubst %, libraries/%/config.status, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
+ $(call removeFiles,$(patsubst %, $(wildcard,libraries/%/include/Hs*Config.h), $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
+ $(call removeTrees,$(patsubst %, libraries/%/autom4te.cache, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
maintainer-clean : distclean
- "$(RM)" $(RM_OPTS) configure mk/config.h.in
- "$(RM)" $(RM_OPTS_REC) autom4te.cache libraries/*/autom4te.cache
- "$(RM)" $(RM_OPTS) ghc.spec
- "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/GNUmakefile, \
- $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
- "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/ghc.mk, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
- "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/configure, \
- $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
- "$(RM)" $(RM_OPTS) libraries/base/include/HsBaseConfig.h.in
- "$(RM)" $(RM_OPTS) libraries/directory/include/HsDirectoryConfig.h.in
- "$(RM)" $(RM_OPTS) libraries/process/include/HsProcessConfig.h.in
- "$(RM)" $(RM_OPTS) libraries/unix/include/HsUnixConfig.h.in
- "$(RM)" $(RM_OPTS) libraries/old-time/include/HsTimeConfig.h.in
+ $(call removeFiles,configure mk/config.h.in)
+ $(call removeTrees,autom4te.cache $(wildcard libraries/*/autom4te.cache))
+ $(call removeFiles,ghc.spec)
+ $(call removeFiles,$(patsubst %, libraries/%/GNUmakefile, \
+ $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
+ $(call removeFiles,$(patsubst %, libraries/%/ghc.mk, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
+ $(call removeFiles,$(patsubst %, libraries/%/configure, \
+ $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
+ $(call removeFiles,libraries/base/include/HsBaseConfig.h.in)
+ $(call removeFiles,libraries/directory/include/HsDirectoryConfig.h.in)
+ $(call removeFiles,libraries/process/include/HsProcessConfig.h.in)
+ $(call removeFiles,libraries/unix/include/HsUnixConfig.h.in)
+ $(call removeFiles,libraries/old-time/include/HsTimeConfig.h.in)
.PHONY: all_libraries
diff --git a/ghc/ghc.mk b/ghc/ghc.mk
index aa6d7ca560..38b3016b30 100644
--- a/ghc/ghc.mk
+++ b/ghc/ghc.mk
@@ -143,7 +143,7 @@ ifeq "$(Windows)" "NO"
install: install_ghc_link
.PNONY: install_ghc_link
install_ghc_link:
- "$(RM)" $(RM_OPTS) "$(DESTDIR)$(bindir)/ghc"
+ $(call removeFiles,"$(DESTDIR)$(bindir)/ghc")
$(LN_S) ghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/ghc"
else
# On Windows we install the main binary as $(bindir)/ghc.exe
@@ -151,7 +151,7 @@ else
install: install_ghc_post
.PHONY: install_ghc_post
install_ghc_post: install_bins
- "$(RM)" $(RM_OPTS) $(DESTDIR)$(bindir)/ghc.exe
+ $(call removeFiles,$(DESTDIR)$(bindir)/ghc.exe)
"$(MV)" -f $(DESTDIR)$(bindir)/ghc-stage$(INSTALL_GHC_STAGE).exe $(DESTDIR)$(bindir)/ghc.exe
endif
diff --git a/includes/ghc.mk b/includes/ghc.mk
index 8d4fd473c0..54f613933e 100644
--- a/includes/ghc.mk
+++ b/includes/ghc.mk
@@ -74,7 +74,7 @@ $(includes_H_CONFIG) : mk/config.h mk/config.mk includes/ghc.mk
endif
$(includes_H_PLATFORM) : includes/Makefile
- "$(RM)" $(RM_OPTS) $@
+ $(call removeFiles,$@)
@echo "Creating $@..."
@echo "#ifndef __GHCPLATFORM_H__" >$@
@echo "#define __GHCPLATFORM_H__" >>$@
diff --git a/libffi/ghc.mk b/libffi/ghc.mk
index 48c71bc8ce..d777c7877a 100644
--- a/libffi/ghc.mk
+++ b/libffi/ghc.mk
@@ -40,13 +40,13 @@ endif
ifneq "$(BINDIST)" "YES"
$(libffi_STAMP_CONFIGURE):
- "$(RM)" $(RM_OPTS) $(libffi_STAMP_STATIC_CONFIGURE)
- "$(RM)" $(RM_OPTS) $(libffi_STAMP_STATIC_BUILD)
- "$(RM)" $(RM_OPTS) $(libffi_STAMP_STATIC_INSTALL)
- "$(RM)" $(RM_OPTS) $(libffi_STAMP_STATIC_SHARED_CONFIGURE)
- "$(RM)" $(RM_OPTS) $(libffi_STAMP_STATIC_SHARED_BUILD)
- "$(RM)" $(RM_OPTS) $(libffi_STAMP_STATIC_SHARED_INSTALL)
- "$(RM)" $(RM_OPTS_REC) $(LIBFFI_DIR) libffi/build
+ $(call removeFiles,$(libffi_STAMP_STATIC_CONFIGURE))
+ $(call removeFiles,$(libffi_STAMP_STATIC_BUILD))
+ $(call removeFiles,$(libffi_STAMP_STATIC_INSTALL))
+ $(call removeFiles,$(libffi_STAMP_STATIC_SHARED_CONFIGURE))
+ $(call removeFiles,$(libffi_STAMP_STATIC_SHARED_BUILD))
+ $(call removeFiles,$(libffi_STAMP_STATIC_SHARED_INSTALL))
+ $(call removeTrees,$(LIBFFI_DIR) libffi/build)
cat ghc-tarballs/libffi/libffi*.tar.gz | $(GZIP_CMD) -d | { cd libffi && $(TAR_CMD) -xf - ; }
mv libffi/libffi-* libffi/build
@@ -95,7 +95,7 @@ $(ffi_HEADER): $(libffi_STAMP_INSTALL) | $$(dir $$@)/.
cp libffi/build/inst/lib/libffi-*/include/ffi.h $@
$(eval $(call clean-target,libffi,, \
- libffi/build libffi/stamp.ffi.* libffi/dist-install))
+ libffi/build $(wildcard libffi/stamp.ffi.*) libffi/dist-install))
endif
diff --git a/mk/tree.mk b/mk/tree.mk
index 2010c362f3..564e55353c 100644
--- a/mk/tree.mk
+++ b/mk/tree.mk
@@ -74,3 +74,24 @@ RM_OPTS = -f
RM_OPTS_REC = -rf
endif
+# If $1 is empty then we don't do anything (as "rm -rf" fails on
+# Solaris; trac #4916).
+# If $1 contains a * then we fail; globbing needs to be done at the call
+# site using $(wildcard ...). This makes it a little safer, as it's
+# harder to accidentally delete something you didn't mean to.
+# Similarly, we fail if any argument contains ".." or starts with a "/".
+
+removeFiles = $(call removeHelper,removeFiles,"$(RM)",$(RM_OPTS),$1)
+removeTrees = $(call removeHelper,removeTrees,"$(RM)",$(RM_OPTS_REC),$1)
+
+removeHelper = $(if $(strip $4),\
+ $(if $(findstring *,$4),\
+ $(error $1: Got a star: $4),\
+ $(if $(findstring ..,$4),\
+ $(error $1: Got dot-dot: $4),\
+ $(if $(filter /%,$4),\
+ $(error $1: Got leading slash: $4),\
+ $2 $3 $4\
+ )))\
+ )
+
diff --git a/rules/build-dependencies.mk b/rules/build-dependencies.mk
index e6d493ccf7..c9c62cdcdc 100644
--- a/rules/build-dependencies.mk
+++ b/rules/build-dependencies.mk
@@ -32,7 +32,7 @@ ifneq "$$(NO_GENERATED_MAKEFILE_RULES)" "YES"
$$($1_$2_depfile_haskell) : $$(includes_H_CONFIG) $$(includes_H_PLATFORM)
$$($1_$2_depfile_haskell) : $$($1_$2_HS_SRCS) $$($1_$2_HS_BOOT_SRCS) $$($1_$2_HC_MK_DEPEND_DEP) | $$$$(dir $$$$@)/.
- "$$(RM)" $$(RM_OPTS) $$@.tmp
+ $$(call removeFiles,$$@.tmp)
touch $$@.tmp
ifneq "$$($1_$2_HS_SRCS)" ""
"$$($1_$2_HC_MK_DEPEND)" -M $$($1_$2_MKDEPENDHS_FLAGS) \
@@ -55,7 +55,7 @@ endif
$$($1_$2_depfile_c_asm) : $$(includes_H_CONFIG) $$(includes_H_PLATFORM)
$$($1_$2_depfile_c_asm) : $$($1_$2_C_FILES_DEPS) $$($1_$2_S_FILES) | $$$$(dir $$$$@)/.
- "$$(RM)" $$(RM_OPTS) $$@.tmp
+ $$(call removeFiles,$$@.tmp)
touch $$@.tmp
ifneq "$$(strip $$($1_$2_C_FILES_DEPS)$$($1_$2_S_FILES))" ""
# We ought to actually do this for each way in $$($1_$2_WAYS), but then
@@ -64,7 +64,7 @@ ifneq "$$(strip $$($1_$2_C_FILES_DEPS)$$($1_$2_S_FILES))" ""
# copy the deps for each way on the assumption that they are the same
$$(foreach f,$$($1_$2_C_FILES_DEPS) $$($1_$2_S_FILES), \
$$(call addCFileDeps,$1,$2,$$($1_$2_depfile_c_asm),$$f,$$($1_$2_WAYS)))
- "$$(RM)" $$(RM_OPTS) $$@.bit
+ $$(call removeFiles,$$@.bit)
endif
echo "$1_$2_depfile_c_asm_EXISTS = YES" >> $$@.tmp
mv $$@.tmp $$@
diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk
index 2497e298c2..00ce06572d 100644
--- a/rules/build-package-way.mk
+++ b/rules/build-package-way.mk
@@ -80,7 +80,7 @@ endif
else
# Build the ordinary .a library
$$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS)
- "$$(RM)" $$(RM_OPTS) $$@ $$@.contents
+ $$(call removeFiles,$$@ $$@.contents)
ifeq "$$($1_$2_SplitObjs)" "YES"
$$(FIND) $$(patsubst %.$$($3_osuf),%_$$($3_osuf)_split,$$($1_$2_$3_HS_OBJS)) -name '*.$$($3_osuf)' -print >> $$@.contents
echo $$($1_$2_$3_NON_HS_OBJS) >> $$@.contents
@@ -92,7 +92,7 @@ ifeq "$$($1_$2_ArSupportsAtFile)" "YES"
else
"$$(XARGS)" $$(XARGS_OPTS) "$$($1_$2_AR)" $$($1_$2_AR_OPTS) $$($1_$2_EXTRA_AR_ARGS) $$@ < $$@.contents
endif
- "$$(RM)" $$(RM_OPTS) $$@.contents
+ $$(call removeFiles,$$@.contents)
endif
$(call all-target,$1_$2,all_$1_$2_$3)
diff --git a/rules/build-package.mk b/rules/build-package.mk
index 32556579cb..d83a79d89d 100644
--- a/rules/build-package.mk
+++ b/rules/build-package.mk
@@ -47,8 +47,8 @@ maintainer-clean : distclean
.PHONY: clean_$1_$2_config
clean_$1_$2_config:
- "$$(RM)" $$(RM_OPTS) $1/config.log $1/config.status $1/include/Hs*Config.h
- "$$(RM)" $$(RM_OPTS_REC) $1/autom4te.cache
+ $$(call removeFiles,$1/config.log $1/config.status $(wildcard $1/include/Hs*Config.h))
+ $$(call removeTrees,$1/autom4te.cache)
ifneq "$$($1_$2_NOT_NEEDED)" "YES"
$$(eval $$(call build-package-helper,$1,$2,$3))
diff --git a/rules/build-perl.mk b/rules/build-perl.mk
index 301d84860c..b39134f05f 100644
--- a/rules/build-perl.mk
+++ b/rules/build-perl.mk
@@ -44,7 +44,7 @@ $1/$2/$$($1_$2_PROG).prl: $1/$$($1_PERL_SRC) $$(UNLIT) | $$$$(dir $$$$@)/.
endif
$1/$2/$$($1_$2_PROG): $1/$2/$$($1_$2_PROG).prl
- "$$(RM)" $$(RM_OPTS) $$@
+ $$(call removeFiles,$$@)
echo '#!$$(PERL)' >> $$@
echo '$$$$TARGETPLATFORM = "$$(TARGETPLATFORM)";' >> $$@
echo '$$$$TABLES_NEXT_TO_CODE = "$(GhcEnableTablesNextToCode)";' >> $$@
diff --git a/rules/clean-target.mk b/rules/clean-target.mk
index 5da31fa881..e54d9fb025 100644
--- a/rules/clean-target.mk
+++ b/rules/clean-target.mk
@@ -17,5 +17,5 @@ clean : clean_$1
clean_$1 : clean_$1_$2
.PHONY: clean_$1_$2
clean_$1_$2:
- "$$(RM)" $$(RM_OPTS_REC) $3
+ $$(call removeTrees,$3)
endef
diff --git a/rules/docbook.mk b/rules/docbook.mk
index 5a7bfdfd83..864fb3583e 100644
--- a/rules/docbook.mk
+++ b/rules/docbook.mk
@@ -37,7 +37,7 @@ html_$1 : $1/$2/index.html
ifneq "$$(BINDIST)" "YES"
$1/$2/index.html: $$($1_DOCBOOK_SOURCES)
- "$$(RM)" $$(RM_OPTS_REC) $$(dir $$@)
+ $$(call removeTrees,$$(dir $$@))
"$$(XSLTPROC)" --stringparam base.dir $$(dir $$@) \
--stringparam use.id.as.filename 1 \
--stringparam html.stylesheet fptools.css \
diff --git a/rules/manual-package-config.mk b/rules/manual-package-config.mk
index c37f204d95..6f350dcac0 100644
--- a/rules/manual-package-config.mk
+++ b/rules/manual-package-config.mk
@@ -41,7 +41,7 @@ $1/package.conf.install:
distclean : clean_$1_package.conf
.PHONY: clean_$1_package.conf
clean_$1_package.conf :
- "$$(RM)" $$(RM_OPTS) $1/package.conf.install $1/package.conf.inplace
+ $$(call removeFiles,$1/package.conf.install $1/package.conf.inplace)
$(call profEnd, manual-package-config($1))
endef
diff --git a/rules/shell-wrapper.mk b/rules/shell-wrapper.mk
index 5cc10dc347..2376db137f 100644
--- a/rules/shell-wrapper.mk
+++ b/rules/shell-wrapper.mk
@@ -36,7 +36,7 @@ all_$1_$2 : $$(INPLACE_BIN)/$$($1_$2_PROG)
$$(INPLACE_BIN)/$$($1_$2_PROG): WRAPPER=$$@
$$(INPLACE_BIN)/$$($1_$2_PROG): $$($1_$2_INPLACE) $$($1_$2_SHELL_WRAPPER_NAME)
- "$$(RM)" $$(RM_OPTS) $$@
+ $$(call removeFiles, $$@)
echo '#!$$(SHELL)' >> $$@
echo 'executablename="$$(TOP)/$$<"' >> $$@
echo 'datadir="$$(TOP)/$$(INPLACE_LIB)"' >> $$@
@@ -65,7 +65,7 @@ install: install_$1_$2_wrapper
install_$1_$2_wrapper: WRAPPER=$$(DESTDIR)$$(bindir)/$$($1_$2_INSTALL_SHELL_WRAPPER_NAME)
install_$1_$2_wrapper:
$$(call INSTALL_DIR,"$$(DESTDIR)$$(bindir)")
- "$$(RM)" $$(RM_OPTS) "$$(WRAPPER)"
+ $$(call removeFiles, "$$(WRAPPER)")
$$(CREATE_SCRIPT) "$$(WRAPPER)"
echo '#!$$(SHELL)' >> "$$(WRAPPER)"
echo 'exedir="$$(ghclibexecdir)"' >> "$$(WRAPPER)"
diff --git a/utils/ghc-pkg/ghc.mk b/utils/ghc-pkg/ghc.mk
index f4205479ea..b6e762530a 100644
--- a/utils/ghc-pkg/ghc.mk
+++ b/utils/ghc-pkg/ghc.mk
@@ -21,7 +21,7 @@ inplace/bin/ghc-pkg : utils/ghc-pkg/dist-install/build/tmp/$(utils/ghc-pkg_dist_
ifeq "$(Windows)" "YES"
cp $< $@
else
- "$(RM)" $(RM_OPTS) $@
+ $(call removeFiles,$@)
echo "#!/bin/sh" >>$@
echo "PKGCONF=$(TOP)/$(INPLACE_PACKAGE_CONF)" >>$@
echo '$(TOP)/$< --global-conf $$PKGCONF $${1+"$$@"}' >> $@
@@ -31,11 +31,11 @@ endif
else
$(GHC_PKG_INPLACE) : utils/ghc-pkg/dist/build/$(utils/ghc-pkg_dist_PROG)$(exeext) | $$(dir $$@)/. $(INPLACE_PACKAGE_CONF)/.
- "$(RM)" $(RM_OPTS) $(INPLACE_PACKAGE_CONF)/*
+ $(call removeFiles,$(wildcard $(INPLACE_PACKAGE_CONF)/*))
ifeq "$(Windows)" "YES"
cp $< $@
else
- "$(RM)" $(RM_OPTS) $@
+ $(call removeFiles,$@)
echo "#!/bin/sh" >>$@
echo "PKGCONF=$(TOP)/$(INPLACE_PACKAGE_CONF)" >>$@
echo '$(TOP)/$< --global-conf $$PKGCONF $${1+"$$@"}' >> $@
@@ -70,7 +70,7 @@ utils/ghc-pkg/dist/build/$(utils/ghc-pkg_dist_PROG)$(exeext): utils/ghc-pkg/Main
utils/ghc-pkg/Version.hs: mk/project.mk
- "$(RM)" $(RM_OPTS) $@
+ $(call removeFiles,$@)
echo "module Version where" >> $@
echo "version, targetOS, targetARCH :: String" >> $@
echo "version = \"$(ProjectVersion)\"" >> $@
@@ -105,7 +105,7 @@ install: install_utils/ghc-pkg_link
.PNONY: install_utils/ghc-pkg_link
install_utils/ghc-pkg_link:
$(call INSTALL_DIR,"$(DESTDIR)$(bindir)")
- "$(RM)" $(RM_OPTS) "$(DESTDIR)$(bindir)/ghc-pkg"
+ $(call removeFiles,"$(DESTDIR)$(bindir)/ghc-pkg")
$(LN_S) ghc-pkg-$(ProjectVersion) "$(DESTDIR)$(bindir)/ghc-pkg"
endif
diff --git a/utils/mkdirhier/ghc.mk b/utils/mkdirhier/ghc.mk
index fe7a47b2c4..0d0013e02f 100644
--- a/utils/mkdirhier/ghc.mk
+++ b/utils/mkdirhier/ghc.mk
@@ -14,7 +14,7 @@ $(MKDIRHIER) : utils/mkdirhier/mkdirhier.sh
-mkdir $(INPLACE)
-mkdir $(INPLACE_BIN)
-mkdir $(INPLACE_LIB)
- "$(RM)" $(RM_OPTS) $@
+ $(call removeFiles,$@)
echo '#!$(SHELL)' >> $@
cat utils/mkdirhier/mkdirhier.sh >> $@
$(EXECUTABLE_FILE) $@
diff --git a/utils/runghc/ghc.mk b/utils/runghc/ghc.mk
index 7c6a34a190..8ec4e8d0b5 100644
--- a/utils/runghc/ghc.mk
+++ b/utils/runghc/ghc.mk
@@ -33,7 +33,7 @@ install_runhaskell: install_bins
"$(CP)" $(DESTDIR)$(bindir)/runghc$(exeext) $(DESTDIR)$(bindir)/runhaskell$(exeext)
else
install_runhaskell:
- "$(RM)" $(RM_OPTS) "$(DESTDIR)$(bindir)/runhaskell"
+ $(call removeFiles,"$(DESTDIR)$(bindir)/runhaskell")
$(LN_S) runghc "$(DESTDIR)$(bindir)/runhaskell"
endif