# Makefile for Texinfo distribution.	-*- Indented-Text -*-
# Copyright (C) 1993 Free Software Foundation, Inc.

# This Makefile is for DJGPP v2.x

# 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. ####

# *** Things you might want to change ***

PWD     = chdir

RM	= -rm -f

# If you use emTeX, leave the following line alone; otherwise change
TEX     = htex386 &plain

EMACS   = emacs.exe

CFLAGS  = -O2 -g
LDFLAGS = -g

# For info program. 
DEFAULT_INFOPATH= .;c:/djgpp/info

# *** Things you should change only if you have a VERY good reason ***

# The following generates a full pathname of the main Texinfo directory.
# It is required because current directory is a global notion in DOS,
# so we must use a full pathname in the variables which are used in
# sub-Makes.
srcdir := $(subst \,/,$(shell $(PWD)))

common  = $(srcdir)/libtxi
VPATH   = $(srcdir);$(common)

CC      = gcc

# The following is necessary to avoid the loooong list of -DSOMETHING
# in $DEFS where we already have everything set up in the system-wide
# <config.h> (#include'd by ../config.h)
DEFS    = -imacros $(srcdir)/config.h
TERMLIBS=
LIBS    = $(TERMLIBS) -L$(srcdir)/libtxi -ltxi
LOADLIBES= $(LIBS)

MAKEINFO= $(srcdir)/makeinfo/makeinfo
TEXINDEX= $(srcdir)/util/texindex

# SHELL = /bin/sh

ALLOCA  =

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

VERSION = 3.6

# Subdirectories that have makefiles
SUBDIRS = libtxi makeinfo info util emacs

MDEFINES= CC='$(CC)' \
	DEFS='$(DEFS)' CFLAGS='$(CFLAGS)' ALLOCA='$(ALLOCA)' \
	LDFLAGS='$(LDFLAGS)' LOADLIBES='$(LOADLIBES)' \
	DEFAULT_INFOPATH='$(DEFAULT_INFOPATH)' RM='$(RM)' \
	EMACS='$(EMACS)' MAKEINFO='$(MAKEINFO)' TEXINDEX='$(TEXINDEX)'

all: sub-all texinfo

sub-all: $(addsuffix /Makefile,$(SUBDIRS))
	cd libtxi
	@echo making sub-all in libtxi
	$(MAKE) $(MDEFINES) sub-all
	cd ..\makeinfo
	@echo making sub-all in makeinfo
	$(MAKE) $(MDEFINES) sub-all
	cd ..\info
	@echo making sub-all in info
	$(MAKE) $(MDEFINES) sub-all
	cd ..\util
	@echo making sub-all in util
	$(MAKE) $(MDEFINES) sub-all
	cd ..\emacs
	@echo making sub-all in emacs
	$(MAKE) $(MDEFINES) sub-all
	cd ..

libtxi/Makefile: libtxi/Makefile.djg
	copy libtxi\Makefile.djg libtxi\Makefile

makeinfo/Makefile: makeinfo/Makefile.djg
	copy makeinfo\Makefile.djg makeinfo\Makefile

info/Makefile: info/Makefile.djg
	copy info\Makefile.djg info\Makefile

util/Makefile: util/Makefile.djg
	copy util\Makefile.djg util\Makefile

emacs/Makefile: emacs/Makefile.djg
	copy emacs\Makefile.djg emacs\Makefile

clean mostlyclean: $(addsuffix /Makefile,$(SUBDIRS))
	cd libtxi
	@echo making $@ in libtxi
	$(MAKE) $(MDEFINES) $@
	cd ..\makeinfo
	@echo making $@ in makeinfo
	$(MAKE) $(MDEFINES) $@
	cd ..\info
	@echo making $@ in info
	$(MAKE) $(MDEFINES) $@
	cd ..\util
	@echo making $@ in util
	$(MAKE) $(MDEFINES) $@
	cd ..\emacs
	@echo making $@ in emacs
	$(MAKE) $(MDEFINES) $@
	cd ..

distclean: clean texclean $(addsuffix /Makefile,$(SUBDIRS))
	cd libtxi
	@echo making $@ in libtxi
	$(MAKE) $(MDEFINES) $@
	cd ..\makeinfo
	@echo making $@ in makeinfo
	$(MAKE) $(MDEFINES) $@
	cd ..\info
	@echo making $@ in info
	$(MAKE)  $(MDEFINES) $@
	cd ..\util
	@echo making $@ in util
	$(MAKE)  $(MDEFINES) $@
	cd ..\emacs
	@echo making $@ in emacs
	$(MAKE)  $(MDEFINES) $@
	cd ..
	$(RM) *.log texinfo texinfo.i? texinfo.i??
	$(RM) Makefile

texclean:
	$(RM) *.aux *.cp *.cps *.dvi *.fn *.fns *.ky *.kys *.pg *.pgs
	$(RM) *.toc *.tp *.tps *.vr *.vrs

realclean: distclean

texinfo: $(srcdir)/texinfo.txi
	./makeinfo/makeinfo -I$(srcdir) texinfo.txi

texinfo.dvi: $(srcdir)/texinfo.txi
	$(TEX) texinfo.txi
	$(TEXINDEX) texinfo.??
	$(TEX) texinfo.txi

force:

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