# Makefile for the API, RUNTIME and SUN packages
#

include ../configs/basic.mk
include ../configs/current.mk

TOBA = ../bin/toba $(TBUILD)
LISTER = ../bin/lister

API: api.done
RUNTIME: runtime.done
SUN: sun.done


# Files for the RUNTIME package
GCFILES = `find ../gc -name '*.o' | grep -v test.o`
RTFILES = ../runtime/*.o ../runtime/runtime.h ../runtime/toba.h

# Build the API package
# Must have previously made the "classes" target in the toba directory
api.done:
	rm -rf API
	classes=`$(LISTER) | sort | grep "^java"` && \
	    $(TOBA) -J -I ../runtime -P API $$classes
	touch api.done api.updated
	sleep 1


# Build the RUNTIME package
# Must have previously made the "classes" target in the toba directory, 
# and the gc and runtime directories
runtime.done: ../runtime/runtime.updated ../gc/gc.a
	rm -rf RUNTIME
	$(TOBA) -J -I ../runtime -P RUNTIME $(GCFILES) $(RTFILES) $(RTLDFLAGS) $(LIBS)
	touch runtime.done runtime.updated
	sleep 1


# Build the SUN package
# Must have previously made the "classes" target in the toba directory
sun.done:
	rm -rf SUN
	classes=`$(LISTER) | sort | \
	    grep '^sun.tools' | egrep -v '(debug|javadoc)'` && \
	    $(TOBA) -J -I ../runtime -P SUN $$classes
	touch sun.done sun.updated
	sleep 1

clean:
	rm -rf *.done *.[ch] so_locations API RUNTIME SUN 

