@@ -106,7 +106,7 @@ prepare-host-tools: \
106
106
$(foreach host,$(CFG_HOST),\
107
107
prepare-host-tool-$(tool)-$(stage)-$(host))))
108
108
109
- prepare-host-dirs :
109
+ prepare-host-dirs : prepare-maybe-clean
110
110
$(call PREPARE_DIR,$(PREPARE_DEST_BIN_DIR ) )
111
111
$(call PREPARE_DIR,$(PREPARE_DEST_LIB_DIR ) )
112
112
$(call PREPARE_DIR,$(PREPARE_DEST_MAN_DIR ) )
@@ -115,7 +115,8 @@ prepare-host-dirs:
115
115
# $(2) is stage
116
116
# $(3) is host
117
117
define DEF_PREPARE_HOST_TOOL
118
- prepare-host-tool-$(1 ) -$(2 ) -$(3 ) : $$(foreach dep,$$(TOOL_DEPS_$(1 ) ) ,prepare-host-lib-$$(dep ) -$(2 ) -$(3 ) ) \
118
+ prepare-host-tool-$(1 ) -$(2 ) -$(3 ) : prepare-maybe-clean \
119
+ $$(foreach dep,$$(TOOL_DEPS_$(1 ) ) ,prepare-host-lib-$$(dep ) -$(2 ) -$(3 ) ) \
119
120
$$(HBIN$(2 ) _H_$(3 ) ) /$(1 )$$(X_$(3 ) ) \
120
121
prepare-host-dirs
121
122
$$(if $$(findstring $(2 ) , $$(PREPARE_STAGE ) ) ,\
@@ -140,7 +141,8 @@ $(foreach tool,$(PREPARE_TOOLS),\
140
141
define DEF_PREPARE_HOST_LIB
141
142
prepare-host-lib-$(1 ) -$(2 ) -$(3 ) : PREPARE_WORKING_SOURCE_LIB_DIR=$$(PREPARE_SOURCE_LIB_DIR )
142
143
prepare-host-lib-$(1 ) -$(2 ) -$(3 ) : PREPARE_WORKING_DEST_LIB_DIR=$$(PREPARE_DEST_LIB_DIR )
143
- prepare-host-lib-$(1 ) -$(2 ) -$(3 ) : $$(foreach dep,$$(RUST_DEPS_$(1 ) ) ,prepare-host-lib-$$(dep ) -$(2 ) -$(3 ) ) \
144
+ prepare-host-lib-$(1 ) -$(2 ) -$(3 ) : prepare-maybe-clean \
145
+ $$(foreach dep,$$(RUST_DEPS_$(1 ) ) ,prepare-host-lib-$$(dep ) -$(2 ) -$(3 ) ) \
144
146
$$(HLIB$(2 ) _H_$(3 ) ) /stamp.$(1 ) \
145
147
prepare-host-dirs
146
148
$$(if $$(findstring $(2 ) , $$(PREPARE_STAGE ) ) ,\
@@ -166,7 +168,7 @@ define DEF_PREPARE_TARGET_N
166
168
# Rebind PREPARE_*_LIB_DIR to point to rustlib, then install the libs for the targets
167
169
prepare-target-$(2 ) -host-$(3 ) -$(1 ) : PREPARE_WORKING_SOURCE_LIB_DIR=$$(PREPARE_SOURCE_LIB_DIR ) /$$(CFG_RUSTLIBDIR ) /$(2 ) /lib
168
170
prepare-target-$(2 ) -host-$(3 ) -$(1 ) : PREPARE_WORKING_DEST_LIB_DIR=$$(PREPARE_DEST_LIB_DIR ) /$$(CFG_RUSTLIBDIR ) /$(2 ) /lib
169
- prepare-target-$(2 ) -host-$(3 ) -$(1 ) : \
171
+ prepare-target-$(2 ) -host-$(3 ) -$(1 ) : prepare-maybe-clean \
170
172
$$(foreach crate,$$(TARGET_CRATES ) , \
171
173
$$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /stamp.$$(crate ) ) \
172
174
$$(if $$(findstring $(2 ) ,$$(CFG_HOST ) ) , \
@@ -194,3 +196,9 @@ $(foreach host,$(CFG_HOST),\
194
196
$(foreach target,$(CFG_TARGET), \
195
197
$(foreach stage,$(PREPARE_STAGES),\
196
198
$(eval $(call DEF_PREPARE_TARGET_N,$(stage),$(target),$(host))))))
199
+
200
+ prepare-maybe-clean :
201
+ $(if $(findstring true,$(PREPARE_CLEAN ) ) ,\
202
+ @$(call E, cleaning destination $@),)
203
+ $(if $(findstring true,$(PREPARE_CLEAN)),\
204
+ $(Q)rm -r $(PREPARE_DEST_DIR),)
0 commit comments