-
Notifications
You must be signed in to change notification settings - Fork 0
/
asm-setup
executable file
·84 lines (66 loc) · 2.54 KB
/
asm-setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/make -sf
#
# Copyright 2016-2017 Gaël PORTAY <[email protected]>
#
# Licensed under the MIT license.
#
PREFIX ?= /usr/local
.INTERMEDIATE: index.html
__make := make
__install := cp -d
__makefile := $(firstword $(MAKEFILE_LIST))
ifeq ($(__makefile),Makefile)
all: asm
else
__make := $(__makefile)
__install := mv
all:
make -f $(__makefile) error >&2
@echo '' >&2
@exit 1
error:
@echo 'Usage: $(__make) [un]install [PREFIX=/usr] [DESTDIR=] to install binary to system.'
@echo ''
@echo 'Example 1: install for all users'
@echo '# $(__make) install'
@echo 'or with super-user privileges:'
@echo '$$ sudo $(__make) install'
@echo ''
@echo 'Example 2: install for current user only'
@echo '$$ $(__make) install DESTDIR=~ PREFIX='
@echo 'or using install-user alias:'
@echo '$$ $(__make) install-user'
Makefile:
ln -s $(__makefile) $@
endif
help:
@echo 'Usage: $(__make) [all] to download sources to current directory.'
@echo ' $(__make) [un]install [PREFIX=/usr] [DESTDIR=] to install binary to system.'
@echo ' $(__make) [un]install-user to install binary to current user.'
@echo ' $(__make) android-screen-monitor to fetch sources.'
@echo ' $(__make) clean to remove temporary files.'
ifneq ($(__makefile),Makefile)
@echo ' $(__make) Makefile to create a Makefile symlink and then run make frontend.'
endif
@echo ' $(__make) help to display this message.'
index.html:
wget -qO- http://adakoda.github.io/android-screen-monitor/ >$@
asm.jar: index.html
sed -n '/Download<\/h3>/,/^$$/{//d;s,.*Version \([0-9.]*\) - <a.*href="\(.*\)">\(.*\)</a>.*,wget -O- \2 | gzip -d >asm-\1.jar \&\& ln -s asm-\1.jar $@ \&\& exit 0,p}' $< | sh
asm: index.html asm.jar
sed -n '/Run<\/h3>/,/^$$/{//d;/<pre><code>/s,.*<code>*\$$ \(.*\)</code>.*,#!/bin/sh\n\1 \$$*,p}' $< >$@
chmod a+x $@
android-screen-monitor:
git clone [email protected]:adakoda/android-screen-monitor.git
install: asm
install -d $(DESTDIR)$(PREFIX)/bin
$(__install) asm asm.jar $(shell readlink asm.jar) $(DESTDIR)$(PREFIX)/bin
sed -e '/^java/s,asm.jar,$(DESTDIR)$(PREFIX)/bin/asm.jar,' -i $(DESTDIR)$(PREFIX)/bin/asm
uninstall:
-for bin in asm asm.jar $(shell readlink asm.jar); do rm -f $(DESTDIR)$(PREFIX)/bin/$$bin; done
install-user:
make -f $(__makefile) install DESTDIR=~ PREFIX=
uninstall-user:
make -f $(__makefile) uninstall DESTDIR=~ PREFIX=
clean:
rm -f Makefile asm asm.jar asm-*.jar