-
-
Notifications
You must be signed in to change notification settings - Fork 156
/
Makefile
82 lines (68 loc) · 2.5 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
77
78
79
80
81
82
AUTOMAKE_OPTIONS = foreign
DESTDIR ?=
PREFIX ?= /usr
HEADER = src/wslu-header
OUTPATH = out
MANPATH = docs
OUTMANPATH = out-docs
CURPATH = $(shell pwd)
SOURCES := $(wildcard src/*.sh)
ETCFILES := $(wildcard src/etc/*)
OUTFILES := $(wildcard out/*)
MANFILES := $(wildcard docs/*)
INSTEDEXES := $(wildcard $(DESTDIR)$(PREFIX)/bin/wsl*)
INSTEDMANOS := $(wildcard $(DESTDIR)$(PREFIX)/share/man/man1/wsl*)
DATETMP = $(shell date +%Y-%m-%d)
VERTMP = $(shell cat ./VERSION)
all: doc
[ -d $(OUTPATH) ] || mkdir $(OUTPATH)
sed -e 's/VERSIONPLACEHOLDER/'$(VERTMP)'/' -e 's|PREFIXPLACEHOLDER|'$(PREFIX)'|' -e 's|DESTDIRPLACEHOLDER|'$(DESTDIR)'|' $(HEADER) > $(HEADER).tmp; \
for file in $(SOURCES); do \
cat $(HEADER).tmp $$file > $(OUTPATH)/`basename $$file`; \
mv $(OUTPATH)/`basename $$file` $(OUTPATH)/`basename $$file .sh`; \
done
rm $(HEADER).tmp
chmod +x $(OUTPATH)/*
install: doc_install res_install conf_install
install -Dm 755 out/* -t $(DESTDIR)$(PREFIX)/bin
uninstall:
for f in $(INSTEDEXES); do \
if [ `basename $$f` != "wslpath" ] && [ `basename $$f` != "wslinfo" ]; then \
rm -f $$f; \
fi; \
done
for f in $(INSTEDMANOS); do \
rm -f $$f; \
done
rm -rf $(DESTDIR)$(PREFIX)/share/man/man7/wslu.7.gz
rm -rf $(DESTDIR)$(PREFIX)/share/wslu
rm -f $(DESTDIR)$(PREFIX)/share/applications/wslview.desktop
doc:
[ -d $(OUTMANPATH) ] || mkdir $(OUTMANPATH)
for file in $(MANFILES); do \
cp $$file $(OUTMANPATH); \
sed -e 's/DATEPLACEHOLDER/'$(DATETMP)'/' -e 's/VERSIONPLACEHOLDER/'$(VERTMP)'/' $(OUTMANPATH)/`basename $$file` > $(OUTMANPATH)/`basename $$file`.tmp; \
mv $(OUTMANPATH)/`basename $$file`.tmp $(OUTMANPATH)/`basename $$file`; \
gzip -f -q $(OUTMANPATH)/`basename $$file`; \
done
doc_install:
install -Dm 644 out-docs/*.1.gz -t $(DESTDIR)$(PREFIX)/share/man/man1
install -Dm 644 out-docs/*.7.gz -t $(DESTDIR)$(PREFIX)/share/man/man7
res_install:
install -Dm 644 src/etc/*.vbs -t $(DESTDIR)$(PREFIX)/share/wslu
install -Dm 644 src/etc/*.ps1 -t $(DESTDIR)$(PREFIX)/share/wslu
install -Dm 644 src/etc/*.ico -t $(DESTDIR)$(PREFIX)/share/wslu
install -Dm 755 src/etc/*.sh -t $(DESTDIR)$(PREFIX)/share/wslu
install -Dm 644 src/etc/wslview.desktop -t $(DESTDIR)$(PREFIX)/share/applications
install -Dm 644 src/etc/conf $(DESTDIR)$(PREFIX)/share/wslu
conf_install:
install -Dm 644 src/etc/user/conf -t $(DESTDIR)/etc/wslu
clean:
rm -rf $(OUTPATH)
rm -rf $(OUTMANPATH)
test:
bats -r tests
shellcheck:
shellcheck -P src/*
coverage:
kcov --include-path="./src,./out" ./tests/coverage bats -r tests