# $Source: /hpux/shared/supp//usr/src/cmd/cron/./makefile,v $
# $Revision: 72.3 $

# Common makefile for cron, crontab, at, and batch

FINDMSG = /usr/bin/findmsg
GENCAT  = /usr/bin/gencat 

CMDS= cron at crontab batch
CMDS_M= cron.M at.M crontab.M
CATS= cron.cat at.cat crontab.cat 
CRONMSGS= cron.msg funcs.msg
CRONTABMSGS= crontab.msg permit.msg funcs.msg
ATMSGS= at.msg funcs.msg pdt.msg ptime.msg pdate.msg permit.msg
REL= hpux_rel.o
REL_C= hpux_rel.c


default: all

all:	$(CMDS) $(CATS)

metrics: $(CMDS_M)

libelm.a: elm.o
	ar cr libelm.a elm.o

cron:	cron.o funcs.o libelm.a $(REL)
	libs="libelm.a";					\
	if ifdef SecureWare || ifdef B1 || ifdef TRUSTED; then	\
	    libs="$$libs -lscmd -lsec -lcurses";		\
	fi;							\
	if ifdef COMSEC; then					\
	    libs="$$libs -lsec";				\
	fi;							\
	$(CC) $(CFLAGS) $(LDFLAGS) $(REL) cron.o funcs.o -o $@ $$libs

cron.M:	cron.c funcs.c $(REL_C)
	$(METRICS) $(REL_C) cron.c funcs.c -o cron.M

cron.cat: $(CRONMSGS)
	  $(GENCAT) $@ $(CRONMSGS)

crontab:	crontab.o permit.o funcs.o $(REL)
	libs="";						\
	if ifdef SecureWare || ifdef B1 || ifdef TRUSTED; then	\
	    libs="$$libs -lscmd -lsec -lcurses";		\
	fi;							\
	$(CC) $(CFLAGS) $(LDFLAGS) $(REL) crontab.o permit.o funcs.o -o $@ $$libs

crontab.M:	crontab.c permit.c funcs.c $(REL_C)
	$(METRICS) $(REL_C) crontab.c permit.c funcs.c -o crontab.M

crontab.cat: $(CRONTABMSGS) 
	$(GENCAT) $@ $(CRONTABMSGS)


at:	at.o pdt.o ptime.o pdate.o funcs.o permit.o $(REL)
	libs="";						\
	if ifdef SecureWare || ifdef B1 || ifdef TRUSTED; then	\
	    libs="$$libs -lscmd -lsec -lcurses";		\
	fi;							\
	$(CC) $(CFLAGS) $(LDFLAGS) $(REL) \
	    at.o pdt.o ptime.o pdate.o funcs.o permit.o -o $@ $$libs

at.M:	at.c pdt.c ptime.c pdate.c funcs.c permit.c $(REL_C)
	$(METRICS) $(REL_C) \
	    at.c pdt.c ptime.c pdate.c funcs.c permit.c -o at.M

at.cat: $(ATMSGS)
	$(GENCAT) $@ $(ATMSGS)

batch:	batch.sh
	cp batch.sh $@

cron.o:	cron.c cron.h
crontab.o:	crontab.c cron.h
at.o:	at.c cron.h

clean:
	/bin/rm -f *.o *.msg libelm.a

clobber:	clean
	/bin/rm -f $(CMDS) $(CATS) $(CMDS_M)

# 
# We define some rules for creating .msg and .cat files so make will do
# our work for us.  With these rules, all we have to do is indicate the
# .cat file depends on the .msg file; make will then know it needs to create
# the .msg from the .c if it doesn't already exist.
#
.c.msg:
	$(FINDMSG) $*.c > $*.msg

.msg.cat:
	$(GENCAT) $*.cat $*.msg

.SUFFIXES: .cat .msg
