# File:	     Makefile
# Author:    David Aspinall
# Copyright: University of Edinburgh, Ludwig-Maximilians Universitt, Mnchen
# ID:	     $Id: Makefile,v 1.3 2003/02/15 12:33:32 da Exp $
#
# Makefile for various Isabelle images.
#
# Usage:   "make [args]" 
#    
#   make test		  -- Run GrailExamples
#   make GrailDef.image   -- Build GrailDef logic image
#   make GrailDef         -- Build GrailDef, with document
#   make images		  -- Make all images
#
# NB: images are usually stored in ~/isabelle/heaps/[MLsystem]/
#
# -----------------------------------------------------------------
#
# To do: could make images inherit (base GrailLogic on GrailDef, etc).
# Doesn't seem worth it for now since each is quite small, but one must
# be wary of using consistent images.
#

## global settings (set normally by isatool itself)

# usual path
ISATOOL=/usr/local/Isabelle/bin/isatool

ISABELLE_HOME=$(shell $(ISATOOL) getenv -b ISABELLE_HOME)
ISABELLE_OUTPUT=$(shell $(ISATOOL) getenv -b ISABELLE_OUTPUT)

SRC = $(ISABELLE_HOME)/src
OUT = $(ISABELLE_OUTPUT)
LOG = $(OUT)/log


## targets

default: PCCBase
images: GrailDef.image GrailLogic.image PCCBase.image
test: GrailExamples

all: images test



# da: I don't really understand why the -b (build image)
# option uses the current dir and the others don't?
# So we must change directory if we want to build an image.

USEDIR = $(ISATOOL) usedir -v true -i true -d pdf # -D generated

%.image: %.deps $(ISABELLE_OUTPUT)/$*
	(cd $*; ${USEDIR} -b HOL $*)

## GrailDef

GrailDef: $(LOG)/HOL-GrailDef.gz

GrailDef.deps:   GrailDef/ROOT.ML GrailDef/document/root.tex GrailDef/*.thy

$(LOG)/HOL-GrailDef.gz: GrailDef.deps
	@$(USEDIR) HOL GrailDef

## GrailLogic

GrailLogic: $(LOG)/HOL-GrailLogic.gz

GrailLogic.deps:  GrailLogic/ROOT.ML GrailLogic/document/root.tex GrailLogic/*.thy

$(LOG)/HOL-GrailLogic.gz: GrailLogic.deps
	@$(USEDIR) HOL GrailLogic

## GrailExamples

GrailExamples: $(LOG)/HOL-GrailExamples.gz

GrailExamples.deps:  GrailExamples/ROOT.ML GrailExamples/document/root.tex GrailExamples/*.thy

$(LOG)/HOL-GrailExamples.gz: GrailExamples.deps
	@$(USEDIR) HOL GrailExamples

## PCCBase

PCCBase: $(LOG)/HOL-PCCBase.gz

PCCBase.deps:  PCCBase/ROOT.ML PCCBase/document/root.tex PCCBase/*.thy

$(LOG)/HOL-PCCBase.gz: PCCBase.deps
	@$(USEDIR) HOL PCCBase




## clean

clean:
	@rm -f $(LOG)/HOL-GrailDef.gz $(LOG)/HOL-GrailExamples.gz
