summaryrefslogtreecommitdiff
path: root/Makefile
blob: cfbe4a9d3a670d712e4c917e61a004149ecdd227 (plain)
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
PREFIX=/usr/local

# in a bind, thes can all be set to the same directory
pbs-bindir = $(PREFIX)/lib/pbs-core
git-bindir = $(PREFIX)/lib/git-core
bindir = $(PREFIX)/bin
libreconfdir = /etc/libretools.d

pbs-progs := $(shell printf '%s\n' pbs-* | fgrep -v .)
git-progs := $(shell printf '%s\n' git-* | fgrep -v .)
bin-progs = pbs
libreconf := $(wildcard pbs-*.conf)

install-targets := \
	$(addprefix $(DESTDIR)$(pbs-bindir)/,$(pbs-progs)) \
	$(addprefix $(DESTDIR)$(git-bindir)/,$(git-progs)) \
	$(addprefix $(DESTDIR)$(bindir)/,$(bin-progs)) \
	$(addprefix $(DESTDIR)$(libreconfdir)/,$(libreconf))

# phony rules

all: PHONY $(pbs-progs) $(git-progs) $(bin-progs) $(libreconf)

clean: PHONY
	rm -f pbs

install: PHONY $(install-targets)

uninstall: PHONY
	for f in $(install-targets); do rm -f -- $(f); done

# actual file rules

pbs: pbs.in
	sed 's|@pbs-bindir@|$(pbs-bindir)|g' < $< > $@
	chmod 755 $@

$(DESTDIR)$(pbs-bindir)/%: % | $(DESTDIR)$(pbs-bindir)
	cp '$*' '${@D}'

$(DESTDIR)$(git-bindir)/%: % | $(DESTDIR)$(git-bindir)
	cp '$*' '${@D}'

$(DESTDIR)$(bindir)/%: % | $(DESTDIR)$(bindir)
	cp '$*' '${@D}'

$(DESTDIR)$(libreconfdir)/%: % | $(DESTDIR)$(libreconfdir)
	install -m644 '$*' '${@D}'

$(addprefix $(DESTDIR),$(pbs-bindir) $(git-bindir) $(bindir) $(libreconfdir)):
	install -d '$@'

# tricks

.PHONY: PHONY