# Makefile for xdvik --kb@mail.tug.org. Public domain.
version = 20a

ac_include ../make/paths.make
ac_include ../make/common.make
ac_include ../make/programs.make

# Make `#include <X11/...>' and `-lX...' work.
# This matches web2c (needed only for Metafont).
x_cppflags = @X_CFLAGS@
x_ldflags = @X_LIBS@
x_pre_libs = @X_PRE_LIBS@
x_extra_libs = @X_EXTRA_LIBS@
x_tool_libs = @x_tool_libs@
x_ext_lib = @x_ext_lib@
# Follow the library order used in X11R6 itself:
#   -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11 (some may not be present).
x_link = $(x_ldflags) $(x_tool_libs) $(x_pre_libs) $(x_ext_lib) -lX11 $(x_extra_libs)

# Extra xdvi-specific compiler options.
ps_def = @PS_DEF@
prog_cflags = $(ps_def) $(x_cppflags)

# We don't use alloca ourselves, but the X library might, and this way
# we avoid buggy versions in -lPW or -lucb.
ALLOCA = alloca.o

objects = xdvi.o dvi_draw.o dvi_init.o events.o font-open.o gf.o pk.o \
  psdps.o psgs.o psheader.o psnews.o special.o util.o vf.o sfDir.o \
  sfDraw.o sfPath.o sfSelFile.o hypertex.o mime.o wwwfetch.o \
  $(ALLOCA)

program = xdvi
programs = gsftopk $(program)

default all: $(programs) xdvi.1 gsftopk.1

$(program): $(kpathsea) $(objects)
	$(kpathsea_link) $(objects) $(x_link) $(LOADLIBES)
gsftopk: $(kpathsea) gsftopk.o
	$(kpathsea_link) gsftopk.o $(LOADLIBES)
squeeze: squeeze.o
	$(link_command) squeeze.o $(LIBS) $(XLOADLIBES)

psheader.c: psheader.txt squeeze
	./squeeze $(srcdir)/psheader.txt $@

xdvi.1: xdvi.man sedscript
	sed -f sedscript <$(srcdir)/xdvi.man >$@
gsftopk.1: gsftopk.man sedscript
	sed -f sedscript <$(srcdir)/gsftopk.man >$@

sedscript: mksedscript
	$(SHELL) $(srcdir)/mksedscript pkpath sizes vfpath figpath \
	headerpath $(DEFS) $(prog_cflags) >$@

ac_include ../make/tkpathsea.make

install: install-exec install-data
uninstall: uninstall-exec uninstall-data

install-exec: $(programs)
	$(SHELL) $(top_srcdir)/../mkdirchain $(bindir)
	for p in $(programs); do $(INSTALL_LIBTOOL_PROG) $(bindir) $$p; done
uninstall-exec:
	for p in $(programs); do rm -f $(bindir)/$$p; done

install-data: xdvi.1 gsftopk.1
	$(SHELL) $(top_srcdir)/../mkdirchain $(mandir) $(psheaderdir)
	$(INSTALL_DATA) $(srcdir)/render.ps $(psheaderdir)/render.ps
	$(INSTALL_DATA) xdvi.1 $(mandir)/xdvi.$(manext)
	$(INSTALL_DATA) gsftopk.1 $(mandir)/gsftopk.$(manext)
uninstall-data:
	rm -f $(psheaderdir)/render.ps
	rm -f $(mandir)/xdvi.$(manext) $(mandir)/gsftopk.$(manext)


distname = xdvik
program_files = *.man *.ac xdvi.icon xdvi.FAQ psheader.txt mksedscript \
  render.ps MOTIF
version_files = gsftopk.c xdvi.c

pre-dist-$(distname):
post-dist-$(distname):
	cd $(top_distdir); rm -f xdvik/psheader.c

ac_include ../make/dist.make
ac_include ../make/config.make

info dvi check:

ac_include ../make/clean.make

distclean::
	rm -f psheader.c sedscript xdvi.1 gsftopk.1

ac_include ../make/rdepend.make
alloca.o: alloca.c
dvi_draw.o: dvi_draw.c config.h ../kpathsea/config.h c-auto.h \
 ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h \
 ../kpathsea/c-ctype.h \
 ../kpathsea/c-fopen.h ../kpathsea/c-vararg.h dvi.h
