SUFFIXES = .java .class .scm .el .lisp

javadir=$(datadir)/java/$(subdir)
JAVACFLAGS = 
CLASSPATH_ENV = CLASSPATH=$(JAVAROOT)@pathsep@$(srcdir)@filesep@$(JAVAROOT)@pathsep@@conf_classpath@$$CLASSPATH
JAVAROOT = $(top_builddir)
GCJ = gcj
JAR = fastjar
LIBTOOL = $(TO_TOPDIR)/libtool
#GCJFLAGS = -gdwarf-2
GCJFLAGS = -g -O
OFILES_DIR = $(TO_TOPDIR)/bin
TO_TOPDIR = $(top_builddir)
ENABLE_GCJ_COMPILED = $(EXTRA_GCJ_COMPILED) $(OFILES_DIR)/$(PACKAGE_FNAME).lo
java_Java= $(java_BUILT) $(java_sources)
GCJ_DEPS = $(java_Java) $(EXTRA_GCJ_DEPS)
DISTFILES = $(DIST_COMMON)  $(java_sources) $(java_SCM) $(TEXINFOS) $(EXTRA_DIST)
CLEANFILES = $(java_BUILT) *.class *.stamp *.jar $(OFILES_DIR)/$(PACKAGE_FNAME).lo $(EXTRA_CLEAN)

DISABLE_GCJ_COMPILED_KAWA1 = $(JAVA) kawa.repl
ENABLE_GCJ_COMPILED_KAWA1 = $(OFILES_DIR)/kawa1$(exeext)
# Compiler to use for compiling builtin .scm/.el/.cl files.
ENABLE_GCJ_COMPILED_CDEP = $(TO_TOPDIR)/kawa1$(exeext)

# Make sure $(KAWA1) is available, if --enable-gcj-compiled.
$(TO_TOPDIR)/kawa1$(exeext):
	cd $(OFILES_DIR) && $(MAKE) kawa1$(exeext)

$(OFILES_DIR)/$(PACKAGE_FNAME).lo:  $(GCJ_DEPS)
	$(LIBTOOL) --mode=compile $(GCJ) $(GCJFLAGS) \
	  -I$(JAVAROOT) -I$(srcdir)/$(JAVAROOT) -c \
	  $^ $(EXTRA_GCJ_INPUTS) -o $(OFILES_DIR)/$(PACKAGE_FNAME).lo

java-classes.stamp: $(java_Java)
	$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) $(JAVACFLAGS) $?
	echo timestamp > java-classes.stamp

scm-classes.stamp: $(java_SCM)
	$(CLASSPATH_ENV) \
	  $(KAWA1) -d $(top_builddir) --module-static-run $(SCM_COMPILE_FLAGS) \
	    -P `echo $(PACKAGE_FNAME)|sed -e s/-/./g`. -C $?
	echo timestamp > scm-classes.stamp

clisp-classes.stamp: $(java_CLISP)
	$(CLASSPATH_ENV) $(KAWA1) -d $(top_builddir) \
	    -P `echo $(PACKAGE_FNAME)|sed -e s/-/./g`. --clisp -C $?
	echo timestamp > clisp-classes.stamp

elisp-classes.stamp: $(java_ELISP)
	$(CLASSPATH_ENV) $(KAWA1) -d $(top_builddir) \
	    -P `echo $(PACKAGE_FNAME)|sed -e s/-/./g`. --elisp -C $?
	echo timestamp > elisp-classes.stamp
