# $Id: Makefile.in,v 1.47 1999/03/10 19:01:13 joda Exp $

SHELL = /bin/sh

srcdir = @srcdir@
VPATH = @srcdir@

top_builddir=..

CC = @CC@
LINK = @LINK@
AR = ar
RANLIB = @RANLIB@
LN_S = @LN_S@
DEFS = @DEFS@
CFLAGS = @CFLAGS@ $(WFLAGS)
WFLAGS = @WFLAGS@
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 random_password.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 random_password.o

all: $(PROGS)

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

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

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

uninstall:
	for x in $(PROG_BIN); do \
	  rm -f $(DESTDIR)$(bindir)/`echo $$x | sed '$(transform)'`; \
	done
	for x in $(PROG_SBIN); do \
	  rm -f $(DESTDIR)$(sbindir)/`echo $$x | sed '$(transform)'`; \
	done
	for x in $(PROG_LIBEXEC); do \
	  rm -f $(DESTDIR)$(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

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
	$(LINK) $(LD_FLAGS) $(LDFLAGS) -o $@ kpasswd.o new_pwd.o $(KLIB) $(LIBROKEN) $(LIBS) $(LIBROKEN)

kadmin_OBJECTS = kadmin.o new_pwd.o random_password.o

kadmin$(EXECSUFFIX): $(kadmin_OBJECTS)
	$(LINK) $(LD_FLAGS) $(LDFLAGS) -o $@ $(kadmin_OBJECTS) $(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)
	$(LINK) $(LD_FLAGS) $(LDFLAGS) -o $@ $(KADMIND_OBJECTS) -L../lib/kdb -lkdb -L../lib/acl -lacl $(KLIB) $(CRACKLIB) $(LIBROKEN) $(LIB_DBM) $(LIBS)

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

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

.PHONY: all Wall install uninstall check clean mostlyclean distclean realclean
