forked from dubiousjim/dcron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (74 loc) · 2.67 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
# Makefile for Dillon's crond and crontab
VERSION = 4.5
# these variables can be configured by e.g. `make SCRONTABS=/different/path`
PREFIX = /usr/local
CRONTAB_GROUP = wheel
SCRONTABS = /etc/cron.d
CRONTABS = /var/spool/cron/crontabs
CRONSTAMPS = /var/spool/cron/cronstamps
# used for syslog
LOG_IDENT = crond
# used for logging to file (syslog manages its own timestamps)
# if LC_TIME is set, it will override any compiled-in timestamp format
TIMESTAMP_FMT = %b %e %H:%M:%S
SBINDIR = $(PREFIX)/sbin
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man
-include config
SHELL = /bin/sh
INSTALL = install -o root
INSTALL_PROGRAM = $(INSTALL) -D
INSTALL_DATA = $(INSTALL) -D -m0644 -g root
INSTALL_DIR = $(INSTALL) -d -m0755 -g root
CFLAGS ?= -O2
CFLAGS += -Wall -Wstrict-prototypes -Wno-missing-field-initializers
SRCS = main.c subs.c database.c job.c concat.c chuser.c
OBJS = main.o subs.o database.o job.o concat.o chuser.o
TABSRCS = crontab.c chuser.c
TABOBJS = crontab.o chuser.o
PROTOS = protos.h
LIBS =
LDFLAGS =
DEFS = -DVERSION='"$(VERSION)"' \
-DSCRONTABS='"$(SCRONTABS)"' -DCRONTABS='"$(CRONTABS)"' \
-DCRONSTAMPS='"$(CRONSTAMPS)"' -DLOG_IDENT='"$(LOG_IDENT)"' \
-DTIMESTAMP_FMT='"$(TIMESTAMP_FMT)"'
# save variables needed for `make install` in config
all: $(PROTOS) crond crontab ;
rm -f config
echo "PREFIX = $(PREFIX)" >> config
echo "SBINDIR = $(SBINDIR)" >> config
echo "BINDIR = $(BINDIR)" >> config
echo "MANDIR = $(MANDIR)" >> config
echo "CRONTAB_GROUP = $(CRONTAB_GROUP)" >> config
echo "SCRONTABS = $(SCRONTABS)" >> config
echo "CRONTABS = $(CRONTABS)" >> config
echo "CRONSTAMPS = $(CRONSTAMPS)" >> config
protos.h: $(SRCS) $(TABSRCS)
fgrep -h Prototype $(SRCS) $(TABSRCS) > protos.h
crond: $(OBJS)
$(CC) $(LDFLAGS) $^ $(LIBS) -o crond
crontab: $(TABOBJS)
$(CC) $(LDFLAGS) $^ -o crontab
%.o: %.c defs.h $(PROTOS)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(DEFS) $< -o $@
install:
$(INSTALL_PROGRAM) -m0700 -g root crond $(DESTDIR)$(SBINDIR)/crond
$(INSTALL_PROGRAM) -m4750 -g $(CRONTAB_GROUP) crontab $(DESTDIR)$(BINDIR)/crontab
$(INSTALL_DATA) crontab.1 $(DESTDIR)$(MANDIR)/man1/crontab.1
$(INSTALL_DATA) crond.8 $(DESTDIR)$(MANDIR)/man8/crond.8
$(INSTALL_DIR) $(DESTDIR)$(SCRONTABS)
$(INSTALL_DIR) $(DESTDIR)$(CRONTABS)
$(INSTALL_DIR) $(DESTDIR)$(CRONSTAMPS)
clean: force
rm -f *.o $(PROTOS)
rm -f crond crontab config
force: ;
man: force
-pandoc -t man -f markdown -s crontab.markdown -o crontab.1
-pandoc -t man -f markdown -s crond.markdown -o crond.8
# for maintainer's use only
TARNAME = /home/abs/_dcron/dcron-$(VERSION).tar.gz
dist: clean man
bsdtar -cz --exclude repo/.git -f $(TARNAME).new -s'=^repo=dcron-$(VERSION)=' -C .. repo
mv -f $(TARNAME).new $(TARNAME)