#-----------------------------------------------------------------------------
# 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.
#
#       lightweight ber library makefile
#
#-----------------------------------------------------------------------------

LDAPSRC	= ..
OUTDIR  = $(LDAPSRC)/unix
PGPPFLDIR = $(LDAPSRC)/../../pfl
PGPPFLINCLUDES = -I$(PGPPFLDIR)/common -I$(PGPPFLDIR)/unix

SRCS	= decode.c encode.c io.c bprint.c pgpSrvMem.c
OBJS	= decode.o encode.o io.o bprint.o pgpSrvMem.o

HDIR	= $(LDAPSRC)/include

INCLUDES= -I$(HDIR) $(PGPPFLINCLUDES)
DEFINES	= $(DEFS)
CFLAGS	= $(INCLUDES) $(DEFINES) $(ACFLAGS)

all:	$(OUTDIR)/liblber.a DONE

$(OUTDIR)/liblber.a: $(OBJS)
	$(AR) ruv $@ $(OBJS)
	@if [ ! -z "$(RANLIB)" ]; then \
		$(RANLIB) $@; \
	fi;

DONE:
	@set -x; echo $(OBJS) > $@

idtest:	idtest.o
	$(CC) $(ALDFLAGS) -o $@ idtest.c $(ISODEINCLUDEFLAG) \
		$(KRBINCLUDEFLAG) $(ISODELIBFLAG) $(ISODELIBS) \
		$(KRBLIBLFAG) $(KRBLIBS) $(ALIBS)

etest:	liblber.a etest.o
	$(CC) $(ALDFLAGS) -o $@ etest.o ./liblber.a $(ALIBS)

dtest:	liblber.a dtest.o
	$(CC) $(ALDFLAGS) -o $@ dtest.o ./liblber.a $(ALIBS)

version.c: $(OBJS)
	$(RM) $@
	(u=$${USER-root} v=`$(CAT) ../../build/version` d=`$(PWD)` \
	h=`$(HOSTNAME)` t=`$(DATE)`; $(SED) -e "s|%WHEN%|$${t}|" \
	-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
	-e "s|%VERSION%|$${v}|" \
	< Version.c > $@)

install:	liblber.a FORCE
	-$(MKDIR) -p $(LIBDIR)
	$(INSTALL) $(INSTALLFLAGS) -m 644 liblber.a $(LIBDIR)
	@if [ ! -z "$(RANLIB)" ]; then \
		(cd /tmp; $(RANLIB) $(LIBDIR)/liblber.a) \
	fi

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

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

clean:	FORCE
	$(RM) $(OUTDIR)/liblber.a *.o core a.out version.c dtest etest idtest

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

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

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

decode.o: decode.c ../include/lber.h
encode.o: encode.c ../include/lber.h
io.o: io.c ../include/lber.h
bprint.o: bprint.c ../include/lber.h
pgpSrvMem.o: pgpSrvMem.c

# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
