2015-08-05 15:10:46 +03:00
package := $( shell head -n1 README.md)
2015-12-11 01:46:26 +03:00
packagedir := systemd-cron
2015-08-05 13:54:01 +03:00
version := $( shell awk '/^version =/ { gsub("\"", "", $$3); print $$3; exit }' Cargo.toml)
2015-07-28 20:52:43 +03:00
schedules := @schedules@
enable_persistent := @enable_persistent@
2016-04-17 20:46:38 +03:00
enable_randomized_delay := @enable_randomized_delay@
2017-03-19 13:17:57 +00:00
enable_strip := @enable_strip@
2015-07-28 20:52:43 +03:00
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
2015-12-10 21:16:12 +03:00
out_manuals := $( patsubst $( CURDIR) /man/%.in,$( builddir) /man/%,$( wildcard $( CURDIR) /man/*) )
2015-07-28 23:28:36 +00:00
out_programs := $( patsubst $( srcdir) /bin/%.rs,$( builddir) /bin/%,$( wildcard $( srcdir) /bin/*.rs) )
2015-07-28 20:54:32 +03:00
outputs := $( out_units) $( out_manuals) $( out_programs)
2015-07-28 20:52:43 +03:00
d e f i n e \ n
e n d e f
null :=
2015-12-10 21:16:12 +03:00
persistent = $( if $( filter $( enable_persistent) ,yes) ,persistent,)
2016-04-17 20:46:38 +03:00
randomized_delay = $( if $( filter $( enable_randomized_delay) ,yes) ,randomized-delay,)
2017-03-19 13:17:57 +00:00
strip = $( if $( filter $( enable_strip) ,yes) ,-s,)
2015-07-28 20:52:43 +03:00
2015-12-18 14:46:51 +03:00
all : build
2015-07-28 20:52:43 +03:00
clean :
2015-12-10 21:16:12 +03:00
rm -rf $( outdir)
2015-07-28 20:52:43 +03:00
2015-12-10 21:40:31 +03:00
distprep : $( distdir ) VERSION
2015-12-10 21:34:58 +03:00
cp -a Cargo.toml Cargo.lock configure Makefile.in LICENSE README.md VERSION src man units $( distdir)
2015-07-28 20:52:43 +03:00
2015-12-10 21:40:31 +03:00
VERSION : Cargo .toml
grep "^version =" Cargo.toml | sed -e 's/^version = "//' -e 's/"$$//' > VERSION
2015-07-28 20:52:43 +03:00
dist : $( tarball )
test : all
$( foreach manpage,$( out_manuals) ,\
man --warnings --encoding= utf8 --local-file $( manpage) 2>& 1 > /dev/null${ \n } )
2015-07-28 23:28:36 +00:00
cargo test
build : all
2015-12-11 01:04:09 +03:00
test -f $( builddir) /bin/systemd-crontab-generator || \
2015-12-11 01:25:11 +03:00
PREFIX = " $( prefix) " RUN_PARTS = " $( runparts) " STATE_DIR = " $( statedir) " \
BIN_DIR = " $( bindir) " CONF_DIR = " $( confdir) " MAN_DIR = " $( mandir) " DOC_DIR = " $( docdir) " \
DATA_DIR = " $( datadir) " LIB_DIR = " $( libdir) " UNIT_DIR = " $( unitdir) " \
2024-11-12 18:48:46 +03:00
cargo install --offline --no-track --path $( CURDIR) --root $( builddir) \
2016-04-17 20:46:38 +03:00
--features " $( foreach schedule,$( schedules) ,sched-$( schedule) ) $( persistent) $( randomized_delay) "
2015-07-28 23:28:36 +00:00
install : build
2017-03-19 13:17:57 +00:00
install -m2755 -g ` getent group cron || echo root` $( strip) -D $( builddir) /bin/crontab $( DESTDIR) $( bindir) /crontab
install -m755 $( strip) -D $( builddir) /bin/systemd-crontab-generator $( DESTDIR) $( libdir) /systemd/system-generators/systemd-crontab-generator
install -m755 $( strip) -D $( builddir) /bin/remove-stale-stamps $( DESTDIR) $( libdir) /$( packagedir) /remove-stale-stamps
install -m755 $( strip) -D $( builddir) /bin/mail-on-failure $( DESTDIR) $( libdir) /$( packagedir) /mail-on-failure
install -m755 $( strip) -D $( builddir) /bin/boot-delay $( DESTDIR) $( libdir) /$( packagedir) /boot-delay
2015-07-28 20:52:43 +03:00
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
2015-12-11 01:46:26 +03:00
rm -f $( DESTDIR) $( libdir) /$( packagedir) /remove-stale-stamps
rm -f $( DESTDIR) $( libdir) /$( packagedir) /mail-on-failure
rm -f $( DESTDIR) $( libdir) /$( packagedir) /boot-delay
2015-07-28 20:52:43 +03:00
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)
2015-07-28 23:28:36 +00:00
.PHONY : all clean build dist distprep install uninstall
2015-07-28 20:52:43 +03:00