#-----------------------------------------------------------------------------
# Copyright (c) 1994 Regents of the University of Michigan.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that this notice is preserved and that due credit is given
# to the University of Michigan at Ann Arbor. The name of the University
# may not be used to endorse or promote products derived from this
# software without specific prior written permission. This software
# is provided ``as is'' without express or implied warranty.
#
#       X.500 ldap fax mailer makefile
#
#-----------------------------------------------------------------------------
LDAPSRC = ../..
HDIR    = $(LDAPSRC)/include
LDIR  = $(LDAPSRC)/libraries
VERSIONFILE = $(LDAPSRC)/build/version

SRCS	= rp500.c main.c faxtotpc.c
OBJS	= rp500.o main.o faxtotpc.o

INCLUDES= -I$(HDIR)
DEFINES	= $(DEFS)

CFLAGS	= $(INCLUDES) $(DEFINES) $(ACFLAGS)
LIBS	= -lldap -llber $(KRBLIBFLAG) $(KRBLIBS) $(ALIBS)

all:	rp500 fax500

rp500:	rpversion.o
	$(CC) $(ALDFLAGS) -o $@ faxtotpc.o rp500.o rpversion.o \
		-L$(LDIR) $(LIBS)

fax500:	fax5version.o
	$(CC) $(ALDFLAGS) -o $@ main.o fax5version.o faxtotpc.o \
		-L$(LDIR) $(LIBS)

rpversion.c:	faxtotpc.o rp500.o $(LDIR)/libldap.a
	$(RM) $@
	(u=$${USER-root} v=`$(CAT) $(VERSIONFILE)` d=`$(PWD)` h=`$(HOSTNAME)` \
	t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \
	-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
	-e "s|%VERSION%|$${v}|" \
	< Versionrp.c > $@)

fax5version.c:	main.o faxtotpc.o $(LDIR)/libldap.a
	$(RM) $@
	(u=$${USER-root} v=`$(CAT) $(VERSIONFILE)` d=`$(PWD)` h=`$(HOSTNAME)` \
	 t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \
	-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
	-e "s|%VERSION%|$${v}|" \
	< Version.c > $@ )

install:	rp500 xrpcomp fax500 FORCE
		-$(MKDIR) -p $(ETCDIR) $(BINDIR)
		$(INSTALL) $(INSTALLFLAGS) -m 755 rp500 $(ETCDIR)
		$(SED) -e 's%ETCDIR%$(ETCDIR)%' xrpcomp > /tmp/xrpcomp.tmp
		$(INSTALL) $(INSTALLFLAGS) -m 755 /tmp/xrpcomp.tmp $(BINDIR)/xrpcomp
		$(RM) /tmp/xrpcomp.tmp
		$(INSTALL) $(INSTALLFLAGS) -m 755 fax500 $(ETCDIR)

lint:	FORCE
	$(LINT) $(INCLUDES) $(DEFINES) $(SRCS)

5lint:	FORCE
	$(5LINT) $(INCLUDES) $(DEFINES) $(SRCS)

clean:	FORCE
	$(RM) *.o core a.out rpversion.c fax5version.c rp500 fax500

depend:	FORCE
	$(MKDEP) $(INCLUDES) $(DEFINES) $(SRCS)

links:
	@$(LN) .src/README .src/xrpcomp .src/*.[ch] .

# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.

rp500.o: rp500.c ../../include/ldapconfig.h ../../include/lber.h
rp500.o: ../../include/ldap.h
main.o: main.c ../../include/ldapconfig.h ../../include/portable.h
main.o: ../../include/lber.h ../../include/ldap.h
faxtotpc.o: faxtotpc.c

# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
