# Makefile for teTeX distribution.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#### Start of system configuration section. ####

srcdir = @srcdir@
VPATH  = $(srcdir)

CC = @CC@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

LN	= @LN_S@
RM	= rm -f
TAR	= tar
MKDIR	= mkdir

DEFS = @DEFS@
LIBS = @LIBS@
LOADLIBES = $(LIBS)

ALLOCA = @ALLOCA@

SHELL = /bin/sh

CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@

prefix = @prefix@
exec_prefix = @exec_prefix@
datadir = @datadir@
bindir = @bindir@
scriptdir = $(bindir)
manext = 1
mandir = @mandir@/man$(manext)
infodir = @infodir@
texmf = @texmfmain@

NCURSESDIR=libs/ncurses
ZLIBDIR=libs/zlib
LIBPNGDIR=libs/libpng
LIBWWWDIR=libs/libwww

#### End of system configuration section. ####

ALLPROGS = access afm2tfm bibtex dialog dmp dvicopy dvilj dvilj2p dvilj4 \
  dvilj4l dvips dvitomp dvitype etex gftodvi gftopk gftype gsftopk \
  install-info kpsestat kpsewhich mag makeindex makeinfo mf mfw \
  mft mpost mpto newer odvicopy odvips odvitype ofm2opl omega opl2ofm \
  otangle otp2ocp outocp ovf2ovp ovp2ovf oxdvi.bin patgen pdftex pfb2pfa \
  pk2bm pktogf pktype pltotf pooltype ps2pk readlink tangle tex texindex \
  tftopl tie ttf2afm vftovp vptovf weave xdvi.bin pdfetex

VERSION = 1.0

# Subdirectories that have makefiles
ESUBDIRS = @ESUBDIRS@ texk
LIBSDIRS = @LIBSDIRS@

default: all
install: all 
	for dir in $(ESUBDIRS); do \
	   echo making $@ in $$dir; \
	     (cd $$dir && PATH=$(scriptdir):$(bindir):$(PATH) \
                $(MAKE) $@) || exit 1; \
	done
	$(srcdir)/selfautofix "$(bindir)" "$(texmf)/web2c"
	cd $(bindir); for i in $(ALLPROGS); do test -f $$i && { echo strip $$i; strip $$i || true; }; done; true
	test -f $(scriptdir)/mktexlsr && \
	  TEXMFMAIN=$(texmf) PATH=$(scriptdir):$(bindir):$(PATH) \
	    $(scriptdir)/mktexlsr
	test -f $(scriptdir)/texconfig && \
	  TEXMFMAIN=$(texmf) PATH=$(scriptdir):$(bindir):$(PATH) \
	    $(scriptdir)/texconfig init

install-exec:
	for dir in $(ESUBDIRS); do \
	   echo making $@ in $$dir; \
	   (cd $$dir && PATH=$(scriptdir):$(bindir):$(PATH) \
              $(MAKE) $@) || exit 1; \
	done
	cd $(bindir); for i in $(ALLPROGS); do test -f $$i && { echo strip $$i; strip $$i || true; }; done; true
	test -f $(scriptdir)/texlinks && \
	  TEXMFMAIN=$(texmf) PATH=$(scriptdir):$(bindir):$(PATH) \
	    $(scriptdir)/texlinks

strip:

check:
	cd texk; TEXMF=$(texmf) TEXMFCNF=$(texmf)/web2c $(MAKE) $@

uninstall:
	for dir in $(ESUBDIRS); do \
	  echo making $@ in $$dir; \
	  (cd $$dir && $(MAKE) $@) || exit 1; \
	done

Makefile: Makefile.in config.status
	$(SHELL) ./config.status

all: @LIBSDEP@
all clean mostlyclean:
	for dir in $(ESUBDIRS); do \
	  echo making $@ in $$dir; \
	  (if test -f $$dir/Makefile; then cd $$dir && $(MAKE) $@; else true; fi) || exit 1; \
	done

libsclean:
	for dir in ""$(LIBSDIRS); do \
	  echo making clean in $$dir; \
	  (if test -f $$dir/Makefile; then cd $$dir && $(MAKE) clean; else true; fi) || exit 1; \
	done

libsdistclean:
	for dir in ""$(LIBSDIRS); do \
	  echo making distclean in $$dir; \
	  (if test -f $$dir/Makefile; then cd $$dir && $(MAKE) distclean; else true; fi) || exit 1; \
	done

distclean: clean
	for dir in $(ESUBDIRS); do \
	  echo making $@ in $$dir; \
	  (if test -f $$dir/Makefile; then cd $$dir && $(MAKE) $@; else true; fi) || exit 1; \
	done
	$(RM) Makefile *.status *.cache *.log dialogconfig.h
	$(RM) libs/klibtool.config texinfo/info/funs.h texinfo/info/doc.c \
              libs/config.log libs/config.status
	$(RM) TAGS

tags TAGS:
	$(RM) TAGS
	find . -name '*.[ch]' -print | xargs etags --append -o TAGS


clean mostlyclean: libsclean
distclean: libsdistclean
realclean: distclean
world: all install strip
pdftex:
	cd texk/web2c; $(MAKE) pdftex
	test -f texk/web2c/pdftex && ls -l texk/web2c/pdftex

$(NCURSESDIR)/lib/libncurses.a:
	cd $(NCURSESDIR)/ncurses; $(MAKE) ../lib/libncurses.a
$(ZLIBDIR)/libz.a:
	cd $(ZLIBDIR); $(MAKE) libz.a
$(LIBPNGDIR)/libpng.a:
	cd $(LIBPNGDIR); $(MAKE) libpng.a
$(LIBWWWDIR)/libwww.a:
	cd $(LIBWWWDIR); $(MAKE) libwww.a

# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:
