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

javadir=$(datadir)/java/$(subdir)
JAVACFLAGS = 
CLASSPATH_ENV = CLASSPATH=$(JAVAROOT)@pathsep@$(srcdir)@filesep@$(JAVAROOT)@pathsep@$$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)
SOURCES = $(java_sources) $(java_SCM)
DIST_SOURCES = $(SOURCES)
CLEANFILES = $(java_BUILT) *.class *.stamp *.jar $(OFILES_DIR)/$(PACKAGE_FNAME).lo $(EXTRA_CLEAN)
clean:
	rm -f $(CLEANFILES)

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)

# Used when pre-processing a file using sed.
DONT_EDIT_SUBS = -e '1i\' -e '// DO NOT EDIT!  -*- buffer-read-only: t -*-' \
   -e '1s|//.*-Java-.*|// This file is automatically generated from $@.in.|'

# 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=$(top_builddir):$(top_srcdir):$$CLASSPATH \
	  $(KAWA1) -d $(top_builddir) --module-static $(SCM_COMPILE_FLAGS) \
	    -P `echo $(PACKAGE_FNAME)|sed -e s/-/./g`. -C $?
	echo timestamp > scm-classes.stamp

clisp-classes.stamp: $(java_CLISP)
	CLASSPATH=$(top_builddir):$(top_srcdir):$$CLASSPATH \
	  $(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=$(top_builddir):$(top_srcdir):$$CLASSPATH \
	  $(KAWA1) -d $(top_builddir) \
	    -P `echo $(PACKAGE_FNAME)|sed -e s/-/./g`. --elisp -C $?
	echo timestamp > elisp-classes.stamp
