# Makefile for dillon's cron and crontab
#

CC  = gcc
CFLAGS = -O2 -Wall -Wstrict-prototypes
LIB = 
SRCS = main.c subs.c database.c job.c
OBJS = main.o subs.o database.o job.o
D_SRCS = crontab.c subs.c
D_OBJS = crontab.o subs.o
PROTOS= protos.h

all:	${PROTOS} crond crontab

crond:	${OBJS}
	${CC} ${CFLAGS} -o crond ${OBJS} ${LIB}
	strip crond

crontab:  ${D_OBJS}
	${CC} ${CFLAGS} -o crontab ${D_OBJS}
	strip crontab

protos.h: ${SRCS} ${D_SRCS}
	fgrep -h Prototype ${SRCS} ${D_SRCS} >protos.h

clean:  cleano
	rm -f crond crontab

cleano:
	rm -f *.o dcron.tgz $(PROTOS)

install:
	rm -f /usr/bin/crond /usr/bin/crontab
	cp -a crond crontab /usr/bin
	chown root.wheel /usr/bin/crond
	chown root.cron /usr/bin/crontab
	chmod 700 /usr/bin/crond
	chmod 4750 /usr/bin/crontab
	-mkdirs /usr/man/man1
	-mkdirs /usr/man/man8
	cp crontab.1 /usr/man/man1
	cp crond.8 /usr/man/man8
	chmod 444 /usr/man/man1/crontab.1
	chmod 444 /usr/man/man8/crond.8

tar: cleano
	(cd ..; tar cvf - dcron | gzip -9 >dcron.tgz.tmp)
	mv -f ../dcron.tgz.tmp dcron.tgz

