# $Id: Makefile.in,v 1.33 2000/05/14 02:31:37 assar Exp $

srcdir		= @srcdir@
VPATH		= @srcdir@

CC		= @CC@
AR		= ar
RANLIB		= @RANLIB@
MAKEDEPEND	= makedepend
ETAGS		= etags
LIBS		= @LIBS@ -L../lib/roken -lroken

INSTALL		= @INSTALL@
INSTALL_DATA	= @INSTALL_DATA@
MKINSTALLDIRS	= @top_srcdir@/mkinstalldirs
prefix		= @prefix@
exec_prefix	= @exec_prefix@
includedir	= @includedir@
libdir		= @libdir@

# Profiler flags
PROF		=

DEFS		= @DEFS@

SHELL		= /bin/sh

CFLAGS		= @CFLAGS@
REALCFLAGS	= $(CFLAGS) $(DEFS) \
		  -I$(srcdir) -I../include -I$(srcdir)/../include $(PROF)

PROGS		= mmaptime_test util-tester heaptest
LIB		= libutil.a

HEADERS		= bool.h hash.h heap.h list.h log.h

SRCS		=				\
		  $(mmaptime_test_SRCS)		\
		  $(libutil_SRCS)		\
		  $(util_tester_SRCS)		\
		  $(heaptest_SRCS)

mmaptime_test_PROG= mmaptime_test
mmaptime_test_SRCS= mmaptime.c mmaptime_test.c
mmaptime_test_OBJS= mmaptime.o mmaptime_test.o

libutil_SRCS	= hash.c list.c log.c \
		  mmaptime.c heap.c
libutil_OBJS	= hash.o list.o log.o \
		  mmaptime.o heap.o

util_tester_PROG = util-tester

util_tester_SRCS = util-tester.c

util_tester_OBJS = util-tester.o

heaptest_PROG	 = heaptest

heaptest_SRCS	 = heaptest.c

heaptest_OBJS	 = heaptest.o

.PHONY:	all install uninstall depend tags clean check

.c.o:
		$(CC) -c $(CPPFLAGS) $(REALCFLAGS) $<

all:		$(PROGS)  $(LIB)

$(mmaptime_test_PROG): $(mmaptime_test_OBJS)
		$(CC) -o $@ $(mmaptime_test_OBJS) $(LIBS) $(PROF)

libutil_LIB:	$(libutil_OBJS)

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

libutil.a:	$(libutil_OBJS)
		$(AR) cr $@ $(libutil_OBJS)
		$(RANLIB) $@

$(util_tester_PROG): libutil.a $(util_tester_OBJS)
		$(CC) -o $@ $(util_tester_OBJS) -L. -lutil $(LIBS) $(PROF)

$(heaptest_PROG): libutil.a $(heaptest_OBJS)
		$(CC) -o $@ $(heaptest_OBJS) -L. -lutil $(LIBS) $(PROF)

check:		all
		./$(heaptest_PROG) 100
		./$(util_tester_PROG) >/dev/null

depend:		$(SRCS)
		$(MAKEDEPEND) --  $(REALCFLAGS) -- $^

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

tags:		TAGS

TAGS:		$(SRCS)
		$(ETAGS) -t $(SRCS)

clean:		
		rm -f $(OBJS) $(PROGS) libutil.a *~ *.o core

mostlyclean:	clean

distclean:	clean
		rm -f Makefile

realclean:	distclean
		rm -f TAGS
