# Generated automatically from Makefile.in by configure.
# This Makefile presumes GNU make in order to do dynamic dependencies

########################################

srcdir  = ..
include ${srcdir}/make.inc
# srcdir . top_srcdir ..

########################################

# directory containing architecture-independent executables
SHAREBIN = $(prefix)/bin

########################################

#
NAME    = wisql
TLIB    = wisql
VERSION = 5.1

ALL     = $(TLIB).tndx $(NAME)

DIRS    = bitmaps help

RECURSE = for i in $(DIRS); do \
		(cd $$i; make $@ ) \
	done

########################################
# there are several subdirectories full of things to install

HELP    := $(filter-out help/CVS help/Makefile.in help/Makefile, $(wildcard help/[A-Za-z]*))
BITMAPS := $(wildcard bitmaps/*.xbm)
TKBIND  := $(wildcard tkbind/*.tcl)

########################################
#

all: $(ALL)

install: $(SHAREBIN) $(UCODB_DIR) \
	$(UCODB_DIR)/help $(UCODB_DIR)/bitmaps $(UCODB_DIR)/tkbind \
	$(UCODB_DIR)/$(TLIB).tndx \
	$(SHAREBIN)/$(NAME) \
	$(HELP:%=$(UCODB_DIR)/%) \
	$(BITMAPS:%=$(UCODB_DIR)/%) \
	$(TKBIND:%=$(UCODB_DIR)/%)
	$(RECURSE)

clean:
	$(RM) $(ALL) $(TLIB).tlib Tlib/AAA_PackageHeader
	$(RM) ucodb.tlib CONFIG.ucodb.cf CVSlog*
	$(RECURSE)

distclean: clean
	$(RM) config.log config.cache config.status Makefile
	$(RECURSE)

${srcdir}/configure: ${srcdir}/configure.in
	cd ${srcdir} && autoconf

Makefile: Makefile.in ${srcdir}/config.status
	cd ${srcdir} && ./config.status

$(NAME): $(NAME).in Makefile
	cd ${srcdir} && ./config.status
	[ -x $< ] && chmod +x $@

${srcdir}/config.status: ${srcdir}/configure
	cd ${srcdir} && ./config.status --recheck

########################################################################
PACKDEF = AAA_Package.mk

include $(PACKDEF)

########

# names of all the packages within the Tlib

PACKAGES := $(shell awk '/[A-Za-z][A-Za-z0-9_-]* *=/ {print $$1}' < $(PACKDEF) )

########

# GNU make is used to create a macro containing a list of
# all the files upon which the Tlib depends

PACKFILES := $(foreach package, $(PACKAGES), $($(package)) )

########################################
# locally-built targets

$(TLIB).tndx: $(TLIB).tlib
	$(BPI) $(TLIB)

$(TLIB).tlib: tlibHeader Tlib/AAA_PackageHeader $(PACKFILES:%=Tlib/%)
	cat tlibHeader > $@
	$(MKTLIB) Tlib $@

Tlib/AAA_PackageHeader: $(PACKDEF)
	@echo "converting $? into $@"
	@echo "# DO NOT EDIT!" > $@
	@echo "# This file was generated by GNU make on `date`" >> $@
	@echo "# The input data came from the file ../$?" >> $@
	@echo "#########################################################" >> $@
	@$(SED) 's/^\([A-Za-z][A-Za-z0-9_-]*\) *= *\(.*\)/\#@package: \1 \2/' $? >>$@

########################################
# installed stuff from this directory

$(UCODB_DIR)/$(TLIB).tndx: $(UCODB_DIR)/$(TLIB).tlib
	$(BPI) $(UCODB_DIR)/$(TLIB)

$(UCODB_DIR)/$(TLIB).tlib: $(TLIB).tlib
	$(INSTALL_DATA) $? $@

$(UCODB_DIR) $(SHAREBIN):
	../mkinstalldirs $@

$(SHAREBIN)/$(NAME): $(NAME)
	$(INSTALL) $? $@

########################################
# installed stuff from subdirectories

$(UCODB_DIR)/help $(UCODB_DIR)/bitmaps $(UCODB_DIR)/tkbind:
	../mkinstalldirs $@

$(UCODB_DIR)/help/% : help/%
	$(INSTALL_DATA) $? $@

$(UCODB_DIR)/bitmaps/%: bitmaps/%
	$(INSTALL_DATA) $? $@

$(UCODB_DIR)/tkbind/%: tkbind/%
	$(INSTALL_DATA) $? $@

########################################
# targets preserved from old Makefile for compatibility

production: install

tlib: $(TLIB).tndx

########################################
CVSlog.gz: CVSlog
	-gzip -f $<

CVSlog:
	-cvs log > $@

TARFILE = $(TLIB)$(VERSION).tar

tar: ../$(TARFILE)

../$(TARFILE): all CVSlog.gz
	cd ../ucodb && $(MAKE)
	$(RM) ../$(TLIB)*.tar*
	cd .. && tar cvfX $(TLIB)$(VERSION).tar Exclude \
		configure configure.in make.inc.in install-sh \
		bpi.in mktlib.in Makefile.in \
		wisql ucodb sybdump
	$(RM) CVSlog.gz

ftp: /usr/local/ftp/src/UCODB/$(TARFILE).gz

/usr/local/ftp/src/UCODB/$(TARFILE).gz: ../$(TARFILE)
	gzip $<
	mv $<.gz $@
