-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
134 lines (105 loc) · 2.99 KB
/
Makefile
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
SYSCONFDIR = /etc
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
LIBDIR = $(PREFIX)/lib
MANDIR = $(PREFIX)/share/man
DOCDIR = $(PREFIX)/share/doc/opensysusers
TESTDIR = /run/sysusers.d
BINMODE = 0755
MODE = 0644
INSTALL = install
MAKE = make
HAVESYSTEMD = yes
HAVEOPENRC = no
HAVEMAN = yes
HAVEDOC = no
INITD = opensysusers.initd
BASIC = basic.conf
ifeq ($(HAVESYSTEMD),yes)
BINNAME = sysusers
else
BINNAME = opensysusers
endif
TESTFILES = $(wildcard test/*.conf)
all: sysusers
ifeq ($(HAVEOPENRC),yes)
all: $(INITD)
endif
ifeq ($(HAVEMAN),yes)
all:
+$(MAKE) HAVEDOC=$(HAVEDOC) INSTALL=$(INSTALL) DOCMODE=$(MODE) MANDIR=$(MANDIR) DOCDIR=$(DOCDIR) DESTDIR=$(DESTDIR) -C man
endif
EDIT = sed "s|@BINNAME[@]|$(BINNAME)|"
RM = rm -f
CHMOD = chmod $(BINMODE)
opensysusers: sysusers
$(INSTALL) $< $@
$(INITD): $(INITD).in
@echo "GEN $@"
@$(RM) "$@"
@$(EDIT) $< >"$@"
@$(CHMOD) "$@"
clean-openrc:
$(RM) $(INITD)
clean-man:
+$(MAKE) INSTALL=$(INSTALL) DOCMODE=$(MODE) MANDIR=$(MANDIR) DOCDIR=$(DOCDIR) DESTDIR=$(DESTDIR) -C man clean
clean: clean-bin
ifeq ($(HAVEOPENRC),yes)
clean: clean-openrc
endif
ifeq ($(HAVEMAN),yes)
clean: clean-man
endif
install-shared:
$(INSTALL) -Dm $(MODE) $(BASIC) $(DESTDIR)$(LIBDIR)/sysusers.d/$(BASIC)
install-default-bin: sysusers
$(INSTALL) -Dm $(BINMODE) sysusers $(DESTDIR)$(BINDIR)/$(BINNAME)
install-custom-bin: sysusers
$(INSTALL) -Dm $(BINMODE) sysusers $(DESTDIR)$(BINDIR)/$(BINNAME)
install-openrc: $(INITD)
$(INSTALL) -Dm $(BINMODE) $(INITD) $(DESTDIR)$(SYSCONFDIR)/init.d/opensysusers
install-man:
+$(MAKE) INSTALL=$(INSTALL) DOCMODE=$(MODE) MANDIR=$(MANDIR) DOCDIR=$(DOCDIR) DESTDIR=$(DESTDIR) -C man install
install-tests:
$(INSTALL) -Dm $(MODE) $(TESTFILES) $(DESTDIR)$(TESTDIR)/
uninstall-shared:
$(RM) $(DESTDIR)$(LIBDIR)/sysusers.d/$(BASIC)
uninstall-default-bin:
$(RM) $(DESTDIR)$(BINDIR)/$(BINNAME)
uninstall-custom-bin:
$(RM) $(DESTDIR)$(BINDIR)/$(BINNAME)
uninstall-openrc:
$(RM) $(DESTDIR)$(SYSCONFDIR)/init.d/opensysusers
uninstall-man:
+$(MAKE) INSTALL=$(INSTALL) DOCMODE=$(MODE) MANDIR=$(MANDIR) DOCDIR=$(DOCDIR) DESTDIR=$(DESTDIR) -C man uninstall
ifeq ($(HAVESYSTEMD),yes)
install: install-shared
uninstall: uninstall-shared
ifeq ($(HAVEMAN),yes)
install: install-man
uninstall: uninstall-man
endif
ifeq ($(BINNAME),sysusers)
install: install-default-bin
uninstall: uninstall-default-bin
else
install: install-custom-bin
uninstall: uninstall-custom-bin
endif
ifeq ($(HAVEOPENRC),yes)
install: install-openrc
uninstall: uninstall-openrc
endif
else
install: install-shared install-default-bin
uninstall: uninstall-shared uninstall-default-bin
ifeq ($(HAVEMAN),yes)
install: install-man
uninstall: uninstall-man
endif
ifeq ($(HAVEOPENRC),yes)
install: install-openrc
uninstall: uninstall-openrc
endif
endif
.PHONY: all install install-custom-bin install-default-bin install-man install-openrc install-shared install-tests uninstall uninstall-custom-bin uninstall-default-bin uninstall-man uninstall-openrc uninstall-shared clean clean-bin clean-man clean-openrc