#
# $Id: Makefile.in,v 1.50 1999/09/16 20:41:46 assar Exp $
#

SHELL = /bin/sh

srcdir = @srcdir@
VPATH = @srcdir@

CC = @CC@
LINK = @LINK@
AR = ar
RANLIB = @RANLIB@
LN_S = @LN_S@
DEFS = @DEFS@ -DROKEN_RENAME -DLIBDIR='"$(libdir)"' @AFS_EXTRA_DEFS@
CFLAGS = @CFLAGS@ $(WFLAGS)
WFLAGS = @WFLAGS@

INSTALL = @INSTALL@
INSTALL_DATA	= @INSTALL_DATA@
MKINSTALLDIRS = @top_srcdir@/mkinstalldirs

prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@

PICFLAGS = @PICFLAGS@
 
LIB_DEPS = @lib_deps_yes@ -lc
build_symlink_command   = @build_symlink_command@
install_symlink_command = @install_symlink_command@

LIBNAME = $(LIBPREFIX)kafs
LIBEXT = @LIBEXT@
SHLIBEXT = @SHLIBEXT@
LIBPREFIX = @LIBPREFIX@
LDSHARED = @LDSHARED@
AFS_EXTRA_OBJS	= @AFS_EXTRA_OBJS@
AFS_EXTRA_LIBS	= @AFS_EXTRA_LIBS@
LIB = $(LIBNAME).$(LIBEXT) $(AFS_EXTRA_LIBS)

SOURCES = afssys.c afskrb.c common.c afslib.c

EXTRA_SOURCE = issuid.c strlcpy.c strlcat.c

EXTRA_OBJECT = issuid.o strlcpy.o strlcat.o

OBJECTS = afssys.o afskrb.o common.o $(EXTRA_OBJECT) $(AFS_EXTRA_OBJS)

all: $(LIB)

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

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

install: all
	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)
	@for i in $(LIB); do \
	echo "$(INSTALL) -m 0555 $$i $(DESTDIR)$(libdir)/$$i" ;\
	$(INSTALL) -m 0555 $$i $(DESTDIR)$(libdir)/$$i ; done
	@install_symlink_command@

uninstall:
	@for i in $(LIB); do \
	echo "rm -f $(DESTDIR)$(libdir)/$$i" ;\
	rm -f $(DESTDIR)$(libdir)/$$i ; done

TAGS: $(SOURCES)
	etags $(SOURCES)

check:

clean:
	rm -f $(LIB) *.o *.a *.so *.so.* so_locations $(EXTRA_SOURCE)

mostlyclean: clean

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

realclean: distclean
	rm -f TAGS

$(LIBNAME).a: $(OBJECTS)
	rm -f $@
	$(AR) cr $@ $(OBJECTS)
	-$(RANLIB) $@


$(LIBNAME).$(SHLIBEXT): $(OBJECTS)
	rm -f $@
	$(LDSHARED) -o $@ $(OBJECTS) $(LIB_DEPS)
	@build_symlink_command@

# AIX: this almost works with gcc, but somehow it fails to use the
# correct ld, use ld instead
afslib.so: afslib.o
	ld -o $@ -bM:SRE -bI:$(srcdir)/afsl.exp -bE:$(srcdir)/afslib.exp @AFS_EXTRA_LD@ afslib.o -lc

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

roken_rename.h:
	$(LN_S) $(srcdir)/../krb/roken_rename.h .

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

issuid.c:
	$(LN_S) $(srcdir)/../roken/issuid.c .

strlcat.c:
	$(LN_S) $(srcdir)/../roken/strlcat.c .

strlcpy.c:
	$(LN_S) $(srcdir)/../roken/strlcpy.c .

