1

I'm using autoconf for a build. I'd like my configure script to check for presence of a Java Compiler and ensure that the version is atleast 1.6 and it is Oracle's Java Compilter.

What do I need to put in my configure.ac script?

sharjeel
  • 5,825
  • 7
  • 34
  • 49

1 Answers1

3

The AX_PROG_JAVA macro and it's associated macros at the GNU Autoconf Macro Archive would be a good place to start. They won't do exactly what you want though (ensure that it's the Oracle compiler and at least Java 1.6).

ldav1s
  • 15,885
  • 2
  • 53
  • 56
  • I think they look for "javac" but on many distros, javac is a symbolic link gcj. So that won't work here. – sharjeel Oct 19 '12 at 18:15
  • Yes, but the user can point `configure` to use the correct javac by using the JAVAC environment variable. – ldav1s Oct 19 '12 at 19:24
  • Why? All you'd need to do is let the macro set up JAVAC, invoke `$JAVAC -version` in configure.ac and handle its output (or if it ran at all). – ldav1s Oct 19 '12 at 23:06
  • Here is the problem on my Ubuntu: $ ls -l `which javac` /usr/bin/javac -> /etc/alternatives/javac $ ls -l /etc/alternatives/javac /etc/alternatives/javac -> /usr/bin/gcj-wrapper-4.4 javac actually points to gcj on Ubuntu at times and it'll fail not during configuration but doing compilation fail. I'd like to give the user message right during configure that Oracle's Java is required – sharjeel Oct 19 '12 at 23:09
  • 1
    That's why I said to invoke `$JAVAC -version` in configure.ac, which will run during `configure`. If the macro sets JAVAC as gcj, `$JAVAC -version` will likely fail to run, since gcj doesn't use the Oracle commandline options. If the JAVAC compiler uses Oracle compatible commandline options you'll get at least version information. – ldav1s Oct 19 '12 at 23:24
  • Yeah. thats what I finally did. But in that case, AX_PROG_JAVA was not necessary. – sharjeel Oct 22 '12 at 18:06