]> git.proxmox.com Git - rustc.git/blob - mk/install.mk
Imported Upstream version 1.0.0-alpha.2
[rustc.git] / mk / install.mk
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.
4 #
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.
10
11 ifdef CFG_DISABLE_VERIFY_INSTALL
12 MAYBE_DISABLE_VERIFY=--disable-verify
13 else
14 MAYBE_DISABLE_VERIFY=
15 endif
16
17 install:
18 ifeq (root user, $(USER) $(patsubst %,user,$(SUDO_USER)))
19 # Build the dist as the original user
20 $(Q)sudo -u "$$SUDO_USER" $(MAKE) prepare_install
21 else
22 $(Q)$(MAKE) prepare_install
23 endif
24 ifeq ($(CFG_DISABLE_DOCS),)
25 $(Q)cd tmp/empty_dir && sh ../../tmp/dist/$(DOC_PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)" "$(MAYBE_DISABLE_VERIFY)"
26 endif
27 $(Q)cd tmp/empty_dir && sh ../../tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)" "$(MAYBE_DISABLE_VERIFY)"
28 # Remove tmp files because it's a decent amount of disk space
29 $(Q)rm -R tmp/dist
30
31 prepare_install: dist-tar-bins | tmp/empty_dir
32
33 uninstall:
34 ifeq (root user, $(USER) $(patsubst %,user,$(SUDO_USER)))
35 # Build the dist as the original user
36 $(Q)sudo -u "$$SUDO_USER" $(MAKE) prepare_uninstall
37 else
38 $(Q)$(MAKE) prepare_uninstall
39 endif
40 ifeq ($(CFG_DISABLE_DOCS),)
41 $(Q)cd tmp/empty_dir && sh ../../tmp/dist/$(DOC_PKG_NAME)-$(CFG_BUILD)/install.sh --uninstall --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)"
42 endif
43 $(Q)cd tmp/empty_dir && sh ../../tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --uninstall --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)"
44 # Remove tmp files because it's a decent amount of disk space
45 $(Q)rm -R tmp/dist
46
47 prepare_uninstall: dist-tar-bins | tmp/empty_dir
48
49 .PHONY: install prepare_install uninstall prepare_uninstall
50
51 tmp/empty_dir:
52 mkdir -p $@
53
54 ######################################################################
55 # Android remote installation
56 ######################################################################
57
58 # Android runtime setup
59 # FIXME: This probably belongs somewhere else
60
61 # target platform specific variables for android
62 define DEF_ADB_DEVICE_STATUS
63 CFG_ADB_DEVICE_STATUS=$(1)
64 endef
65
66 $(foreach target,$(CFG_TARGET), \
67 $(if $(findstring android, $(target)), \
68 $(if $(findstring adb,$(CFG_ADB)), \
69 $(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
70 $(info install: install-runtime-target for $(target) enabled \
71 $(info install: android device attached) \
72 $(eval $(call DEF_ADB_DEVICE_STATUS, true))), \
73 $(info install: install-runtime-target for $(target) disabled \
74 $(info install: android device not attached) \
75 $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
76 ), \
77 $(info install: install-runtime-target for $(target) disabled \
78 $(info install: adb not found) \
79 $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
80 ), \
81 ) \
82 )
83
84 ifeq (install-runtime-target,$(firstword $(MAKECMDGOALS)))
85 $(eval $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)):;@:)
86 L_TOKEN := $(word 2,$(MAKECMDGOALS))
87 ifeq ($(L_TOKEN),)
88 CFG_RUNTIME_PUSH_DIR=/system/lib
89 else
90 CFG_RUNTIME_PUSH_DIR=$(L_TOKEN)
91 endif
92
93 ifeq ($(CFG_ADB_DEVICE_STATUS),true)
94 ifdef VERBOSE
95 ADB = adb $(1)
96 ADB_PUSH = adb push $(1) $(2)
97 ADB_SHELL = adb shell $(1) $(2)
98 else
99 ADB = $(Q)$(call E, adb $(1)) && adb $(1) 1>/dev/null
100 ADB_PUSH = $(Q)$(call E, adb push $(1)) && adb push $(1) $(2) 1>/dev/null
101 ADB_SHELL = $(Q)$(call E, adb shell $(1) $(2)) && adb shell $(1) $(2) 1>/dev/null
102 endif
103
104 define INSTALL_RUNTIME_TARGET_N
105 install-runtime-target-$(1)-host-$(2): $$(TSREQ$$(ISTAGE)_T_$(1)_H_$(2)) $$(SREQ$$(ISTAGE)_T_$(1)_H_$(2))
106 $$(Q)$$(call ADB_SHELL,mkdir,$(CFG_RUNTIME_PUSH_DIR))
107 $$(Q)$$(foreach crate,$$(TARGET_CRATES), \
108 $$(call ADB_PUSH,$$(TL$(1)$(2))/$$(call CFG_LIB_GLOB_$(1),$$(crate)), \
109 $$(CFG_RUNTIME_PUSH_DIR));)
110 endef
111
112 define INSTALL_RUNTIME_TARGET_CLEANUP_N
113 install-runtime-target-$(1)-cleanup:
114 $$(Q)$$(call ADB,remount)
115 $$(Q)$$(foreach crate,$$(TARGET_CRATES), \
116 $$(call ADB_SHELL,rm,$$(CFG_RUNTIME_PUSH_DIR)/$$(call CFG_LIB_GLOB_$(1),$$(crate)));)
117 endef
118
119 $(foreach target,$(CFG_TARGET), \
120 $(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
121 $(eval $(call INSTALL_RUNTIME_TARGET_N,$(taget),$(CFG_BUILD))) \
122 $(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,$(target))) \
123 ))
124
125 install-runtime-target: \
126 install-runtime-target-arm-linux-androideabi-cleanup \
127 install-runtime-target-arm-linux-androideabi-host-$(CFG_BUILD)
128 else
129 install-runtime-target:
130 @echo "No device to install runtime library"
131 @echo
132 endif
133 endif