# 
# The LOOP Project
# 
# The LOOP Team, Dresden University and Nijmegen University
# 
# Copyright (C) 2002
# 
# 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 of
# the License, 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 in file COPYING in this or one of the
# parent directories for more details.
# 
# Created 23.1.02 by Hendrik
# 
# Time-stamp: <Monday 8 October 01 17:58:00 tews@ithif51>
# 
# Top level Makefile
# 
# $Id: Makefile.in,v 1.10 2010-11-02 14:51:27 tews Exp $
# 


######################################################################
#
# CONFIGURE SECTION
#
######################################################################


# prefix for BINDIR and LIBDIR, set this to /usr/local,
# or leave it and set BINDIR and LIBDIR individually
PREFIX=/usr/local


# Directory for executables. 
# This is where ccslc (and optionally ccslc.opt) will be installed
BINDIR=$(PREFIX)/bin

# Man page directory.
# the manpages will be installed in MANDIR/man1
MANDIR=$(PREFIX)/share/man

# Emacs lisp directory
# the place where the emacs lisp code for the ccsl emacs mode goes
ELIBDIR=${PREFIX}/share/emacs/site-lisp

# Set the names of the ocaml compilers. Does not need a change 
# under normal circumstances. 
# Using the .opt versions saves you about just as much time as
# you need to read this.
OCAMLC_NAME=ocamlc
OCAMLOPT_NAME=
#OCAMLC_NAME=ocamlc.opt
#OCAMLOPT_NAME=ocamlopt.opt

######################################################################
#
# END OF CONFIGURE SECTION
#
######################################################################

# There should be no need to change anything below.

# OCAMLDIR holds the directory where the ocaml executables can be found
# In all normal circumstances these executables are found via the 
# the search path and OCAMLDIR should stay empty.
OCAMLDIR=
#
# If the executables are not in the search path, then set the variable 
# like
#OCAMLDIR=/usr/local/ocaml-2.04/bin

# The programm used for installing
INSTALL=./install-sh -c

# insert -g here for compiling with debugging support
export COMPFLAGS=


#append a slash to OCAMLDIR
ifeq ($(OCAMLDIR),)
OCAMLDIR1=$(OCAMLDIR)
else
OCAMLDIR1=$(subst //,/,$(OCAMLDIR)/)
endif

# names of the ocaml binaries

export OCAMLLEX=$(OCAMLDIR1)ocamllex
export OCAMLYACC=$(OCAMLDIR1)ocamlyacc
export OCAMLCP=$(OCAMLDIR1)ocamlcp
export OCAMLDEP=$(OCAMLDIR1)ocamldep
export OCAMLMKTOP=$(OCAMLDIR1)ocamlmktop

export OCAMLC=$(OCAMLDIR1)$(OCAMLC_NAME)
export OCAMLOPT=$(OCAMLDIR1)$(OCAMLOPT_NAME)


all: 
	$(MAKE) -C Keywords -e
	$(MAKE) -C Common -e
	$(MAKE) -C Ccsl -e ccslc
	$(MAKE) -C Doc -e grammar.html ccslc.1

opt: 
	$(MAKE) -C Common -e native
	$(MAKE) -C Ccsl -e ccslc.opt


install:
	$(INSTALL) -d $(BINDIR)
#	$(INSTALL) -d $(PVSLIBDIR)
	$(INSTALL) -d $(MANDIR)/man1
	$(INSTALL) -d $(ELIBDIR)
	$(INSTALL) Ccsl/ccslc $(BINDIR)
	if test -f Ccsl/ccslc.opt ; then \
		$(INSTALL) Ccsl/ccslc.opt $(BINDIR) ; \
	fi
#	for f in Lib/Pvs/* ; do \
#		$(INSTALL) $$f $(PVSLIBDIR); \
#	done
	for f in Emacs/*el ; do \
		$(INSTALL) $$f $(ELIBDIR); \
	done
	$(INSTALL) Doc/ccslc.1 $(MANDIR)/man1
	$(INSTALL) Doc/ccslc.opt.1 $(MANDIR)/man1


uninstall:
	rm -f $(BINDIR)/ccslc
	rm -f $(BINDIR)/ccslc.opt
	rmdir $(BINDIR)
#	for f in Lib/Pvs/* ; do \
#		rm -f $(PVSLIBDIR)/`basename $$f`; \
#	done
	for f in Emacs/*el ; do \
		rm -f $(ELIBDIR)/`basename $ff`; \
	done
#	rmdir $(PVSLIBDIR)


depend:
	for f in Keywords Common Ccsl ; do \
		touch $$f/.depend; \
	done
	$(MAKE) -C Keywords depend
	$(MAKE) -C Ccsl depend

clean:
	$(MAKE) -C Common cleanall
	$(MAKE) -C Doc clean

stable:
	cvs tag -d latest-stable
	cvs tag latest-stable

.PHONY: all opt clean install uninstall depend stable

# How to do a release !
# 
# 1. check or increase version number
# 2. write NEWS, ChangeLog files
#    ./makeconfig
# 3. commit
# 4. cvs tag merged-to-head-28-10-02
# 5. merge
# 6. conflicts
# 7. ./makecvsconfig
# 8. commit merges
# 9. cvs tag merged-from-work-17-12-02
# 


### Local Variables: ***
### version-control: t ***
### kept-new-versions: 5 ***
### time-stamp-line-limit: 30 ***
### End: ***
