# This file is part of mCWEB.
# It is distributed WITHOUT ANY WARRANTY, express or implied.
# Version 1.0 --- June 1996

# Copyright (C) 1996 Markus Öllinger

# Permission is granted to make and distribute verbatim copies of this
# document provided that the copyright notice and this permission notice
# are preserved on all copies.

# Permission is granted to copy and distribute modified versions of this
# document under the conditions for verbatim copying, provided that the
# entire resulting derived work is given a different name and distributed
# under the terms of a permission notice identical to this one.

# 
# Read the README file, then edit this file to reflect local conditions
#

# directory for TeX inputs (mcwebmac.tex goes here)
MACROSDIR= TeX:inputs/cweb

# directory for mCWEB inputs in @i files
CWEBINPUTS= TeX:inputs/cweb

# extension for manual pages ("l" distinguishes local from system stuff)
#MANEXT= l
MANEXT= 1

# directory for manual pages (mcweb.1 goes here)
MANDIR= man/man$(MANEXT)

# destination directory for executables; must end in : or /
DESTDIR= c:

# directory for GNU EMACS Lisp code (cweb.el goes here)
EMACSDIR= 

# Set DESTPREF to null if you want to call the executables "tangle" and "weave"
# (probably NOT a good idea; I recommend leaving DESTPREF=mc)
DESTPREF= mc

# Set CCHANGES to changefile with changes to mcommon.w
CCHANGES= mcommon-Amiga.ch

# Set TCHANGES to changefile with changes to mctangle.w
TCHANGES= mctangle-Amiga.ch

# Set WCHANGES to changefile with changes to mcweave.w
WCHANGES= mcweave-Amiga.ch

# compiler an linker options for release an debug versions
# for SAS-C 6.0 and up
CFLAGS= code=far data=far nominc def CWEBINPUTS="$(CWEBINPUTS)" \
Ignore=100 Ignore=161 Ignore=304 Ignore=317 optimize opttime
#CFLAGS= code=far data=far nominc def CWEBINPUTS="$(CWEBINPUTS)" \
#Ignore=100 Ignore=161 debug=sf map
LINKFLAGS= lib LIB:scnb.lib LIB:amiga.lib from LIB:c.o
#LINKFLAGS= addsym lib LIB:scnb.lib LIB:amiga.lib from LIB:c.o

# What C compiler are you using?
CC= sc:c/sc

# What linker ar you using?
LD= sc:c/slink

# What make are you using?
MAKE= sc:c/smake

# How to call TeX with plain and LaTeX macro package
TEX= TeX
LATEX= LaTeX


# DIFF is used below to show file differences
DIFF= sc:c/diff -l5000

# RM and CP are used below to remove and copy files
RM= C:Delete
CP= C:Copy

##########  You shouldn't have to change anything after this point #######

#CWEAVE = work:cweb3.4/bin/cweave
#CTANGLE = work:cweb3.4/bin/ctangle
CWEAVE = mcweave
CTANGLE = mctangle
SOURCES = mcweave.w mcommon.w mctangle.w
ALMOSTALL = mcommon.w mctangle.w smakefile README mcommon.c mcommon.h \
	mctangle.c mcwebman.tex mcwebmac.tex comm-man.ch ctang-man.ch \
	cweav-man.ch mcweb.1 cweb.el prod.w mcwebman.bbl mcwebman.mp \
	mcwebman.1 mcwebman.2
ALL =  $(ALMOSTALL) mcweave.w bibnames.sty texnames.sty path.sty epsfig.sty

.SUFFIXES: .dvi .tex .w

.w.tex:
	$(CWEAVE) $*

.tex.dvi:	
	tex $<

.w.dvi:
	$(MAKE) $*.tex
	$(MAKE) $*.dvi

all: mctangle mcweave

cautiously: mctangle
	$(CP) mcommon.c SAVEcommon.c
	mctangle mcommon $(CCHANGES)
	$(DIFF) mcommon.c SAVEcommon.c
	$(RM) SAVEcommon.c
	$(CP) mctangle.c SAVEctangle.c
	mctangle mctangle $(TCHANGES)
	$(DIFF) mctangle.c SAVEctangle.c
	$(RM) SAVEctangle.c

SAVEctangle.c:
	$(CP) mctangle.c SAVEctangle.c

SAVEcommon.c:
	$(CP) mcommon.c SAVEcommon.c

mcommon.c: mcommon.w $(CCHANGES)
	$(CTANGLE) mcommon $(CCHANGES)

mcommon.o: mcommon.c

mctangle: mctangle.o mcommon.o
	$(LD) $(LINKFLAGS) mctangle.o mcommon.o to $*

mctangle.o: mctangle.c

mctangle.c: mctangle.w $(TCHANGES)
	$(CTANGLE) mctangle $(TCHANGES)

mcweave: mcweave.o mcommon.o
	$(LD) $(LINKFLAGS) mcweave.o mcommon.o to $*

mcweave.o: mcweave.c

mcweave.c: mcweave.w $(WCHANGES)
	$(CTANGLE) mcweave $(WCHANGES)

#doc: $(SOURCES:.w=.dvi)

usermanual: mcwebman.tex mcwebmac.tex
	$(LATEX) mcwebman

fullmanual: usermanual $(SOURCES) comm-man.ch ctang-man.ch cweav-man.ch
	$(MAKE) mcweave
	mcweave mcommon.w comm-man.ch
	$(TEX) mcommon.tex
	mcweave mctangle.w ctang-man.ch
	$(TEX) mctangle.tex
	mcweave mcweave.w cweav-man.ch
	$(TEX) mcweave.tex

# be sure to leave mctangle.c and mcommon.c for bootstrapping
clean:
	$(RM) \#?.o mcommon.tex mcweave.tex mcweave.c mctangle.tex \
	  \#?.log \#?.dvi \#?.toc \#?.idx \#?.scn mcweave mcweave.info \
	  mctangle mctangle.info

install: all
	-$(CP) mcweave $(DESTDIR)$(DESTPREF)weave
	-$(CP) mctangle $(DESTDIR)$(DESTPREF)tangle
#	-$(CP) mcweb.1 $(MANDIR)/mcweb.$(MANEXT)
	-$(CP) mcwebmac.tex $(MACROSDIR)
#	-$(CP) cweb.el $(EMACSDIR)

tags: $(ALL)
	etags -z $(ALL)

mcweb.tar: $(ALL)
	tar cvhf mcweb.tar $(ALL)
