#
#	socket based version of libXIpc.a
#
CC=		cc
CFLAGS=		-g $(INCLUDE)
OBJS=		XIpc.o XIpcServer.o XIpcClient.o XIpcCombined.o
HEADERFILES=	XIpc.h XIpcClient.h XIpcServer.h
XIPCLIB=	libXIpc.a

#
#	set DIR to the location of the HP widget set for picking up
#	include files for Xt based applications.
#
DIR=		/usr/local/src/lib/X.V11R4/contrib/toolkits/Xw
XLIBS=		$(DIR)/lib/libXw.a -lX11
INCLUDE=	-I$(DIR)/Xw -I$(DIR)
XTOBJS=		XtAddXIpc.o XtHdXIpcTCl.o

#
#	libraries
#
LIBS=

all:	$(XIPCLIB)

#
#	main library
#
$(XIPCLIB):	$(OBJS) $(XTOBJS)
	-rm -f $(XIPCLIB)
	ar rcv $(XIPCLIB) $(OBJS) $(XTOBJS)
	ranlib $(XIPCLIB)

#
#	sample servers and clients - xt tests simple Xt handlers
#
test_suite:	xs xc

xs:	xs.o $(XIPCLIB)
	cc -o xs xs.o $(XIPCLIB) $(LIBS)

xc:	xc.o $(XIPCLIB)
	cc -o xc xc.o $(XIPCLIB) $(LIBS)

xc2:	xc2.o $(XIPCLIB)
	cc -o xc2 xc2.o $(XIPCLIB) $(LIBS)


xt_test_suite:	xt_xs xt_xc


xt_xs:	xt_xs.o $(XIPCLIB)
	cc -o xt_xs xt_xs.o $(XIPCLIB) $(LIBS)

xt_xc:	xt_xc.o $(XIPCLIB)
	cc -o xt_xc xt_xc.o $(XIPCLIB) $(LIBS) \
		$(DIR)/Xw/libXw.a -lXt -lX11

#
#	akcl lisp support
#
akcl.xipc:	XIpcAKCL.o $(XIPCLIB)
	-rm -f akcl.xipc
	-(echo '(si:faslink "XIpcAKCL.o" "$(XIPCLIB) -lX11 -lc")'; \
	  echo '(save "akcl.xipc")') | akcl
	ls -l akcl.xipc

XIpcAKCL.o:	XIpcDefs.lsp XIpcAKCL.lsp
	-rm -f XIpcAKCL.o
	-(echo '(compile-file "XIpcAKCL")'; echo '(bye)') | akcl
	ls -l XIpcAKCL.o

XIpcDefs.lsp:	$(HEADERFILES)
	-rm -f XIpcDefs.lsp
	-cat $(HEADERFILES) | grep "#define" | \
		egrep "XIPC_MONITOR|XIPC_SERVER|XIPC_CLIENT" | \
		sed -e "s;/\*.*\*/;;" | sed -e "s/#define/(defconstant/" | \
		sed -e "s/$$/)/" | sed -e "s/_/-/g" > XIpcDefs.lsp
	ls -l XIpcDefs.lsp

#
#	house keeping
#
lint:
	-lint xs.c XIpcServer.c XIpc.c
	-lint xc.c XIpcClient.c XIpc.c

clean:
	-rm -f xs xc xt_xs xt_xc *.o $(XIPCLIB) XIpcDefs.lsp akcl.xipc
