# Makefile for xdvik 
#
# - 1999/05/08: janl: Removed submakes for libwww and kpathsea.  That's what
#   the top makefile is for!
#
version = 21

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

# 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 = $(LDLIBWWW) $(x_ldflags) $(x_tool_libs) $(x_pre_libs) $(x_ext_lib) -lX11 $(x_extra_libs)

LDLIBWWW=@LDLIBWWW@
LIBWWWCPPFLAGS=@LIBWWWCPPFLAGS@
LIBWWWDEP=@LIBWWWDEP@
LIBWWWDIR = ../../libs/libwww
LIBWWWSRCDIR = $(srcdir)/../../libs/libwww

# Extra xdvi-specific compiler options.
ps_def = @PS_DEF@
prog_cflags = $(LIBWWWCPPFLAGS) $(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.bin
programs = $(program)

default all: $(programs) xdvi.1 

$(program): $(kpathsea) $(objects) $(LIBWWWDEP)
	$(kpathsea_link) $(objects) $(x_link) $(LOADLIBES)

squeeze: squeeze.o
	$(kpathsea_link) squeeze.o $(kpathsea) $(LIBS) $(XLOADLIBES)

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

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

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

$(LIBWWWDIR)/libwww.a:
	cd $(LIBWWWDIR); $(MAKE) $(makeargs) libwww.a

ac_include ../make/tkpathsea.mk

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

install-exec: $(programs)
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir)
	for p in $(programs); do $(INSTALL_LIBTOOL_PROG) $(bindir) $$p; done
	$(INSTALL_SCRIPT) $(srcdir)/xdvi-sh $(scriptdir)/xdvi
uninstall-exec:
	for p in $(programs) xdvi; do rm -f $(bindir)/$$p; done

install-data: xdvi.1 
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(mandir) 
	$(INSTALL_DATA) xdvi.1 $(mandir)/xdvi.$(manext)
uninstall-data:
	rm -f $(mandir)/xdvi.$(manext) 


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

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

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

info dvi check:

ac_include ../make/clean.mk

clean::
	rm -f *.flc

#clean::
#	test -f $(LIBWWWDIR)/Makefile && { cd $(LIBWWWDIR); $(MAKE) clean; } || true

distclean::
	rm -f psheader.c sedscript xdvi.1 *.flc
#	test -f $(LIBWWWDIR)/Makefile && { cd $(LIBWWWDIR); $(MAKE) distclean; } || true

ac_include ../make/rdepend.mk
ac_include depend.mk
