-
Notifications
You must be signed in to change notification settings - Fork 66
/
simple-make.sh
52 lines (49 loc) · 857 Bytes
/
simple-make.sh
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
#!/bin/sh
#
# Convert the Makefile into a shell script and # execute it via the shell
#
sed -n '
# Set optional variables
/ ?= / {
s/[()"]//g
s/\([^ ]*\) ?= \(.*\)/\1="${\1:-\2}"/
p
b
}
# Convert Makefile rules into shell functions
/:$/ {
s/^\([^\t].*\):$/\1() {/p
n
:body
s/^\t@/\t/
y/()/{}/
s/\tinstall/\tcommand install/
s/^\t/ /p
# Close function and terminate block processing on empty line
# (Reset "t" status)
t reset
:reset
s/^$/}/p
t
# Read next line and repeat
n
b body
}
# Convert the PHONY rules list into a case statement
/^\.PHONY:/ {
s/^\.PHONY: default //
i\
case "'$1'" in
s/ /|/g
s/$/)/p
i\
'$1'\
;;\
*)
s/^/ echo "Usage: gfw_make {/
s/)$/}"/p
i\
;;\
esac
}
' Makefile | bash