@@ -33,15 +33,15 @@ prepare-base: PREPARE_SOURCE_LIB_DIR=$(PREPARE_SOURCE_DIR)/$(CFG_LIBDIR_RELATIVE
33
33
prepare-base : PREPARE_SOURCE_MAN_DIR=$(S ) /man
34
34
prepare-base : PREPARE_DEST_BIN_DIR=$(PREPARE_DEST_DIR ) /bin
35
35
prepare-base : PREPARE_DEST_LIB_DIR=$(PREPARE_DEST_DIR ) /$(CFG_LIBDIR_RELATIVE )
36
- prepare-base : PREPARE_DEST_MAN_DIR=$(PREPARE_DEST_DIR ) /man1
36
+ prepare-base : PREPARE_DEST_MAN_DIR=$(PREPARE_DEST_DIR ) /man/ man1
37
37
prepare-base : prepare-host prepare-targets
38
38
39
39
prepare-everything : prepare-host prepare-targets
40
40
41
41
DEFAULT_PREPARE_DIR_CMD = umask 022 && mkdir -p
42
42
DEFAULT_PREPARE_BIN_CMD = install -m755
43
43
DEFAULT_PREPARE_LIB_CMD = install -m644
44
- DEFAULT_PREPARE_MAN_CMD = install -m755
44
+ DEFAULT_PREPARE_MAN_CMD = install -m644
45
45
46
46
# On windows we install from stage3, but on unix only stage2
47
47
# Because of the way these rules are organized, preparing from any
@@ -55,14 +55,14 @@ endif
55
55
# Create a directory
56
56
# $(1) is the directory
57
57
define PREPARE_DIR
58
- @$(Q )$(call E, install : $(1 ) )
58
+ @$(Q )$(call E, prepare : $(1 ) )
59
59
$(Q )$(PREPARE_DIR_CMD ) $(1 )
60
60
endef
61
61
62
62
# Copy an executable
63
63
# $(1) is the filename/libname-glob
64
64
define PREPARE_BIN
65
- @$(call E, install : $(PREPARE_DEST_BIN_DIR ) /$(1 ) )
65
+ @$(call E, prepare : $(PREPARE_DEST_BIN_DIR ) /$(1 ) )
66
66
$(Q )$(PREPARE_BIN_CMD ) $(PREPARE_SOURCE_BIN_DIR ) /$(1 ) $(PREPARE_DEST_BIN_DIR ) /$(1 )
67
67
endef
68
68
75
75
# problem. I'm sorry, just don't remove the $(nop), alright?
76
76
define PREPARE_LIB
77
77
$(nop )
78
- @$(call E, install : $(PREPARE_WORKING_DEST_LIB_DIR ) /$(1 ) )
78
+ @$(call E, prepare : $(PREPARE_WORKING_DEST_LIB_DIR ) /$(1 ) )
79
79
$(Q ) LIB_NAME="$(notdir $(lastword $(wildcard $(PREPARE_WORKING_SOURCE_LIB_DIR ) /$(1 ) ) ) ) "; \
80
80
MATCHES="$(filter-out % $(notdir $(lastword $(wildcard $(PREPARE_WORKING_SOURCE_LIB_DIR ) /$(1 ) ) ) ) ,\
81
81
$(wildcard $(PREPARE_WORKING_DEST_LIB_DIR ) /$(1 ) ) ) "; \
91
91
# Copy a man page
92
92
# $(1) - source dir
93
93
define PREPARE_MAN
94
- @$(call E, install : $(PREPARE_DEST_MAN_DIR ) /$(1 ) )
94
+ @$(call E, prepare : $(PREPARE_DEST_MAN_DIR ) /$(1 ) )
95
95
$(Q )$(PREPARE_MAN_CMD ) $(PREPARE_SOURCE_MAN_DIR ) /$(1 ) $(PREPARE_DEST_MAN_DIR ) /$(1 )
96
96
endef
97
97
@@ -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 -rf $(PREPARE_DEST_DIR),)
0 commit comments