# Makefile for compiling the Charva library with the GNU Compiler for Java
# (GCJ), contributed by Nick Liebmann.
# Tested on Red Hat Linux with gcj version 3.2.2, and on Fedora Core 3 with gcj 3.4.2.

# Use the "library" target (i.e. "make -f c/src/Makefile.gcj.txt library")
# to compile all the class files in "charva.jar" into a shared library
# named "libcharva.so". Of course, you need to run "ant dist" (to make charva.jar)
# and "ant makeDLL" (to make libTerminal.so) before running this Makefile.

library :
	gcj --classpath=java/lib/commons-logging.jar -shared -fjni -o c/lib/libcharva.so java/dist/lib/charva.jar
	gcj -shared -o c/lib/libcommons-logging-api.so java/lib/commons-logging-api.jar


# Use this target to compile the Tutorial application into an executable named "charvatutgcj"
# in the current directory (i.e. "make -f c/src/Makefile.gcj.txt charvatutgcj").

charvatutgcj :
	gcj -Ijava/lib/commons-logging-api.jar -Ijava/dist/lib/charva.jar \
	-Lc/lib -lcharva -lcommons-logging-api -lTerminal \
	-ggdb --main=tutorial.charva.Tutorial \
	-o charvatutgcj \
	test/src/tutorial/charva/Tutorial.java

# To run the compiled and linked tutorial application on Linux, type the
# following commands in the $CHARVA_HOME directory. The $LD_LIBRARY_PATH environment
# variable has to be set otherwise Linux can't find the libcharva.so and libTerminal.so
# shared libraries.
# Of course, you can also just copy these libraries to your system's library
# directory.
#
#
#	$ export LD_LIBRARY_PATH=`pwd`/c/lib
#	$ ./charvatutgcj
