# Generated automatically from Makefile.in by configure.
# FileName	[ Makefile.in ]
#
# PackageName	[ NuSMV ]
#
# Synopsis	[ Package-wide Makefile ]
#
# Description	[ This file requires GNU's make program.
#		  Run "configure" to generate the Makefile, or use
#		  "config.status" (created by configure) to regenerate the
#		  Makefile after modifying this file. ]
#
# SeeAlso	[configure.in]
#
# Author	[Marco Roveri]
#
# Copyright	[Copyright (C) 1998-2001 by CMU and ITC-irst. 
#
# NuSMV version 2 is free software; you can redistribute it and/or 
# modify it under the terms of the GNU Lesser General Public 
# License as published by the Free Software Foundation; either 
# version 2 of the License, or (at your option) any later version.
#
# NuSMV version 2 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 
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public 
# License along with this library; if not, write to the Free Software 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
#
# For more information of NuSMV see <http://nusmv.irst.itc.it>
# or email to <nusmv-users@irst.itc.it>.
# Please report bugs to <nusmv-users@irst.itc.it>.
#
# To contact the NuSMV development board, email to <nusmv@irst.itc.it>.]
#
# Revision	[$Id: Makefile.in,v 1.2 2003/03/14 14:31:21 flerda Exp $]

# Default target:

default : version all

version :
	touch src/sm/smVers.c

#----------------------------------------------------------------------
# All NuSMV packages
#----------------------------------------------------------------------
ALL_PKGS = parser utils node dd cmd sm opt compile mc ltl img simulate set bmc sim sat rbc be dag prop

#----------------------------------------------------------------------
# The list of packages to compile -- change this if you're not compiling
# all of NuSMV
#----------------------------------------------------------------------
PKGS = $(ALL_PKGS)

# Generate the list of all packages NOT in the PKGS list

MISSING_PKGS = $(filter-out $(PKGS), $(ALL_PKGS))

#----------------------------------------------------------------------
# Packages Documented
#----------------------------------------------------------------------

DOC_PKGS = parser node dd cmd sm opt compile mc ltl img simulate set bmc sim sat rbc be dag prop

#----------------------------------------------------------------------
# For disabling echoing of commands
#----------------------------------------------------------------------
.SILENT:

#----------------------------------------------------------------------
# For safety
#----------------------------------------------------------------------

SHELL = /bin/sh
.SUFFIXES:

#----------------------------------------------------------------------
# The name of the product and its version
#----------------------------------------------------------------------

PRODUCT = NuSMV
VERSION = 2.1.0-PO
RELDATE = by $(shell whoami) on $(shell date +"%Y-%m-%d %H:%M:%S")

ifeq (no,yes)
VERSION := $(VERSION)-zchaff
endif

# Compile and version information printed by the compiler
#
# CUR_DATE and CUR_VER are strings surrounded by double quotes that contain
# spaces, e.g., "NuSMV release 1.0"

VERDATE = -DCUR_DATE="\"$(RELDATE)\"" -DCUR_VER="\"$(PRODUCT) $(VERSION)\""

#----------------------------------------------------------------------
# Directories for everything
#----------------------------------------------------------------------

# Directory in which to install architecture-independent files
# Set by ./configure --prefix=...
prefix =	/home/flerda/NuSMV-PO

# Directory in which to install architecture-dependent files
# Set by ./configure --exec-prefix=...
exec_prefix =	${prefix}

# Directory where master source files reside (used with MISSING_PKGS)
# Defaults to srcdir, but may be overridden with
# ./configure --srcdir=
master_srcdir =	.

# Directory where local source files (for editing) reside (used with PKGS)
# Set by ./configure --with-local-srcdir=
local_srcdir =	.

# Directory in which to install binaries
bindir =	$(exec_prefix)/bin

# Directory in which to install libraries
libdir =	$(exec_prefix)/lib

# Directory in which to install headers
includedir =	$(prefix)/include

# Directory in which to install architecture-independent library files
datadir = 	$(prefix)/share/nusmv

# Directory where object (and other generated) files will be placed
# during the build
objectdir =	obj

