# Generated automatically from Makefile.in by configure.
#
# KROC top level Makefile
#
# $Source: /proj/kroc/develop/RCS/Makefile.in,v $
#
# $Id: Makefile.in,v 1.41 1997/03/31 11:59:58 djb1 Exp $
#
# (C) Copyright 1995,1996 Dave Beckett <D.J.Beckett@ukc.ac.uk>,
# University of Kent at Canterbury, England
#
# If this file has the name "Makefile.in" then it is a template for a
# Makefile; to generate the actual Makefile, run "./configure", which is a
# configuration script generated by hand (constructs like "@foo@" will get
# replaced in the actual Makefile.
#

HOST=i686-pc-linux-gnu

PACKAGE=kroc
PACKAGE_VERSION=1.0.3beta
PACKAGE_BINHOST=i686-pc-linux-gnu

prefix=/usr/local

# Defaults

DEFS=
#DEFS=-DDEBUG
#DEFS=-DDEBUG -DTRACE

#OPT=-g
#OPT=-O
OPT=-g -O

# If you choose this, you may want to edit bin/kroc to pick 'cc' as the
# linking compiler.
#CC=cc
CC=gcc

# gcc @ UKC only:
#CCFLAGS=-ansi -pedantic -Wall -Wshadow -Wformat -Wpointer-arith\
#	-Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings\
#	-I/usr/local/lib/ansi-include
# More: -W -Wtraditional -Wcast-qual -Wconversion -Wmissing-declarations -Wredundant-decls 
# Rest of world (or whatever works for you):
CCFLAGS=-ansi -pedantic -Wall -Wshadow -Wformat -Wpointer-arith\
	-Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings\
	-I/usr/local/lib/ansi-include \
	-Wconversion -Wmissing-declarations
# Bound to work:
#CCFLAGS=
#CCFLAGS=

# Do we need to run 'ranlib' on libraries? 
RANLIB=ranlib

# What flag, if any, is needed for 'as' to run through cpp?
ASFLAGS=


################ DO NOT CHANGE ANYTHING BELOW HERE ##################

ASCIIDOCS=README TARGETS INSTALL NEWS TODO
HTMLDOCS=README.html TARGETS.html INSTALL.html NEWS.html TODO.html
ALLDOCS=$(ASCIIDOCS) $(HTMLDOCS)

# Common Distribution files
DISTFILES=BUGS COPYING FORM Manifest $(ALLDOCS)\
	VERSION config.guess config.sub configure\
	Makefile.in bin/kroc.in bin/kmakef\
	docs/README docs/o2cl.ps docs/kroc.ps docs/occam docs/ocinf\
	docs/udo.html docs/udo.ps docs/dstring.ps docs/dstring.html
# Common distribution directories
DISTDIRS=examples course

# Things made by running ./config.status ...
PROTOTYPE_OUTPUTS=Makefile bin/kroc 
# src/config.h src/config.inc
# ... from these prototypes
PROTOTYPES=Makefile.in bin/kroc.in 
# src/config.h.in src/config.inc.in

# Configured files (things built by running ./configure)
CONFIGFILES=setup.csh setup.sh BINHOST $(PROTOTYPE_OUTPUTS)

TESTDIRS=tests/cgtests

# Things to include in binary distribution [directories and targets]
BINDISTDIRS=examples course
# Things to include only in source distribution [directories and targets]
SRCDISTDIRS=src

# Libraries to build once compiler is made (not in source release)
LIBSDIRS=inmos/libs

# Empty files in distribution
DISTEFILES=
# Directories that must exist in distribution
DISTEDIRS=$(SRCDISTDIRS) bin docs lib stamps
# and in a source-distribution
# [The last three are not available publically yet.]
SRCDISTEDIRS=$(DISTEDIRS) inmos inmos/libs inmos/libs/hostio inmos/libs/hostsp
# Things to remove in distribution
DISTRMTHINGS=find . \( -name RCS -o -name \*~ \) -exec rm -rf {} \;

COMMONDISTTHINGS=$(DISTFILES) $(DISTDIRS)

# Directories for make examples / build / test / install
EXDIRS=$(BINDISTDIRS)
BUILDDIRS=$(BINDISTDIRS)
TESTDIRS=tests/cgtests
INSTALLDIRS=$(SRCDISTDIRS)

