								#-*-Fun-*-
# This file, MAKEFILE.PC, is part of CWEB-p.
# The CWEB programs by Silvio Levy are based on programs by D. E. Knuth.
# ANSI-C conforming changes and Turbo-C++ implementation are made by
# Hans-Hermann Bode <HHBODE@DOSUNI1.BITNET or
# hhbode@dosuni1.rz.uni-osnabrueck.de>, additional support for other
# ANSI-C compilers provided by Klaus Guntermann
# <gunterma@ITI.INFORMATIK.TH-DARMSTADT.DE>.
# The programs are distributed WITHOUT ANY WARRANTY, express or implied.
# This makefile last updated September 1992 by Hans-Hermann Bode.

# Copyright (C) 1987,1990 Silvio Levy and Donald E. Knuth
# Copyright (C) 1991,1992 Hans-Hermann Bode

# 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 distributed under the terms of a
# permission notice identical to this one.

# Read the readme.pc file, then edit this file to reflect local conditions.

# This makefile, written by Hans-Hermann Bode (HHBODE@DOSUNI1.BITNET), will
# produce CTANGLE and CWEAVE for the ANSI-C/Turbo-C++ implementation of CWEB.
# It is intended for Turbo Make.
#
# Say `make all' to create all executables and the macro package, say
# `make doc' to generate the DVI files. To delete all intermediate files
# created in the make processes say `make clean', to delete even the DVI files
# say `make veryclean'.

CC=tcc
CFLAGS=-mh -AT -DSTAT -DDEBUG -DINCLUDEDIR
TEX=tex

.SWAP					# swap make out of memory while
					# executing commands

# .PHONY: all tangle weave common webmac
all: tangle weave webmac
tangle: ctangle.exe
weave: cweave.exe
common: common.obj
webmac: ccwebmac.tex

# .PHONY: doc man tdoc wdoc cdoc
doc: man tdoc wdoc cdoc
man: cwebman.dvi
tdoc: ctangle.dvi
wdoc: cweave.dvi
cdoc: common.dvi

# *** Make executables:

ctangle.exe: ctangle.obj common.obj
cweave.exe: cweave.obj common.obj
ctangle.c: ctangle.w common-p.h ctangl-p.ch
	- ctangle $*.w ctangl-p.ch	# exception from implicit rule
cweave.c: cweave.w common-p.h prod-p.w cweave-p.ch
common.c: common.w common-p.ch

.w.c:
	- ctangle $*.w $*-p.ch

.c.obj:
	$(CC) $(CFLAGS) -c $<

.obj.exe:
	$(CC) $(CFLAGS) $< common.obj

.c.exe:
	$(CC) $(CFLAGS) $< common.obj

# *** Make documentation:

ctangle.tex: ctangle.w common-p.h ctangl-p.ch
	- cweave $*.w ctangl-p.ch	# exception from implicit rule
cweave.tex: cweave.w common-p.h prod-p.w cweave-p.ch
common.tex: common.w common-p.ch

.w.tex:
	- cweave $*.w $*-p.ch

.tex.dvi:
	- $(TEX) $*

# *** Make include files:

common-p.h: common.h common-p.hch
	- wmerge common.h common-p.hch > $<
prod-p.w: prod.w prod-p.ch
	- wmerge prod.w prod-p.ch > $<
ccwebmac.tex: cwebmac.tex ccwebmac.ch
	- wmerge cwebmac.tex ccwebmac.ch > $<

# *** Delete intermediate files:

# .PHONY: clean veryclean

clean:
	if exist *.~ del *.~
	if exist cweave.c del cweave.c
	if exist *.obj del *.obj
	if exist common.tex del common.tex
	if exist ctangle.tex del ctangle.tex
	if exist cweave.tex del cweave.tex
	if exist *.log del *.log
	if exist *.toc del *.toc

veryclean: clean
	if exist *.dvi del *.dvi
