# $Id: Makefile.in,v 1.27 2004/05/28 15:45:59 kerns Exp $
@MCOMMON@

CWEB = @CWEB@
CTANGLE = $(CWEB)/ctangle
CWEAVE = $(CWEB)/cweave
TEXINPUTS = TEXINPUTS=.:$(CWEB):

# FIXME -- These should be found by autoconf
TEX = tex
PDFTEX = pdftex
XDVI = xdvi
DVIPS = dvips

srcdir =	.
VPATH = 	.
.PATH:		.

# one up
basedir = ..
# top dir
topdir = ../..
# this dir relative to top dir
thisdir = src/lib


DEBUG=@DEBUG@

GMP_INC=@GMP_INC@

first_rule: all
dummy:

LIBSRCS = alloc.c attr.c base64.c bsys.c bget_msg.c \
	  bnet.c bnet_server.c \
	  bpipe.c bshm.c btime.c \
	  cram-md5.c crc32.c daemon.c edit.c fnmatch.c \
	  hmac.c idcache.c jcr.c lex.c alist.c dlist.c \
	  md5.c message.c mem_pool.c parse_conf.c \
	  queue.c rwlock.c scan.c serial.c sha1.c \
	  semlock.c signal.c smartall.c tree.c \
	  util.c var.c watchdog.c workq.c btimers.c


LIBOBJS = alloc.o attr.o base64.o bsys.o bget_msg.o \
	  bnet.o bnet_server.o \
	  bpipe.o bshm.o btime.o \
	  cram-md5.o crc32.o daemon.o edit.o fnmatch.o \
	  hmac.o idcache.o jcr.o lex.o alist.o dlist.o \
	  md5.o message.o mem_pool.o parse_conf.o \
	  queue.o rwlock.o scan.o serial.o sha1.o \
	  semlock.o signal.o smartall.o tree.o \
	  util.o var.o watchdog.o workq.o btimers.o


EXTRAOBJS = @OBJLIST@


.SUFFIXES:	.c .o .ch .dvi .pdf .tex .view .w .1
.PHONY:
.DONTCARE:

# inference rules
.c.o:
	$(CXX) $(DEFS) $(DEBUG) -c $(WCFLAGS) $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $<

.cc.o:
	$(CXX) $(DEFS) $(DEBUG) -c $(WCFLAGS) $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $<

.w.c:
	$(CTANGLE) $<

.w.tex:
	$(CWEAVE) $<

.tex.dvi:
	( $(TEXINPUTS) ; export TEXINPUTS; $(TEX) $< )

.tex.pdf:
	( $(TEXINPUTS) ; export TEXINPUTS; $(PDFTEX) $< )

.dvi.view:
	$(XDVI) -s 0 $<

#-------------------------------------------------------------------------
all: Makefile libbac.a
	@echo "==== Make of lib is good ===="
	@echo " "

libbac.a: $(LIBOBJS)
	$(AR) rc  $@ $(LIBOBJS)
	$(RANLIB) $@


Makefile: $(srcdir)/Makefile.in $(topdir)/config.status
	cd $(topdir) \
	  && CONFIG_FILES=$(thisdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status

rwlock_test:
	rm -f rwlock.o
	$(CXX) -DTEST_RWLOCK $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE)  $(CFLAGS) rwlock.c
	$(CXX) $(LDFLAGS) -L. -o $@ rwlock.o $(LIBS) $(DLIB) -lbac -lm
	rm -f rwlock.o
	$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) rwlock.c

md5sum:
	rm -f md5.o
	$(CXX) -DMD5_SUM $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE)  $(CFLAGS) md5.c
	$(CXX) $(LDFLAGS) -L. -o $@ md5.o $(LIBS) $(DLIB) -lbac -lm
	rm -f md5.o
	$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) md5.c


sha1sum:
	rm -f sha1.o
	$(CXX) -DSHA1_SUM $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE)	$(CFLAGS) sha1.c
	$(CXX) $(LDFLAGS) -L. -o $@ sha1.o $(LIBS) $(DLIB) -lbac -lm
	rm -f sha1.o
	$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) md5.c
	 
install:

uninstall:

clean:
	$(RMF) *.a core a.out *.o *.bak *.tex *.pdf *~ *.intpro *.extpro 1 2 3
	$(RMF) rwlock_test md5sum sha1sum

realclean: clean
	$(RMF) tags

distclean: realclean
	if test $(srcdir) = .; then $(MAKE) realclean; fi
	(cd $(srcdir); $(RMF) Makefile; $(RMF) -r CVS)

# Semi-automatic generation of dependencies:
# Use gcc -MM because X11 `makedepend' doesn't work on all systems
# and it also includes system headers.
# `semi'-automatic since dependencies are generated at distribution time.

depend:
	@$(MV) Makefile Makefile.bak
	@$(SED) "/^# DO NOT DELETE:/,$$ d" Makefile.bak > Makefile
	@$(ECHO) "# DO NOT DELETE: nice dependency list follows" >> Makefile
	@$(CXX) -S -M $(CPPFLAGS) $(XINC) -I$(srcdir) -I$(basedir) $(SQL_INC) *.c >> Makefile
	@if test -f Makefile ; then \
	    $(RMF) Makefile.bak; \
	else \
	   $(MV) Makefile.bak Makefile; \
	   echo -e "Something went wrong\n\a"; \
	fi

# -----------------------------------------------------------------------
# DO NOT DELETE: nice dependency list follows