INMOS_OCCAM_LIBS=lib/liboccam8.a lib/occam8.lib\
	lib/liboccamutl.a lib/occamutl.lib\
	lib/libconvert.a lib/convert.lib\
	lib/libstring.a lib/string.lib\
	lib/libsnglmath.a lib/snglmath.lib\
	lib/libdblmath.a lib/dblmath.lib\
	lib/mathhdr.inc lib/mathvals.inc\
	lib/libhostio.a lib/hostio.lib lib/hostio.inc\
	lib/libhostsp.a lib/hostsp.lib\
	lib/libstreamio.a lib/streamio.lib lib/streamio.inc

OFA_OCCAM_LIBS=lib/libcourse.a lib/course.lib \
        lib/consts.inc

# Everything in the binary distribution
BINDISTTHINGS=$(COMMONDISTTHINGS) $(BINDISTDIRS) BINHOST\
	bin/occ21 bin/ilibr bin/tranpc bin/ocinf\
	lib/libkroc.a\
	$(INMOS_OCCAM_LIBS) \
        $(OFA_OCCAM_LIBS)

# Everything in the source distribution
SRCDISTTHINGS=$(COMMONDISTTHINGS) $(SRCDISTDIRS) $(TESTDIRS)\
	README.source

TEMPDIR=/proj/kroc/release/

all: help

help: general-help

general-help:
	@echo -n "MAKE Targets for $(PACKAGE) $(PACKAGE_VERSION) on $(HOST) "
	@if [ -r inmos/libs/Makefile ]; then \
	  echo "(full source release)"; \
	elif [ -r src/Makefile ]; then \
	  echo "(source release)"; \
	else \
	  echo "(binary release)"; \
	fi	
	@echo
	@echo "  \"make clean\"        : Delete example programs"
	@echo "  \"make examples\"     : Build example programs"
	@if [ -r src/Makefile ]; then \
	  echo "  \"make srcdistclean\" : Clean 'src' tree binaries, temporary and config files"; \
	  echo "  \"make distclean\"    : Clean everything that is built or configured"; \
	  echo "  \"make build\"        : Create binaries in 'src' tree"; \
	  echo "  \"make install-core\" : \"build\" and install files into 'bin' and 'lib'"; \
	  echo "  \"make install\"      : \"install-core\" then \"clean-and-install-libs\" (SLOW)"; \
	  echo "  \"make test\"         : Build and run tests"; \
	  echo ""; \
	  if [ -r inmos/libs/Makefile ]; then \
	    echo "To get help on targets for working with INMOS libraries, type \"make libs-help\""; \
	  fi; \
	  echo "To get help on targets for creating releases, type \"make dist-help\""; \
	fi

libs-help:
	@echo -n "MAKE Targets for $(PACKAGE) $(PACKAGE_VERSION) on $(HOST) "
	@if [ -r inmos/libs/Makefile ]; then \
	  echo "(full source release)"; \
	  echo ""; \
	  echo "To work on INMOS libraries:"; \
	  echo "  \"make clean-libs\"   : Clean library objects, libraries from source tree"; \
	  echo "  \"make install-libs\" : Build libraries and install them (SLOW)"; \
	  echo "  \"make clean-and-install-libs\" : \"clean-libs\" then \"install-libs\""; \
	elif [ -r src/Makefile ]; then \
	  echo "(source release)"; \
	  echo ""; \
	  echo "No targets available"; \
	else \
	  echo "(binary release)"; \
	  echo ""; \
	  echo "No targets available"; \
	fi	

dist-help:
	@echo -n "MAKE Targets for $(PACKAGE) $(PACKAGE_VERSION) on $(HOST) "
	@if [ -r inmos/libs/Makefile ]; then \
	  echo "(full source release)"; \
	elif [ -r src/Makefile ]; then \
	  echo "(source release)"; \
	else \
	  echo "(binary release)"; \
	fi	

	@echo "";
	@if [ -r src/Makefile ]; then \
	  echo "To create binary or source releases:"; \
	  echo "  \"make bindist\"  : Compile binaries, libraries, create distribution tree"; \
	  echo "                    and output source tar files in $(TEMPDIR)"; \
	  echo "  \"make srcdist\"  : Clean 'src' tree of binaries and output source"; \
	  echo "                    tar files in $(TEMPDIR)"; \
	else \
	  echo "No targets available"; \
	fi	

