summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 4ad8c641575e0f0ddf965c3bfecdc6cc852dcd78 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#
# This makefile requires make compliant with POSIX Issue 8.
# It also reliably works with modern GNU make.
# Do not make changes here.
# Use the included .mak files.
#

.POSIX:

IT = conferror

-include config.mak

it: $(IT)

conferror:
	@echo "Please use ./configure first." ; exit 1

ALL_EXTRAS ::=
INSTALL_EXTRAS ::=

-include package/extras.mak

include package/targets.mak
include package/deps.mak

INSTALL ::= ./tools/install.sh

all: $(ALL_BINS) $(ALL_LIBS) $(ALL_EXTRAS)

clean:
	@exec rm -rf -- $(ALL_BINS) service source bundle etc

distclean: clean
	@exec rm -f -- config.mak

tgz: distclean
	@. package/info && \
	rm -rf ../../stage/$$package-$$version && \
	cp -a . ../../stage/$$package-$$version && \
	cd ../../stage && \
	tar -zpcv --owner=0 --group=0 --numeric-owner --exclude=.git* -f $$package-$$version.tar.gz $$package-$$version && \
	sha256sum $$package-$$version.tar.gz > $$package-$$version.tar.gz.sha256 && \
	exec rm -rf $$package-$$version

install: $(INSTALL_BINS) $(INSTALL_LIBS) $(INSTALL_EXTRAS)

$(ALL_BINS) $(ALL_LIBS):
	@test -z $$(dirname "$@") || mkdir -p -- $$(dirname "$@")
	exec sed \
		-e 's/@syslogdir@/$(syslogdir)/g' \
		-e 's/@usrlogdir@/$(usrlogdir)/g' \
		-e 's/@logdep@/$(logdep)/g' \
		-e 's/@logconfig@/$(logconfig)/g' \
		-e 's/@loguser@/$(loguser)/g' \
		-e 's/@sysconfdir@/$(sysconfdir)/g' \
		-e 's/@usrconfdir@/$(usrconfdir)/g' \
		-e 's/@tmpfsdir@/$(tmpfsdir)/g' \
		-e 's/@sysrundir@/$(sysrundir)/g' \
		-e 's/@usrrundir@/$(usrrundir)/g' \
		-e 's/@timeout@/$(timeout)/g' \
		-e 's/@shebangdir@/$(shebangdir)/g' \
 	-- $^ > $@

$(INSTALL_BINS) $(INSTALL_LIBS):
	exec $(INSTALL) -D -m 644 $^ $(DESTDIR)/$@
	grep -F -- $^ - < package/modes | { read name mode owner && \
	if [ x$${mode} != x ] ; then chmod $${mode} $@ ; fi && \
	if [ x$${owner} != x ] ; then chown -- $${owner} $@ ; fi ; } || exit 0


$(DESTDIR)$(exthome):
	exec $(INSTALL) -D -l $(package)-$(version) $@

$(SLASHCOMMAND_BINS):
	exec $(INSTALL) -D -l $(DESTDIR)$(exthome)/command/$$(basename $@) $@

update: $(DESTDIR)$(exthome)
global-links: $(SLASHCOMMAND_BINS)

.PHONY: \
	it all clean distclean tgz update global-links \
	install uninstall \
	$(DESTDIR)$(exthome) $(SLASHCOMMAND_BINS)