####################################################################
#   Copyright (c) 1996 NPACT Working Group. You may copy,          #
#   distribute, and modify it freely as long as you preserve this  #
#   copyright and permission notice.                               #
#                                                                  #
#   NPACT Working Group is a joint force of                        #
#      NPAC at Syracuse University,                                #
#      PACT at Harbin Institute of Technology, and                 #
#      PACT at Peking University                                   #   
####################################################################

SHELL   = /bin/sh

VERSION = @VERSION@

srcdir      = @srcdir@
top_srcdir  = @top_srcdir@

TESTDIR = testsuite
SRCDIR  = src

SUBDIR  = ${SRCDIR} ${TESTDIR}

VPATH = .:${srcdir}

all: ${srcdir}/configure config.status Makefile
	@for i in ${SUBDIR}; \
	do (cd $$i; $(MAKE) "MAKE=$(MAKE)"); done

Makefile: ${srcdir}/Makefile.in
	@echo
	@echo Please configure the package to generate new makefile ...
	@exit

check:
	@echo "Recursively checking testsuite dir"
	@for i in ${TESTDIR}; \
	do (cd $$i; $(MAKE) "MAKE=$(MAKE)" -i check); done

clean:
	@for i in ${SUBDIR}; \
	do (cd $$i; $(MAKE) "MAKE=$(MAKE)" clean); done

distclean: clean 
	@echo Deleting installed stuff if prefix is current dir ...;
	if [ -d bin ] ; then rm -r -f bin ; fi
	if [ -d include ] ; then rm -r -f include ; fi
	if [ -d lib ] ; then rm -r -f lib; fi
	@echo Deleting testing results ...
	@for i in ${TESTDIR}; \
	do (cd $$i; $(MAKE) "MAKE=$(MAKE)" distclean); done
	@echo Deleting generated configure files ...
	rm -f config.cache config.status config.log
	rm -f ./src/include/config.h 
	@echo Deleting generated Makefiles ...
	rm -f Makefile
	find ${SUBDIR} -name Makefile  -exec rm {} \;

install:
	@for i in ${SRCDIR}; \
	do (cd $$i; $(MAKE) "MAKE=$(MAKE)" install); done

uninstall:
	@for i in ${SRCDIR}; \
	do (cd $$i; $(MAKE) "MAKE=$(MAKE)" uninstall); done


#
# For generating configure script
#

${srcdir}/configure: ${srcdir}/configure.in ${srcdir}/acconfig.h
	cd ${srcdir}/ && autoconf
	autoheader

config.status: ${srcdir}/configure
	@echo
	@echo Please configure the package first ...
	@exit
