aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 61d51fb0593be1f3e0f4509a5a2feae15e51f220 (plain) (blame)
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
.POSIX:

CONFIGFILE = config.mk
include $(CONFIGFILE)

all: base shell
base: sleep-until
shell: bash zsh fish
bash: sleep-until.bash
zsh: sleep-until.zsh
fish: sleep-until.fish

clocks.h:
	sed -n 's/^[ \t]*#[ \t]*define[ \t][ \t]*\(CLOCK_[^ \t]*\).*$$/X(\1)/p' < /usr/include/bits/time.h > $@

sleep-until.o: sleep-until.c clocks.h
	$(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)

sleep-until: sleep-until.o
	$(CC) -o $@ sleep-until.o $(LDFLAGS)

sleep-until.bash: completion
	auto-auto-complete bash --output $@ --source $<

sleep-until.zsh: completion
	auto-auto-complete zsh --output $@ --source $<

sleep-until.fish: completion
	auto-auto-complete fish --output $@ --source $<

install: install-base install-shell
install-shell: install-bash install-zsh install-fish

install-base: sleep-until
	mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1"
	cp -- sleep-until "$(DESTDIR)$(PREFIX)/bin"
	cp -- sleep-until.1 "$(DESTDIR)$(MANPREFIX)/man1"

install-bash: sleep-until.bash
	mkdir -p -- "$(DESTDIR)$(PREFIX)/share/bash-completion/completions"
	cp -- sleep-until.bash "$(DESTDIR)$(PREFIX)/share/bash-completion/completions/sleep-until"

install-zsh: sleep-until.zsh
	mkdir -p -- "$(DESTDIR)$(PREFIX)/share/zsh/site-functions"
	cp -- sleep-until.zsh "$(DESTDIR)$(PREFIX)/share/zsh/site-functions/_sleep-until"

install-fish: sleep-until.fish
	mkdir -p -- "$(DESTDIR)$(PREFIX)/share/fish/completions"
	cp -- sleep-until.fish "$(DESTDIR)$(PREFIX)/share/fish/completions/sleep-until.fish"

uninstall:
	-rm -f -- "$(DESTDIR)$(BINDIR)/sleep-until"
	-rm -f -- "$(DESTDIR)$(MANPREFIX)/man1/sleep-until.1"
	-rm -f -- "$(DESTDIR)$(PREFIX)/share/fish/completions/sleep-until.fish"
	-rmdir -- "$(DESTDIR)$(PREFIX)/share/fish/completions"
	-rmdir -- "$(DESTDIR)$(PREFIX)/share/fish"
	-rm -f -- "$(DESTDIR)$(PREFIX)/share/zsh/site-functions/_sleep-until"
	-rmdir -- "$(DESTDIR)$(PREFIX)/share/zsh/site-functions"
	-rmdir -- "$(DESTDIR)$(PREFIX)/share/zsh"
	-rm -f -- "$(DESTDIR)$(PREFIX)/share/bash-completion/completions/sleep-until"
	-rmdir -- "$(DESTDIR)$(PREFIX)/share/bash-completion/completions"
	-rmdir -- "$(DESTDIR)$(PREFIX)/share/bash-completion"

clean:
	-rm -f -- sleep-until *.o clocks.h *.bash *.zsh *.fish

.PHONY: all base shell bash zsh fish install install-base install-shell install-base install-zsh install-fish uninstall clean