PACKAGE		= Gdtclft
VERSION		= 2.2
LIB		= ${PACKAGE}2
SHLIB_MAJOR	= 2
SHLIB_MINOR	= 1

SRCS		= gdhandle.c gdCmd.c

PREFIX		?=/usr/local
TCL_VER		?=8.2

.if exists(${PREFIX}/lib/tcl${TCL_VER}/tclConfig.sh)
# If for some reason  the file does not exist -- make the best guess. In
# reality, it will exist by the time we are actually doing the build, so
# the quality of the guess does not matter. But we still try well. -mi
TCL_STUB_LIB_SPEC!=	. ${PREFIX}/lib/tcl${TCL_VER}/tclConfig.sh; \
		echo $$TCL_STUB_LIB_SPEC
.else
TCL_STUB_LIB_SPEC=	-L${PREFIX}/lib -ltclstub${TCL_VER:S/.//}
.endif

LDADD		= -L${PREFIX}/lib -lgd -lttf -lpng -lz -lm ${TCL_STUB_LIB_SPEC}

CFLAGS		+=-I${PREFIX}/include/tcl${TCL_VER} -I${PREFIX}/include/gd
CFLAGS		+=-DNDEBUG -Wall -I. -DUSE_TCL_STUBS -I${PREFIX}/include
CFLAGS		+=-DVERSION=\"${VERSION}\"

MANn		= gdtclft.n
INTERNALLIB	= don't build the useless static version

all: ${SHLIB_NAME} pkgIndex.tcl

pkgIndex.tcl:
	echo 'package ifneeded $(PACKAGE) $(VERSION) [list load [file join $$dir $(SHLIB_NAME)] $(PACKAGE)]' > pkgIndex.tcl

DIR		= lib/tcl${TCL_VER}/gdtclft
SHLIBDIR	= ${PREFIX}/${DIR}
MANDIR		= ${PREFIX}/man/man

${SHLIBDIR}:
	${MKDIR} ${SHLIBDIR}

env:
	@${ECHO} SHLIB_NAME=${SHLIB_NAME} SHLIB_LINK=${SHLIB_LINK} DIR=${DIR}

beforeinstall: ${SHLIBDIR}
	${INSTALL_DATA} pkgIndex.tcl ${SHLIBDIR}

.include <bsd.lib.mk>
