#
# rcsid $Header: /usr/cvsroot/magic/tcltk/Makefile,v 1.1.1.1 2005/05/09 23:29:23 tim Exp $
#

MODULE   = tcltk
MAGICDIR = ..
SRCS = tclmagic.c

include ${MAGICDIR}/defs.mak

DFLAGS += -DMAGIC_DATE="\"`date`\""
CLEANS += magic.sh magic.tcl magicexec magicdnull

TCL_FILES = \
	tkcon.tcl \
	tkshell.tcl \
	wrapper.tcl \
	console.tcl \
	techbuilder.tcl \
	padlist.tcl \
	tools.tcl \
	magic.tcl

tcl-main: magicexec magicdnull magic.tcl magic.sh

install-tcl: magicexec magicdnull ${BINDIR}/magic.sh ${TCL_FILES}
	${RM} ${TCLDIR}/magicexec
	${CP} magicexec ${TCLDIR}/magicexec
	${RM} ${TCLDIR}/magicdnull
	${CP} magicdnull ${TCLDIR}/magicdnull
	(cd ${TCLDIR}; ${RM} ${TCL_FILES})
	for i in ${TCL_FILES}; do \
		${CP} $$i ${TCLDIR}; done

magicexec: magicexec.c
	${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} magicexec.c -o magicexec \
		${LIBS} ${LIB_SPECS}

magicdnull: magicdnull.c
	${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} magicdnull.c -o magicdnull \
		${LIBS} ${LIB_SPECS}

magic.tcl: magic.tcl.in
	sed -e /TCL_DIR/s%TCL_DIR%${TCLDIR}%g  \
            -e /SHDLIB_EXT/s%SHDLIB_EXT%${SHDLIB_EXT}%g magic.tcl.in > magic.tcl

magic.sh: magic.sh.in
	sed -e /TCL_DIR/s%TCL_DIR%${TCLDIR}%g \
	    -e /TCLLIB_DIR/s%TCLLIB_DIR%${TCL_LIB_DIR}%g \
	    -e /WISH_EXE/s%WISH_EXE%${WISH_EXE}%g magic.sh.in > magic.sh

${TCLDIR}/%: %
	${RM} ${TCLDIR}/$*
	${CP} $* ${TCLDIR}/$*

${BINDIR}/magic.sh: magic.sh
	${RM} ${BINDIR}/magic.sh ${BINDIR}/magic
	${CP} magic.sh ${BINDIR}/magic
	(cd ${BINDIR}; chmod 0755 magic)

include ${MAGICDIR}/rules.mak
