# Current Gd version;  used in various names.

VERSION = @GD_VERSION@
LIBNAME = @GD_SHARED_LIB_FILE@

#----------------------------------------------------------------
# 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).
#----------------------------------------------------------------

# 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@

# 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 in which to install libtcl.so or libtcl.a:
LIB_INSTALL_DIR =	$(INSTALL_ROOT)$(exec_prefix)/lib

# Directory in which to install scripts
SCRIPT_INSTALL_DIR =	$(INSTALL_ROOT)$(prefix)/lib/gd${VERSION}

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

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

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

# Directory in which to install manual entry for tclsh:
MAN1_INSTALL_DIR =	$(MAN_INSTALL_DIR)/man1

# Directory in which to install manual entries for Tcl's C library
# procedures:
MAN3_INSTALL_DIR =	$(MAN_INSTALL_DIR)/man3

# Directory in which to install manual entries for the built-in
# Tcl commands:
MANN_INSTALL_DIR =	$(MAN_INSTALL_DIR)/mann

# To change the compiler switches, for example to change from -O
# to -g, change the following lines:
CFLAGS = @CFLAGS@

# To enable memory debugging reverse the comment characters on the following
# lines.  Warning:  if you enable memory debugging, you must do it
# *everywhere*, including all the code that calls Tcl, and you must use
# ckalloc and ckfree everywhere instead of malloc and free.
MEM_DEBUG_FLAGS =
#MEM_DEBUG_FLAGS = -DTCL_MEM_DEBUG

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

# Tcl used to let the configure script choose which program to use
# for installing, but there are just too many different versions of
# "install" around;  better to use the install-sh script that comes
# with the distribution, which is slower but guaranteed to work.

INSTALL =		@srcdir@/install-sh -c
INSTALL_PROGRAM =	${INSTALL}
INSTALL_DATA =		${INSTALL} -m 644
MKINSTALLDIRS =		$(TOP_DIR)/../config/mkinstalldirs

# The following symbol defines additional compiler flags to enable
# Tcl itself to be a shared library.

SHLIB_CFLAGS = @SHLIB_CFLAGS@
#SHLIB_CFLAGS =

# The symbols below provide support for dynamic loading and shared
# libraries.  See configure.in for a description of what the
# symbols mean.  The values of the symbols are normally set by the
# configure script.  You shouldn't normally need to modify any of
# these definitions by hand.

SHLIB_LD = @TCL_SHLIB_LD@

SHLIB_SUFFIX = @TCL_SHLIB_SUFFIX@
#SHLIB_SUFFIX = .so

GD_SHARED_LIB_FILE = @GD_SHARED_LIB_FILE@
#GD_SHARED_LIB_FILE = libgd$(VERSION)${SHLIB_SUFFIX}

GD_UNSHARED_LIB_FILE = @GD_UNSHARED_LIB_FILE@
#GD_UNSHARED_LIB_FILE = libgd$(VERSION).a

GD_LIB_FILE = @GD_LIB_FILE@
#GD_LIB_FILE = ${GD_UNSHARED_LIB_FILE}

#----------------------------------------------------------------
# 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.
#----------------------------------------------------------------

AC_FLAGS =		@TCL_DEFS@
RANLIB =		@TCL_RANLIB@
LN_S =			ln -s
TOP_DIR =		@TOP_DIR@
CC =			@TCL_CC@

#----------------------------------------------------------------
# The information below should be usable as is.  The configure
# script won't modify it and you shouldn't need to modify it
# either.
#----------------------------------------------------------------


CC_SWITCHES =	${CFLAGS} @SHLIB_CFLAGS@ -I. ${AC_FLAGS}

OBJS= gd.o gdfontt.o gdfonts.o gdfontmb.o gdfontl.o gdfontg.o gdCmd.o
HEADERS= gd.h gdfontt.h gdfonts.h gdfontmb.h gdfontl.h gdfontg.h

# Note: building the programs with the shared libraries causes the
# ld command to want Tcl resolved, since gdCmd.o is part of the
# shared library.

GD_PROGS = @GD_PROGS@

all: ${GD_LIB_FILE} ${GD_PROGS}

# The following target is configured by autoconf to generate either
# a shared library or non-shared library for Gd.

@GD_UNSHARED_LIB_FILE@: $(OBJS)
	rm -f $(GD_UNSHARED_LIB_FILE)
	ar cr $(GD_UNSHARED_LIB_FILE) $(OBJS)
	$(RANLIB) $(GD_UNSHARED_LIB_FILE)


