]> git.lizzy.rs Git - rust.git/blob - mk/install.mk
Merge remote-tracking branch 'brson/repl'
[rust.git] / mk / install.mk
1 # FIXME: Docs are currently not installed from the stageN dirs.
2 # For consistency it might be desirable for stageN to be an exact
3 # mirror of the installation directory structure.
4
5 # Installation macro. Call with source directory as arg 1,
6 # destination directory as arg 2, and filename/libname-glob as arg 3
7 ifdef VERBOSE
8  INSTALL = install -m755 $(1)/$(3) $(2)/$(3)
9  INSTALL_LIB = install -m644 `ls -drt1 $(1)/$(3) | tail -1` $(2)/
10 else
11  INSTALL = $(Q)$(call E, install: $(2)/$(3)) && install -m755 $(1)/$(3) $(2)/$(3)
12  INSTALL_LIB = $(Q)$(call E, install_lib: $(2)/$(3)) &&                    \
13                install -m644 `ls -drt1 $(1)/$(3) | tail -1` $(2)/
14 endif
15
16 # The stage we install from
17 ISTAGE = 2
18
19 PREFIX_ROOT = $(CFG_PREFIX)
20 PREFIX_BIN = $(PREFIX_ROOT)/bin
21 PREFIX_LIB = $(PREFIX_ROOT)/$(CFG_LIBDIR)
22
23 define INSTALL_TARGET_N
24   # $(1) is the target triple
25   # $(2) is the host triple
26
27 # T{B,L} == Target {Bin, Lib} for stage ${ISTAGE}
28 TB$(1)$(2) = $$(TBIN$$(ISTAGE)_T_$(1)_H_$(2))
29 TL$(1)$(2) = $$(TLIB$$(ISTAGE)_T_$(1)_H_$(2))
30
31 # PT{R,B,L} == Prefix Target {Root, Bin, Lib}
32 PTR$(1)$(2) = $$(PREFIX_LIB)/rustc/$(1)
33 PTB$(1)$(2) = $$(PTR$(1)$(2))/bin
34 PTL$(1)$(2) = $$(PTR$(1)$(2))/$(CFG_LIBDIR)
35
36 install-target-$(1)-host-$(2): $$(SREQ$$(ISTAGE)_T_$(1)_H_$(2))
37         $$(Q)mkdir -p $$(PTL$(1)$(2))
38         $$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_RUNTIME))
39         $$(Q)$$(call INSTALL_LIB, \
40                 $$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CORELIB_GLOB))
41         $$(Q)$$(call INSTALL_LIB, \
42                 $$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(STDLIB_GLOB))
43         $$(Q)$$(call INSTALL_LIB, \
44                 $$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(LIBRUSTC_GLOB))
45         $$(Q)$$(call INSTALL_LIB, \
46                 $$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(LIBSYNTAX_GLOB))
47         $$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),libmorestack.a)
48
49 endef
50
51 $(foreach target,$(CFG_TARGET_TRIPLES), \
52  $(eval $(call INSTALL_TARGET_N,$(target),$(CFG_HOST_TRIPLE))))
53
54 INSTALL_TARGET_RULES = $(foreach target,$(CFG_TARGET_TRIPLES), \
55  install-target-$(target)-host-$(CFG_HOST_TRIPLE))
56
57 install: all install-host install-targets
58
59 # Shorthand for build/stageN/bin
60 HB = $(HBIN$(ISTAGE)_H_$(CFG_HOST_TRIPLE))
61 HB2 = $(HBIN2_H_$(CFG_HOST_TRIPLE))
62 # Shorthand for build/stageN/lib
63 HL = $(HLIB$(ISTAGE)_H_$(CFG_HOST_TRIPLE))
64 # Shorthand for the prefix bin directory
65 PHB = $(PREFIX_BIN)
66 # Shorthand for the prefix bin directory
67 PHL = $(PREFIX_LIB)
68
69 install-host: $(SREQ$(ISTAGE)_T_$(CFG_HOST_TRIPLE)_H_$(CFG_HOST_TRIPLE))
70         $(Q)mkdir -p $(PREFIX_BIN)
71         $(Q)mkdir -p $(PREFIX_LIB)
72         $(Q)mkdir -p $(PREFIX_ROOT)/share/man/man1
73         $(Q)$(call INSTALL,$(HB2),$(PHB),rustc$(X))
74         $(Q)$(call INSTALL,$(HB2),$(PHB),fuzzer$(X))
75         $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_LIBFUZZER))
76         $(Q)$(call INSTALL,$(HB2),$(PHB),cargo$(X))
77         $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_LIBCARGO))
78         $(Q)$(call INSTALL,$(HB2),$(PHB),rusti$(X))
79         $(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc$(X))
80         $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_LIBRUSTDOC))
81         $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUNTIME))
82         $(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(CORELIB_GLOB))
83         $(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(STDLIB_GLOB))
84         $(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(LIBRUSTC_GLOB))
85         $(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(LIBSYNTAX_GLOB))
86         $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUSTLLVM))
87         $(Q)$(call INSTALL,$(S)/man, \
88              $(PREFIX_ROOT)/share/man/man1,rustc.1)
89
90 install-targets: $(INSTALL_TARGET_RULES)
91
92
93 HOST_LIB_FROM_HL_GLOB = \
94   $(patsubst $(HL)/%,$(PHL)/%,$(wildcard $(HL)/$(1)))
95
96 uninstall:
97         $(Q)rm -f $(PHB)/rustc$(X)
98         $(Q)rm -f $(PHB)/cargo$(X)
99         $(Q)rm -f $(PHB)/rusti$(X)
100         $(Q)rm -f $(PHB)/rustdoc$(X)
101         $(Q)rm -f $(PHL)/$(CFG_RUSTLLVM)
102         $(Q)rm -f $(PHL)/$(CFG_FUZZER)
103         $(Q)rm -f $(PHL)/$(CFG_CARGO)
104         $(Q)rm -f $(PHL)/$(CFG_RUSTDOC)
105         $(Q)rm -f $(PHL)/$(CFG_RUNTIME)
106         $(Q)for i in \
107           $(call HOST_LIB_FROM_HL_GLOB,$(CORELIB_GLOB)) \
108           $(call HOST_LIB_FROM_HL_GLOB,$(STDLIB_GLOB)) \
109           $(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTC_GLOB)) \
110           $(call HOST_LIB_FROM_HL_GLOB,$(LIBSYNTAX_GLOB)) \
111         ; \
112         do rm -f $$i ; \
113         done
114         $(Q)rm -Rf $(PHL)/rustc
115         $(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rustc.1