#
#	Xtroff ImakeFile
#
#	make [all]	compiles the programs in this directory 
#	make install	makes and installs everything, including the fonts
#			and width tables for the default sun device. Yuk.
#	make xfonts	makes and installs the scaled (& converted) fonts
#			for X Windows
#	make width	Installs the devsun width info and runs makedev
#	make clean	cleans this directory
#	
#	The following two defines might need to be changed.  The VFONTS
#	definition points towards the directory containing the Sun modified
#	Berkeley versatec font catalog.  These bits of these fonts are used
#	as the default screen font.  See the file fontstuff/MakeSunFonts for
#	more details.  
#	
#	The RSTFONTS definition points to the RST (Imagen) font
#	files.  If you don't have an Imagen printer then you won't need to
#	worry about these bits.  If you do have an Imagen printer then you
#	may want to see the file fontstuff/MakeImagenFonts for a way of getting
#	more accurate bits on the screen.  If you don't want to worry about
#	the fonts (and I don't blame you) then SunTroff will use the
#	Versatec fonts described above.
#
#	The SUNTROFF_FONTS points to the directory where the fonts
#	sit. It has subdirectories of the form 'dev'$DEVICE for each
#	typesetter's fonts - devsun is the default for the scaled
#	versatec fonts, devimp is for imagen, etc. 
#	Make sure you comment out the "compressdir" for suntroff, or if your
#	X server is not able to load compressed fonts(most can).
VFONTS=/usr/lib/vfont
RSTFONTS=/usr/uturing/ron/rst
# Xfonts go here - wish the X11 server could read vfonts like 
# the X10 server used to.
SUNTROFF_FONTS=/local/share/X11/fonts
#DEVICE=imp	#imagen
DEVICE=sun	#versatec - other printers like lw.
WIDTHDIR=/local/share/troff
MAKEDEV=/local/src/v8troff/troff/makedev
#	Percent MUST be two digits
#	For the imagen, percent is 120 / 300, i.e 40. 
#PERCENT=40
#	For versatec fonts, which we use for laserwriters etc., 
#	percent should be 120/200. i.e. 66. We use 50 for a better 
#	error margin.
PERCENT=50
#	For lots of debugging info, especially FONTDEBUG.
#DEBUG=-DFONTDEBUG -DWINDOWDEBUG -DTYPEDEBUG -DDEBUG
#CDEBUGFLAGS=-g
DEBUG=
CDEBUGFLAGS=-O

# 	Define -DNOADJUST is you don't want the adjustment of character 
#	positions to make the X font match the troff font more closely. 
#	It looks better if you don't define it, but if you have exact fonts, 
#	or are experimenting...
# 	We have Menu/Menu.o, checkitem/CheckItem.o and menuitem/MenuItem.o 
# 	installed as XtStuff - In fact, we keep all three (Menu. checkitem, 
#	menuitem) in one directory to make matters simpler. 
#	Window is straight from Chris Peterson's xman program.
CFLAGS = $(CDEBUGFLAGS) -DFONTDIR=\"${WIDTHDIR}\" \
	-DBITDIR=\"${SUNTROFF_FONTS}\" $(DEBUG) \
	-I./bitmaps -I./XtStuff -DNOADJUST
# These should be defined in an Imake.tmpl - except that the 
# normal Imake.tmpl insists on these being compiled in the 
# X directory tree.
XAWLIB=$(USRLIBDIR)/libXaw.a
XTOOLLIB=$(USRLIBDIR)/libXt.a
XLIB=$(USRLIBDIR)/libX11.a
MATHLIB=-lm

FC = fc
XTSTUFF = 	XtStuff/libXtStuff.a
OBJS1 =		xwindows.o suntroff.o parse.o font.o draw.o \
		fixpoint.o curves.o
SRCS1 =		xwindows.c suntroff.c parse.c font.c draw.c \
		fixpoint.c curves.c
PROGRAMS = 	xtroff
PREVIEWER = 	xtroff

ComplexProgramTarget_1(xtroff,$(XTSTUFF) $(XAWLIB) $(XTOOLLIB) $(XLIB),$(MATHLIB))

$(XTSTUFF):
		cd XtStuff; make $(MFLAGS)			

xfonts:
		-mkdir $(SUNTROFF_FONTS)
		cd fontstuff; make $(MFLAGS) CFLAGS="$(CFLAGS)" \
			VFONTS=$(VFONTS) \
			RSTFONTS=$(RSTFONTS) PREVIEWER=$(PREVIEWER) \
			FC=$(FC) PERCENT=$(PERCENT) \
			SUNTROFF_FONTS=$(SUNTROFF_FONTS) \
			DEVICE=dev$(DEVICE)
#		compressdir $(SUNTROFF_FONTS)

width:
		cp -r devsun ${WIDTHDIR};
		cd ${WIDTHDIR}/devsun;  \
		${MAKEDEV} DESC;	\
		rm -f [a-zA-Z] [a-zA-Z][a-zA-Z]


install::	xfonts width

clean::
		cd XtStuff ; make $(MFLAGS) clean
		cd fontstuff ; make $(MFLAGS) clean

depend::
		cd XtStuff; make $(MFLAGS) depend

Makefile::
		cd XtStuff ; make Makefile

tar:
		make clean
		-rm /tmp/xtroff.tar.Z
		cd ..; tar cvfX - xtroff/ExcludeFiles ./xtroff \
			| compress > /tmp/xtroff.tar.Z 

lint:
	lint -abz $(SRCS) $(LDFLAGS) -lXaw -lXt -lX11 -lm $(LINTFLAGS)
