#
# $Id: Makefile.in,v 1.25.2.1 2000/09/03 19:04:25 lha Exp $
#

SHELL	= /bin/sh

srcdir	= @srcdir@
VPATH	= @srcdir@

CC	= @CC@
AR	= ar
RANLIB	= @RANLIB@
INCLUDES = -I.					\
	   -I$(srcdir)				\
	   -I../../include			\
	   -I$(srcdir)/../../include		\
	   -I../.. -I$(srcdir)/../..		\
	   -I../../rxdef			\
	   @KRB4_INC_FLAGS@

CFLAGS	= @CFLAGS@

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

LIBS		= -L. -lko \
		  -L../../util -lutil \
		  -L../roken -lroken \
		  $(KRB4_LIB_FLAGS) \
		  @LIBS@

prefix		= @prefix@
exec_prefix	= @exec_prefix@
includedir	= @includedir@
libdir		= @libdir@
sysconfdir	= @sysconfdir@
ARLACACHEDIR	= @ARLACACHEDIR@
ARLACONFFILE	= @ARLACONFFILE@

target_os	= @target_os@
target_vendor	= @target_vendor@
target_cpu	= @target_cpu@

#PICFLAGS = @PICFLAGS@
 
LIBNAME = $(LIBPREFIX)ko
#LIBEXT = @LIBEXT@
LIBEXT = a
#SHLIBEXT = @SHLIBEXT@
#LIBPREFIX = @LIBPREFIX@
LIBPREFIX = lib
#LDSHARED = @LDSHARED@
LIB = $(LIBNAME).$(LIBEXT)
PROGS = gensysname kotest

DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)\" \
	 -DARLACACHEDIR=\"$(ARLACACHEDIR)\" \
	 -DARLACONFFILE=\"$(ARLACONFFILE)\" \
	$(GENSYSNAMEDEFS)

LIB_SOURCES = koerror.c \
	kocell.c \
	ports.c \
	part.c \
	sysname.c \
	vlmisc.c \
	afsconf.c \
	auth.c

SOURCES = $(LIB_SOURCES) $(gensysname_SRCS)

LIB_OBJECTS = koerror.o \
	kocell.o \
	ports.o \
	part.o \
	sysname.o \
	vlmisc.o \
	afsconf.o \
	auth.o

HEADERS = cellconfig.h auth.h

GENSYSNAMEDEFS= @DEFS@ -DARLAOS=\"$(target_os)\" \
		-DARLAVENDOR=\"$(target_vendor)\" \
		-DARLACPU=\"$(target_cpu)\" 

gensysname_SRCS = gensysname.c

gensysname_OBJS = gensysname.o

kotest_SRCS = kotest.c

kotest_OBJS = kotest.o

OBJECTS = $(LIB_OBJECTS) 

all: $(LIB) $(PROGS)

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

sysname.c: gensysname
	./gensysname -c > $@

.c.o:
	$(CC) -c $(CPPFLAGS) $(DEFS) $(INCLUDES) $(CFLAGS) $(PICFLAGS) $<

install: all
	$(MKINSTALLDIRS) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
	$(INSTALL_DATA) $(LIB) $(DESTDIR)$(libdir)/$(LIB)
	for i in $(HEADERS); do \
	  $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir)/$$i; \
	done

uninstall:
	rm -f $(DESTDIR)$(libdir)/$(LIB)
	for i in $(HEADERS); do \
	  rm -f $(DESTDIR)$(includedir)/$$i; \
	done

TAGS: $(SOURCES)
	etags $(SOURCES)


gensysname: $(gensysname_OBJS)
	$(CC) -o $@ $(gensysname_OBJS) -L../../util -lutil -L../roken -lroken

kotest: $(kotest_OBJS) $(LIBNAME).a
	$(CC) -o $@ $(kotest_OBJS) $(LIBS)

check:

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

mostlyclean: clean

distclean: clean
	rm -f Makefile *~

realclean: distclean
	rm -f TAGS

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

#$(LIBNAME).$(SHLIBEXT): $(LIB_OBJECTS)
#	rm -f $@
#	$(LDSHARED) -o $@ $(LIB_OBJECTS)

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

Makefile:	Makefile.in ../../config.status
	cd ../..; CONFIG_FILES=lib/ko/Makefile CONFIG_HEADERS= $(SHELL) config.status


.PHONY: all install uninstall check clean mostlyclean distclean realclean
