##############################
#   Makefile for QuickPage   #
##############################

#
# The following options are recognized:
#
#	DAEMONUSER		- the daemon's run-time UID
#	DAEMONGROUP		- the daemon's run-time GID
#	FACILITY		- the syslog facility to use
#	LOCKDIR			- the directory to create lockfiles in
#	SOLARIS			- define if you are using Solaris 2.x
#	SNPP_SERVER		- the default SNPP server
#	SNPP_SERVER_FILE	- a file containing the default SNPP server
#	SYSTEM_CONFIG		- the location of the configuration file
#	NEED_STRERROR		- your system does NOT support strerror()
#

CCENV=		-DSOLARIS -DFACILITY=LOG_LOCAL1 # -DSNPP_SERVER=\"short\"
#DEBUG=		-g -DDEBUG

CFLAGS=		-mr $(DEBUG) $(CCENV)
LDLIBS=		-lsocket -lnsl

#CC=cc
#CC=gcc
RM=		/bin/rm -f


#####################################################################
# ----- you shouldn't need to change anything below this line ----- #
#####################################################################

VERSION=	3.2
PROG=		qpage
NAME=		$(PROG)-$(VERSION)
INCL=		$(PROG).h

SRCS=		$(PROG).c usersnpp.c srvrsnpp.c queue.c \
		config.c util.c ixo.c ident.c readmail.c \
		sendmail.c

OBJS=		$(PROG).o usersnpp.o srvrsnpp.o queue.o \
		config.o util.o ixo.o ident.o readmail.o \
		sendmail.o

CLNTSRCS=	$(PROG).c usersnpp.c util.c readmail.c
CLNTOBJS=	$(PROG).o usersnpp.o util.o readmail.o

.c.o:
		$(CC) $(CFLAGS) $(CPPFLAGS) -c $<

all:		$(PROG)

$(OBJS):	$(INCL)

$(PROG):	$(OBJS)
		$(RM) $(PROG)
		$(CC) -o $(PROG) $(OBJS) $(LDFLAGS) $(LDLIBS)

client:
		@$(MAKE) CCENV='-DCLIENT_ONLY $(CCENV)' OBJS="$(CLNTOBJS)"

lint:
		$(LINT) -mux $(CCENV) $(SRCS)

client-lint:
		$(LINT) -mux -DCLIENT_ONLY $(CCENV) $(CLNTSRCS)

clean:
		$(RM) $(PROG) $(OBJS) core tags

tar:		clean history doc
		$(RM) ../$(NAME).work-in-progress.tar.Z ../$(NAME).tar.Z
		tar -cvf ../$(NAME).work-in-progress.tar -C .. $(NAME)
		compress ../$(NAME).work-in-progress.tar
		(cd ..; tar -cvfFFX - $(NAME)/exclude $(NAME)/* \
			| compress > $(NAME).tar.Z)
		zcat ../$(NAME).tar.Z | tar -tvf -

tags:		$(SRCS) $(INCL)
		ctags $(SRCS) $(INCL)

history:
		sccs prt $(SRCS) > HISTORY

last:
		@sccs prt -y $(SRCS) | awk '{print $$1,$$2,$$3,$$4,$$5,$$6}'

version:
		sccs admin -f q$(VERSION) $(INCL) $(SRCS)

diffs:
		sccs diffs $(INCL) $(SRCS)

doc:		$(PROG).man
		troff -man qpage.man \
			| /usr/lib/lp/postscript/dpost > qpage.ps
		nroff -man $(PROG).man \
			| sed -e 's/.//g' > $(PROG).doc

pkg:
		pkgmk -o -d /tmp PSTAMP=`date "+%y%m%d"`
		pkgtrans -os /tmp TJDtmp TJDqpage
		mv /tmp/TJDtmp TJDqpage
		rm -rf /tmp/TJDqpage
