diff --git a/Common.mak b/Common.mak index daef12728..acea1f431 100644 --- a/Common.mak +++ b/Common.mak @@ -104,9 +104,9 @@ ifeq ($(HOSTPLATFORM),WINDOWS) endif endif -LL := ls -l DONT_PRINT := > $(NULLSTREAM) 2>&1 DONT_PRINT_STDERR := 2> $(NULLSTREAM) +DONT_FAIL := ; exit 0 HAVE_SH := 1 # when no sh.exe is found in PATH on Windows, no path is prepended to it @@ -114,8 +114,34 @@ ifeq (sh.exe,$(SHELL)) HAVE_SH := 0 endif +define LL + ls -l $1 +endef +define MKDIR + mkdir -p $1 +endef +define RM + rm -f $(filter-out / *,$1) +endef +define RMDIR + rm -rf $(filter-out / *,$1) +endef + ifeq (0,$(HAVE_SH)) - LL := dir + DONT_FAIL := & rem + + define LL + dir $(subst /,\,$1) + endef + define MKDIR + if not exist $(subst /,\,$1) mkdir $(subst /,\,$1) + endef + define RM + del /f /q $(subst /,\,$(filter-out / *,$1)) $(DONT_PRINT_STDERR) $(DONT_FAIL) + endef + define RMDIR + rmdir /s /q $(subst /,\,$(filter-out / *,$1)) $(DONT_PRINT_STDERR) $(DONT_FAIL) + endef # if, printf, exit, and ; are unavailable without sh PRETTY_OUTPUT := 0 diff --git a/GNUmakefile b/GNUmakefile index 7347e548e..57cdb189b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -812,13 +812,13 @@ start: $(BUILD_STARTED) tools: $(addsuffix $(EXESUFFIX),$(tools_targets)) | start - @$(LL) $^ + @$(call LL,$^) $(games): $$(foreach i,$(roles),$$($$@_$$i)$(EXESUFFIX)) | start - @$(LL) $^ + @$(call LL,$^) ebacktrace: $(ebacktrace_dll) | start - @$(LL) $^ + @$(call LL,$^) ifeq ($(PLATFORM),WII) ifneq ($(ELF2DOL),) @@ -842,7 +842,7 @@ ifneq ($$(STRIP),) endif ifeq ($$(PLATFORM),DARWIN) cp -RPf "platform/Apple/bundles/$$($1_$2_proper).app" "./" - mkdir -p "$$($1_$2_proper).app/Contents/MacOS" + $(call MKDIR,"$$($1_$2_proper).app/Contents/MacOS") cp -f "$$($1_$2)$$(EXESUFFIX)" "$$($1_$2_proper).app/Contents/MacOS/" endif @@ -965,13 +965,8 @@ $(engine_obj)/rev.$o: $(engine_src)/rev.cpp | $(engine_obj) ### Directories -ifeq (0,$(HAVE_SH)) $(foreach i,$(components),$($i_obj)): - -if not exist $(subst /,\,$@) mkdir $(subst /,\,$@) -else -$(foreach i,$(components),$($i_obj)): - -mkdir -p $@ ; exit 0 -endif + -$(call MKDIR,$@) ### Phonies @@ -979,17 +974,19 @@ clang-tools: $(filter %.c %.cpp,$(foreach i,$(call getdeps,duke3d,game),$(call e echo $^ -- -x c++ $(CXXONLYFLAGS) $(COMPILERFLAGS) $(foreach i,$(components),$($i_cflags)) $(CWARNS) $(addprefix clean,$(games)): - -rm -f $(foreach i,$(roles),$($(subst clean,,$@)_$i)$(EXESUFFIX)) + -$(call RM,$(foreach i,$(roles),$($(subst clean,,$@)_$i)$(EXESUFFIX))) + -$(call RMDIR,$($(subst clean,,$@)_obj)) ifeq ($(PLATFORM),DARWIN) - -rm -rf $(foreach i,$(roles),"$($(subst clean,,$@)_$i_proper).app") + -$(call RMDIR,$(foreach i,$(roles),"$($(subst clean,,$@)_$i_proper).app")) endif cleantools: - -rm -f $(addsuffix $(EXESUFFIX),$(tools_targets)) + -$(call RM,$(addsuffix $(EXESUFFIX),$($(subst clean,,$@)_targets))) + -$(call RMDIR,$($(subst clean,,$@)_obj)) clean: cleanduke3d cleantools - -rm -rf $(obj)/ - -rm -f $(ebacktrace_dll) + -$(call RMDIR,$(obj)) + -$(call RM,$(ebacktrace_dll)) printtools: echo "$(addsuffix $(EXESUFFIX),$(tools_targets))"