#
# Makefile for libutil
#
# Copyright 2002 Silicon Graphics, Inc. All rights reserved.
#
DEPTH 	     = .
EXTRA_CFLAGS = $(GFLAGS) -DARCH=$(ARCH) 

# set up include directory search order
EXTRA_CFLAGS += -I. -I../libklib/include -I../liballoc -I../libconfig

# Turn on strict protype and error checking
EXTRA_CFLAGS += -Wall -Wstrict-prototypes

LIBUTIL = liblkcd_util.a
TARGETS = $(LIBUTIL) 
CFILES  = kl_btnode.c kl_htnode.c kl_queue.c kl_stringtab.c kl_alloc.c \
	  kl_libutil.c
HFILES  = kl_alloc.h  kl_btnode.h  kl_htnode.h  kl_queue.h kl_stringtab.h \
	  kl_libutil.h kl_lib.h
OFILES  = $(CFILES:.c=.o)

all: default

default: $(TARGETS)

clean:
	/usr/bin/find . -name ".[A-z]*.flags" -print | xargs /bin/rm -f
	/usr/bin/find . -name ".depend" -print | xargs /bin/rm -f
	(cd arch/$(ARCH) ; make TOPDIR=$(TOPDIR) ARCH=$(ARCH) clean; cd ..)
	/bin/rm -f *.o

mrproper clobber: clean
	/bin/rm -f $(TARGETS)

$(TARGETS): $(OFILES)
	make -C arch/$(ARCH) TOPDIR=$(TOPDIR) ARCH=$(ARCH)
	$(AR) ccurl $(LIBUTIL) $(OFILES)

headers: 
	mkdir -p $(ROOT)/usr/include/lkcd
	install -m 644 $(HFILES) $(ROOT)/usr/include/lkcd

exports install: $(TARGETS) headers
	mkdir -p $(ROOT)/usr/lib/lkcd
	install -m 644 $(TARGETS) $(ROOT)/usr/lib/lkcd

include $(DEPTH)/../Rules.make

