summaryrefslogtreecommitdiff
path: root/Makefile
blob: 54488cc4a419ef2b52d6813e0430d59b98ad04d0 (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
export OPENRC_RUN = /usr/bin/openrc-run
export BINDIR = /usr/bin

SYSCONFDIR ?= etc

MACRO_PROG = ./replace.sh
INIT_FILES = $(shell find init.d.in -type f | sed -e 's/\.in$$//g' -e 's/init\.d\.in/init.d/g')
CONF_FILES = $(shell find conf.d.in -type f | sed -e 's/\.in$$//g' -e 's/conf\.d\.in/conf.d/g')
DEST_INIT_D = $(DESTDIR)/$(SYSCONFDIR)/init.d
DEST_CONF_D = $(DESTDIR)/$(SYSCONFDIR)/conf.d

all: $(INIT_FILES) $(CONF_FILES)

init.d:
	mkdir $@

conf.d:
	mkdir $@

init.d/%: init.d.in/%.in init.d
	$(MACRO_PROG) $< > $@
	chmod +x $@

conf.d/%: conf.d.in/%.in conf.d
	$(MACRO_PROG) $< > $@
	chmod +x $@

.PHONY: clean install
clean:
	rm $(INIT_FILES) $(CONF_FILES)

install:
	install -d "$(DEST_INIT_D)"
	install -d "$(DEST_CONF_D)"

	$(foreach file,$(INIT_FILES),install -Dm 755 "$(file)" "$(DEST_INIT_D)";)
	$(foreach file,$(CONF_FILES),install -Dm 755 "$(file)" "$(DEST_CONF_D)";)