# Generated automatically from Makefile.in by configure.
#
# tk/unix/Makefile.in --
#
# Makefile to build a wish with Extended Tcl (wishx).
# 
#------------------------------------------------------------------------------
# Copyright 1992-1995 Karl Lehenbauer and Mark Diekhans.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appear in all copies.  Karl Lehenbauer and
# Mark Diekhans make no representations about the suitability of this
# software for any purpose.  It is provided "as is" without express or
# implied warranty.
#------------------------------------------------------------------------------
# $Id: Makefile.in,v 8.24 1997/12/16 17:08:30 markd Exp $
#------------------------------------------------------------------------------
#

#------------------------------------------------------------------------------
# Common and user-editable defines.
#
srcdir = .
include /dsk/data/de/src/tclX8.0.3/unix/Common.mk
include /dsk/data/de/src/tclX8.0.3/unix/Config.mk

#------------------------------------------------------------------------------
# Local macros.
#
CC_SWITCHES = ${CPPFLAGS} ${XCFLAGS} ${CFLAGS} ${SYSCFLAGS} \
              ${TK_DEFS} ${TCL_DEFS}\
	      -I${TKX_GENERIC_DIR} -I${TKX_UNIX_SRC_DIR} \
	      -I${TK_GENERIC_DIR} -I${TK_UNIX_DIR} \
	      -I${TCLX_GENERIC_DIR} -I${TCLX_UNIX_SRC_DIR} \
	      -I${TKX_UNIX_BLD_DIR} -I${TCLX_UNIX_BLD_DIR} \
	      -I${TCL_GENERIC_DIR} -I${TCL_UNIX_DIR} ${TK_XINCLUDES}

LD_SWITCHES = ${LDFLAGS} ${TCL_LD_FLAGS} ${XLDFLAGS} ${XCFLAGS} ${CFLAGS}

# The ordering of the libraries is important.  Some X libs on SysV include
# "random" in a BSD module.  This would conflict with the one in the TclX
# library if it was brought in.

LIBS = ${TKX_LD_SEARCH_FLAGS} ${TK_LIB} ${TK_XLIBSW}  -lm -lc

ALL_LIBS = ${TKX_BUILD_LIB_SPEC} ${TK_LIB} ${TK_XLIBSW} \
	   ${TCLX_BUILD_LIB_SPEC} ${TCL_LIB} ${TK_LIBS} ${TCLX_LIBS} \
	   ${XLDLIBS} ${TKX_CC_SEARCH_FLAGS}

STATIC_LIBS = ${TKX_STLIB_NAME} ${TK_UNIX_DIR}/${TK_STLIB_NAME} ${TK_XLIBSW} \
              ${TCLX_UNIX_SRC_DIR}/${TCLX_STLIB_NAME} \
	      ${TCL_UNIX_DIR}/${TCL_STLIB_NAME} \
              ${TK_LIBS} ${TCLX_LIBS} ${XLDLIBS} ${TKX_CC_SEARCH_FLAGS}

#------------------------------------------------------------------------------
# Source and target macros.
#
GENERIC_OBJS = tkXinitSA.o tkXinit.o tkXshell.o

GENERIC_SOBJS = tkXinitDSA..o tkXinit..o \
		tkXshell..o

OBJS = ${GENERIC_OBJS}

SOBJS = ${GENERIC_SOBJS}

RUNTIME_DIR = ${srcbasedir}/tk/runtime

# C source optionally built by tcl2c
STANDALONE_SRCS = tkx.c

STANDALONE_OBJS = tkx.o

LIBTCLX = ../../tcl/unix/${TCLX_STLIB_NAME}
TCL = ../../tcl/unix/tcl

HELP_DIR = ${srcbasedir}/tk/help

TEST_OBJS = tkTest.o tkSquare.o tkXunixTest.o

TEST_SAOBJS = tkTest.o tkSquare.o tkXunixTestSA.o

#------------------------------------------------------------------------------
# Dependencies for generating the libraries and linking the executable.
# If a link fails, purge the executable, as some systems leave invalid
# executables around.
#
all: wishx RUNTIME tktest

static: wishx.static tktest.static

standalone: wishx.standalone tktest.standalone hello

