Thread: [Java-gnome-developer] starting a new project
Brought to you by:
afcowie
From: Olivier E. <ev...@pr...> - 2005-03-30 09:39:26
|
Hi All, It is a little complex to start a new project that use java-gnome (and/or others java libs) with eclipse *and* autoconf/automake. The main idea is to help new projects that want integrate from the beginning gcj and pkg-config. Is there possibilities to create templates for libraries and applications? That could also help to deploy new applications/librairies on all distrib (Debian/Gentoo/Slack). I adapted your automake, autoconf files for my library but I don't know if it is the good way, and I don't know how to proceed for an application. The example you give (Makefile) for an application must be rewrite depending the distribution target. Could you please give me help to make these templates! Regards, Olivier -- ------------------ LinuX for Geneva www.programmers.ch |
From: Andrew C. <an...@op...> - 2005-03-30 17:21:26
|
On Wed, 2005-30-03 at 11:42 +0200, Olivier Evalet wrote: > It is a little complex to start a new project that use java-gnome > (and/or others java libs) with eclipse *and* autoconf/automake. The main > idea is to help new projects that want integrate from the beginning gcj > and pkg-config. Well on purpose I don't use autoconf and automake. The nature of Java gives a rather unique twist to the configuration problem, not the least of which being that once you have prerequisite jars located and a suitable Java VM in place, then all you need is a very straight forward Makefile. [I'm writing a paper about this, in fact] I have not yet abstracted my work on this out into a separate form usable by other projects, but if you're interested in an alternate approach to the configuration problem you might grab the sources of a project I'm working on and have a look. http://research.operationaldynamics.com/darcs/xseq/HACKING > Is there possibilities to create templates for libraries > and applications? I *will* be splicing this work out at some point. I thought "configure4j" a nice moniker. AfC Paris -- Andrew Frederick Cowie Management Consultant Technology strategy, managing change, establishing procedures, and executing successful upgrades to mission critical business infrastructure. http://www.operationaldynamics.com/ Sydney New York Toronto London |
From: Olivier E. <ev...@pr...> - 2005-03-31 17:11:18
|
Hi Andrew, > > I *will* be splicing this work out at some point. I thought > "configure4j" a nice moniker. > Great, I can help you ! do you have a TODO? I read your scripts (very clean code, thanks!!) and I did some small changes (attached files): ------------------------------------------------------------------- 1) set default configure options (for my project) 2) set default main class on configure $MAINCLASS 3) set native gcj jars $NATIVE_JARS on configure 4) add generic $ext_jars to extend classpath 5) added the "make native" option on the Makefile 6) tested on debian an gentoo ;) STILL TODO 1) check gcj, gij, etc... version ------------------------------------------------------------------- It will be nice to build the classpath for extra libraries, but there are not true jar finder on distribs (or I dont know how todo). I found different way: a)gentoo, pkg-config --variable classpath or java-config, but not all packages are configured for that ... b)debian, I found nothing, there are some idea but nothing is really done http://java.debian.net/index.php/ c)redhat, I can't test it! There are some hacks possible for debian and gentoo with tools like find, dpkg and qpkg. Regards, Olivier PS please be indulgent with my poor English ;) -- ------------------ LinuX for Geneva www.programmers.ch |
From: Ray A. <ra...@do...> - 2005-04-03 07:11:12
|
Hey All, On this note, has anyone used ant's recently (well, about a year) added support for gcj native builds, libs, linking, etc... Ant really is very straight forwared to use and readable. Ray, PS: I really wanted to go the "Java-GNOME Con 1", since I live so close, but probably wouldn't have been much help AND couldn't get away. Hope those who attended had fun/were productive. Maybe next year. On Thu, 2005-31-03 at 19:13 +0200, Olivier Evalet wrote: > Hi Andrew, > > > > > I *will* be splicing this work out at some point. I thought > > "configure4j" a nice moniker. > > > Great, I can help you ! do you have a TODO? > > I read your scripts (very clean code, thanks!!) and I did some small > changes (attached files): > ------------------------------------------------------------------- > 1) set default configure options (for my project) > 2) set default main class on configure $MAINCLASS > 3) set native gcj jars $NATIVE_JARS on configure > 4) add generic $ext_jars to extend classpath > 5) added the "make native" option on the Makefile > 6) tested on debian an gentoo ;) > > STILL TODO > 1) check gcj, gij, etc... version > > ------------------------------------------------------------------- > It will be nice to build the classpath for extra libraries, but there > are not true jar finder on distribs (or I dont know how todo). I found > different way: > > a)gentoo, pkg-config --variable classpath or java-config, but not all > packages are configured for that ... > > b)debian, I found nothing, there are some idea but nothing is really done > http://java.debian.net/index.php/ > > c)redhat, I can't test it! > > There are some hacks possible for debian and gentoo with tools like > find, dpkg and qpkg. > > > > Regards, > Olivier > > PS please be indulgent with my poor English ;) > > > plain text document attachment (Makefile) > # > # If you need to debug some classpath, includes, or command line arguments > # option, then comment out MAKEFLAGS line below, or set V=1 on the command > # line before make. > # > ifdef V > else > MAKEFLAGS=-s > endif > > all: build/classes-dist > > .PHONY: all run test clean distclean > > # -------------------------------------------------------------------- > # Variable setup. You may want to set your editor to wrap to see the > # full CLASSPATH > # -------------------------------------------------------------------- > > -include .config > > # [this will be called by the above include if .config is missing. > # we don't call ./configure automatically to allow scope for > # manual configuration and overrides] > .config: > echo > echo "You need to run ./configure to check prerequisites" > echo "and setup preferences before you can build xseq." > ( if [ ! -x configure ] ; then chmod +x configure ; echo "I just made it executable for you." ; fi ) > echo > exit 1 > > # Variables we expect to be set in .config are: > # JAVAGNOME_JARS > # XML_JARS > # JUNIT_JARS > # JNI_PATH > # JAVAC[_CMD] [expected to be 9 chars wide] > # JAVA[_CMD] [expected to be 9 chars wide] > > # [This is just a quick sanity check] > build/config: build/dirs .config > @echo "CHECK build system configuration" > ( if [ ! "$(JAVAGNOME_JARS)" ] ; then echo "Sanity check failed. Run ./configure" ; exit 1 ; fi ) > touch $@ > > # [not in use at present; code and unit tests in stash/] > # BERKELEY_JARS=/usr/lib/db-4.2.jar > > # [note that Berkeley DB isn't used just now, so its jars are not here] > CLASSPATH=$(JAVAGNOME_JARS):$(XML_JARS):$(EXT_JARS) > > #SOURCES_DIST=$(shell find src -name '*.java') > SOURCES_DIST=$(shell find src -name '*.java') > SOURCES_TESTS=$(shell find tests -name '*.java') > > # [we now go to the bother of listing the .class targets individually in order > # to allow us to use gcj, which doesn't compile all the things it needs to > # (as javac does) even though it has to finds things by scanning. This > # can considerably slow a javac build depending on the order which classes > # are encountered; oh well] > CLASSES_DIST=$(shell echo $(SOURCES_DIST) | sed -e's/.java/.class/g' -e's/src/tmp\/classes/g') > CLASSES_TESTS=$(shell echo $(SOURCES_TESTS) | sed -e's/.java/.class/g' -e's/tests/tmp\/classes/g') > > # > # convenience target: setup pre-reqs > # > build/dirs: > @echo "MKDIR preping temporary files and build directories" > -test -d build || mkdir build > -test -d tmp/classes || mkdir -p tmp/classes > -test -d tmp/native || mkdir -p tmp/native > touch $@ > > # [these are only necessary as a defence against the system having evolved > # since it was ./configured. Java is so bad at identifying the root cause > # being missing files that were expected that such a safety check helps > # innocent builders maintain their sanity.] > build/check-jars: > @echo "CHECK prerequite core jar files" > ( if [ ! "$(CLASSPATH)" ] ; then echo "\"CLASSPATH\" variable is an empty. How did you get here?" ; exit 1 ; fi ) > ( for i in `echo $(CLASSPATH) | sed -e's/:/ /g'` ; do if [ ! -f $$i ] ; then echo $$i not found. ; exit 1 ; fi ; done ) > touch $@ > > build/check-jars-tests: > @echo "CHECK prerequite unit test jar files" > ( if [ ! "$(JUNIT_JARS)" ] ; then echo "\"JUNIT_JARS\" variable is an empty. How did you get here?" ; exit 1 ; fi ) > ( for i in `echo $(JUNIT_JARS) | sed -e's/:/ /g'` ; do if [ ! -f $$i ] ; then echo $$i not found. ; exit 1 ; fi ; done ) > touch $@ > > # -------------------------------------------------------------------- > # Source compilation > # -------------------------------------------------------------------- > > # [anything Java JVM runtime should depend on this target] > build/classes: build/classes-dist build/classes-tests > > tmp/classes/%.class: src/%.java > @echo "$(JAVAC_CMD) $<" > $(JAVAC) -d tmp/classes -classpath tmp/classes:$(CLASSPATH):src $< > > tmp/classes/%.class: tests/%.java > @echo "$(JAVAC_CMD) $<" > $(JAVAC) -d tmp/classes -classpath tmp/classes:$(CLASSPATH):$(JUNIT_JARS):src:tests $< > > # > # build the sources (that are part of the distributed app) > # > > build/classes-dist: build/config build/check-jars $(CLASSES_DIST) > touch $@ > > # > # build the test sources > # > build/classes-tests: build/config build/check-jars-tests build/classes-dist $(CLASSES_TESTS) > touch $@ > > # -------------------------------------------------------------------- > # Runtime convenience targets > # -------------------------------------------------------------------- > > test: build/classes > @echo "$(JAVA_CMD) AllXmlTests [JUnit]" > LD_LIBRARY_PATH=$(JNI_PATH) \ > $(JAVA) -classpath $(CLASSPATH):$(JUNIT_JARS):tmp/classes xseq.services.AllXmlTests > @echo "$(JAVA_CMD) AllDomainTests [JUnit]" > LD_LIBRARY_PATH=$(JNI_PATH) \ > $(JAVA) -classpath $(CLASSPATH):$(JUNIT_JARS):tmp/classes xseq.domain.AllDomainTests > > # [this is classes and not classes-dist because at the moment any use of this > # target is to setup, but needing a the support of a test environment, which > # WindowRunner provides] > debug: build/classes > @echo "$(JAVA_CMD) $(MAINCLASS) --debug=all" > LD_LIBRARY_PATH=$(JNI_PATH) \ > $(JAVA) -classpath $(CLASSPATH):tmp/classes $(MAINCLASS) --debug=all > > # [to be changed to classes-dist and xseq.client.ProcedureClient] > run: build/classes > @echo "$(JAVA_CMD) $(MAINCLASS)" > LD_LIBRARY_PATH=$(JNI_PATH) \ > $(JAVA) -classpath $(CLASSPATH):tmp/classes $(MAINCLASS) > > # [try to build native ] > native: > @echo "Build native $(MAINCLASS) " > gcj --encoding=ISO8859-1 -classpath $(CLASSPATH) -L`echo $(JNI_PATH) | sed -e's/:/ -L/g'` \ > $(NATIVE_JARS) -fPIC --main=$(MAINCLASS) -o $(MAINCLASS) $(SOURCES_DIST) > > # -------------------------------------------------------------------- > # House keeping > # -------------------------------------------------------------------- > > # [note that we don't remove .config here, as a) darcs doesn't pick it up > # so if it's hanging around it won't cause problems, and b) if it is removed > # here, then `make clean all` fails] > clean: > @echo "RM temporary build directories" > -rm -rf build > -rm -rf tmp > -rm -rf hs_err_* > -rm $(MAINCLASS) > distclean: clean > @echo "RM build configuration information" > -rm -f .config .config.tmp > @echo "RM development artifacts" > -rm -f share/*.gladep share/*.glade.bak share/*.gladep.bak > plain text document attachment (configure) > #!/usr/bin/perl -w > > use strict; > > use File::Basename; > > # > # Configure xseq for building. We: > # > # - determine the operating system > # > # - set known defaults that correspond to that OS > # > # - for items where we have multiple possibilities, work through the > # possibilities until we find one > # > # - for items where there are options to choose from (notably which java > # compiler and VM we're using), we select a sensible default unless > # instructed otherwise on the command line. > # > > my $os; > > # There's nothing worse than having an old config file, getting half way > # through this, having it break, and then being able to build, but getting > # errors because configure really didn't finish. We do leave .config.tmp > # in place on error to facilitate troubleshooting. > > `rm -f .config`; > > # -------------------------------------------------------------------- > # Process command line arguments for overrides > # -------------------------------------------------------------------- > > my $quiet; > my $compiler = "gcj"; > my $runtime = "gij"; > my $main = "org.programmers.installer.InstallBase"; > > foreach my $arg (@ARGV) { > my ($key, $value) = split /=/, "$arg"; > > if ($key eq "quiet") { > $quiet = 1; > } elsif ($key =~ /^runtime/) { > $runtime="$value"; > } elsif ($key =~ /^compiler/) { > $compiler="$value" > } elsif ($key =~ /^main/) { > $main="$value"; > } > } > > # -------------------------------------------------------------------- > # Utility and checking functions > # -------------------------------------------------------------------- > > # > # Very simply: if the msg does not contain a newline, then it is assumed > # to introduce a statement, so we print it and left pad it with spaces. > # If the text does contain a newline, then probably it is concluding a > # statment (ok, failed, whatever) but not necessarily - just print the thing > # without any padding. > # > sub output { > my $str = shift; > if ($str =~ /\n/) { > print $str unless $quiet; > } else { > printf "%-35s", $str unless $quiet; > } > } > > sub which { > my $program = shift; > my $ret = `which $program 2>/dev/null`; > chomp $ret; > return $ret; > } > > sub bail { > my $status = shift || "failed"; > my $msg = shift || ""; > > # assuming that we're in an incomplete line > output "$status\n\n"; > > > print "$msg\n\n" if $msg; > print "Failed to complete configuration.\n"; > exit(1); > } > > if ( ! defined($main)) { > bail "failed", "You must specify a main class to configure a project\n"; > return; > } > > > sub check_lib (\@$) { > my $arraylibs = $_[0]; > my $native = $_[1]; > if (defined($native)){ > output " - native lib $native"; > # TODO must be checked, but the LIB_PATH is required > push (@$arraylibs," -l$native"); > print "found\n"; > } > } > > sub check_prereq (\@$$$) { > my $arrayref = $_[0]; > my $item = $_[1]; > my $file = $_[2]; > my $package = $_[3]; > > output " - ".$item; > > my $str; > > if ( ! -f "$file" ) { > $str = "In order to build $main, you need ".basename($file)." (we\n"; > $str .= "expected to find it in ".dirname($file).") which is part of\n"; > $str .= "the $item Java library. On a ".ucfirst($os)." system,\n"; > $str .= "you should be able to get this requirement by doing:\n\n"; > $str .= " # "; > > if ($os eq "gentoo") { > $str .= "emerge"; > } elsif ($os eq "debian") { > $str .= "apt-get install"; > } elsif ($os eq "fedora") { > $str .= "yum install"; > } else { > $str .= "[FIXME fetch and install command for this OS]"; > } > $str .= " $package"; > > bail "not found!", $str; > } > print "found\n"; > > > push (@$arrayref, $file); > } > > # if we return without setting the variable pointed at by scalarref, its being > # empty will be used later to indicate that this compiler wasn't present / > # usable. > # > # The "not present" check is somewhat spurious given the input in many cases > # is the result of a `which` call. > > sub check_compiler (\$$$$) { > my $scalarref = $_[0]; > my $item = $_[1]; > my $program = $_[2]; > my $args = $_[3]; > > chomp $program; > if ( ! -f "$program") { > $$scalarref = ""; > return; > } > > # appealing to my sense of economy, we only print something out if > # it's there - that way we can list lots of options to check without > # cluttering things endlessly. > output " - ".$item; > > if ( ! -x "$program") { > output "found but not executable\n"; > $$scalarref = ""; > return; > } > > # Ok, so inline code is lame, but it's so small, and only one, > # and, avoids having a file in tests/ that will be picked up later > # as neededing compiling. > open HELLO, ">Hello.java"; > print HELLO <<HERE ; > public class Hello { > public static void main(String[] args) { > System.out.print("Hello"); > } > } > HERE > close HELLO; > > `$program $args Hello.java >/dev/null 2>&1`; > if ($? != 0) { > output "doesn't work\n"; > $$scalarref = ""; > return > } > > output "works\n"; > $$scalarref = "$program $args"; > } > > > sub check_runtime (\$$$$) { > my $scalarref = $_[0]; > my $item = $_[1]; > my $program = $_[2]; > my $args = $_[3]; > > chomp $program; > if ( ! -f "$program") { > $$scalarref = ""; > return; > } > > output " - ".$item; > > if ( ! -x "$program") { > output "found but not executable\n"; > $$scalarref = ""; > return; > } > my $output = `$program $args Hello 2>/dev/null`; > > if (($? != 0) || ($output ne "Hello")) { > output "doesn't work\n"; > $$scalarref = ""; > return > } > > output "works\n"; > $$scalarref = "$program $args"; > } > > > # -------------------------------------------------------------------- > # Determine Operating System > # -------------------------------------------------------------------- > > output "\n"; > > open CONFIG, ">.config.tmp"; > print CONFIG <<HERE ; > # This is an automatically generated Makefile fragment which is used to > # configure xseq for building. Do not edit (your changes will be overwritten > # next time ./configure is run), do not commit to repository. Anyone packaging > # xseq on any operating system: please do not override this file by patching > # it! Figure out what the problem is, and let us know so we can improve the > # ./configure perl script which generates it. > > HERE > > output "Indentify operating system:"; > > if (( -f "/etc/gentoo-release" ) || ( -f "/etc/make.conf" )) { > output "Gentoo\n"; > $os = "gentoo"; > } elsif ( -f "/etc/debian_version") { > output "Debian\n"; > # and Ubuntu > $os = "debian"; > } elsif ( -f "/etc/fedora-release" ) { > output "Fedora Core"; > $os = "fedora"; > } > > if ($os) { > print CONFIG "OS=$os\n"; > } else { > bail "unknown!", <<HERE ; > What we really need you to do is to look into this configure program, and > tell us what to add. Based on the examples of what is specified for other > distributions, you can probably quickly figure out what the appropriate > settings are for your platform. > > Letting us know what changes you had to make here (ie, whatever actions > resulted in a .config that allows you to build, test, and run xseq) we can > help others with your operating system take advantage of this program. > HERE > } > > output "\n"; > > > # -------------------------------------------------------------------- > # Specifiy locations of dependencies, by operating system, and > # verify pre-requsites are present. > # -------------------------------------------------------------------- > > my @xml_jars; > my @javagnome_jars; > my @junit_jars; > my @ext_jars; > my @native_jars; > my $jni_path; > > > output "Check for required native jars:\n"; > # > # ADD YOUR NATIVE JARS HERE > # > check_lib(@native_jars,"gtkjar2.4"); > check_lib(@native_jars,"gladejar2.8"); > check_lib(@native_jars,"gnomejar2.8"); > check_lib(@native_jars, "partedjava-1.0"); > > output "\n"; > output "Check for required jar files:\n"; > > > # ADVICE TO PEOPLE EXTENDING THIS SECTION FOR THEIR OWN OPERATING SYSTEM: > # You might as well list things in such an order that you tell the builder > # the package whose dependencies will bring the rest of the pre-requisites > # in along the way... > > > if ($os eq "gentoo") { > check_prereq(@xml_jars, > "Xerces XML parser", > "/usr/share/xerces-2/lib/xercesImpl.jar", > "xerces"); > check_prereq(@xml_jars, > "Apache XML Commons DOM APIs", > "/usr/share/xerces-2/lib/xml-apis.jar", > "xml-commons"); > > check_prereq(@javagnome_jars, > "GTK+ Java bindings", > "/usr/share/libgtk-java-2.4/lib/gtk2.4.jar", > "libgtk-java"); > > check_prereq(@javagnome_jars, > "LibGlade Java bindings", > "/usr/share/libglade-java-2.8/lib/glade2.8.jar", > "libglade-java"); > > check_prereq(@junit_jars, > "JUnit test framework", > "/usr/share/junit/lib/junit.jar", > "junit"); > > check_prereq(@ext_jars, > "Parted java bindings", > "/usr/share/java/parted1.0-1.0.jar", > "parted-java"); > > > > $jni_path = "/usr/lib"; > > } elsif ($os eq "debian") { > # This is a GNU lookalike, but is not necessary - and libxerces-2 > # pulls in libjaxp1.2-java which contains xml-apis.jar, just not by > # that name > #check_prereq(@xml_jars, > # "W3C DOM APIs", > # "/usr/share/java/gnujaxp-1.1.jar", > # "libgnujaxp-java"); > check_prereq(@xml_jars, > "Xerces XML parser", > "/usr/share/java/xercesImpl.jar", > "libxerces2-java"); > check_prereq(@xml_jars, > "Apache XML Commons DOM APIs", > "/usr/share/java/jaxp-1.2.jar", > "libjaxp1.2-java"); > > check_prereq(@javagnome_jars, > "GTK+ Java bindings", > "/usr/share/java/gtk2.4.jar", > "libgtk2-java"); > check_prereq(@javagnome_jars, > "LibGlade Java bindings", > "/usr/share/java/glade2.8.jar", > "libglade2-java"); > > check_prereq(@junit_jars, > "JUnit test framework", > "/usr/share/java/junit.jar", > "junit"); > > check_prereq(@ext_jars, > "Parted java bindings", > "/usr/share/java/parted1.0-1.0.jar", > "parted-java"); > > $jni_path = "/usr/lib:/usr/lib/jni"; > > } elsif ($os eq "fedora") { > check_prereq(@xml_jars, > "Xerces XML parser", > "/usr/share/java/xerces-j2.jar", > "xerces-j2"); > check_prereq(@xml_jars, > "Apache XML Commons DOM APIs", > "/usr/share/java/jaxp-1.2.jar", > "libjaxp1.2-java"); > check_prereq(@xml_jars, > "Xerces Samples", > "/usr/share/xerces-j2/xerces-j2-samples.jar", > "xerces-j2-demo"); > > check_prereq(@javagnome_jars, > "GTK+ Java bindings", > "/usr/share/java/gtk2.4.jar", > "libgtk-java"); > check_prereq(@javagnome_jars, > "LibGlade Java bindings", > "/usr/share/java/glade2.8.jar", > "libglade-java"); > > check_prereq(@junit_jars, > "JUnit test framework", > "/usr/share/java/junit.jar", > "junit"); > > $jni_path = "/usr/lib"; > > } else { > bail "failed!", "This OS not configured with defaults!\nTHIS IS AN INTERNAL ERROR, PLEASE FILE A BUG."; > } > > > # -------------------------------------------------------------------- > # Record jar locations > # -------------------------------------------------------------------- > > print CONFIG <<HERE ; > > # The lists of jars are colon separated, suitable for being > # concatonated into a CLASSPATH > > HERE > > print CONFIG "XML_JARS=".join(":", @xml_jars)."\n"; > print CONFIG "JAVAGNOME_JARS=".join(":",@javagnome_jars)."\n"; > print CONFIG "JUNIT_JARS=".join(":",@junit_jars)."\n"; > print CONFIG "EXT_JARS=".join(":",@ext_jars)."\n"; > print CONFIG "NATIVE_JARS=".join(" ",@native_jars)."\n"; > > print CONFIG <<HERE ; > > # the JNI_PATH is what is passed as LD_LIBRARY_PATH when running > # java Virtual Machines so that JNI shared libraries are picked up > > HERE > print CONFIG "JNI_PATH=$jni_path\n"; > print CONFIG "MAINCLASS=$main\n"; > > output "\n"; > > # -------------------------------------------------------------------- > # Check compilers: locations, necessary arguments, and that they work > # -------------------------------------------------------------------- > > output "Check Java compilers:\n"; > > # compilers we will check for: > my $javac; > my $jikes; > my $gcjC; # The moniker $gcjC referes to `gcj -C`. In the future will > # use the variable $gcj to mean "gcj as used to build native > # code". See HACKING for details. > > if ($os eq "gentoo") { > if ( ! -x "/usr/bin/java-config") { > bail "", "INTERNAL ERROR couldn't find java-config"; > } > > # check jikes. Since Jikes isn't a JRE of its own, it needs to be > # told about where to find the Java system classes. (java.lang, etc) > # we make an educated guess until java-config can tell us properly. > my $rt = `java-config -O`; > chomp $rt; > $rt .="/jre/lib/rt.jar"; > check_compiler($jikes, "IBM jikes", which("jikes"), "-bootclasspath $rt") if ( -f "$rt"); > > # check javac (the one specified by Gentoo's java-config tool) > # The $vendor business is just some precision prettiness for the > # display. > my $path; my $vendor; > $path = `java-config --javac`; > if ($path =~ /sun/i) { > $vendor = "Sun"; > } elsif ($path =~ /blackdown/i) { > $vendor = "Blackdown"; > } elsif ($path =~ /ibm/i) { > $vendor = "IBM"; > } else { > $vendor = "System"; > } > check_compiler($javac, "$vendor javac", $path, ""); > > # check gcj. -C means generate .class files, not .o files (which are > # for linking into native executables. > check_compiler($gcjC, "GCJ gcj -C (bytecode mode)", which("gcj"), "-C"); > > } elsif ($os eq "debian") { > # we can do much better than this, especially for java/javac. > # Do we access the alternatives system, or just go with known > # paths, or...? `which` is lame > > # check jikes. Since Jikes isn't a JRE of its own, it needs to be told > # about where to find the Java system classes. (java.lang, etc) The > # only way they'll be present is if a real Java VM is installed FIXME: > # How to find those on a Debian system? See the Gentoo block above for > # ideas. (at last report, libgcj's version of the GNU CLASSPATH > # libraries won't work here) > check_compiler($jikes, "IBM jikes", which("jikes"), "-bootclasspath FIXME"); > > # check for a proper "real" JDK's javac as installed (and maybe > # selected in the alternatives system) by the user. In other words, > # javac -> /opt/sun-jdk-1.4.2.02/bin/javac, not javac -> kaffec. > check_compiler($javac, "Real javac", which("javac"), ""); > > # check gcj. The moniker $gcjC referes to `gcj -C`. See HACKING. > check_compiler($gcjC, "GCJ (bytecode mode)", which("gcj"), "-C"); > > } elsif ($os eq "fedora") { > # we can do much better than this, especially for java/javac. > # Should we just go with known paths, or...? `which` is so lame > > # check for jikes. Presumably -bootclasspath will need to be set > # like on Gentoo and Debian; to what? > check_compiler($jikes, "IBM jikes", which("jikes"), "-bootclasspath FIXME"); > > # check for a proper JDK javac as installed (and selected in a FIXME > # redhat specific way if there is such a thing). NOT kaffec! > check_compiler($javac, "Real javac", which("javac"), ""); > > # check for gcj > check_compiler($gcjC, "GCJ (bytecode mode)", which("gcj"), "-C"); > > } else { > bail "failed!", "This OS not configured with a workable Java compiler checks!\nTHIS IS AN INTERNAL ERROR, PLEASE FILE A BUG."; > } > > output "\n"; > > # -------------------------------------------------------------------- > # Check runtimes > # -------------------------------------------------------------------- > > output "Check Java virtual machines:\n"; > > # runtimes we will check for: > my $java; > my $gij; > my $kaffe; > > if ($os eq "gentoo") { > # check java (the one specified by Gentoo's java-config tool) > # Is there any actual scenario where the javac would be from one > # vendor's JDK and the java from anothers JRE? I can't imagine, but > # do the $vendor check again. It's only cosmetic in any event. > my $path; my $vendor; > $path = `java-config --java`; > if ($path =~ /sun/i) { > $vendor = "Sun"; > } elsif ($path =~ /blackdown/i) { > $vendor = "Blackdown"; > } elsif ($path =~ /ibm/i) { > $vendor = "IBM"; > } else { > $vendor = "System"; > } > check_runtime($java, "$vendor java VM", $path, ""); > > # check gij (the bytecode interpreter from the GCJ project) > check_runtime($gij, "GCJ gij", which("gij"), ""); > > # check kaffe > check_runtime($kaffe, "kaffe VM", which("kaffe"), ""); > > } elsif ($os eq "debian") { > # check for a proper JDK/JRE java Virtual Machine (presumably either > # blackdown, or the real thing from Sun or IBM, as installed by the > # user). NOTE that this does *NOT* mean Sable VM or kaffe (so, if the > # Debian alternatives system can say that's what's providing > # java-runtime, then we need to take advantage of that. This is for a > # real JRE only, ie java -> /opt/sun-jdk-1.4.2.02/bin/java, not for > # java -> kaffe. > check_runtime($java, "Real java VM", which("java"), ""); > > # check gij (the bytecode interpreter from the GCJ project). In Debian > # it is in package gij-3.4 and so named in /usr/bin. > check_runtime($gij, "GCJ gij", which("gij-3.4"), ""); > > # check kaffe. Don't take it personally, but kaffe is not meant as a > # robust production ready VM. It's a research tool (so described on > # their home page) but given the progress in GNU classpath lately it > # *may* work, so we do check for it - we just don't pick it by > # preference. > check_runtime($kaffe, "Kaffe VM", which("kaffe"), ""); > > } elsif ($os eq "fedora") { > # check for a proper JDK/JRE java Virtual Machine (as installed and > # selected in a FIXME redhat specific way if there is such a thing) > # note that this does NOT mean Sable VM or kaffe. > check_runtime($java, "Real java VM", which("java"), ""); > > # check gij (the bytecode interpreter from the GCJ project) > check_runtime($gij, "GCJ gij", which("gij"), ""); > > # check kaffe. See the comment about Kaffe above in the Debian block. > check_runtime($kaffe, "Kaffe VM", which("kaffe"), ""); > } else { > bail "failed!", "This OS not configured with appropriate Java VM checks!\nTHIS IS AN INTERNAL ERROR, PLEASE FILE A BUG."; > } > > > # -------------------------------------------------------------------- > # Choose between java compilers and VMs > # -------------------------------------------------------------------- > > output "\n"; > > print CONFIG <<HERE ; > > # the JAVAC variable contains the path to the java source compiler, the JAVA > # variable contains the path to the java runtime virtual machine. In both > # cases, the _CMD variable is for the terse output when make commands are > # running. > > HERE > > > output "Select compiler:"; > > if ($compiler) { > # if overridden, check override... > if ($compiler eq "javac") { > bail "bad override", "javac specified but not detected as a workable compiler." unless $javac; > } elsif ($compiler eq "jikes") { > bail "bad override", "jikes specified but not detected as a workable compiler." unless $jikes; > } elsif ($compiler eq "gcj") { > bail "bad override", "gcj (-C) specified but gcj not detected as a workable compiler." unless $gcjC; > } else { > bail "bad override", <<HERE ; > You specified compiler=$compiler on the command line, but that's not an option. > Valid choices are javac, jikes, or gcj - but of course that compiler must be > installed (and detected!) in order to be able to specifiy it. > HERE > } > > } else { > # otherwise, pick a compiler. > if ($jikes) { > $compiler = "jikes"; > } elsif ($javac) { > $compiler = "javac"; > } elsif ($gcjC) { > $compiler = "gcj"; > } else { > bail "failed", "No java compiler was detected."; > } > } > > if ($compiler eq "javac") { > print CONFIG "JAVAC=$javac\n"; > print CONFIG "JAVAC_CMD=JAVAC \n"; > } elsif ($compiler eq "jikes") { > print CONFIG "JAVAC=$jikes\n"; > print CONFIG "JAVAC_CMD=JIKES \n"; > } elsif ($compiler eq "gcj") { > print CONFIG "JAVAC=$gcjC\n"; > print CONFIG "JAVAC_CMD=GCJ [-C] \n"; > } else { > bail "failed", "INTERNAL ERROR no compiler selected."; > } > output "$compiler\n"; > > > output "Select runtime:"; > > # Note that java is favoured over gij only because the error messages > # are better! (Ok, and, frankly, the compliance is obviously better > # if its a real Java VM). The Free ones are getting there... > > if ($runtime) { > # if overridden, check override... > if ($runtime eq "java") { > bail "bad override", "java specified but not detected." unless $java; > } elsif ($runtime eq "gij") { > bail "bad override", "gij specified but not detected." unless $gij; > } elsif ($runtime eq "kaffe") { > bail "bad override", "kaffe specified but not detected." unless $kaffe; > } else { > bail "bad override", <<HERE ; > You specified runtime=$runtime on the command line, but that's not an option. > Valid choices are java, gij, or kaffe - but of course that virtual machine > must be installed (and detected!) before you can specifiy it. > HERE > } > > } else { > if ($java) { > $runtime = "java"; > } elsif ($gij) { > $runtime = "gij"; > } elsif ($kaffe) { > $runtime = "kaffe"; > } else { > bail "failed", "No usable Java runtime environment was detected."; > } > } > > if ($runtime eq "java") { > print CONFIG "JAVA=$java\n"; > print CONFIG "JAVA_CMD=JAVA \n"; > } elsif ($runtime eq "gij") { > print CONFIG "JAVA=$gij\n"; > print CONFIG "JAVA_CMD=GIJ \n"; > } elsif ($runtime eq "kaffe") { > print CONFIG "JAVA=$kaffe\n"; > print CONFIG "JAVA_CMD=KAFFE \n"; > } else { > bail "failed", "INTERNAL ERROR no virtual machine selected"; > } > output "$runtime\n"; > > `rm Hello.java Hello.class`; > > > # -------------------------------------------------------------------- > # Done! Create .config file > # -------------------------------------------------------------------- > > output "Write .config file:"; > close CONFIG; > system "mv .config.tmp .config"; > > output "ok\n"; > output "\n"; > -- Ray Auge <ra...@do...> |