#
# tksrc/Makefile.in --
#
# Makefile to build a wish with Extended Tcl (wishx).
# 
#------------------------------------------------------------------------------
# Copyright 1992-1993 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 3.1 1993/11/25 03:21:14 markd Exp $
#------------------------------------------------------------------------------
#
SHELL = /bin/sh

#------------------------------------------------------------------------------
# Autoconfig defines that can be overridden in Config.mk

CC          = gcc
RANLIB      = ranlib
MCS         = echo
srcdir      = .
srcbasedir  = ..
bldbasedir  = /src/tclx7.3a
VPATH       = .
prefix      = /usr/local
exec_prefix = /usr/local
ARCH        = 
XINCLUDES   = 
LIBS        = 
XLIBSW      = -lc -lX -lsys

#------------------------------------------------------------------------------
# Include user-editable defines.

include ../config.mk

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

LIBTK.A      = ${TK_UCB_LIB}/libtk.a
LIBTKX.A     = libtkx.a
WISHX        = wishx.exe
APPINIT      = tkXAppInit.c
SYSLIBS      = 

LIBTCL.A  = ${TCL_UCB_LIB}/libtcl.a
LIBTCLX.A = ../src/libtclx.a

# 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 Tcl
# library if it was brought in.

LDLIBS = ${LIBTKX.A} ${LIBTK.A} ${XLIBSW} ${LIBTCLX.A} ${LIBTCL.A} -lm ${LIBS}

CC_FLAGS = ${CFLAGS} -I${srcbasedir}/src -I. -I${TK_UCB_SRC} -I${TCL_UCB_SRC}
 
.c.o:
	${CC} ${CC_FLAGS} -c $<

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

OBJS=tkXinit.o   tkXmain.o  tkXshell.o

UCBOBJS=tkWindow.o

#------------------------------------------------------------------------------
# Compile the TkX library and link wishx.  If the link fails, purge
# the executable, as some systems leave invalid executables around.

all: made.tmp ${WISHX} ${APPINIT} ${SYSLIBS} ${TCL_PLUS_BUILD}

${WISHX}: tkXAppInit.o ${LIBTKX.A} ${LIBTK.A} ${LIBTCLX.A} ${LIBTCL.A} made.tmp
	${CC} -c ${CC_FLAGS} tkXAppInit.c
	${CC} tkXAppInit.o ${LDLIBS} ${XLDLIBS} \
	    -o wishx 
	makego32 wishx
	del wishx

made.tmp ${LIBTKX.A}: ${OBJS} ${UCBOBJS}
	${AR} cr ${LIBTKX.A} ${OBJS} ${UCBOBJS}
	${RANLIB} ${LIBTKX.A}
	touch made.tmp

#tkWindow.o: tkWindow.c
#	${CC} -c -I${TK_UCB_SRC} ${CC_FLAGS} ${DEFS} \
#	    -DTK_LIBRARY=\"$TK_MASTER/3_6a\" tkWindow.c

tkWindow.c: ${TK_UCB_SRC}/tkWindow.c
	rm -f tkWindow.c
	echo #include "tclXconfig.h" >tkWindow.c
	cat ${TK_UCB_SRC}/tkWindow.c  >>tkWindow.c

#tkXinit.o: tkXinit.c
#	${CC} -c ${CC_FLAGS} -DTK_MASTERDIR=\"$TK_MASTERDIR/3_6a\" \
#            ${srcdir}/tkXinit.c

#${APPINIT}: tkXAppInit.c
#	rm -f ${APPINIT}
#	cp ${srcdir}/tkXAppInit.c ${APPINIT}

#${SYSLIBS}: SYSLIBS
#	rm -f ${SYSLIBS}
#	cp SYSLIBS ${SYSLIBS}

#------------------------------------------------------------------------------
# Make sure tkXmain.c compiles and links with C++.


#------------------------------------------------------------------------------
clean:
	-rm -f made.tmp  libtkx.a
	-rm -f *.o ${WISHX} wishx++

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

#distclean: clean
#	rm -f Makefile SYSLIBS
