# Generated automatically from Makefile.in by configure.
CFLAGS = -g -O -Wall -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wmissing-prototypes  -DSTDC_HEADERS=1 -DHAVE_STRDUP=1 

VERSION = 1.5
SONAME = 1

LIB = libftdb.a
LIBSH = libftdb.so.$(VERSION)
LIBSONAME = libftdb.so.$(SONAME)
LIBOBJS = trie.o ftdb.o stubs.o locks.o 

SHCFLAGS = -fPIC

prefix = /usr/local
includedir = $(prefix)/include
libdir = $(prefix)/lib

REALTARGETS = $(LIB) shared tcllib

LIBS=-ldl -lm

#--------------------------------------

SOURCES = $(subst .o,.c,$(OBJS) $(LIBOBJS)) 

SHAREDDIR = shared
SHAREDOBJS = $(patsubst %,$(SHAREDDIR)/%, $(LIBOBJS))

ifeq (.depend,$(wildcard .depend))
TARGET=$(REALTARGETS)
else
TARGET=depend $(REALTARGETS)
endif

all:	$(TARGET)

$(LIB): $(LIB)($(LIBOBJS))

tcllib: tclftdb.so

tclftdb.so: shared/ftdb_tcl.o $(LIBSH)
	gcc -shared -o tclftdb.so shared/ftdb_tcl.o $(LIBSH)

veryclean: clean
	rm -f .depend config.* Makefile
	rmdir shared

clean:
	rm -f $(PROGS) $(OBJS) $(LIBOBJS) $(LIB) core $(LIBSH)  \
		$(SHAREDOBJS) shared/ftdb_tcl.o

depend:
	$(CPP) $(CFLAGS) -M $(SOURCES) > .depend

shareddir:
	mkdir -p shared

shared: shareddir $(LIBSH)

$(LIBSH): $(SHAREDOBJS)
	gcc -shared -o $(LIBSH) -Wl,-soname,$(LIBSONAME) $(SHAREDOBJS)

$(SHAREDDIR)/%.o : %.c
	$(CC) $(SHCFLAGS) -c $(CFLAGS) -o $@ $<

install: $(LIB)
	install -m 755 -o 0 -g 0 -d $(libdir)
	install -m 755 -o 0 -g 0 -d $(includedir)
	install -m 644 -o 0 -g 0 ftdb.h $(includedir)
	install -m 644 -o 0 -g 0 $(LIB) $(libdir)
	if [ -f tclftdb.so ]; then \
		install -m 755 -o 0 -g 0 tclftdb.so $(libdir); \
	fi
	if [ -f $(LIBSH) ]; then \
		install -m 755 -o 0 -g 0 $(LIBSH) $(libdir); \
		ln -sf $(LIBSH) $(libdir)/libftdb.so; \
	fi

archive: 
	@rm -rf /tmp/ftdb-$(VERSION)
	@mkdir /tmp/ftdb-$(VERSION)
	@tar cSpf - * | (cd /tmp/ftdb-$(VERSION); tar xSpf -)
	@cd /tmp/ftdb-$(VERSION); \
	    make clean; \
	    find . -name "RCS" -exec rm {} \;  ; \
	    find . -name ".depend" -exec rm {} \;  ; \
	    rm -rf *gz test shared
	@cd /tmp; tar czSpf ftdb-$(VERSION).tar.gz ftdb-$(VERSION)
	@rm -rf /tmp/ftdb-$(VERSION)
	@cp /tmp/ftdb-$(VERSION).tar.gz .
	@rm -f /tmp/ftdb-$(VERSION).tar.gz 
	@echo " "
	@echo "The final archive is ./ftdb-$(VERSION).tar.gz. You should run"
	@echo "-n$(VERSION): RCS/*,v on all of the directories btw."

ifeq (.depend,$(wildcard .depend))
include .depend
endif

