#
# This Makefile will regenerate the mx and tx programs, plus the
# utilities txcmd and txinfo, in versions suitable for use on UNIX
# systems.  Before invoking the "make" program, change both the
# MX_LIB_DIR and TX_LIB_DIR definitions below to contain the absolute
# path name for this directory (or move the files default.tx, default.mx,
# bindings.doc, and tutorial1 to some other library directory and
# change MX_LIB_DIR and TX_LIB_DIR to hold the absolute path name of that
# directory).  You'll also need to change LIBS to point to your copy
# of the X11 library.  This Makefile assumes that the Sx and Tcl
# libraries are in the subdirectories sx and tcl, respectively.  Change
# the SX_LIB and TCL_LIB definitions below if they're not.  If you are
# running on a system that has an include file <alloca.h> (check
# /usr/include to be sure) then delete or rename the file alloca.h in
# this directory.  If you're running under HP-UX, change some of the
# flags to alternate forms commented out below.
#

TCL_LIB = tcl
SX_LIB  = sx
CFLAGS = -g -I. -I$(TCL_LIB) -I$(SX_LIB) -DMX_VERSION=\"2.4\" \
	-DTX_VERSION=\"2.4\" \
	-DMX_LIB_DIR=\"/sprite2/users/ouster/mx\" \
	-DTX_LIB_DIR=\"/sprite2/users/ouster/mx\"

LIBS = $(TCL_LIB)/tcl.a $(SX_LIB)/sx.a

LDLIBS = -lX11
# if using HP-UX, use this: LDLIBS = -lX11 -lPW -lBSD

OBJS = mxCmdAM.o mxCmdNR.o mxCmdSZ.o mxCmdUtils.o mxDisplay.o \
	mxEntry.o mxFile.o mxHighlight.o mxHistory.o mxIndent.o \
	mxSearch.o mxSelect.o mxUndo.o mxWindow.o cmdPub.o \
	Proc_Detach.o option.o regex.o

MXOBJS = ${OBJS} mx.o

TXOBJS = ${OBJS} Bit_FindFirstSet.o fsDispatch.o setenv.o \
	Time_Add.o Time_Subtract.o tx.o txUnix.o txUtmp.o \
	txWindow.o txCmdAZ.o

all:	mx tx txcmd txinfo

mx:	${MXOBJS} ${LIBS}
	${CC} ${CFLAGS} ${MXOBJS} ${LIBS} ${LDLIBS} -o mx

tx:	${TXOBJS} ${LIBS}
	${CC} ${CFLAGS} ${TXOBJS} ${LIBS} ${LDLIBS} -o tx

txcmd:  txcmd.o
	${CC} ${CFLAGS} txcmd.o -o txcmd

txinfo:  txinfo.o
	${CC} ${CFLAGS} txinfo.o -o txinfo

$(TCL_LIB)/tcl.a:
	cd tcl; make

$(SX_LIB)/sx.a:
	cd sx; make

clean:
	rm -f ${OBJS} ${MXOBJS} ${TXOBJS} txcmd.o txinfo.o mx tx txcmd txinfo
	cd tcl; make clean
	cd sx; make clean
