#
#	Xtroff ImakeFile
#
#	make [all]	compiles the programs in this directory, and the
#			relevant subdirectories - fontstuff are font
#			manipulation programs, xfonts has the stuff for
#			by piping the 75dpi bdf through awk scripts
#			to remap it to PostScript collation sequences,
#			and generating compressed snf.
#	make install	makes and installs the programs
#	make vfonts	makes and installs scaled and converted vfonts
#			for the devsun device. Not strictly necessary, but
#			useful for large fonts. xpic can use them too.
#	make imfonts	Scales and converts Imagen RST fonts if you have them
#			for the Imagen device. Good if you have them.
#	make devsun	Installs the devsun width info and runs makedev
#			Do this if you install the vfonts
#	make devpsc	Installs the devpsc width info and runs makedev
#			If you already have a devpsc device, from 
#			Transcript(tm), or some other ditroff to
#			PostScript(tm) translation package,
#			then you probably don't need this.
#	make devX11	Installs the devX11 width info and runs makedev
#
#	If you want to generate a Makefile for Suntools suntroff instead
#	of xtroff, uncomment the following definition.
#
/* #define SUNTROFF */
#
#	For lots of debugging info, especially FONTDEBUG.
#          DEBUG = -DFONTDEBUG -DWINDOWDEBUG -DTYPEDEBUG -DDEBUG
          DEBUG =
#    CDEBUGFLAGS = -g

# 	defining -DNOADJUST excludes some experimental code which tries to 
#	adjust character positions to make the X font match the troff 
#	font more closely. It may look better if you don't define it - 
#	ligatures, especially 'fi' come out wrong at present if it is
#	undefined.
# 	-DFASTARCS does not use an ellipse drawing algorithm that approximates
# 	ellipses as polygons. Define it if your server draws arcs fast.
#	(Leave it undefined on Suns, uVaxen, anything using the R3 sample
#	server miarc.c code)
#	-DBEZERKELYISM allows the parser to understand the ditroff
#	sequences emitted by Berkeley ditroff. (May work, I don't have
#	Berkeley ditroff to test it)
# 	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 adapted from the R2 version Chris Peterson's xman program.
        DEFINES = -DFONTDIR=\"${WIDTHDIR}\" -DBITDIR=\"${SUNTROFF_FONTS}\" \
		  $(DEBUG) -DNOADJUST $(SUNTOOLS)

       INCLUDES = -I./bitmaps $(DEV_INCLUDES) -I$(INCDIR) -I$(INCROOT)
        MATHLIB = -lm

#ifndef SUNTROFF
       PROGRAMS = xtroff
      PREVIEWER = xtroff
             FC = bdftosnf
        WINDOWS = xwindows	/* Source file for windows code */
        XTSTUFF = XtStuff/libXtStuff.a
LOCAL_LIBRARIES = $(XTSTUFF) $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
 SUNTROFF_FONTS = $(FONTDIR)/xtroff
   DEV_INCLUDES = -I./XtStuff
    DEV_SUBDIRS = XtStuff # devX11
#else
       PROGRAMS = suntroff
      PREVIEWER = suntroff
             FC = cat
        DEV_LIBS = -lsuntool -lsunwindow -lpixrect
        WINDOWS = sunwindows
       SUNTOOLS = -DSUNTOOLS
 SUNTROFF_FONTS = /local/lib/suntroff
#endif

  SYS_LIBRARIES = $(DEV_LIBS) $(MATHLIB)
           OBJS = $(WINDOWS).o suntroff.o parse.o font.o draw.o \
		  fixpoint.o curves.o arc.o xfont.o
           SRCS = $(WINDOWS).c suntroff.c parse.c font.c draw.c \
		  fixpoint.c curves.c arc.c xfont.c

.SUFFIXES: .manX .man

.manX.man:
	rm -f $*.man
	sed -e 's?WIDTHDIR?$(WIDTHDIR)?g' -e 's?XAPPLOADDIR?$(XAPPLOADDIR)?g' \
	    -e 's?FONTDIR?$(SUNTROFF_FONTS)?g' $*.manX > $*.man

