# 
# $Id: Makefile.in,v 1.41 1999/10/03 16:39:27 joda Exp $
#

srcdir		= @srcdir@
top_srcdir	= @top_srcdir@
VPATH		= @srcdir@

top_builddir	= ../../..

SHELL		= /bin/sh

CC 	= @CC@
YACC	= @YACC@
RANLIB 	= @RANLIB@
DEFS 	= @DEFS@
WFLAGS = @WFLAGS@
CFLAGS 	= @CFLAGS@ $(WFLAGS)
LD_FLAGS = @LD_FLAGS@
LIBS	= @LIBS@
LIB_DBM = @LIB_DBM@
MKINSTALLDIRS = $(top_srcdir)/mkinstalldirs

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@

LN_S = @LN_S@

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

ATHENA = ../../..

INCTOP = $(ATHENA)/include

LIBTOP = $(ATHENA)/lib

LIBKAFS = @KRB_KAFS_LIB@
LIBKRB	= -L$(LIBTOP)/krb -lkrb
LIBDES	= -L$(LIBTOP)/des -ldes
LIBOTP  = @LIB_otp@
LIBROKEN= -L$(LIBTOP)/roken -lroken

PROGS = ftpd$(EXECSUFFIX)

ftpd_SOURCES = ftpd.c ftpcmd.c logwtmp.c ls.c popen.c security.c krb4.c kauth.c
ftpd_OBJS = ftpd.o ftpcmd.o logwtmp.o ls.o popen.o security.o krb4.o kauth.o

SOURCES = $(ftpd_SOURCES)
OBJECTS = $(ftpd_OBJS)

all: $(PROGS)

$(ftpd_OBJS): security.h

security.c:
	$(LN_S) $(srcdir)/../ftp/security.c .
security.h:
	$(LN_S) $(srcdir)/../ftp/security.h .
krb4.c:
	$(LN_S) $(srcdir)/../ftp/krb4.c .
gssapi.c:
	$(LN_S) $(srcdir)/../ftp/gssapi.c .

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

install: all
	$(MKINSTALLDIRS) $(DESTDIR)$(libexecdir)
	for x in $(PROGS); do \
	  $(INSTALL_PROGRAM) $$x $(DESTDIR)$(libexecdir)/`echo $$x | sed '$(transform)'`; \
	done

uninstall:
	for x in $(PROGS); do \
	  rm -f $(DESTDIR)$(libexecdir)/`echo $$x | sed '$(transform)'`; \
	done

ftpd$(EXECSUFFIX): $(ftpd_OBJS)
	$(CC) $(LD_FLAGS) $(LDFLAGS) -o $@ $(ftpd_OBJS) -L../common -lcommon $(LIBKAFS) $(LIBKRB) $(LIBOTP) $(LIBDES) $(LIBROKEN) $(LIB_DBM) $(LIBS) $(LIBROKEN)

ftpcmd.c: ftpcmd.y
	$(YACC) $(YFLAGS) $<
	chmod a-w y.tab.c
	mv -f y.tab.c ftpcmd.c

TAGS: $(SOURCES)
	etags $(SOURCES)

CLEANFILES = ftpd$(EXECSUFFIX) ftpcmd.c security.c security.h krb4.c gssapi.c

clean cleandir:
	rm -f *~ *.o core \#* $(CLEANFILES)

distclean: 
	rm -f Makefile

.PHONY: all install uninstall clean cleandir distclean