# Directory where documentation will be placed during the build
docdir =	$(master_srcdir)/doc
htmldocdir =	$(docdir)/html
helpdir =	$(master_srcdir)/share/help
usrmandir =     $(docdir)/user-man

# Directories to search for NuSMV library files
# Set by ./configure --with-nusmv-libdir=
nusmvlibdir =	.

# Name of the library to create
LIBRARY =	$(objectdir)/lib$(PRODUCT).a

# Main directory of the cudd package
cuddhomedir =	../cudd-2.3.0.1

# Directories to search for cudd .h files (space-separated)
cuddlibdir =	../cudd-2.3.0.1/lib

# Directories to search for cudd .h files (space-separated)
cuddincdir =	../cudd-2.3.0.1/include


# If the ZCHAFF sat solver is enabled. This is for makefiles usage only. 
# Values can be "yes" or "no". 
# For conditional source level usage use the SAT_ENABLE_ZCHAFF_SOLVER macro.
HAVE_SAT_ZCHAFF = no

# Directory to search for the zchaff library
zchafflibdir = ../zchaff

# Directory to search for the SAT.h file (absolute path)
ifneq ($(shell echo ../zchaff | egrep '^/.+'),)
zchaffincdir_abs = ../zchaff
else 
zchaffincdir_abs = $(shell pwd)/../zchaff
endif

# File that is tested to check whether cudd have been built
cuddtest =	$(cuddincdir)/util.h

# Base name of the nusmv source directory
nusmvbasename =	$(shell basename $$PWD)



#----------------------------------------------------------------------
# The following are set by the configure script
#----------------------------------------------------------------------

# To handle pre-processing capability:
ifeq (yes,yes)
	__CPP_CMD = -DCPP_CMD="/usr/local/bin/cpp" 
else
	__CPP_CMD = 
endif

AC_FLAGS =	 -DNDEBUG=1 -DSTDC_HEADERS=1 -DHAVE_LIBBSD=1 -DHAVE_LIBREADLINE=1 -DHAVE_DIRENT_H=1 -DHAVE_SYS_TERMIOS_H=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SIGNAL_H=1 -DHAVE_SYS_SIGNAL_H=1 -DIOCTL_WITH_TERMIOS=1 -DTIME_WITH_SYS_TIME=1 -DRETSIGTYPE=void -DRETSIGTYPE=void -DHAVE_GETTIMEOFDAY=1 -DHAVE_STRCHR=1 -DHAVE_STRSTR=1 -DHAVE_SETVBUF=1 -DHAVE_GETENV=1 -DHAVE_UNLINK=1  $(__CPP_CMD)
LIBDIRS =	
RANLIB =	ranlib
CC =		gcc
LINKER =	gcc
CFLAGS =	-g -O3 
CUDDLIBS =	-lcudd -lmtr -lst -lcudd_util
ZCHAFFLIB =     
LIBS =		-lm -lbsd  -lreadline -ltermcap $(ZCHAFFLIB) #-lfl
YACC =		bison -y
LEX =		flex
NAWK =		gawk
INSTALL =	/usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA =	${INSTALL} -m 644

#----------------------------------------------------------------------
# List of all examples to include in the distribution
#----------------------------------------------------------------------
EXAMPLES = abp example_irst prod-cons tcas guidance production-cell \
	   brp queue deadlock p-queue reactor example_cmu pci smv-dist \
	   msi bmc_tutorial

#----------------------------------------------------------------------
# List of all files in the doc directory
#----------------------------------------------------------------------

DOCUMENTATION = user-man html user-man/html

#----------------------------------------------------------------------
# List of all files in the doc/papers directory
#----------------------------------------------------------------------
PAPERS =

#----------------------------------------------------------------------
# List of all files in the share directory
#----------------------------------------------------------------------

SHAREFILES = master.nusmvrc