config.status: $(PROTOTYPES)
	./configure

$(PROTOTYPE_OUTPUTS): $(PROTOTYPES)
	@echo "Rebuilding $@ from prototype(s)"
	./config.status

examples: stamps/examples-made

stamps/examples-made:
	@for dir in $(EXDIRS); do\
	  echo Making build in $$dir; \
	  (cd $$dir && $(MAKE) prefix="$(prefix)" DEFS="$(DEFS)" CC="$(CC)" OPT="$(OPT)" CCFLAGS="$(CCFLAGS)" RANLIB="$(RANLIB)" ASFLAGS="$(ASFLAGS)" build); \
	done
	@touch stamps/examples-made

clean clean-examples:
	@for dir in $(EXDIRS); do\
	  echo Making clean in $$dir; \
	  (cd $$dir && $(MAKE) clean); \
	done
	@rm -f stamps/examples-made

test:
	@for dir in $(TESTDIRS); do\
	  echo Making $@ in $$dir; \
	  (cd $$dir && $(MAKE) $(MFLAGS) prefix="$(prefix)" $@); \
	done

install: install-core clean-and-install-libs

clean-and-install-libs: clean-libs install-libs

install-core: build
	@for dir in $(INSTALLDIRS); do\
	  echo Making $@ in $$dir; \
	  (cd $$dir && $(MAKE) prefix="$(prefix)" HOST="$(HOST)" DEFS="$(DEFS)" CC="$(CC)" OPT="$(OPT)" CCFLAGS="$(CCFLAGS)" RANLIB="$(RANLIB)" ASFLAGS="$(ASFLAGS)" install); \
	done

install-mkdir:
	@for dir in $(prefix) $(prefix)bin $(prefix)/lib $(prefix)/man; do \
	if test ! -d $$dir then \
	  echo mkdir $$dir; \
	  mkdir $$dir; \
	fi

install-libs: build-libs

build-libs clean-libs distclean-libs install-libs:
	@target=`echo $@ | sed -e 's/-libs$$//'`; \
	for dir in $(LIBSDIRS); do\
	  if [ -d $$dir ]; then \
	    echo Making $$target in $$dir; \
	    (cd $$dir && $(MAKE) prefix="$(prefix)" HOST="$(HOST)" DEFS="$(DEFS)" CC="$(CC)" OPT="$(OPT)" CCFLAGS="$(CCFLAGS)" RANLIB="$(RANLIB)" ASFLAGS="$(ASFLAGS)" $$target); \
	  fi \
	done

build: bindistbuild Makefile bin/kroc

bindistbuild: srcdistconfigure
bindistbuild srcdistconfigure:
	@target=`echo $@ | sed -e 's/^...dist//'`; \
	for dir in $(SRCDISTDIRS); do\
	  echo Making $$target in $$dir; \
	  (cd $$dir && $(MAKE) prefix="$(prefix)" HOST="$(HOST)" DEFS="$(DEFS)" CC="$(CC)" OPT="$(OPT)" CCFLAGS="$(CCFLAGS)" RANLIB="$(RANLIB)" ASFLAGS="$(ASFLAGS)" $$target); \
	done

srcdistclean: distclean-libs
	@for dir in $(SRCDISTDIRS); do\
	  echo Making distclean in $$dir; \
	  (cd $$dir && $(MAKE) $(MFLAGS) distclean); \
	done
	-rm -f stamps/srcdist-* *~

bindistclean:
	@for dir in $(BINDISTDIRS); do\
	  echo Making distclean in $$dir; \
	  (cd $$dir && $(MAKE) $(MFLAGS) distclean); \
	done
	-rm -f stamps/dist-*
	-rm -f bin/tranpc bin/ocinf lib/libkroc.a

distclean: bindistclean srcdistclean
	-rm -f $(CONFIGFILES) config.status

PACKNAME=$(PACKAGE)-$(PACKAGE_VERSION)
PACKBINNAME=$(PACKNAME)-$(PACKAGE_BINHOST)
PACKTAR=$(TEMPDIR)$(PACKBINNAME).tar
PACKTARGZ=$(PACKTAR).gz
PACKTARZ=$(PACKTAR).Z

