#-----------------------------------------------------------------------------
# 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.
#
#       gopher to x.500 gateway makefile
#
#-----------------------------------------------------------------------------

LDAPSRC	= ../..
HDIR	= $(LDAPSRC)/include
LDIR	= $(LDAPSRC)/libraries
VERSIONFILE = $(LDAPSRC)/build/version

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

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

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

DLIBS	= $(LDIR)/libldap.a $(LDIR)/liblber.a

all:	go500gw go500

go500gw:	gwversion.o
	$(CC) $(ALDFLAGS) -o $@ $(GWOBJS) -L$(LDIR) $(LIBS)

go500:	goversion.o
	$(CC) $(ALDFLAGS) -o $@ $(GOOBJS) -L$(LDIR) $(LIBS)

goversion.c: go500.o detach.o setproctitle.o $(DLIBS)
	$(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 > $@)

gwversion.c: go500gw.o detach.o setproctitle.o $(DLIBS)
	$(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}|" \
	< Versiongw.c > $@)

install:	go500 go500gw go500gw.help FORCE
	-$(MKDIR) -p $(ETCDIR)
	$(INSTALL) $(INSTALLFLAGS) -m 755 go500 $(ETCDIR)
	$(INSTALL) $(INSTALLFLAGS) -m 755 go500gw $(ETCDIR)
	-$(MV) $(ETCDIR)/go500gw.help $(ETCDIR)/go500gw.help-
	$(INSTALL) $(INSTALLFLAGS) -m 644 go500gw.help $(ETCDIR)

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

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

clean:	FORCE
	$(RM) *.o core a.out gwversion.c goversion.c go500gw go500

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

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

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

go500.o: go500.c ../../include/portable.h ../../include/ldapconfig.h
go500.o: ../../include/lber.h ../../include/ldap.h ../../include/disptmpl.h
go500gw.o: go500gw.c ../../include/lber.h ../../include/ldap.h
go500gw.o: ../../include/disptmpl.h ../../include/portable.h
go500gw.o: ../../include/ldapconfig.h
detach.o: detach.c ../../include/portable.h
setproctitle.o: setproctitle.c

# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