HELPFILES = $(notdir $(wildcard $(helpdir)/*))

#----------------------------------------------------------------------
# Include the make templates from all the packages
#
# Each of these templates (e.g., array/array.make) should contains lines
# of the form
#
# CSRC += source1.c source2.c
# HEADERS += header1.h header2.h
# LEXSRC += file1.l
# YACCSRC += file2.y
# GENERATEDCSRC += ctlpLex.c ctlpRead.c
# GENERATEDHEADERS += grammar.h
#----------------------------------------------------------------------

MAKEINCLUDES = $(foreach package, $(PKGS), \
	$(local_srcdir)/src/$(package)/$(package).make)

include $(MAKEINCLUDES)

OBJECTS = $(addprefix $(objectdir)/,$(GENERATEDCSRC:.c=.o)) $(addprefix $(objectdir)/,$(CSRC:.c=.o))

#----------------------------------------------------------------------
# Include the dependencies in each of the packages directories. The include
# directive does not produce an error if the dependency file does not
# exists
#
#----------------------------------------------------------------------

DEPENDENCIES = $(foreach package, $(PKGS), \
	$(local_srcdir)/src/$(package)/$(package).d)

-include $(DEPENDENCIES)

#----------------------------------------------------------------------
# Include and library paths
#
# INCLUDEDIRS looks like " -I/projects/smv/ ..."
# LIBRARYDIRS looks like " -L/projects/smv/ ..."
#----------------------------------------------------------------------
INCLUDEDIRS =   $(addprefix -I,$(cuddincdir)) \
		$(foreach package, $(PKGS), -I$(local_srcdir)/src/$(package)) \
		$(foreach package, $(MISSING_PKGS), \
		-I$(master_srcdir)/src/$(package)) \
		-I$(objectdir) 


LIBRARYDIRS = 	$(addprefix -L,$(nusmvlibdir)) $(addprefix -L,$(objectdir))   \
		$(addprefix -L,$(cuddlibdir)) $(addprefix -L,$(zchafflibdir)) \
		$(LIBDIRS)

#----------------------------------------------------------------------
# Build VPATH so make looks for source and object files in each of the PKG
# directories as well as the object directory
#
# VPATH looks like /projects/smv:/projects/cudd/: ...
#----------------------------------------------------------------------

VPATH = $(local_srcdir):$(master_srcdir):$(addprefix :$(local_srcdir)/src/,$(PKGS))\
	:$(addprefix :$(master_srcdir)/src/,$(MISSING_PKGS)):$(objectdir)\
	:$(local_srcdir)/share

#----------------------------------------------------------------------
# Implicit rules
#----------------------------------------------------------------------

# For compiling a source file into the object directory

$(objectdir)/%.o : %.c  $(cuddtest)
	@echo Compiling file $< into $@
	$(CC) -c $(CFLAGS) $(AC_FLAGS) $(VERDATE) \
		-DNAWK=\"$(NAWK)\" -DLIBRARY=\"$(datadir)\" \
		$(INCLUDEDIRS) \
		-o $@  $<

#----------------------------------------------------------------------
# Rule for checking that the CUDD library has been built
#----------------------------------------------------------------------
$(cuddtest) :
	@if [ ! -f $(cuddtest) ]; then \
		echo "ERROR: The CUDD library has not been built."; \
		echo "       Build it with command \"cd $(cuddhomedir) ; make\""; \
		echo "       and then re-build $(PRODUCT)."; \
		echo "       Please refer to the README file for instructions on compiling $(PRODUCT)."; \
		exit 1; \
	fi

#----------------------------------------------------------------------
# Rule to produce/delete the dependency file for every package
#----------------------------------------------------------------------
AUXVAR = $(VPATH)
dependencies:
	@for pkg in $(PKGS) ; do \
		$(MAKE) --no-print-directory \
			-f $(master_srcdir)/helpers/dependency.make \
			YACC="$(YACC)" LEX="$(LEX)" \
			CFLAGS="$(CFLAGS)" AC_FLAGS="$(AC_FLAGS)" \
			INCLUDEDIRS="$(INCLUDEDIRS)" objectdir=$(objectdir) \
			PKGNAME=$(local_srcdir)/src/$$pkg/$$pkg \
			vpath="$(AUXVAR)" \
			$(local_srcdir)/src/$$pkg/$$pkg.d ; \
	done

cleandependencies:
	rm -f $(local_srcdir)/src/*/*.d	

#----------------------------------------------------------------------
# Main rules:
#----------------------------------------------------------------------

all : $(objectdir) src/ltl/ltl2smv $(PRODUCT) 

$(objectdir) : 
	echo Creating directory $(objectdir)
	mkdir $(objectdir)

zchaff_link :
ifeq ($(HAVE_SAT_ZCHAFF),yes)
	rm -f $(objectdir)/zchaff.h
	ln -s $(zchaffincdir_abs)/SAT.h $(objectdir)/zchaff.h
endif

links : zchaff_link


$(PRODUCT) : $(objectdir) links $(LIBRARY) 
	echo Creating $(PRODUCT)

ifeq (yes,no)
	echo "WARNING *** Pre-processing capability via cpp is not supported by the NuSMV  ***" 
	echo "WARNING *** executable is being created.                                     ***"
	echo "WARNING *** See the configure options for activating pre-processing support. ***"
	echo
endif

ifeq ($(HAVE_SAT_ZCHAFF),yes)
	echo "WARNING *** This version of NuSMV is linked to the zchaff SAT solver  ***"
	echo "WARNING *** (see http://www.ee.princeton.edu/~chaff/).                ***"
	echo "WARNING *** Zchaff is used in Bounded Model Checking when the         ***"
	echo "WARNING *** environment variable sat_solver is set to \"zchaff\".       ***"
	echo "WARNING *** Notice that zchaff is for non-commercial purposes only.   ***"
	echo "WARNING *** NO COMMERCIAL USE OF ZCHAFF IS ALLOWED WITHOUT WRITTEN    ***"
	echo "WARNING *** PERMISSION FROM PRINCETON UNIVERSITY.                     ***"
	echo "WARNING *** Please contact Sharad Malik (malik@ee.princeton.edu)      ***"
	echo "WARNING *** for details.                                              ***"
	echo
endif
	$(LINKER) -o $(PRODUCT) \
		$(LIBRARYDIRS) -l$(PRODUCT) $(CUDDLIBS) $(LIBS)

exe : $(objectdir) $(OBJECTS)
	$(LINKER) -o $(PRODUCT) $(OBJECTS) \
		$(LIBRARYDIRS) -l$(PRODUCT) $(CUDDLIBS) $(LIBS)

$(LIBRARY): $(objectdir) $(OBJECTS)
	@echo Creating library archive $(LIBRARY)
	rm -f $(LIBRARY)
	ar cr $(LIBRARY) $(OBJECTS)
	$(RANLIB) $(LIBRARY)

.PHONY: src/ltl/ltl2smv

src/ltl/ltl2smv: 
	$(MAKE) -C src/ltl/ltl2smv --no-print-directory

#----------------------------------------------------------------------
# Rules for installation
#----------------------------------------------------------------------

install : $(LIBRARY) $(PRODUCT) installdirs allDoc
	@echo Installing $(PRODUCT) into $(bindir)/$(PRODUCT)
	$(INSTALL_PROGRAM) $(PRODUCT) $(bindir)/$(PRODUCT)
	@echo Installing ./src/ltl/ltl2smv/ltl2smv into $(bindir)/ltl2smv
	$(INSTALL_PROGRAM) ./src/ltl/ltl2smv/ltl2smv $(bindir)/ltl2smv
	@echo Installing $(LIBRARY) $(libdir)/`basename $(LIBRARY)`
	$(INSTALL_DATA) $(LIBRARY) $(libdir)/`basename $(LIBRARY)`
	@echo Installing sharefiles....
	@for file in $(SHAREFILES) ; do \
		echo "Installing $(datadir)/$$file"; \
		$(INSTALL_DATA) $(master_srcdir)/share/$$file \
			$(datadir)/$$file; \
	done
	@echo Installing helpfiles...
	@for file in $(HELPFILES) ; do \
		echo "Installing $(datadir)/help/$$file"; \
		$(INSTALL_DATA) $(master_srcdir)/share/help/$$file \
			$(datadir)/help/$$file; \
	done
	@echo Installing header files
	@for header in $(HEADERS); do \
		echo "Installing $(includedir)/$$header"; \
		$(INSTALL_DATA) $(master_srcdir)/src/*/$$header \
			$(includedir)/$$header; \
	done
	@for header in $(GENERATEDHEADERS); do \
		echo "Installing $(includedir)/$$header"; \
		$(INSTALL_DATA) $(master_srcdir)/obj/$$header \
			$(includedir)/$$header; \
	done

uninstall :
	@echo Removing $(bindir)/$(PRODUCT)
	rm -f $(bindir)/$(PRODUCT)
	@echo Removing $(bindir)/ltl2smv
	rm -f  $(bindir)/ltl2smv
	@echo Removing $(libdir)/$(LIBRARY)
	rm -f $(libdir)/$(LIBRARY)
	@echo Removing Sharefiles
	@for file in $(SHAREFILES) ; do \
		echo "Removing $(datadir)/$$file"; \
		rm -f $(datadir)/$$file; \
	done
	@echo Removing helpfiles
	@for file in $(HELPFILES) ; do \
		echo "Removing $(datadir)/help/$$file"; \
		rm -f $(datadir)/help/$$file; \
	done
	echo Removing $(datadir)/help
	rmdir $(datadir)/help
	echo Removing $(datadir)
	rmdir $(datadir)
	@echo Removing header files
	@for header in $(HEADERS); do \
		echo "Removing $(includedir)/$$header"; \
		rm -f $(includedir)/$$header; \
	done
	@for header in $(GENERATEDHEADERS); do \
		echo "Removing $(includedir)/$$header"; \
		rm -f $(includedir)/$$header; \
	done

installdirs :
	$(master_srcdir)/helpers/mkinstalldirs $(bindir) $(libdir) \
	$(includedir) $(datadir) $(datadir)/help

#----------------------------------------------------------------------
# Perform regression test on the examples 
#----------------------------------------------------------------------

check : $(PRODUCT)
	$(master_srcdir)/helpers/regression_test $(master_srcdir) examples/smv-dist

rcheck : $(PRODUCT)
	$(master_srcdir)/helpers/regression_test $(master_srcdir) examples

#----------------------------------------------------------------------
# Distribution-related definitions
#----------------------------------------------------------------------

DISTRIBUTION = $(PRODUCT)-$(VERSION)

# Directories to include in the distribution file
DISTDIRS = src share helpers share/help obj doc doc/papers examples \
	contrib $(addprefix doc/,$(DOCUMENTATION)) \
	doc/user-man/cmd \
	$(addprefix doc/papers/,$(PAPERS)) \
	$(foreach paperd, $(PAPERS), $(wildcard doc/papers/$(paperd)/*))\
	$(addprefix examples/,$(EXAMPLES)) $(addprefix src/,$(PKGS)) \
	src/ltl/ltl2smv src/ltl/ltl2smv/examples

# Build/install helper files
HELPERS = $(addprefix helpers/, \
	install-sh mkinstalldirs dependency.make regression_test)
DISTFILES = README INSTALL NEWS LGPL-2.1 \
	configure configure.in aclocal.m4 Makefile.in $(HELPERS) \
	$(CSRC) $(HEADERS) $(LEXSRC) $(YACCSRC) $(MAKEINCLUDES) \
	$(foreach example, $(EXAMPLES), $(wildcard examples/$(example)/*)) \
	$(foreach doc_d, $(filter-out user-man, $(DOCUMENTATION)), $(wildcard doc/$(doc_d)/*)) \
	doc/user-man/nusmv.ps \
	doc/user-man/Makefile \
	doc/user-man/nusmv.texi \
	doc/user-man/epsf.tex \
	$(wildcard doc/user-man/cmd/*.texi) \
	$(wildcard doc/user-man/cmdpo.*) \
	$(foreach var_d, $(foreach doc_d, $(PAPERS), $(wildcard doc/papers/$(doc_d)/*)), $(wildcard $(var_d)/*))\
	$(addprefix share/,$(SHAREFILES)) \
	$(addprefix share/help/,$(HELPFILES)) \
	$(wildcard src/ltl/ltl2smv/*.c) \
	$(wildcard src/ltl/ltl2smv/*.h) \
	$(wildcard src/ltl/ltl2smv/*.l) \
	$(wildcard src/ltl/ltl2smv/*.y) \
	$(wildcard src/ltl/ltl2smv/Makefile) \
	$(wildcard src/ltl/ltl2smv/examples/*) \
	$(wildcard contrib/*)

distdir        = nusmv-$(VERSION)
distbindir     = $(distdir)/bin
distlibdir     = $(distdir)/lib
distincludedir = $(distdir)/include
distsharedir   = $(distdir)/share
distdatadir    = $(distdir)/share/nusmv
disthelpdir    = $(distdir)/share/nusmv/help
distcontribdir = $(distdir)/contrib

DISTRIBUTIONBIN= `uname -ms|tr " " "-"`

#----------------------------------------------------------------------
# Rules for making a distribution file
#----------------------------------------------------------------------

dist : allDoc $(DISTRIBUTION).tar.gz 

$(DISTRIBUTION).tar.gz : $(filter-out %/CVS,$(DISTFILES))
	@echo Starting to create the $(PRODUCT) $(VERSION) distribution
	rm -rf $(DISTRIBUTION)
	mkdir $(DISTRIBUTION)
	for dir in $(DISTDIRS); do \
	  mkdir $(DISTRIBUTION)/$$dir; \
	done
	@echo "Copying distribution files"
	@for file in $^; do \
	  echo "  $$file"; \
	  cp -p $(master_srcdir)/$$file $(DISTRIBUTION)/$$file; \
	done
	- chmod -R a+r $(DISTRIBUTION)
	- chmod -R u+w $(DISTRIBUTION)
	mv $(DISTRIBUTION) $(nusmvbasename)
	@echo Going to ../cudd-2.3.0.1 and cleaning
	@cd ../cudd-2.3.0.1 && $(MAKE) --no-print-directory distclean
	@echo cudd-2.3.0.1 Cleaned
	@echo Creating distribution file : $(DISTRIBUTION).tar.gz
	tar cf - $(nusmvbasename) -C .. --exclude CVS cudd-2.3.0.1 | gzip -9 > $(DISTRIBUTION).tar.gz
	rm -rf $(nusmvbasename)
	@echo done

distbin : $(objectdir) src/ltl/ltl2smv/ltl2smv $(PRODUCT)
	echo Creating binary distribution for $(DISTRIBUTIONBIN)
	rm -rf $(distdir)
	mkdir $(distdir)
	echo Creating directories
	$(master_srcdir)/helpers/mkinstalldirs $(distbindir) $(distlibdir)\
		$(distsharedir) $(distdatadir) $(disthelpdir)\
		$(distincludedir) $(distcontribdir)
	@for file in README INSTALL LGPL-2.1 NEWS ; do \
		echo Install $$file into $(distdir)/$$file ; \
		$(INSTALL_DATA) $$file $(distdir)/$$file ; \
	done
	echo Installing $(PRODUCT) into $(distbindir)/$(PRODUCT)
	$(INSTALL_PROGRAM) $(PRODUCT) $(distbindir)/$(PRODUCT)
	echo Installing ./src/ltl/ltl2smv/ltl2smv into $(distbindir)/ltl2smv
	$(INSTALL_PROGRAM) ./src/ltl/ltl2smv/ltl2smv $(distbindir)/ltl2smv
	echo Installing $(LIBRARY) into $(distlibdir)/`basename $(LIBRARY)`
	$(INSTALL_DATA) $(LIBRARY) $(distlibdir)/`basename $(LIBRARY)`
	echo -n Installing sharefiles.
	@for file in $(SHAREFILES) ; do \
		echo -n . ;\
		$(INSTALL_DATA) $(master_srcdir)/share/$$file \
			$(distdatadir)/$$file; \
	done
	echo .done
	echo $(helpdir)
	echo $(HELPFILES)
	echo -n Installing help files.
	@for file in $(HELPFILES) ; do \
		echo -n . ;\
		$(INSTALL_DATA) $(master_srcdir)/share/help/$$file \
			$(distdatadir)/help/$$file; \
	done
	echo .done
	echo -n Installing header files.
	@for header in $(HEADERS); do \
		echo -n . ;\
		$(INSTALL_DATA) $(master_srcdir)/src/*/$$header \
			$(distincludedir)/$$header; \
	done
	@for header in $(GENERATEDHEADERS); do \
		echo -n . ;\
		$(INSTALL_DATA) $(master_srcdir)/obj/$$header \
			$(distincludedir)/$$header; \
	done
	echo .done
	echo -n Installing contributed files.
	@for file in $(filter-out %/CVS,$(wildcard contrib/*)) ; do \
		echo -n . ;\
		$(INSTALL_DATA) $(master_srcdir)/$$file $(distcontribdir)/ ;\
	done
	echo .done


	- chmod -R a+r $(distdir)
	- chmod -R u+w $(distdir)
	echo Creating binary distribution tar file: $(DISTRIBUTION)_$(DISTRIBUTIONBIN).tar.gz
	tar cf - $(distdir) | gzip -9 > $(DISTRIBUTION)_$(DISTRIBUTIONBIN).tar.gz
	rm -rf $(distdir)

#----------------------------------------------------------------------
# Rules for rebuilding the configure file and Makefile
#----------------------------------------------------------------------

${master_srcdir}/configure : configure.in
	cd ${master_srcdir} && autoconf

config.status : configure
	./config.status --recheck

Makefile : Makefile.in config.status
	./config.status

#----------------------------------------------------------------------
# Rules for cleaning
#----------------------------------------------------------------------

clean mostlyclean :
	echo Cleaning directories
	rm -rf examples/*/result examples/*/result_diff \
		obj/* $(LIBRARY) $(PRODUCT) include \
		$(foreach bddpkg, $(BDDPKGS), $(PRODUCT)-$(bddpkg))
	- cd src/ltl/ltl2smv && $(MAKE) clean

distclean : clean cleandoc
	echo Cleaning distribution
	rm -f Makefile config.status config.cache config.log

#----------------------------------------------------------------------
# Rule for performing a lint-like check on the source code
#----------------------------------------------------------------------

check_code : $(CSRC)
	@rm -f *.o_checkcode
	@for file in $^; do \
	  echo "------------------------ Checking $$file"; \
	  gcc -c $(CFLAGS) $(AC_FLAGS) $(VERDATE) $(INCLUDEDIRS) \
		-Wall -W -o obj/checkcode_output.o $$file; \
	  rm -f obj/checkcode_output.o; \
	done
	@rm -f *.o_checkcode

#----------------------------------------------------------------------
# Rules for generating the documentation and command help files
# for all the packages
#----------------------------------------------------------------------

allDoc : docs indexes helps userman

docs : $(CSRC) $(HEADERS) $(LEXSRC) $(YACCSRC)
	test -d $(docdir) || mkdir $(docdir)
	test -d $(htmldocdir) || mkdir $(htmldocdir)
	for pkg in $(DOC_PKGS); do \
		extdoc --html=$(htmldocdir) $(local_srcdir)/src/$$pkg/$$pkg; \
	done
	touch $(objectdir)/$@

indexes : docs
	@echo Creating documentation index
	extindex $(htmldocdir)
	touch $(objectdir)/$@

helps : docs
	test -d $(helpdir) || mkdir $(helpdir)
	for file in $(htmldocdir)/*Cmd.html ; do \
		echo Converting $$file ; \
		lynx -dump $$file > $(helpdir)/`basename $$file .html`.txt ; \
	done
	touch $(objectdir)/$@

userman : 
	@cd $(usrmandir) && $(MAKE) --no-print-directory

cleandoc :
	echo Cleaning doc/html directory
	-rm $(objectdir)/docs
	-rm $(objectdir)/indexes
	-rm -f $(htmldocdir)/*.html
	echo Cleaning share/help directory
	-rm $(objectdir)/helps
	-rm -f $(helpdir)/*Cmd.txt
	@cd $(usrmandir) && $(MAKE) clean

#----------------------------------------------------------------------
# Rules for debugging the Makefile
#----------------------------------------------------------------------

DEBUG_VARS = 	ALL_PKGS \
		PKGS \
		MISSING_PKGS \
		VPATH \
		INCLUDEDIRS \
		CSRC \
		OBJECTS \
		HEADERS \
		MAKEINCLUDES \
		CFLAGS \
		AC_FLAGS \
		master_srcdir \
		local_srcdir \
		DISTRIBUTION \
		DISTDIRS \
		DISTFILES \
		DISTRIBUTIONBIN

debug_make:
	@$(foreach var, $(DEBUG_VARS), echo $(var)=$($(var)) ; )