wishx: tkXAppInit.o libtkx8.0.3.so libtkx8.0.3.a ${TCL} Makefile
	${CC} ${LD_SWITCHES} tkXAppInit.o ${ALL_LIBS} \
	    -o $@ || (rm -f $@; exit 1)

wishx.static: tkXAppInit.o ${TKX_STLIB_NAME} ${LIBTCLX} Makefile
	${CC} ${LD_SWITCHES} tkXAppInit.o ${STATIC_LIBS} -o $@ || \
	    (rm -f $@; exit 1)

wishx.standalone: tkXAppInitSA.o ${TKX_STLIB_NAME} ${LIBTCLX} Makefile
	${CC} ${LD_SWITCHES} tkXAppInitSA.o ${STATIC_LIBS} -o $@ || \
	    (rm -f $@; exit 1)

${TKX_STLIB_NAME}: ${OBJS}
	${AR} cr ${TKX_STLIB_NAME} ${OBJS}
	${RANLIB} ${TKX_STLIB_NAME}

libtkx8.0.3.so: ${SOBJS}
	rm -f ${TKX_SHLIB_NAME}
	${TCL_SHLIB_LD} -o ${TKX_SHLIB_NAME} ${SOBJS} \
	    ${TK_BUILD_LIB_SPEC} ${TCLX_BUILD_LIB_SPEC} \
	    ${TCL_BUILD_LIB_SPEC} ${TCL_SHLIB_LD_LIBS}

hello:	hello.c
	${CC} ${LD_SWITCHES} -o $@ hello.c ${STATIC_LIBS}

#------------------------------------------------------------------------------
# We need the "help" directory here so that the help command will work before
# installation. Normally just symlink, unless we don't have them.
#
RUNTIME: tkx.tcl tclhelp help.tmp

tkx.tcl: ${RUNTIME_DIR}/tkx.tcl
	rm -f tkx.tcl
	cp ${RUNTIME_DIR}/tkx.tcl tkx.tcl

tclhelp: ${RUNTIME_DIR}/tclhelp.tcl
	rm -f tclhelp
	echo Creating tclhelp script
	@echo "#!/bin/sh"       			 >tclhelp
	@echo "# The next line restarts using wishx \\"	>>tclhelp
	@echo 'exec wishx $$0 $${1+"$$@"}'		>>tclhelp
	@echo ""					>>tclhelp
	@echo "package require Tk ${TK_VERSION}"	>>tclhelp
	@echo "package require Tclx ${TCLX_VERSION}"	>>tclhelp
	@echo ""					>>tclhelp
	@cat ${RUNTIME_DIR}/tclhelp.tcl 		>>tclhelp
	@chmod a+rx,a-w tclhelp

help.tmp:
	if [ "YES" = "YES" ]; then \
	    rm -rf help ;\
	    ln -s ${HELP_DIR} help ;\
	else \
	    rm -rf help ;\
	    (cd ${HELP_DIR}; tar -cf - help) | tar -xf - ;\
	fi
	touch help.tmp

#------------------------------------------------------------------------------
# Generate the test program.
#

tktest: ${TEST_OBJS} libtkx8.0.3.so libtkx8.0.3.a ${TCL}
	${CC} ${LD_SWITCHES} ${TEST_OBJS} ${ALL_LIBS} \
	    -o $@ || (rm -f $@; exit 1)

tktest.static: ${TEST_OBJS} libtkx8.0.3.a ${TCL}
	${CC} ${LD_SWITCHES} ${TEST_OBJS} ${STATIC_LIBS} \
	    -o $@ || (rm -f $@; exit 1)

tktest.standalone: ${TEST_SAOBJS} libtkx8.0.3.a ${TCL}
	${CC} ${LD_SWITCHES} ${TEST_SAOBJS} ${STATIC_LIBS} \
	    -o $@ || (rm -f $@; exit 1)

tkTest.o: ${TK_SRC}/generic/tkTest.c
	${CC} -c ${CC_SWITCHES} ${TK_SRC}/generic/tkTest.c

tkSquare.o: ${TK_SRC}/generic/tkSquare.c
	${CC} -c ${CC_SWITCHES} ${TK_SRC}/generic/tkSquare.c

