#  Makefile for the ELM mail program.
#
# $Source: /nfs/hpindgr/dcia1/KCS.cm/rcs/inet_davis_800/elm/src/RCS/makefile,v $
# @(#) $Revision: 1.19.212.1 $
#
# (c) Copyright Hewlett-Packard Company, 1986, 1987, 1988, 1989
# (c) Copyright Yokogawa-Hewlett-Packard Ltd., 1988, 1989
#
#  Acknowledgment is made to Dave Taylor for his creation of
#  the original version of this software.


##############################

HEADERS=			\
	../hdrs/defs.h		\
	../hdrs/headers.h	\
	../hdrs/sysdefs.h

OBJS1 =			\
	addr_utils.o	\
	alias.o		\
	aliasdb.o	\
	aliaslib.o	\
	args.o		\
	bounceback.o	\
	builtin.o	\
	calendar.o	\
	checkname.o	\
	connect_to.o	\
	date.o		\
	delete.o	\
	del_alias.o	\
	domains.o	\
	edit.o		\
	editmsg.o	\
	errno.o		\
	expires.o	\
	file.o		\
	file_utils.o	\
	fileio.o	\
	forms.o		\
	getopt.o	\
	hdrconfg.o	\
	hdrconfg_b.o	\
	help.o		\
	initialize.o	\
	in_utils.o	\
	leavembox.o	\
	limit.o		\
	mailmsg1.o	\
	mailmsg2.o	\
	mailtime.o	\
	mkhdrs.o	\
	newmbox.o	\
	opt_utils.o	\
	options.o	\
	out_utils.o	\
	pattern.o	\
	pmalloc.o	\
	quit.o		\
	read_rc.o	\
	remail.o	\
	reply.o		\
	returnaddr.o	\
	save_opts.o	\
	savecopy.o	\
	screen.o	\
	showmsg.o	\
	showmsgcmd.o	\
	signals.o	\
	softkeys.o	\
	sort.o		\
	string2.o	\
	strings.o	\
	syscall.o	\
	utils.o		\
	validname.o

OBJS2 = 		\
	curses.o	\
	elm.o		

SRCS1 =			\
	addr_utils.c	\
	alias.c		\
	aliasdb.c	\
	aliaslib.c	\
	args.c		\
	bounceback.c	\
	builtin.c	\
	calendar.c	\
	checkname.c	\
	connect_to.c	\
	date.c		\
	delete.c	\
	del_alias.c	\
	domains.c	\
	edit.c		\
	editmsg.c	\
	errno.c		\
	expires.c	\
	file.c		\
	file_utils.c	\
	fileio.c	\
	forms.c		\
	getopt.c	\
	hdrconfg.c	\
	hdrconfg_b.c	\
	help.c		\
	initialize.c	\
	in_utils.c	\
	leavembox.c	\
	limit.c		\
	mailmsg1.c	\
	mailmsg2.c	\
	mailtime.c	\
	mkhdrs.c	\
	newmbox.c	\
	opt_utils.c	\
	options.c	\
	out_utils.c	\
	pattern.c	\
	pmalloc.c	\
	quit.c		\
	read_rc.c	\
	remail.c	\
	reply.c		\
	returnaddr.c	\
	save_opts.c	\
	savecopy.c	\
	screen.c	\
	showmsg.c	\
	showmsgcmd.c	\
	signals.c	\
	softkeys.c	\
	sort.c		\
	string2.c	\
	strings.c	\
	syscall.c	\
	utils.c		\
	validname.c

SRCS2 = 		\
	curses.c	\
	elm.c

##############################

SHELL	= /usr/bin/sh
RM	= /usr/bin/rm -f
TOUCH	= /usr/bin/touch
SED	= /usr/bin/sed
FINDMSG = /usr/bin/findmsg
GENCAT	= /usr/bin/gencat

CFLAGS	= ${NEWCCFLAGS}
LDFLAGS = -s ${NEWLDFLAGS}
BIN	= ../bin
DEFINE	= -DNLS -DNO_VM
FLAGS	= -O -I../hdrs
LIBS	= -lHcurses

# If you're on an ACSnet system in Australia (or elsewhere) then you'll 
# want to uncomment the following line additional;
#
#   DEFINE= ${DEFINE} -DACSNET

default: all
all: ${BIN}/elm elm.cat
metrics: ${BIN}/elm.M
elm: ${BIN}/elm

${BIN}/elm: ${OBJS1} encode.o ${OBJS2} version.o ../hpux_rel.o 
	${CC} ${LDFLAGS} -o ${BIN}/elm -n ${OBJS1} encode.o	\
		${OBJS2} ${LIBS} version.o ../hpux_rel.o

${BIN}/elm.M: ${SRCS1} encode.c ${SRCS2} version.c ../hpux_rel.c
	${METRICS} ${CFLAGS} ${FLAGS} -o ${BIN}/elm.M -n ${SRCS1} encode.c \
		${SRCS2} ${LIBS} version.c ../hpux_rel.c
#
# Due to the large number of source files that need to be cataloged,
# this seems a more practical way of making the message catalog than
# explicitly listing all the .cat or .msg files in a macro.
# If source for a command does not exist, we can assume that the
# makefile will complain when it tries to compile it, so we don't
# worry about trying to find all the source files at this point.
#
# This trick was lifted from the uucp makefile  12/5/91
#

elm.cat: ./*.c
	for i in ./*.c;               \
	do                  \
		$(FINDMSG) $$i > ./elm.msg;  \
		$(GENCAT) $@ ./elm.msg;      \
	done 

${OBJS1}: ${HEADERS} ../hdrs/elm.h
	${CC} -c ${CCOPTS} ${CFLAGS} ${FLAGS} -DELM ${DEFINE} $*.c 

curses.o: ${HEADERS} curses.c ../hdrs/curses.h
	${CC} -c ${CFLAGS} ${FLAGS} -DELM -DRAWMODE ${DEFINE} curses.c

elm.o: ../hdrs/elm.h ../hdrs/defs.h ../hdrs/sysdefs.h	\
		../hdrs/curses.h elm.c
	${CC} -c ${CFLAGS} ${FLAGS} -DELM ${DEFINE} elm.c

../hpux_rel.o: ../hpux_rel.c
	cd ..;						\
	${CC} -c ${CFLAGS} ${FLAGS} -DELM ${DEFINE} hpux_rel.c

version.c: version.mstr ../hdrs/version_id.h ${HEADERS}
	${SED} -e "s/COMPILE_TIME/`date`/" version.mstr > version.c; \
	${RM} version.tmp

version.o: version.c ${OBJS1} ${OBJS2}
	${CC} -c ${CFLAGS} ${FLAGS} -DELM ${DEFINE} version.c
#
# CRYPT-specific source has a limited access list.  If encode.c is not
# available, touch the file so that the (non-CRYPT) make can still work.
#
encode.c:
	if test ! -f encode.c; then	${TOUCH} encode.c; fi

encode.o:
	${CC} -c ${CFLAGS} ${FLAGS} -DELM ${DEFINE} encode.c 

clean:
	${RM} ${OBJS1} ${OBJS2} version.c version.o encode.o \
	      ../hpux_rel.o elm.msg

clobber: clean
	${RM} ${BIN}/elm elm.cat