bindist: stamps/dist-targz stamps/dist-tarz

stamps/dist-targz: stamps/dist-tar
	gzip -9 < $(PACKTAR) > $(PACKTARGZ)
	@echo "Built $(PACKTARGZ)"
	@touch stamps/dist-targz

stamps/dist-tarz: stamps/dist-tar
	compress < $(PACKTAR) > $(PACKTARZ)
	@echo "Built $(PACKTARZ)"
	@touch stamps/dist-tarz

stamps/dist-tar: VERSION $(ALLDOCS)
	$(MAKE) bindistclean bindistbuild install 
	rm -rf dist
	mkdir dist dist/$(PACKNAME)
	gnutar -c -f - `ls -1d $(BINDISTTHINGS)|sort -u` | (cd dist/$(PACKNAME); gnutar -x -f -)
	chmod -R u+w dist/$(PACKNAME)
	chmod -R go-w dist/$(PACKNAME)
	-cd dist/$(PACKNAME); (touch $(DISTEFILES) >/dev/null 2>&1 || exit 0)
	-cd dist/$(PACKNAME); (mkdir $(DISTEDIRS) >/dev/null 2>&1 || exit 0)
	-cd dist/$(PACKNAME); ($(DISTRMTHINGS) >/dev/null 2>&1 || exit 0)
	cd dist; gnutar cf $(PACKTAR) $(PACKNAME)
	rm -rf dist
	@echo "Built binary distribution: $(PACKTAR)"
	@touch stamps/dist-tar

SRCPACKNAME=$(PACKAGE)-$(PACKAGE_VERSION)
SRCPACKTAR=$(TEMPDIR)$(SRCPACKNAME)-src.tar
SRCPACKTARGZ=$(SRCPACKTAR).gz
SRCPACKTARZ=$(SRCPACKTAR).Z

srcdist: stamps/srcdist-targz stamps/srcdist-tarz

stamps/srcdist-targz: stamps/srcdist-tar
	gzip -9 < $(SRCPACKTAR) > $(SRCPACKTARGZ)
	@echo "Built $(SRCPACKTARGZ)"
	@touch stamps/srcdist-targz

stamps/srcdist-tarz: stamps/srcdist-tar
	compress < $(SRCPACKTAR) > $(SRCPACKTARZ)
	@echo "Built $(SRCPACKTARZ)"
	@touch stamps/srcdist-tarz

stamps/srcdist-tar: VERSION $(ALLDOCS)
	$(MAKE) distclean
	rm -rf dist
	mkdir dist dist/$(SRCPACKNAME)
	gnutar -c -f - `ls -1d $(SRCDISTTHINGS) | sort -u` | (cd dist/$(SRCPACKNAME); gnutar -x -f -)
	chmod -R u+w dist/$(SRCPACKNAME)
	-cd dist/$(SRCPACKNAME); (touch $(DISTEFILES) >/dev/null 2>&1 || exit 0)
	-cd dist/$(SRCPACKNAME); (mkdir $(SRCDISTEDIRS) >/dev/null 2>&1 || exit 0)
	-cd dist/$(SRCPACKNAME); ($(DISTRMTHINGS) >/dev/null 2>&1 || exit 0)
	cd dist; gnutar cf $(SRCPACKTAR) $(SRCPACKNAME)
	rm -rf dist
	@touch stamps/srcdist-tar
	@echo "Built source distribution: $(SRCPACKTAR)"

HTML2ASCII=lynx -dump
HTML2FILTER=perl -pe 's/\[\d+\]//; s/^[	 ]+$$//;' | cat -s

fmtdocs: $(ASCIIDOCS)

README: README.html
	$(HTML2ASCII) $? | $(HTML2FILTER) > $@

TARGETS: TARGETS.html
	$(HTML2ASCII) $? | $(HTML2FILTER) > $@

INSTALL: INSTALL.html
	$(HTML2ASCII) $? | $(HTML2FILTER) > $@

NEWS: NEWS.html
	$(HTML2ASCII) $? | $(HTML2FILTER) > $@

TODO: TODO.html
	$(HTML2ASCII) $? | $(HTML2FILTER) > $@