#define IHaveSubdirs
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'

SUBDIRS = $(DEV_SUBDIRS)

MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))

ComplexProgramTarget($(PREVIEWER))

#ifndef SUNTROFF
NamedMakeSubdirs(XtStuff/libXtStuff.a,XtStuff)
InstallAppDefaults(XTroff)
#endif

#	Xtroff doesn't need (more important, doesn't use properly) the 
#	devsun fonts, which are still here for the Suntools version.
#	You may want to do a 'make vfonts devsun' if you use xpic, which
#	can use those fonts too. (They are nice and large, for making slides)

#	The following defines might need to be changed for suntroff
#	or if you're making the devsun fonts anyway.  The VFONTS
#	definition points towards the directory containing the Sun
#	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 xtroff will use the
#	X fonts described above for.
#
#	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. 


         VFONTS = /usr/lib/vfont
       RSTFONTS = /local/lib/imagen/fonts/rst
      RSTDEVICE = imp	#imagen
      SUNDEVICE = sun	#versatec - other printers like lw.
#ifdef SUNTROFF
       WIDTHDIR = /local/share/troff
#else
       WIDTHDIR = $(LIBDIR)/troff
#endif
        MAKEDEV = makedev

#	Percent MUST be two digits
#	For the imagen, percent is 120 / 300, i.e 40. 
     RSTPERCENT = 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.
     SUNPERCENT = 50

vfonts::
		-mkdir $(SUNTROFF_FONTS)
		cd fontstuff; make $(MFLAGS) CDEBUGFLAGS="$(CDEBUGFLAGS)" \
			VFONTS=$(VFONTS) \
			RSTFONTS=$(RSTFONTS) PREVIEWER=$(PREVIEWER) \
			FC=$(FC) SUNPERCENT=$(SUNPERCENT) \
			RSTPERCENT=$(RSTPERCENT) \
			SUNTROFF_FONTS=$(SUNTROFF_FONTS)/dev$(SUNDEVICE) \
			RSTDEVICE=dev$(RSTDEVICE) SUNDEVICE=dev$(SUNDEVICE) \
			sunfonts

imfonts::
		-mkdir $(SUNTROFF_FONTS)
		cd fontstuff; make $(MFLAGS) CDEBUGFLAGS="$(CDEBUGFLAGS)" \
			VFONTS=$(VFONTS) \
			RSTFONTS=$(RSTFONTS) PREVIEWER=$(PREVIEWER) \
			FC=$(FC) SUNPERCENT=$(SUNPERCENT) \
			RSTPERCENT=$(RSTPERCENT) \
			SUNTROFF_FONTS=$(SUNTROFF_FONTS)/dev$(RSTDEVICE) \
			RSTDEVICE=dev$(RSTDEVICE) SUNDEVICE=dev$(SUNDEVICE) \
			rstfonts

devsun::
		-mkdir ${WIDTHDIR}/dev$(SUNDEVICE) ;\
		cp devsun/DESC devsun/? devsun/?? ${WIDTHDIR}/dev$(SUNDEVICE); \
		cd ${WIDTHDIR}/dev$(SUNDEVICE);  \
		${MAKEDEV} DESC;	\
		rm -f [a-zA-Z] [a-zA-Z][a-zA-Z]

Makefiles::
	@echo 'Making Makefiles in devpsc...' ; \
	$(MAKE) subdirMakefiles NEWTOP=../ MAKEFILE_SUBDIR=devpsc

devpsc::
		cd devpsc; make $(MFLAGS) MAKEDEV=$(MAKEDEV) \
			WIDTHDIR=$(WIDTHDIR) install

clean::
		rm -f xtroff.man
		cd devpsc; make clean

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

#lint:
#	cd XtStuff; make llib-lXtStuff.ln
#	lint -abz $(SRCS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES) \
#		XtStuff/llib-lXtStuff.ln -lXaw -lXt -lX11 -lm $(LINTFLAGS)
