# Makefile for LDAP "saucer" client

HDIR	= $(LDAPSRC)/include
INSTMAN	= $(MANDIR)/man$(SECT)
LDAPSRC	= ../..
LDIR	= $(LDAPSRC)/libraries
SECT	= 1
VERFILE	= $(LDAPSRC)/build/version

CFLAGS	= -I$(HDIR) $(DEFINES) $(ACFLAGS)
SRCS	= main.c
OBJS	= $(SRCS:.c=.o)
LIBS	= -lldap -llber $(KRBLIBFLAG) $(KRBLIBS) $(ALIBS)

all:	saucer

saucer:	$(OBJS)
	$(CC) $(ALDFLAGS) -o $@ $(OBJS) -L$(LDIR) $(LIBS)

protoize: $(SRCS)
	protoize -c "$(CFLAGS)" $(SRCS)

unprotoize: $(SRCS)
	unprotoize -c "$(CFLAGS)" $(SRCS)

install:	saucer FORCE
	-$(MKDIR) -p $(BINDIR)
	$(INSTALL) $(INSTALLFLAGS) -m 755 saucer $(BINDIR)
	-$(MKDIR) -p $(INSTMAN)
	@TMPMAN=/tmp/ldapman.$$$$; \
	VERSION=`$(CAT) $(VERFILE)`; \
	for page in *.$(SECT); do \
	    $(SED) -e 's%ETCDIR%$(ETCDIR)%' -e "s%LDVERSION%$$VERSION%" \
		    $$page > $$TMPMAN; \
	    echo "installing $(INSTMAN)/$$page"; \
	    $(INSTALL) $(INSTALLFLAGS) -m 644 $$TMPMAN $(INSTMAN)/$$page; \
	done; \
	$(RM) $$TMPMAN

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

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

clean:  FORCE
	$(RM) *.o core a.out saucer

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

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

