]> git.lizzy.rs Git - rust.git/blob - mk/install.mk
mk: Run 'make install' through install.sh
[rust.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
12 install: dist-install-dir-$(CFG_BUILD)
13         $(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(CFG_PREFIX)"
14
15 uninstall: dist-install-dir-$(CFG_BUILD)
16         $(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(CFG_PREFIX)" --uninstall
17
18
19 ######################################################################
20 # Android remote installation
21 ######################################################################
22
23 # Android runtime setup
24 # FIXME: This probably belongs somewhere else
25
26 # target platform specific variables
27 # for arm-linux-androidabi
28 define DEF_ADB_DEVICE_STATUS
29 CFG_ADB_DEVICE_STATUS=$(1)
30 endef
31
32 $(foreach target,$(CFG_TARGET), \
33   $(if $(findstring $(target),"arm-linux-androideabi"), \
34     $(if $(findstring adb,$(CFG_ADB)), \
35       $(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
36         $(info install: install-runtime-target for $(target) enabled \
37           $(info install: android device attached) \
38           $(eval $(call DEF_ADB_DEVICE_STATUS, true))), \
39         $(info install: install-runtime-target for $(target) disabled \
40           $(info install: android device not attached) \
41           $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
42       ), \
43       $(info install: install-runtime-target for $(target) disabled \
44         $(info install: adb not found) \
45         $(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
46     ), \
47   ) \
48 )
49
50 ifeq (install-runtime-target,$(firstword $(MAKECMDGOALS)))
51 $(eval $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)):;@:)
52 L_TOKEN := $(word 2,$(MAKECMDGOALS))
53 ifeq ($(L_TOKEN),)
54 CFG_RUNTIME_PUSH_DIR=/system/lib
55 else
56 CFG_RUNTIME_PUSH_DIR=$(L_TOKEN)
57 endif
58
59 ifeq ($(CFG_ADB_DEVICE_STATUS),true)
60 ifdef VERBOSE
61  ADB = adb $(1)
62  ADB_PUSH = adb push $(1) $(2)
63  ADB_SHELL = adb shell $(1) $(2)
64 else
65  ADB = $(Q)$(call E, adb $(1)) && adb $(1) 1>/dev/null
66  ADB_PUSH = $(Q)$(call E, adb push $(1)) && adb push $(1) $(2) 1>/dev/null
67  ADB_SHELL = $(Q)$(call E, adb shell $(1) $(2)) && adb shell $(1) $(2) 1>/dev/null
68 endif
69
70 define INSTALL_RUNTIME_TARGET_N
71 install-runtime-target-$(1)-host-$(2): $$(TSREQ$$(ISTAGE)_T_$(1)_H_$(2)) $$(SREQ$$(ISTAGE)_T_$(1)_H_$(2))
72         $$(Q)$$(call ADB_SHELL,mkdir,$(CFG_RUNTIME_PUSH_DIR))
73         $$(Q)$$(foreach crate,$$(TARGET_CRATES),\
74             $$(call ADB_PUSH,$$(TL$(1)$(2))/$$(call CFG_LIB_GLOB_$(1),$$(crate)),\
75                         $$(CFG_RUNTIME_PUSH_DIR));)
76 endef
77
78 define INSTALL_RUNTIME_TARGET_CLEANUP_N
79 install-runtime-target-$(1)-cleanup:
80         $$(Q)$$(call ADB,remount)
81         $$(Q)$$(foreach crate,$$(TARGET_CRATES),\
82             $$(call ADB_SHELL,rm,$$(CFG_RUNTIME_PUSH_DIR)/$$(call CFG_LIB_GLOB_$(1),$$(crate)));)
83 endef
84
85 $(eval $(call INSTALL_RUNTIME_TARGET_N,arm-linux-androideabi,$(CFG_BUILD)))
86 $(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,arm-linux-androideabi))
87
88 install-runtime-target: \
89         install-runtime-target-arm-linux-androideabi-cleanup \
90         install-runtime-target-arm-linux-androideabi-host-$(CFG_BUILD)
91 else
92 install-runtime-target:
93         @echo "No device to install runtime library"
94         @echo
95 endif
96 endif