#
# Copyright (C) 1990, 1993 by Ted Kim.
#
# This software work was developed at UCLA with support in part from
# DARPA Contract F29601-87-C-0072.
#

#
# Makefile for XWIP
#

#	DOCDIR = manual installation directory
#	XBIN = X11 binary directory
#	XINCLUDE = X11 include file directory
DOCDIR = /u/w1/tek/lib
XBIN = /usr/local/bin
XINCLUDE = /usr/include/X11
XLIBDIR= /usr/local/lib/X11
DISTDIR = ../dist

CFLAGS = -O -UR4 -DXLIBDIR=\"$(XLIBDIR)\" -I$(XINCLUDE)
LDFLAGS =
STATIC =

CC = cc
COMPRESS = compress
CP = cp
DVIPS = dvips
INSTALL = install -c
LATEX = latex
LD = ld
LPR = lpr
MAKEDEPEND = makedepend
MAKEINDEX = makeindex
MV = mv
PLINT = plint
RM = rm
SHAR2 = shar2
SUM = sum
TAR = tar

#	DOCS = documents to generate and install
#	DUMPS = prolog dumps to install
DUMPS = spx qpx
PROLOGFILES = xwip.o cfont.pl xatom.pl
DEFINES = attrib.h conn.h dl.h ff.h
SRCS = cfconst.c cftable.c color.c conn.c cursor.c dl.c event.c ff.c gc.c \
	graphics.c image.c keyboard.c misc.c pixmap.c pointer.c prop.c res.c \
	text.c window.c wm.c
OBJS = ff.o dl.o conn.o window.o prop.o pixmap.o color.o gc.o graphics.o \
	image.o text.o cursor.o pointer.o keyboard.o wm.o event.o res.o misc.o 
DOCS = xwip.ps xwip.dvi
DOCFILES = cfont.tex xwip.aux xwip.ind xwip.toc TAGS
FILES = xwip.idx xwip.ilg xwip1.log xwip2.log
UTILS = cfconst xaconst cftable
UOBJS = cfconst.o xaconst.o cftable.o

default: programs

all:	programs document

programs: $(PROLOGFILES)
	@echo
	@echo "prolog object generation done"
	@echo

xwip.o:	$(OBJS)
	rm -f xwip.o
	$(LD) $(STATIC) -r -o xwip.o $(OBJS)
cfont.pl: cfconst
	./cfconst < $(XINCLUDE)/cursorfont.h > cfont.pl
cfconst: cfconst.o
	$(CC) -o cfconst cfconst.o
xatom.pl: xaconst
	./xaconst < $(XINCLUDE)/Xatom.h > xatom.pl
xaconst: xaconst.o
	$(CC) -o xaconst xaconst.o

document: $(DOCS)
	@echo
	@echo "document generation done"
	@echo

# rules may run latex twice to get refs right
xwip.ps: xwip.dvi
	$(DVIPS) xwip > xwip.ps
# alternate rule = xwip.dvi: cfont.tex xwip.ind xwip.tex
xwip.dvi: cfont.tex xwip.aux xwip.ind xwip.tex xwip.toc
	$(LATEX) '\batchmode' '\input xwip.tex'
	$(MV) xwip.log xwip2.log
cfont.tex: cftable
	./cftable < $(XINCLUDE)/cursorfont.h > cfont.tex
cftable: cftable.o
	$(CC) -o cftable cftable.o
xwip.ind: xwip.idx
	$(MAKEINDEX) xwip.idx
# alternate rule = xwip.idx: xwip.tex
xwip.aux + xwip.idx + xwip.toc: xwip.tex
	$(LATEX) '\batchmode' '\input xwip.tex' 
	$(MV) xwip.log xwip1.log
index:
	$(MAKEINDEX) xwip.idx
print:	xwip.ps
	$(LPR) xwip.ps
	
clean:	
	$(RM) -f *~ $(UTILS) $(UOBJS)
	$(RM) -f $(DUMPS) $(PROLOGFILES) $(OBJS)
	$(RM) -f $(DOCS) $(DOCFILES) $(FILES)
# save space, but don't kill any final products
dusty:
	$(RM) -f *~ $(UTILS) $(UOBJS) $(OBJS) $(FILES)
depend:
	$(MAKEDEPEND) -s "# DO NOT DELETE" -- $(DEFINES) -- $(SRCS)	
tags:
	etags -tw *.[ch] 
install:
	$(INSTALL) -m 755 $(DUMPS) $(XBIN)
	$(INSTALL) -m 444 $(DOCS) $(DOCDIR)
orig:
	$(CP) Makefile.dist Makefile
plint:
	$(PLINT) *.pl *.c > plint.out
dist:	orig xwip.ps
	$(RM) -f *~ $(UTILS) $(UOBJS)
	$(RM) -f $(DUMPS) $(PROLOGFILES) $(OBJS) 
	$(RM) -f $(DOCFILES) $(FILES)
	$(TAR) cf $(DISTDIR)/xwip.tar .
	(cd $(DISTDIR); \
	 $(COMPRESS) xwip.tar; \
	 $(SUM) xwip.tar.Z > checksum; \
	 $(SHAR2) -v -s -b -D -c -f -omsg -l49 xwip.tar.Z)

# DO NOT DELETE THIS LINE -- make depend depends on it.

# predefined dependencies for people without makedepend

ff.o: dl.h ff.h attrib.h
dl.o: dl.h

conn.o: dl.h conn.h ff.h
window.o: dl.h conn.h ff.h attrib.h
prop.o: dl.h conn.h ff.h
pixmap.o: dl.h conn.h ff.h attrib.h
color.o: dl.h conn.h ff.h
gc.o: dl.h conn.h ff.h attrib.h
graphics.o: dl.h conn.h ff.h
image.o: dl.h conn.h ff.h
text.o: dl.h conn.h ff.h
cursor.o: dl.h conn.h ff.h
pointer.o: dl.h conn.h ff.h attrib.h
keyboard.o: dl.h conn.h ff.h attrib.h
wm.o: dl.h conn.h ff.h
event.o: dl.h conn.h ff.h attrib.h
res.o: dl.h conn.h ff.h attrib.h
misc.o: dl.h conn.h ff.h attrib.h

cfconst.o:
xaconst.o:
cftable.o:

#
# eof
#