tkXtest.o: ${TKX_GENERIC_DIR}/tkXtest.c
	${CC} -c ${CC_SWITCHES} ${TKX_GENERIC_DIR}/tkXtest.c

#------------------------------------------------------------------------------
# If test directory in not in build tree, copy it from the source tree.
#
${bldbasedir}/tk/tests:
	mkdir ${bldbasedir}/tk/tests
	cp ${srcbasedir}/tk/tests/*.test ${bldbasedir}/tk/tests

#------------------------------------------------------------------------------
# Run the UCB tests with wishx.

test: all
	echo "cd ${TK_SRC}/tests; source all; exit" | \
	    ./runtest -geometry +0+0

test.static: all
	echo "cd ${TK_SRC}/tests; source all; exit" | \
	    ./runtest.static -geometry +0+0

test.verbose: all
	echo "cd ${TK_SRC}/tests; set VERBOSE 1; source all; exit" | \
	    ./runtest -geometry +0+0

#------------------------------------------------------------------------------
# Build help for Tk.  These files are normally part of the distribution and
# not rebuilt by users.
#
buildhelp:
	rm -rf ${HELP_DIR} help
	mkdir ${HELP_DIR}
	${BLDMANHELP} ${TK_SRC}/doc ${srcbasedir}/unix/tools/tkmanpages \
	    ${HELP_DIR} Tk.brf

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

install: install-exec install-runtime
	${INSTCOPY} ${TKX_UNIX_SRC_DIR}/tkXAppInit.c \
	    ${INSTALL_ROOT}${TKX_INST_RUNTIME}
	${INSTCOPY} ${HELP_DIR} ${INSTALL_ROOT}${TKX_INST_RUNTIME}/help

install-runtime:
	${INSTCOPY} tkx.tcl ${INSTALL_ROOT}${TKX_INST_RUNTIME}

install-exec:
	${INSTCOPY} wishx ${INSTALL_ROOT}${TKX_INST_BIN}
	${STRIP} ${INSTALL_ROOT}${TKX_INST_BIN}/wishx
	if test "Xlibtkx8.0.3.a" != "X"; then \
	    ${INSTCOPY} ${TKX_STLIB_NAME} ${INSTALL_ROOT}${TKX_INST_LIB}; \
	    ${RANLIB} ${INSTALL_ROOT}${TKX_INST_LIB}/${TKX_STLIB_NAME}; \
	fi
	${INSTCOPY} tkxConfig.sh ${INSTALL_ROOT}${TKX_INST_LIB}
	if test "YES" = "YES"; then \
	    ${INSTCOPY} ${TKX_SHLIB_NAME} ${INSTALL_ROOT}${TKX_INST_LIB} ;\
	    ${INSTCOPY} pkgIndex.tcl ${INSTALL_ROOT}${TKX_EXEC_RUNTIME} ;\
	fi
	${INSTCOPY} tclhelp ${INSTALL_ROOT}${TKX_INST_BIN}

#------------------------------------------------------------------------------
config:
	(cd ../../unix && configure)

#------------------------------------------------------------------------------
clean:
	-rm -f tkXAppInit.o ${OBJS} ${SOBJS} ${TEST_OBJS} ${TEST_SAOBJS}
	-rm -f wishx wishx.static wishx.standalone
	-rm -f tktest tktest.static tktest.standalone tkXAppInitSA.o
	-rm -f ${TKX_STLIB_NAME} ${TKX_SHLIB_NAME} 
	-rm -f ${STANDALONE_SRCS} ${STANDALONE_OBJS} tkXAppInitSA.c
	-rm -rf tkx.tcl tclhelp help help.tmp

#------------------------------------------------------------------------------
# Restore to the distributed state.

distclean: clean
	-rm -f Makefile tkxConfig.sh pkgIndex.tcl
	-rm -f runtest runtest.static runtest.standalone

# Disable Sun's parallel make, it doesn't get the dependencies right.
.NO_PARALLEL:


#==============================================================================
# Repetitive rules below:

#------------------------------------------------------------------------------
# Dependencies for generating objects.
#
tkXinit.o: ${TKX_GENERIC_DIR}/tkXinit.c Makefile
	${CC} -c ${CC_SWITCHES} -DTKX_LIBRARY=\"${TKX_INST_RUNTIME}\" \
	  ${TKX_GENERIC_DIR}/tkXinit.c

tkXshell.o: ${TKX_GENERIC_DIR}/tkXshell.c
	${CC} -c ${CC_SWITCHES} ${TKX_GENERIC_DIR}/tkXshell.c

tkXAppInit.o: ${TKX_UNIX_SRC_DIR}/tkXAppInit.c
	${CC} -c ${CC_SWITCHES} ${TKX_UNIX_SRC_DIR}/tkXAppInit.c

tkXinitSA.o: ${TKX_GENERIC_DIR}/tkXinitSA.c ${STANDALONE_SRCS}
	${CC} -c ${CC_SWITCHES} ${TKX_GENERIC_DIR}/tkXinitSA.c

tkXinitDSA.o: ${TKX_GENERIC_DIR}/tkXinitDSA.c Makefile
	${CC} -c ${CC_SWITCHES} ${TKX_GENERIC_DIR}/tkXinitDSA.c

tkXAppInitSA.c: ${TKX_UNIX_SRC_DIR}/tkXAppInit.c Makefile
	rm -f tkXinitSA.c
	sed -e s/Tclx_Init/Tclx_InitStandAlone/ \
	    -e s/Tcl_Init/Tcl_InitStandAlone/ \
	    -e s/Tkx_Init/Tkx_InitStandAlone/ \
	    -e s/Tk_Init/Tk_InitStandAlone/ \
	    ${TKX_UNIX_SRC_DIR}/tkXAppInit.c >tkXAppInitSA.c

tkXunixTest.o: ${TKX_UNIX_SRC_DIR}/tkXunixTest.c
	${CC} -c ${CC_SWITCHES} ${TKX_UNIX_SRC_DIR}/tkXunixTest.c

tkXunixTestDA.o: ${TKX_UNIX_SRC_DIR}/tkXunixTestSA.c
	${CC} -c ${CC_SWITCHES} ${TKX_UNIX_SRC_DIR}/tkXunixTestSA.c

tkXunixTestSA.c: ${TKX_UNIX_SRC_DIR}/tkXunixTest.c Makefile
	rm -f tkXinitSA.c
	sed -e s/Tclx_Init/Tclx_InitStandAlone/ \
	    -e s/Tcl_Init/Tcl_InitStandAlone/ \
	    -e s/Tkx_Init/Tkx_InitStandAlone/ \
	    -e s/Tk_Init/Tk_InitStandAlone/ \
	    ${TKX_UNIX_SRC_DIR}/tkXunixTest.c >tkXunixTestSA.c


#------------------------------------------------------------------------------
# Dependencies for generating objects (position independant versions).
#
tkXinit..o: ${TKX_GENERIC_DIR}/tkXinit.c Makefile
	@:
	${CC} -c ${CC_SHOBJ_FLAG} ${CC_SWITCHES} ${TCL_SHLIB_CFLAGS} \
	    -DTKX_LIBRARY=\"${TKX_INST_RUNTIME}\" ${TKX_GENERIC_DIR}/tkXinit.c
	@:

tkXinitDSA..o: ${TKX_GENERIC_DIR}/tkXinitDSA.c Makefile
	@:
	${CC} -c ${CC_SHOBJ_FLAG} ${CC_SWITCHES} ${TCL_SHLIB_CFLAGS} \
	    ${TKX_GENERIC_DIR}/tkXinitDSA.c
	@:

tkXshell..o: ${TKX_GENERIC_DIR}/tkXshell.c
	@:
	${CC} -c ${CC_SHOBJ_FLAG} ${CC_SWITCHES} ${TCL_SHLIB_CFLAGS} \
	    ${TKX_GENERIC_DIR}/tkXshell.c
	@:

#------------------------------------------------------------------------------
# Rules to build standalone .c files using tcl2c.  Explicit rules are required,
# as not all makes can handle cross-directory rules.

tkx.c: ${RUNTIME_DIR}/tkx.tcl
	${TCL2C} -o $@ -a -n $@ $<
hello.c: ${TKX_GENERIC_DIR}/hello.tcl
	${TCL2C} -o $@ -tkx $<
.c.o:
	${CC} -c ${CC_SWITCHES} $<
