
PRODUCT     = @PRODUCT@
VERSION     = @VERSION@
CLEAN       = @CLEAN@
@SET_MAKE@

srcdir      = @srcdir@
top_srcdir  = @top_srcdir@
prefix      = @prefix@
exec_prefix = @exec_prefix@
bindir		= @bindir@
libdir		= @libdir@
includedir  = $(prefix)/include
classdir    = ${prefix}/classes

INSTALL     = @INSTALL@
INSTALL_DAT = @INSTALL_DAT@
INSTALL_PRG = @INSTALL_PRG@

SUBDIRS     = util tool
DISTFILES   = Makefile.in ${SOURCE}

SOURCE	= World.java ATerm.java ATermList.java ATermAppl.java ATermInt.java \
		ATermPlaceholder.java ATermReal.java ATermBlob.java \
		ATermChannel.java ParseError.java \
		ATermSize.java ATest.java Primes.java
	
XTRACLASSES	= HashedWeakRef.class TestFailedException.class InputChannel.class

CLASSES	= $(patsubst %.java,%.class,$(SOURCE))

all: ${CLASSES}
	@for dir in ${SUBDIRS}; \
	do \
		echo "make all in $$dir"; \
		cd $$dir; ${MAKE} -s all; \
		cd ..; \
	done

%.class: %.java
	javac -classpath ..:$$CLASSPATH $<

test: ${CLASSES}
	java -classpath ..:$$CLASSPATH aterm.ATest

clean:
	@rm -f ${CLASSES} *~ core
	@for dir in ${SUBDIRS}; \
	do \
		echo "make clean in $$dir"; \
		cd $$dir; ${MAKE} -s clean; \
		cd ..; \
	done

install:
	@mkdir -p ${classdir}/aterm
	@for file in ${CLASSES} ${XTRACLASSES}; do \
		${INSTALL_DAT} $$file ${classdir}/aterm; \
	done
	@for dir in ${SUBDIRS}; \
	do \
		echo "make install in $$dir"; \
		cd $$dir; ${MAKE} -s install; \
		cd ..; \
	done

dist:
	@cp ${DISTFILES} ${DISTDIR}
	@for dir in ${SUBDIRS}; \
	do \
		echo "make dist in $$dir"; \
		mkdir ${DISTDIR}/$$dir; \
		cd $$dir; ${MAKE} -s DISTDIR=${DISTDIR}/$$dir dist; \
		cd ..; \
	done

