forked from systemd-cron/systemd-cron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
215 lines (173 loc) · 7.29 KB
/
Makefile.in
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
CFLAGS ?= -O2
CFLAGS += -Wall
version := $(shell cat VERSION)
schedules := @schedules@
schedules_not := @schedules_not@
enable_runparts := @enable_runparts@
enable_persistent := @enable_persistent@
enable_randomized_delay := @enable_randomized_delay@
enable_setgid := @enable_setgid@
use_loglevelmax := @use_loglevelmax@
prefix := @prefix@
bindir := @bindir@
confdir := @confdir@
datadir := @datadir@
libdir := @libdir@
statedir := @statedir@
mandir := @mandir@
docdir := @docdir@
unitdir := @unitdir@
generatordir := @generatordir@
runparts := @runparts@
srcdir := $(CURDIR)/src
outdir := $(CURDIR)/out
builddir := $(outdir)/build
distname := systemd-cron-$(version)
distdir := $(outdir)/dist/$(distname)
tarball := $(outdir)/dist/$(distname).tar.xz
out_services := $(foreach schedule,$(schedules),$(builddir)/units/cron-$(schedule).service)
out_timers := $(foreach schedule,$(schedules),$(builddir)/units/cron-$(schedule).timer)
out_targets := $(foreach schedule,$(schedules),$(builddir)/units/cron-$(schedule).target)
out_units := $(out_services) $(out_timers) $(out_targets) $(builddir)/units/cron.target \
$(builddir)/units/cron-update.path $(builddir)/units/cron-update.service \
$(builddir)/units/[email protected]
out_manuals := $(patsubst $(srcdir)/man/%.in,$(builddir)/man/%,$(wildcard $(srcdir)/man/*))
out_programs := $(patsubst $(srcdir)/bin/%.py,$(builddir)/bin/%,$(wildcard $(srcdir)/bin/*.py))
outputs := $(out_units) $(out_manuals) $(out_programs) $(builddir)/bin/crontab_setgid
define \n
endef
null :=
ifneq ($(enable_runparts),no)
requires = $(subst ${null} ${null},\n,$(foreach schedule,$(schedules),Requires=cron-$(schedule).timer))
else
requires = Requires=systemd-cron-cleaner.timer
endif
use_runparts = $(if $(filter $(enable_runparts),yes),True,False)
persistent = $(if $(filter $(enable_persistent),yes),True,False)
randomized_delay = $(if $(filter $(enable_randomized_delay),yes),True,False)
# $(call in2out,$input,$output,$schedule,$requires)
define in2out
sed \
-e "s|\@confdir\@|$(confdir)|g" \
-e "s|\@statedir\@|$(statedir)|g" \
-e "s|\@bindir\@|$(bindir)|g" \
-e "s|\@libdir\@|$(libdir)|g" \
-e "s|\@unitdir\@|$(unitdir)|g" \
-e "s|\@generatordir\@|$(generatordir)|g" \
-e "s|\@runparts\@|$(runparts)|g" \
-e "s|\@use_runparts\@|$(use_runparts)|g" \
-e "s|\@version\@|$(version)|g" \
-e "s|\@persistent\@|$(persistent)|g" \
-e "s|\@randomized_delay\@|$(randomized_delay)|g" \
-e "s|\@use_loglevelmax\@|$(use_loglevelmax)|g" \
-e "s|\@schedule\@|$3|g" \
-e "s|\@requires\@|$4|g" \
$1 > $2
endef
all: $(builddir) $(outputs)
clean:
rm -rf $(outdir)
distprep: $(distdir)
cp -a configure $(distdir)
cp -a Makefile.in $(distdir)
cp -a LICENSE $(distdir)
cp -a README.md $(distdir)
cp -a VERSION $(distdir)
cp -a src $(distdir)
dist: $(tarball)
test: all
$(foreach manpage,$(out_manuals),\
man --warnings --encoding=utf8 --local-file $(manpage) 2>&1 > /dev/null${\n})
$(foreach program,$(out_programs),\
pyflakes3 $(program) ${\n})
install: all
install -m755 -D $(builddir)/bin/crontab $(DESTDIR)$(bindir)/crontab
install -m755 -D $(builddir)/bin/systemd-crontab-generator $(DESTDIR)$(generatordir)/systemd-crontab-generator
install -m755 -D $(builddir)/bin/remove_stale_stamps $(DESTDIR)$(libdir)/systemd-cron/remove_stale_stamps
install -m755 -D $(builddir)/bin/mail_on_failure $(DESTDIR)$(libdir)/systemd-cron/mail_on_failure
install -m755 -D $(builddir)/bin/boot_delay $(DESTDIR)$(libdir)/systemd-cron/boot_delay
install -m644 -D $(srcdir)/lib/sysusers.d/systemd-cron.conf $(DESTDIR)$(libdir)/sysusers.d/systemd-cron.conf
ifneq ($(enable_setgid),no)
install -m755 -D $(builddir)/bin/crontab_setgid $(DESTDIR)$(libdir)/systemd-cron/crontab_setgid
if getent group cron > /dev/null 2>&1; then \
chgrp cron $(DESTDIR)$(libdir)/systemd-cron/crontab_setgid ; \
chmod 2755 $(DESTDIR)$(libdir)/systemd-cron/crontab_setgid ; \
fi
endif
install -m644 -D $(builddir)/man/systemd.cron.7 $(DESTDIR)$(mandir)/man7/systemd.cron.7
install -m644 -D $(builddir)/man/crontab.1 $(DESTDIR)$(mandir)/man1/crontab.1
install -m644 -D $(builddir)/man/crontab.5 $(DESTDIR)$(mandir)/man5/crontab.5
install -m644 -D $(builddir)/man/anacrontab.5 $(DESTDIR)$(mandir)/man5/anacrontab.5
install -m644 -D $(builddir)/man/systemd-crontab-generator.8 $(DESTDIR)$(mandir)/man8/systemd-crontab-generator.8
install -m644 -D $(builddir)/units/cron.target $(DESTDIR)$(unitdir)/cron.target
install -m644 $(builddir)/units/cron-update.path $(DESTDIR)$(unitdir)
install -m644 $(builddir)/units/cron-update.service $(DESTDIR)$(unitdir)
install -m644 $(builddir)/units/[email protected] $(DESTDIR)$(unitdir)
ifneq ($(enable_runparts),no)
$(foreach schedule,$(schedules),\
install -m644 $(builddir)/units/cron-$(schedule).timer $(DESTDIR)$(unitdir)${\n})
$(foreach schedule,$(schedules),\
install -m644 $(builddir)/units/cron-$(schedule).target $(DESTDIR)$(unitdir)${\n})
$(foreach schedule,$(schedules),\
install -m644 $(builddir)/units/cron-$(schedule).service $(DESTDIR)$(unitdir)${\n})
endif
$(builddir)/units/cron-update.path: $(srcdir)/units/cron-update.path.in
$(call in2out,$<,$@)
$(builddir)/units/cron-update.service: $(srcdir)/units/cron-update.service.in
$(call in2out,$<,$@)
$(builddir)/units/[email protected]: $(srcdir)/units/[email protected]
$(call in2out,$<,$@)
$(builddir)/units/cron-%.service: $(srcdir)/units/cron-schedule.service.in
$(call in2out,$<,$@,$*)
ifeq ($(use_loglevelmax),no)
sed -i -e '/^LogLevelMax=/d' $@
endif
$(builddir)/units/cron-boot.service: $(srcdir)/units/cron-boot.service.in
$(call in2out,$<,$@,boot)
$(builddir)/units/cron-%.timer: $(srcdir)/units/cron-schedule.timer.in
$(call in2out,$<,$@,$*)
ifneq ($(enable_persistent),yes)
sed -i -e '/^Persistent=/d' $@
endif
$(builddir)/units/cron-boot.timer: $(srcdir)/units/cron-boot.timer.in
$(call in2out,$<,$@,boot)
$(builddir)/units/cron-%.target: $(srcdir)/units/cron-schedule.target.in
$(call in2out,$<,$@,$*)
$(builddir)/units/cron.target: $(srcdir)/units/cron.target.in
$(call in2out,$<,$@,,$(requires))
$(builddir)/man/%: $(srcdir)/man/%.in
$(call in2out,$<,$@)
$(builddir)/man/systemd.cron.7: $(srcdir)/man/systemd.cron.7.in
$(call in2out,$<,$@)
$(foreach schedule_not,$(schedules_not),\
sed -i $@ -e '/cron-$(schedule_not).timer/d' \
-e '/cron\.$(schedule_not)/,+3d' \
-e '/journalctl -u cron-$(schedule_not)/,+1d' ${\n})
$(builddir)/bin/systemd-crontab-generator: $(srcdir)/bin/systemd-crontab-generator.py
$(call in2out,$<,$@)
ifneq ($(enable_runparts),no)
# BUG: this should only run if schedule_not in hourly/daily/weekly/monthly
$(foreach schedule_not,$(schedules_not),\
sed -i $@ -e '/\/etc\/cron.$(schedule_not)/d' ${\n})
endif
chmod +x $@
$(builddir)/bin/%: $(srcdir)/bin/%.py
$(call in2out,$<,$@)
chmod +x $@
$(builddir)/bin/crontab_setgid: $(srcdir)/bin/crontab_setgid.c
ifneq ($(enable_setgid),no)
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -DCRONTAB_DIR='"$(statedir)"' -o $@
endif
$(outputs): | $(builddir)
$(outdir):
mkdir -p $@
$(builddir):
mkdir -p $@
mkdir -p $@/bin
mkdir -p $@/man
mkdir -p $@/units
$(distdir):
mkdir -p $(distdir)
$(tarball): distprep
cd $(distdir)/..; tar -cJ --owner=root --group=root --file $(tarball) $(distname)
.PHONY: all clean dist distprep install