#-----------------------------------------------------------------------------
# Copyright (c) 1990 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.
#
#       gopher to x.500 gateware server makefile
#
#-----------------------------------------------------------------------------

SRCS	= go500.c go500gw.c detach.c setproctitle.c
OBJS	= go500.o go500gw.o detach.o setproctitle.o
GOOBJS	= go500.o detach.o goversion.o setproctitle.o
GWOBJS	= go500gw.o detach.o gwversion.o setproctitle.o

CFLAGS	= -I../h $(ACFLAGS)
LIBS	= -lldap -llber $(KRBLIBFLAG) $(KRBLIBS)
DLIBS	= ../libldap/libldap.a ../liblber/liblber.a

default:
	(cd ../; make ldap-gopher)

all:	go500gw go500

go500gw:	gwversion.o
	$(CC) $(ALDFLAGS) -o $@ $(GWOBJS) -L../libldap -L../liblber $(LIBS)

go500:	goversion.o
	$(CC) $(ALDFLAGS) -o $@ $(GOOBJS) -L../libldap -L../liblber $(LIBS)

goversion.c: go500.o detach.o setproctitle.o $(DLIBS)
	rm -f $@
	(u=$${USER-root} v=`cat ../version` d=`pwd` h=`hostname` t=`date`; \
	sed -e "s|%WHEN%|$${t}|" \
	-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
	-e "s|%VERSION%|$${v}|" \
	< Version.c > $@)

gwversion.c: go500gw.o detach.o setproctitle.o $(DLIBS)
	rm -f $@
	(u=$${USER-root} v=`cat ../version` d=`pwd` h=`hostname` t=`date`; \
	sed -e "s|%WHEN%|$${t}|" \
	-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
	-e "s|%VERSION%|$${v}|" \
	< Versiongw.c > $@)

install:	$(ETCDIR)/go500 $(ETCDIR)/go500gw $(ETCDIR)/go500gw.help

$(ETCDIR)/go500:	go500
	$(INSTALL) $(INSTALLFLAGS) -m 755 go500 $(ETCDIR)

$(ETCDIR)/go500gw:	go500gw
	$(INSTALL) $(INSTALLFLAGS) -m 755 go500gw $(ETCDIR)

$(ETCDIR)/go500gw.help:	go500gw.help
	$(INSTALL) $(INSTALLFLAGS) -m 644 go500gw.help $(ETCDIR)

lint:;
	lint -I. $(SRCS)

5lint:;
	/usr/5bin/lint -I. $(SRCS)

clean:;
	rm -f *.o core a.out gwversion.c goversion.c go500gw go500

depend:;
	../mkdep $(CFLAGS) $(SRCS)

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

go500.o: go500.c ../h/lber.h ../h/ldap.h
detach.o: detach.c

# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
