forked from mjhennig/loop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (62 loc) · 1.72 KB
/
Makefile
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
##
# Mathias J. Hennig wrote this script. As long as you retain this notice
# you can do whatever you want with this stuff. If we meet some day, and
# you think this stuff is worth it, you can buy me a beer in return.
##
##
# Where to store the install manifest
log=./.install_manifest
##
# Where to find nirvana
null=/dev/null
##
# Obligatoric stuff to pretend portability
chmod=chmod
cp=cp -r
find=find
echo=echo
mkdir=mkdir -p
rm=rm -r
tar=tar -cvzf
test=test
wc=wc
which=which
xargs=xargs
zip=zip -r
##
# Instead of a quirky DEFAULT_TARGET..
nothing:
@$(echo) Available targets: all check install uninstall
@$(echo) Recommended install command: PREFIX=/usr/local make all
##
# Now the "real" targets are following:
##
all: check install
check: ./loop.sh
$(which) bc cat getopt printf sleep test >> $(null)
$(chmod) +x ./loop.sh
$(test) x3 = "x`./loop.sh -i 3 $(echo) 'Hello World!' | $(wc) -l`"
install: ./loop.sh ./loop.1
$(mkdir) "$$PREFIX/bin" "$$PREFIX/man/man1"
$(cp) ./loop.sh "$$PREFIX/bin/loop"
$(echo) "$$PREFIX/bin/loop" >> "$(log)"
$(cp) ./loop.1 $$PREFIX/man/man1/loop.1
$(echo) "$$PREFIX/man/man1/loop.1" >> "$(log)"
$(chmod) 755 "$$PREFIX/bin/loop"
$(chmod) 644 "$$PREFIX/man/man1/loop.1" "$(log)"
uninstall:
$(test) -e "$(log)" && $(xargs) $(rm) < "$(log)"
$(test) -e "$(log)" && $(rm) "$(log)"
##
# Unofficial targets
##
loop-%.tar.gz: ./README ./Makefile ./loop.sh ./loop.1
$(test) -e "loop-$*" || ( $(mkdir) "loop-$*" && $(cp) $^ "loop-$*" )
$(tar) "loop-$*.tar.gz" "loop-$*"
loop-%.zip: ./README ./Makefile ./loop.sh ./loop.1
$(test) -e "loop-$*" || ( $(mkdir) "loop-$*" && $(cp) $^ "loop-$*" )
$(zip) "loop-$*.zip" "loop-$*"
clean:
$(find) . -type d -name 'loop-*' | $(xargs) $(rm)
distclean:
$(rm) loop-*