autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_CHECK_PROGS and java compiler options


From: John Calcote
Subject: Re: AC_CHECK_PROGS and java compiler options
Date: Sat, 22 Aug 2009 15:32:42 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.1) Gecko/20090715 Thunderbird/3.0b3

Hi Ralf,

Hey, thanks for the response.

On 8/22/2009 1:59 AM, Ralf Wildenhues wrote:
Hello John,

* John Calcote wrote on Fri, Aug 21, 2009 at 02:44:03AM CEST:
I'm wondering about best practices for checking for programs like
the javac compiler. For instance, I currently have a line in my
project's configure.ac file that looks like this:

AC_CHECK_PROGS([JAVAC], ["gcj -C -ftarget=1.4 -fsource=1.4" "guavac
-target 1.4 -source 1.4" "jikes -target 1.4 -source 1.4" "javac
-target 1.4 -source 1.4"])
Why are you doing this?  AC_CHECK_PROGS will cut off the arguments when
searching for the program anyway, it don't try to run the program.

The reason that *I* do this is so that the program variable (JAVAC) will be set to the specified string (possibly prefixed with a path, if the skip argument is used). For example, if gcj is found in the path, then JAVAC should be set to "gcj -C". This is because, for gcj to act like Sun's javac program, you need to pass the -C option (otherwise it will compile Java sources to native code instead of Java byte code). But if none of the programs is found until the search reaches javac, then JAVAC should be set to just "javac".

This system was fine, when the *only* difference between programs was the -C option on gcj. Then it made sense to just pass -C in the search for gcj. But now that I need to specify target JVM and source version restrictions, it seems silly to pass the same set of additional command line options to all programs *except* gcj (which requires a slightly different format for these options). If they were all the same, I'd just add them to the JAVACFLAGS variable.

The semantics of AC_CHECK_PROGS are purely done so that one can pass in
variables to AC_CHECK_PROGS that are also used likewise elsewhere; but
for the tests done by this macro, they are not relevant.

Hmmm. I thought the point of being able to pass options to various search programs in AC_CHECK_PROGS was to be able to conform run-time characteristics of one of the programs to that of the others in the list, if options were required in order to do so. Those options are then pasted onto the command that's ultimately set in the variable. At least, that's what the comments in the macro definition appear to be telling the reader.

In fact, this works very well. When I use $(JAVAC) in my Makefile.am files, I do get the correct options passed for the first located program - "gcj -C -ftarget=1.4 -fsource=1.4" on my 64-bit linux system, and "javac -target 1.4 -source 1.4" on systems with only the Sun java compiler installed.

I was just asking if there's a better way to pass different options to different commands found by AC_CHECK_PROGS, but in fact, I can't really envision anything else that would work better. It just /feels/ like the wrong place to do what I'm trying to do.

John




reply via email to

[Prev in Thread] Current Thread [Next in Thread]