systemd-cron-next/Makefile.in
2015-12-10 21:40:31 +03:00

136 lines
5.0 KiB
Makefile

package := $(shell head -n1 README.md)
version := $(shell awk '/^version =/ { gsub("\"", "", $$3); print $$3; exit }' Cargo.toml)
schedules := @schedules@
enable_persistent := @enable_persistent@
prefix := @prefix@
bindir := @bindir@
confdir := @confdir@
datadir := @datadir@
libdir := @libdir@
statedir := @statedir@
mandir := @mandir@
docdir := @docdir@
unitdir := @unitdir@
runparts := @runparts@
srcdir := $(CURDIR)/src
outdir := $(CURDIR)/out
builddir := $(outdir)/build
distname := $(package)-$(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/cron-failure@.service
out_manuals := $(patsubst $(CURDIR)/man/%.in,$(builddir)/man/%,$(wildcard $(CURDIR)/man/*))
out_programs := $(patsubst $(srcdir)/bin/%.rs,$(builddir)/bin/%,$(wildcard $(srcdir)/bin/*.rs))
outputs := $(out_units) $(out_manuals) $(out_programs)
define \n
endef
null :=
persistent = $(if $(filter $(enable_persistent),yes),persistent,)
all: $(builddir) $(outputs)
clean:
rm -rf $(outdir)
distprep: $(distdir) VERSION
cp -a Cargo.toml Cargo.lock configure Makefile.in LICENSE README.md VERSION src man units $(distdir)
VERSION: Cargo.toml
grep "^version =" Cargo.toml | sed -e 's/^version = "//' -e 's/"$$//' > VERSION
dist: $(tarball)
test: all
$(foreach manpage,$(out_manuals),\
man --warnings --encoding=utf8 --local-file $(manpage) 2>&1 > /dev/null${\n})
cargo test
build: all
RUN_PARTS="$(runparts)" STATE_DIR="$(statedir)" cargo install --path $(CURDIR) --root $(builddir) \
--features "$(schedules) $(persistent)"
install: build
install -m2755 -g `getent group cron || echo root` -s -D $(builddir)/bin/crontab $(DESTDIR)$(bindir)/crontab
install -m755 -s -D $(builddir)/bin/systemd-crontab-generator $(DESTDIR)$(libdir)/systemd/system-generators/systemd-crontab-generator
install -m755 -s -D $(builddir)/bin/remove-stale-stamps $(DESTDIR)$(libdir)/$(package)/remove-stale-stamps
install -m755 -s -D $(builddir)/bin/mail-on-failure $(DESTDIR)$(libdir)/$(package)/mail-on-failure
install -m755 -s -D $(builddir)/bin/boot-delay $(DESTDIR)$(libdir)/$(package)/boot-delay
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/cron-failure@.service $(DESTDIR)$(unitdir)
$(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})
uninstall:
rm -f $(DESTDIR)$(bindir)/crontab
rm -f $(DESTDIR)$(libdir)/systemd/system-generators/systemd-crontab-generator
rm -f $(DESTDIR)$(libdir)/$(package)/remove-stale-stamps
rm -f $(DESTDIR)$(libdir)/$(package)/mail-on-failure
rm -f $(DESTDIR)$(libdir)/$(package)/boot-delay
rm -f $(DESTDIR)$(mandir)/man7/systemd.cron.7
rm -f $(DESTDIR)$(mandir)/man1/crontab.1
rm -f $(DESTDIR)$(mandir)/man5/crontab.5
rm -f $(DESTDIR)$(mandir)/man5/anacrontab.5
rm -f $(DESTDIR)$(mandir)/man8/systemd-crontab-generator.8
rm -f $(DESTDIR)$(unitdir)/cron.target
rm -f $(DESTDIR)$(unitdir)/cron-update.path
rm -f $(DESTDIR)$(unitdir)/cron-update.service
rm -f $(DESTDIR)$(unitdir)/cron-failure@.service
$(foreach schedule,$(schedules),\
rm -f $(DESTDIR)$(unitdir)/cron-$(schedule).timer${\n})
$(foreach schedule,$(schedules),\
rm -f $(DESTDIR)$(unitdir)/cron-$(schedule).target${\n})
$(foreach schedule,$(schedules),\
rm -f $(DESTDIR)$(unitdir)/cron-$(schedule).service${\n})
$(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 build dist distprep install uninstall