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