summaryrefslogtreecommitdiff
path: root/Makefile
blob: 802117aaa361babad3f840fd0c88c9c069cd63eb (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
56
57
58
59
60
61
62
63
64
65
66
67
68
# Configuration
DESTDIR=

#prefix=/usr/local
prefix=/usr
exec_prefix=$(prefix)
datarootdir=$(prefix)/share

bindir=$(exec_prefix)/bin
sbindir=$(exec_prefix)/sbin
#sysconfdir=$(prefix)/etc
sysconfdir=/etc
datadir=$(datarootdir)
docdir=$(datarootdir)/doc

################################################################################

pseudo-packages=abslibre-tools chroot-tools fullpkg mips64el-tools pr-tools toru
packages=libretools libretools-pr libretools-mips64el

libretools=abslibre-tools chroot-tools fullpkg toru misc
libretools-pr=pr-tools
libretools-mips64el=mips64el-tools

################################################################################

all: PHONY libretools
install: PHONY install-libretools install-doc

install-doc: $(patsubst doc/%,$(DESTDIR)$(docdir)/libretools/%,$(wildcard doc/*))

$(DESTDIR)$(docdir)/libretools/%: doc/%
	install -Dm644 '$<' '$@'

$(DESTDIR)$(sysconfdir)/libretools.conf: src/libretools.conf
	install -Dm644 '$<' '$@'

$(foreach pkg,$(pseudo-packages) .,                   \
$(eval                                                \
$(DESTDIR)$(bindir)/%: src/$(pkg)/%;                  \
	install -Dm755 '$$<' '$$@'                    \
)                                                     \
$(eval                                                \
$(DESTDIR)$(sysconfdir)/libretools.d/%: src/$(pkg)/%; \
	install -Dm644 '$$<' '$$@'                    \
))

################################################################################

progs = $(shell find src/$1 -maxdepth 1 -type f      -executable -printf '%f\n')
confs = $(shell find src/$1 -maxdepth 1 -type f -not -executable -printf '%f\n')
files = $(addprefix $(DESTDIR)$2/,$(call progs,$1)) \
        $(addprefix $(DESTDIR)$3/,$(call confs,$1))

.SECONDEXPANSION:
$(packages): %: PHONY $$($$*)
$(addprefix install-,$(packages)): install-%: PHONY $$(addprefix install-,$$($$*))

$(pseudo-packages) misc: %: PHONY
$(addprefix install-,$(pseudo-packages)): install-%: PHONY $$(call files,$$*,$(bindir),$(sysconfdir)/libretools.d)
# special cases
install-misc: PHONY $(call files,.,$(bindir),$(sysconfdir))

################################################################################

FORCE: PHONY
PHONY:
.PHONY: FORCE PHONY