# $Id: Makefile.in,v 1.39 1997/12/05 07:45:27 joda Exp $

SHELL = /bin/sh

srcdir = @srcdir@
VPATH = @srcdir@

top_builddir=..

CC = @CC@
AR = ar
RANLIB = @RANLIB@
LN_S = @LN_S@
DEFS = @DEFS@
CFLAGS = @CFLAGS@
LD_FLAGS = @LD_FLAGS@

LIB_tgetent = @LIB_tgetent@
LIB_readline = @LIB_readline@
LIB_DBM = @LIB_DBM@
LIBS = @LIBS@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
MKINSTALLDIRS = @top_srcdir@/mkinstalldirs

CRACKLIB = @CRACKLIB@

prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
libexecdir = @libexecdir@
bindir = @bindir@
sbindir = @sbindir@
transform=@program_transform_name@
EXECSUFFIX=@EXECSUFFIX@

PROG_BIN	= kpasswd$(EXECSUFFIX) \
		  kadmin$(EXECSUFFIX)
PROG_SBIN	= ksrvutil$(EXECSUFFIX)
PROG_LIBEXEC	= kadmind$(EXECSUFFIX)
PROGS = $(PROG_BIN) $(PROG_SBIN) $(PROG_LIBEXEC)

SOURCES = kpasswd.c kadmin.c kadm_server.c kadm_funcs.c pw_check.c \
          admin_server.c kadm_ser_wrap.c ksrvutil.c ksrvutil_get.c \
	  new_pwd.c

OBJECTS = kpasswd.o kadmin.o kadm_server.o kadm_funcs.o \
          admin_server.o kadm_ser_wrap.o ksrvutil.o ksrvutil_get.o \
	  new_pwd.o

all: $(PROGS)

Wall:
	make CFLAGS="-g -Wall -Wno-comment -Wmissing-prototypes -Wmissing-declarations -D__USE_FIXED_PROTOTYPES__"

.c.o:
	$(CC) -c $(CPPFLAGS) $(DEFS) -I../include -I$(srcdir) $(CFLAGS) $<

install: all
	$(MKINSTALLDIRS) $(bindir)
	for x in $(PROG_BIN); do \
	  $(INSTALL_PROGRAM) $$x $(bindir)/`echo $$x | sed '$(transform)'`; \
	done
	$(MKINSTALLDIRS) $(sbindir)
	for x in $(PROG_SBIN); do \
	  $(INSTALL_PROGRAM) $$x $(sbindir)/`echo $$x | sed '$(transform)'`; \
	done
	$(MKINSTALLDIRS) $(libexecdir)
	for x in $(PROG_LIBEXEC); do \
	  $(INSTALL_PROGRAM) $$x $(libexecdir)/`echo $$x | sed '$(transform)'`; \
	done
	@rm -f $(prefix)/sbin/kadmin

uninstall:
	for x in $(PROG_BIN); do \
	  rm -f $(bindir)/`echo $$x | sed '$(transform)'`; \
	done
	for x in $(PROG_SBIN); do \
	  rm -f $(sbindir)/`echo $$x | sed '$(transform)'`; \
	done
	for x in $(PROG_LIBEXEC); do \
	  rm -f $(libexecdir)/`echo $$x | sed '$(transform)'`; \
	done

TAGS: $(SOURCES)
	etags $(SOURCES)

check:

clean:
	rm -f *.a *.o $(PROGS)

mostlyclean: clean

distclean: clean
	rm -f Makefile *.tab.c *~

realclean: distclean
	rm -f TAGS

dist: $(DISTFILES)
	for file in $(DISTFILES); do \
	  ln $$file ../`cat ../.fname`/lib \
	    || cp -p $$file ../`cat ../.fname`/lib; \
	done

KLIB=-L../lib/kadm -lkadm -L../lib/krb -lkrb -L../lib/des -ldes -L../lib/com_err -lcom_err
LIBROKEN=-L../lib/roken -lroken

kpasswd$(EXECSUFFIX): kpasswd.o new_pwd.o
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ kpasswd.o new_pwd.o $(KLIB) $(LIBROKEN) $(LIBS) $(LIBROKEN)

kadmin$(EXECSUFFIX): kadmin.o new_pwd.o
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ new_pwd.o kadmin.o $(KLIB) -L../lib/sl -lsl $(LIBROKEN) $(LIBS) $(LIB_readline) $(LIBROKEN)

KADMIND_OBJECTS=kadm_server.o kadm_funcs.o admin_server.o kadm_ser_wrap.o pw_check.o

kadmind$(EXECSUFFIX): $(KADMIND_OBJECTS)
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ $(KADMIND_OBJECTS) -L../lib/kdb -lkdb -L../lib/acl -lacl $(KLIB) $(CRACKLIB) $(LIBROKEN) $(LIB_DBM) $(LIBS) $(LIBROKEN)

ksrvutil$(EXECSUFFIX): ksrvutil.o ksrvutil_get.o
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ ksrvutil.o ksrvutil_get.o $(KLIB) $(LIBROKEN) $(LIBS) $(LIBROKEN)

$(OBJECTS): ../include/config.h
