# $Source: /hpux/shared/supp//usr/src/cmd/hdb.ct/./makefile,v $
# $Revision: 78.1 $

# Common makefile for ct

FINDMSG = findmsg
GENCAT = gencat

# This assumes that the uucp directory is also in shared source (i.e. on
# the same level in the source tree
UUDIR = ../hdb.uucp

FLAGS = -DSTANDALONE

CTOBJS =  ct.o callers.o getargs.o line.o uucpdefs.o ulockf.o\
	 conn.o hpux_rel.o

CTSRCS =  ct.c $(UUDIR)/callers.c $(UUDIR)/getargs.c \
	$(UUDIR)/line.c $(UUDIR)/uucpdefs.c $(UUDIR)/ulockf.c\
	conn.c hpux_rel.c

CTMSGS = ct.msg $(UUDIR)/callers.msg $(UUDIR)/getargs.msg \
	$(UUDIR)/line.msg $(UUDIR)/uucpdefs.msg $(UUDIR)/ulockf.msg \
	 $(UUDIR)/conn.msg

default: ct ct.cat

metrics: ct.M

ct:  $(CTOBJS)
	$(CC) $(CFLAGS) $(FLAGS) $(LDFLAGS) $(CTOBJS) -o ct

ct.M:  $(CTSRCS)
	$(METRICS) $(CFLAGS) $(FLAGS) $(CTSRCS) -o ct.M

clean:
	rm -f *.o *.msg

clobber: clean
	rm -f ct ct.cat

callers.o:	$(UUDIR)/callers.c   $(UUDIR)/uucp.h $(UUDIR)/parms.h
	$(CC) -c $(CFLAGS) $(FLAGS) $(UUDIR)/callers.c

getargs.o:	$(UUDIR)/getargs.c   $(UUDIR)/uucp.h $(UUDIR)/parms.h
	$(CC) -c $(CFLAGS) $(FLAGS) $(UUDIR)/getargs.c
 
line.o:		$(UUDIR)/line.c   $(UUDIR)/uucp.h $(UUDIR)/parms.h
	$(CC) -c $(CFLAGS) $(FLAGS) $(UUDIR)/line.c

uucpdefs.o:	$(UUDIR)/uucpdefs.c  $(UUDIR)/uucp.h $(UUDIR)/parms.h
	$(CC) -c $(CFLAGS) $(FLAGS) $(UUDIR)/uucpdefs.c

ulockf.o:	$(UUDIR)/ulockf.c  $(UUDIR)/uucp.h $(UUDIR)/parms.h
	$(CC) -c $(CFLAGS) $(FLAGS) $(UUDIR)/ulockf.c

conn.o:		conn.c
	$(CC) -c $(CFLAGS) $(FLAGS) conn.c

ct.cat: $(CTMSGS)
	$(GENCAT) $@ $(CTMSGS)

#
# We define two new rules for creating .msg and .cat files so that we can
# let make's internal rules do the work for us.  With these rules, we only
# need to specify that the .cat depends on the .msg; make will know it needs
# to create the .msg from the .c automatically.
#
.c.msg:
	$(FINDMSG) $*.c > $*.msg

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

.SUFFIXES: .cat .msg

#
# We re-define the .c.o rule so that implicit compiles to .o files will
# use the FLAGS macro defined above.
#
.c.o:
	$(CC) $(CFLAGS) $(FLAGS) -c $<
