#
# This file is a Makefile for IMG.  If it has the name "Makefile.in"
# then it is a template for a Makefile;  to generate the actual Makefile,
# run "./configure", which is a configuration script generated by the
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.

# This is the master makefile to compile all the packages in this
# extensions in one go.

PACKAGE_NAME	=	@PACKAGE_NAME@
PACKAGE_VERSION	=	@PACKAGE_VERSION@
CYGPATH		=	@CYGPATH@
SUBDIRS		=	@subdirs@

#
#----------------------------------------------------------------
# Things you can change to personalize the Makefile for your own
# site (you can make these changes in either Makefile.in or
# Makefile, but changes to Makefile will get lost if you re-run
# the configuration script).
#----------------------------------------------------------------

# Directory in which the source of this extension can be found
srcdir		=	@srcdir@

# Default top-level directories in which to install architecture-
# specific files (exec_prefix) and machine-independent files such
# as scripts (prefix).  The values specified here may be overridden
# at configure-time with the --exec-prefix and --prefix options
# to the "configure" script.

prefix		= @prefix@
exec_prefix	= @exec_prefix@
libdir      = @libdir@
datarootdir	= @datarootdir@
includedir  = @includedir@
mandir      = @mandir@

# Directory containing scripts supporting the work of this makefile
tool		=	$(srcdir)/tools

INSTALL_OPTIONS =
INSTALL		= $(SHELL) $(srcdir)/tclconfig/install-sh -c ${INSTALL_OPTIONS}
INSTALL_DATA_DIR = ${INSTALL} -d -m 755
INSTALL_PROGRAM	= ${INSTALL} -m 755
INSTALL_DATA	= ${INSTALL} -m 644
INSTALL_SCRIPT	= ${INSTALL_PROGRAM}
INSTALL_LIBRARY	= ${INSTALL_DATA}


# The following definition can be set to non-null for special systems
# like AFS with replication.  It allows the pathnames used for installation
# to be different than those used for actually reference files at
# run-time.  INSTALL_ROOT is prepended to $prefix and $exec_prefix
# when installing files.
INSTALL_ROOT =

# Directory where libimg.a is at run-time:
LIB_RUNTIME_DIR =	$(libdir)/$(PACKAGE_NAME)$(PACKAGE_VERSION)

# Directory in which to install the archive libimg.a:
LIB_INSTALL_DIR =	$(INSTALL_ROOT)$(LIB_RUNTIME_DIR)

# Directory in which to install the extended shell tclsh:
BIN_INSTALL_DIR =	$(INSTALL_ROOT)$(exec_prefix)/bin

# Directory in which to install the include file transform.h:
INCLUDE_INSTALL_DIR =	$(INSTALL_ROOT)$(prefix)/include

# Top-level directory in which to install manual entries:
MAN_INSTALL_DIR =	$(INSTALL_ROOT)$(mandir)

# Directory where libz, libpng and libjpeg are (or will be) installed.
IMG_INSTALL_DIR	=	$(INSTALL_ROOT)$(IMG_RUNTIME_DIR)

# Some versions of make, like SGI's, use the following variable to
# determine which shell to use for executing commands:
SHELL =		/bin/sh

#----------------------------------------------------------------
# The information below is modified by the configure script when
# Makefile is generated from Makefile.in.  You shouldn't normally
# modify any of this stuff by hand.
#----------------------------------------------------------------

INSTALL_SHLIB =		$(INSTALL) -m 555
RANLIB =		@RANLIB@
SHLIB_SUFFIX =		@SHLIB_SUFFIX@
SHARED_BUILD	= @SHARED_BUILD@

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

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

default:	all

all:
	for sub in $(SUBDIRS) ; \
	do	\
		here=`pwd` && \
		cd $$sub && \
		$(MAKE) all || exit $$? && \
		cd $$here ; \
	done

test:	all
	for sub in $(SUBDIRS) ; \
	do	\
		here=`pwd` && \
		cd $$sub && \
		$(MAKE) top_builddir=$$here test || exit $$? && \
		cd $$here ; \
	done

install-man:
	mkdir -p $(MAN_INSTALL_DIR)/mann
	for i in $(srcdir)/doc/*.man ; \
	do	\
		dtplite -ext n -o $(MAN_INSTALL_DIR)/mann nroff $$i ; \
	done

collate: all
	rm -f pkgIndex.tcl
	touch pkgIndex.tcl
	for sub in $(SUBDIRS) ; \
	do	\
		here=`pwd` && \
		cd $$sub && \
		$(MAKE) install \
			exec_prefix=$$here/Img/exec_prefix		\
			prefix=$$here/Img/prefix			\
			pkglibdir=$$here/Img/exec_prefix/lib/Img	\
			libdir=$$here/Img/exec_prefix/lib		\
			includedir=$$here/Img/prefix/include		\
			DESTDIR=					\
			|| exit $$? &&					\
		cd $$here && \
		if test "x$(SHARED_BUILD)" = "x1"; then \
		cat Img/exec_prefix/lib/Img/pkgIndex.tcl >> pkgIndex.tcl ; \
		fi ; \
	done
	chmod ugo+w     Img/exec_prefix/lib/Img/pkgIndex.tcl
	mv pkgIndex.tcl Img/exec_prefix/lib/Img/pkgIndex.tcl
	chmod ugo+w     Img/exec_prefix/lib/Img/pkgIndex.tcl
	for p in Img/exec_prefix/lib/*.sh ; do \
		sed -e 's#$(libdir)/[^/ ]*\([/ ]\)#$(LIB_RUNTIME_DIR)\1#' \
			$$p > $$p.1 && mv -f $$p.1 $$p ; \
	done

install-libraries: collate
	mkdir -p    $(INSTALL_ROOT)$(LIB_RUNTIME_DIR)
	for p in Img/exec_prefix/lib/Img/* ; do \
		$(INSTALL_PROGRAM) $$p $(INSTALL_ROOT)$(LIB_RUNTIME_DIR)/`basename $$p` ; \
	done
	mkdir -p $(INSTALL_ROOT)$(libdir)
	for p in Img/exec_prefix/lib/*.sh ; do \
		$(INSTALL_PROGRAM) $$p $(INSTALL_ROOT)$(libdir)/`basename $$p` ; \
	done
	if [ -n "`ls Img/prefix/include`" ]; then \
	mkdir -p $(INSTALL_ROOT)$(includedir) && \
	for p in Img/prefix/include/* ; do \
		$(INSTALL_DATA) $$p $(INSTALL_ROOT)$(includedir)/`basename $$p` ; \
	done; fi

install: install-libraries install-man

bindist:

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

clean:
	for sub in $(SUBDIRS) ; \
	do	\
		here=`pwd` && \
		cd $$sub && \
		$(MAKE) clean || exit $$? && \
		cd $$here ; \
	done
	rm -rf Img

distclean:	clean
	rm -f config.* $(jpegdir)/config.log $(jpegdir)/config.status
	rm -f Makefile
	for sub in $(SUBDIRS) ; \
	do	\
		here=`pwd` && \
		cd $$sub && \
		$(MAKE) distclean || exit $$? && \
		cd $$here ; \
	done

#-------------------------------------------------------#
# DO NOT DELETE THIS LINE -- make depend depends on it.