@GD_SHARED_LIB_FILE@: $(OBJS)
	rm -f ${GD_SHARED_LIB_FILE}
	PATH=$(GD_BIN_DIR):${PATH}; export PATH; \
	LD_LIBRARY_PATH=${exec_prefix}/lib:${LD_LIBRARY_PATH}; \
	export LD_LIBRARY_PATH; \
	@TCL_SHLIB_LD@ -o $@ @TCL_LIB_HNAME@ $(OBJS)
	chmod 555 ${GD_SHARED_LIB_FILE}


LIBS=@GD_BUILD_LIB_SPEC@ -lm


gddemo: gddemo.o $(GD_LIB_FILE) gd.h gdfonts.h gdfontl.h
	$(CC) gddemo.o -o gddemo	$(LIBS)

giftogd: giftogd.o $(GD_LIB_FILE) gd.h
	$(CC) giftogd.o -o giftogd	$(LIBS) 

TCL_GENERIC_DIR = @TCL_TOP_DIR@/generic
TCLX_GENERIC_DIR = @TCLX_TOP_DIR@/tcl/generic

gdCmd.o: gdCmd.c
	${CC} -c ${CC_SWITCHES} -I${TCL_GENERIC_DIR} \
	-I${TCLX_GENERIC_DIR} -I@includedir@ -DTCLX_SUPPORT  ${MEM_DEBUG_FLAGS} \
	-DGD_VERSION=\"${VERSION}\" -c gdCmd.c

webgif: webgif.o $(GD_LIB_FILE) gd.h
	$(CC) webgif.o -o webgif	$(LIBS)

clean:
	rm -f *.o *.a gddemo giftogd webgif so_locations
	if test -n "$(SHLIB_SUFFIX)" ; then rm -f *$(SHLIB_SUFFIX); fi

distclean: clean
	rm -f config.status config.log config.cache Makefile pkgIndex.tcl gdConfig.sh

install: install-binaries

install-binaries: install-$(GD_LIB_FILE) ${GD_PROGS}
	@if test -n "$(GD_PROGS)" ; \
	then \
	    echo "Installing webgif" ; \
	    $(INSTALL_PROGRAM) webgif $(BIN_INSTALL_DIR)/webgif ; \
	    echo "Installing giftogd" ; \
	    $(INSTALL_PROGRAM) giftogd $(BIN_INSTALL_DIR)/giftogd ; \
	    echo "Installing gddemo" ; \
	    $(INSTALL_PROGRAM) gddemo $(BIN_INSTALL_DIR)/gddemo ; \
	fi
	@echo "Installing gd.h"
	@$(INSTALL_DATA) gd.h ${INCLUDE_INSTALL_DIR}
	@echo "Installing gdConfig.sh"
	@$(INSTALL_DATA) gdConfig.sh ${LIB_INSTALL_DIR}


install-$(GD_UNSHARED_LIB_FILE): $(GD_UNSHARED_LIB_FILE)
	@echo "Installing $(GD_UNSHARED_LIB_FILE)"
	@$(INSTALL_DATA) $(GD_UNSHARED_LIB_FILE) \
		$(LIB_INSTALL_DIR)/$(GD_UNSHARED_LIB_FILE)
	@$(RANLIB) $(LIB_INSTALL_DIR)/$(GD_UNSHARED_LIB_FILE)
	@cd $(LIB_INSTALL_DIR); \
	    rm -f libgd.a; \
	    ln -s $(GD_UNSHARED_LIB_FILE) libgd.a


install-$(GD_SHARED_LIB_FILE): $(GD_SHARED_LIB_FILE)
	@echo "Installing $(GD_SHARED_LIB_FILE)"
	@$(INSTALL_DATA) $(GD_SHARED_LIB_FILE) \
		$(LIB_INSTALL_DIR)/$(GD_SHARED_LIB_FILE)
	@cd $(LIB_INSTALL_DIR); \
	    rm -f libgd@TCL_SHLIB_SUFFIX@; \
	    ln -s $(GD_SHARED_LIB_FILE) libgd@TCL_SHLIB_SUFFIX@
	@for i in $(SCRIPT_INSTALL_DIR); \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
	    fi; \
	done;
	@echo "Installing pkgIndex.tcl"
	@$(INSTALL_DATA) pkgIndex.tcl $(SCRIPT_INSTALL_DIR)/pkgIndex.tcl

Makefile: Makefile.in
	$(SHELL) config.status


.c.o:
	$(CC) -c $(CC_SWITCHES) $<

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