dvi_init.o: dvi_init.c config.h ../kpathsea/config.h c-auto.h \
 ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h \
 ../kpathsea/c-fopen.h \
 ../kpathsea/c-stat.h ../kpathsea/magstep.h ../kpathsea/tex-glyph.h \
 ../kpathsea/tex-file.h dvi.h
events.o: events.c config.h ../kpathsea/config.h c-auto.h \
 ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h 
font-open.o: font-open.c config.h ../kpathsea/config.h c-auto.h \
 ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h \
 ../kpathsea/c-fopen.h \
 ../kpathsea/tex-glyph.h ../kpathsea/tex-file.h
gf.o: gf.c config.h ../kpathsea/config.h c-auto.h ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h 
gsftopk.o: gsftopk.c ../kpathsea/config.h c-auto.h ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h ../kpathsea/c-ctype.h \
 ../kpathsea/c-fopen.h ../kpathsea/proginit.h ../kpathsea/tex-file.h \
 ../kpathsea/tex-make.h 
hypertex.o: hypertex.c config.h ../kpathsea/config.h c-auto.h \
 ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h \
 ../kpathsea/c-ctype.h \
 ../kpathsea/c-fopen.h ../kpathsea/c-stat.h 
mime.o: mime.c config.h ../kpathsea/config.h c-auto.h \
 ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h \
 ../kpathsea/c-ctype.h \
 ../kpathsea/c-fopen.h ../kpathsea/variable.h
pk.o: pk.c config.h ../kpathsea/config.h c-auto.h ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h 
psdps.o: psdps.c
psgs.o: psgs.c config.h ../kpathsea/config.h c-auto.h \
 ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h \
 ../kpathsea/c-pathmx.h 
psheader.o: psheader.c
psnews.o: psnews.c
sfDir.o: sfDir.c \
 sfinternal.h \
 ../kpathsea/config.h \
 c-auto.h ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h ../kpathsea/c-dir.h \
 ../kpathsea/c-stat.h
sfDraw.o: sfDraw.c ../kpathsea/config.h c-auto.h ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h ../kpathsea/c-stat.h \
 sfinternal.h 
sfPath.o: sfPath.c \
 ../kpathsea/config.h c-auto.h ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h ../kpathsea/c-stat.h \
 sfinternal.h 
sfSelFile.o: sfSelFile.c config.h ../kpathsea/config.h c-auto.h \
 ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h \
 ../kpathsea/c-stat.h \
 sfinternal.h 
special.o: special.c config.h ../kpathsea/config.h c-auto.h \
 ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h \
 ../kpathsea/c-fopen.h \
 ../kpathsea/c-ctype.h \
 ../kpathsea/c-stat.h ../kpathsea/line.h ../kpathsea/tex-file.h
squeeze.o: squeeze.c 
util.o: util.c config.h ../kpathsea/config.h c-auto.h \
 ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h \
 ../kpathsea/c-ctype.h \
 ../kpathsea/c-fopen.h ../kpathsea/c-vararg.h
vf.o: vf.c config.h ../kpathsea/config.h c-auto.h ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h \
 dvi.h
wwwfetch.o: wwwfetch.c config.h ../kpathsea/config.h c-auto.h \
 ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h \
 ../kpathsea/c-fopen.h \
 ../kpathsea/c-stat.h 
xdvi.o: xdvi.c config.h ../kpathsea/config.h c-auto.h \
 ../kpathsea/c-std.h \
 ../kpathsea/c-unistd.h ../kpathsea/systypes.h \
 ../kpathsea/c-memstr.h \
 ../kpathsea/c-errno.h \
 ../kpathsea/c-minmax.h \
 ../kpathsea/c-limits.h \
 ../kpathsea/c-proto.h ../kpathsea/debug.h ../kpathsea/types.h \
 ../kpathsea/lib.h ../kpathsea/progname.h \
 xdvi.h \
 c-openmx.h \
 ../kpathsea/c-ctype.h \
 ../kpathsea/c-fopen.h ../kpathsea/c-pathch.h ../kpathsea/c-stat.h \
 ../kpathsea/proginit.h ../kpathsea/tex-file.h ../kpathsea/tex-hush.h \
 ../kpathsea/tex-make.h \
 xdvi.icon 
