1 # Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
11 # FIXME: Docs are currently not installed from the stageN dirs.
12 # For consistency it might be desirable for stageN to be an exact
13 # mirror of the installation directory structure.
15 # The stage we install from
18 install: PREPARE_HOST=$(CFG_BUILD)
19 install: PREPARE_TARGETS=$(CFG_TARGET)
20 install: PREPARE_STAGE=$(ISTAGE)
21 install: PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
22 install: PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
23 install: PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
24 install: PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
25 install: PREPARE_SOURCE_DIR=$(PREPARE_HOST)/stage$(PREPARE_STAGE)
26 install: PREPARE_SOURCE_BIN_DIR=$(PREPARE_SOURCE_DIR)/bin
27 install: PREPARE_SOURCE_LIB_DIR=$(PREPARE_SOURCE_DIR)/$(CFG_LIBDIR_RELATIVE)
28 install: PREPARE_SOURCE_MAN_DIR=$(S)/man
29 install: PREPARE_DEST_BIN_DIR=$(DESTDIR)$(CFG_PREFIX)/bin
30 install: PREPARE_DEST_LIB_DIR=$(DESTDIR)$(CFG_LIBDIR)
31 install: PREPARE_DEST_MAN_DIR=$(DESTDIR)$(CFG_MANDIR)/man1
32 install: prepare-everything
37 PREFIX_ROOT = $(CFG_PREFIX)
38 PREFIX_BIN = $(PREFIX_ROOT)/bin
39 PREFIX_LIB = $(CFG_LIBDIR)
41 INSTALL_TOOLS := $(PREPARE_TOOLS)
43 # Shorthand for build/stageN/bin
44 HB = $(HBIN$(ISTAGE)_H_$(CFG_BUILD))
45 HB2 = $(HBIN2_H_$(CFG_BUILD))
46 # Shorthand for build/stageN/lib
47 HL = $(HLIB$(ISTAGE)_H_$(CFG_BUILD))
48 # Shorthand for the prefix bin directory
50 # Shorthand for the prefix bin directory
53 HOST_LIB_FROM_HL_GLOB = \
54 $(patsubst $(HL)/%,$(PHL)/%,$(wildcard $(HL)/$(1)))
56 uninstall: $(foreach tool,$(INSTALL_TOOLS),uninstall-tool-$(tool))
57 $(Q)rm -Rf $(PHL)/$(CFG_RUSTLIBDIR)
60 uninstall-tool-$(1): $$(foreach dep,$$(TOOL_DEPS_$(1)),uninstall-lib-$$(dep))
61 $$(Q)rm -f $$(PHB)/$(1)$$(X_$$(CFG_BUILD))
62 $$(Q)rm -f $$(CFG_MANDIR)/man1/$(1).1
65 $(foreach tool,$(INSTALL_TOOLS),$(eval $(call UNINSTALL_TOOL,$(tool))))
68 uninstall-lib-$(1): $$(foreach dep,$$(RUST_DEPS_$(1)),uninstall-lib-$$(dep))
69 $$(Q)rm -f $$(call HOST_LIB_FROM_HL_GLOB,$$(call CFG_LIB_GLOB_$$(CFG_BUILD),$(1)))
72 $(foreach lib,$(CRATES),$(eval $(call UNINSTALL_LIB,$(lib))))
75 # Android runtime setup
76 # FIXME: This probably belongs somewhere else
78 # target platform specific variables
79 # for arm-linux-androidabi
80 define DEF_ADB_DEVICE_STATUS
81 CFG_ADB_DEVICE_STATUS=$(1)
84 $(foreach target,$(CFG_TARGET), \
85 $(if $(findstring $(target),"arm-linux-androideabi"), \
86 $(if $(findstring adb,$(CFG_ADB)), \
87 $(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
88 $(info install: install-runtime-target for $(target) enabled \
89 $(info install: android device attached) \
90 $(eval $(call DEF_ADB_DEVICE_STATUS, true))), \
91 $(info install: install-runtime-target for $(target) disabled \
92 $(info install: android device not attached) \
93 $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
95 $(info install: install-runtime-target for $(target) disabled \
96 $(info install: adb not found) \
97 $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
102 ifeq (install-runtime-target,$(firstword $(MAKECMDGOALS)))
103 $(eval $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)):;@:)
104 L_TOKEN := $(word 2,$(MAKECMDGOALS))
106 CFG_RUNTIME_PUSH_DIR=/system/lib
108 CFG_RUNTIME_PUSH_DIR=$(L_TOKEN)
111 ifeq ($(CFG_ADB_DEVICE_STATUS),true)
114 ADB_PUSH = adb push $(1) $(2)
115 ADB_SHELL = adb shell $(1) $(2)
117 ADB = $(Q)$(call E, adb $(1)) && adb $(1) 1>/dev/null
118 ADB_PUSH = $(Q)$(call E, adb push $(1)) && adb push $(1) $(2) 1>/dev/null
119 ADB_SHELL = $(Q)$(call E, adb shell $(1) $(2)) && adb shell $(1) $(2) 1>/dev/null
122 define INSTALL_RUNTIME_TARGET_N
123 install-runtime-target-$(1)-host-$(2): $$(TSREQ$$(ISTAGE)_T_$(1)_H_$(2)) $$(SREQ$$(ISTAGE)_T_$(1)_H_$(2))
124 $$(Q)$$(call ADB_SHELL,mkdir,$(CFG_RUNTIME_PUSH_DIR))
125 $$(Q)$$(foreach crate,$$(TARGET_CRATES),\
126 $$(call ADB_PUSH,$$(TL$(1)$(2))/$$(call CFG_LIB_GLOB_$(1),$$(crate)),\
127 $$(CFG_RUNTIME_PUSH_DIR));)
130 define INSTALL_RUNTIME_TARGET_CLEANUP_N
131 install-runtime-target-$(1)-cleanup:
132 $$(Q)$$(call ADB,remount)
133 $$(Q)$$(foreach crate,$$(TARGET_CRATES),\
134 $$(call ADB_SHELL,rm,$$(CFG_RUNTIME_PUSH_DIR)/$$(call CFG_LIB_GLOB_$(1),$$(crate)));)
137 $(eval $(call INSTALL_RUNTIME_TARGET_N,arm-linux-androideabi,$(CFG_BUILD)))
138 $(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,arm-linux-androideabi))
140 install-runtime-target: \
141 install-runtime-target-arm-linux-androideabi-cleanup \
142 install-runtime-target-arm-linux-androideabi-host-$(CFG_BUILD)
144 install-runtime-target:
145 @echo "No device to install runtime library"