# Makefile for TeX Live distribution, modified from teTeX

# 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)
# Prefix for each installed program, normally empty or `g'.
binprefix = 
# Prefix for each installed man page, normally empty or `g'.
manprefix = 
manext = 1
mandir = @mandir@/man$(manext)
infodir = @infodir@

VERSION = 1.0

# Subdirectories that have makefiles
# SUBDIRS = dialog texinfo texk
ESUBDIRS = @ESUBDIRS@ texk
DSUBDIRS = @DSUBDIRS@

MDEFINES = bindir='$(bindir)' datadir='$(datadir)' mandir='$(mandir)' \
	manext='$(manext)' prefix='$(prefix)' binprefix='$(binprefix)' \
	scriptdir='$(scriptdir)' manprefix='$(manprefix)' \
	infodir='$(infodir)' CFLAGS='$(CFLAGS)' \
	CC='$(CC)' ALLOCA='$(ALLOCA)' LDFLAGS='$(LDFLAGS)' \
	DEFAULT_INFOPATH='$(DEFAULT_INFOPATH)'

default: all
install: all
	for dir in $(ESUBDIRS); do \
	   echo making $@ in $$dir; \
	   (cd $$dir && PATH=$(scriptdir):$(bindir):$(PATH) \
              $(MAKE) $(MDEFINES) $@) || break; \
	done
	PATH=$(scriptdir):$(bindir):$(PATH) $(scriptdir)/mktexlsr
	PATH=$(scriptdir):$(bindir):$(PATH) $(scriptdir)/texconfig init

strip:
	cd $(bindir); strip * >/dev/null 2>&1 || true

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

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

config.status: configure
	$(SHELL) ./config.status --recheck

configure: configure.in
	cd $(srcdir) && autoconf

all clean mostlyclean:
	for dir in $(ESUBDIRS); do \
	  echo making $@ in $$dir; \
	  (cd $$dir && $(MAKE) $(MDEFINES) $@ || exit 1); \
	done
	-(cd texmf/web2c; $(RM) *.efmt *.fmt *.base *.mem *.pool)
	-(cd psutils; make CC="$(CC)" -f Makefile.unix $@)
	-(cd t1utils; make CC="$(CC)" $@)


realclean: clean

distclean: clean
	for dir in $(ESUBDIRS); do \
	  echo making $@ in $$dir; \
	  (cd $$dir && $(MAKE) $(MDEFINES) $@ || exit 1); \
	done
	$(RM) Makefile *.status *.cache *.log
	$(RM) -rf bin man info include lib
	-(cd psutils; make -f Makefile.unix realclean)

psutils.build:
	texk/mkinstalldirs $(mandir) $(bindir) $(prefix)/texmf/psutils $(infodir)
	( cd psutils ; \
	make -f Makefile.unix PERL=`which perl` \
	INCLUDEDIR=$(prefix)/texmf/psutils BINDIR=$(bindir) \
	MANDIR=$(mandir) INSTALL=cp INSTALLMAN=cp clean install; \
	cd ..)

t1utils.build:
	texk/mkinstalldirs $(mandir) $(bindir)
	( cd t1utils; \
	make clean; \
	make BINDIR=$(bindir) MANDIR=$(mandir); \
	cp t1disasm t1asm t1ascii t1binary unpost $(bindir); \
	cp t1disasm.1 t1asm.1 t1ascii.1 t1binary.1 unpost.1 $(mandir); \
	cd .. )


realclean: distclean
world: all install psutils.build t1utils.build strip

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