# $Id: Makefile.in,v 1.33 1997/04/05 21:24:35 assar Exp $

SHELL = /bin/sh

srcdir = @srcdir@
VPATH = @srcdir@

topdir = ../..

CC = @CC@
AR = ar
RANLIB = @RANLIB@
DEFS = @DEFS@ -DBINDIR='"$(bindir)"'
CFLAGS = @CFLAGS@
LD_FLAGS = @LD_FLAGS@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
LIBS = @LIBS@
MKINSTALLDIRS = @top_srcdir@/mkinstalldirs

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

PROG_BIN	= kauth$(EXECSUFFIX) ksrvtgt
PROG_LIBEXEC	= kauthd$(EXECSUFFIX)
PROGS = $(PROG_BIN) $(PROG_LIBEXEC)

SOURCES_KAUTH  = kauth.c rkinit.c
SOURCES_KAUTHD = kauthd.c
SOURCES_COMMON = encdata.c marshall.c

OBJECTS_KAUTH  = kauth.o rkinit.o
OBJECTS_KAUTHD = kauthd.o
OBJECTS_COMMON = marshall.o encdata.o

OBJECTS = $(OBJECTS_KAUTH) $(OBJECTS_KAUTHD)
SOURCES = $(SOURCES_KAUTH) $(SOURCES_KAUTHD) $(SOURCES_COMMON)

KRB_KAFS_LIB = @KRB_KAFS_LIB@

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) $(libexecdir)
	for x in $(PROG_BIN); do \
	  $(INSTALL_PROGRAM) $$x $(bindir)/`echo $$x| sed '$(transform)'`; \
	done
	if test -f $(bindir)/zrefresh -o -r  $(bindir)/zrefresh; then \
	  true; \
	else \
	  $(INSTALL_PROGRAM) $(srcdir)/zrefresh $(bindir)/`echo zrefresh | sed '$(transform)'`; \
	fi
	for x in $(PROG_LIBEXEC); do \
	  $(INSTALL_PROGRAM) $$x $(libexecdir)/`echo $$x| sed '$(transform)'`; \
	done

uninstall:
	for x in $(PROG_BIN); do \
	  rm -f $(bindir)/`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/krb -lkrb -L../../lib/des -ldes
LIBROKEN=-L../../lib/roken -lroken

kauth$(EXECSUFFIX): $(OBJECTS_KAUTH) $(OBJECTS_COMMON)
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ $(OBJECTS_KAUTH) $(OBJECTS_COMMON) $(KRB_KAFS_LIB) $(KLIB) $(LIBROKEN) $(LIBS) $(LIBROKEN)

kauthd$(EXECSUFFIX): $(OBJECTS_KAUTHD) $(OBJECTS_COMMON)
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ $(OBJECTS_KAUTHD) $(OBJECTS_COMMON) $(KLIB) $(LIBROKEN) $(LIBS) $(LIBROKEN)

ksrvtgt: ksrvtgt.in
	sed -e "s!%bindir%!$(bindir)!" $(srcdir)/ksrvtgt.in > $@
	chmod +x $@


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