[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AM_PROG_GCJ fails at `make' if nothing else defines OBJEXT
From: |
Jack Kelly |
Subject: |
Re: AM_PROG_GCJ fails at `make' if nothing else defines OBJEXT |
Date: |
Sun, 7 Jun 2009 20:16:01 +1000 |
On Sun, Jun 7, 2009 at 4:06 PM, Ralf Wildenhues<address@hidden> wrote:
>> 2. The suffix mechanism might not be quite enough for Java projects
>> with native methods using the C++ interface.
>
> I'm sorry, but I fail to parse this. Even with the example you gave, it
> is unclear to me. Can you rephrase this, state the problem setup in
> more detail, and which parts are not supported by Automake? Can these
> parts easily be worked around by the Makefile.am author?
This is the best I can come up with:
configure.ac:
8<---
AC_INIT([a], [b], [c])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CXX
AM_PROG_GCJ
AC_PATH_PROG([GCJH], [gcjh], [no])
AS_IF([test "$GCJH" = no], [AC_MSG_ERROR([bad luck.])])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
8<---
Makefile.am:
8<---
noinst_PROGRAMS = cnitest
BUILT_SOURCES = CniTest.h
cnitest_SOURCES = CniTest.java CniTest_native.cc
cnitest_LDFLAGS = --main=CniTest
.java.class:
$(GCJ) -C $<
# The -cp is to work around a bug in ubuntu's gcjh setting the
# classpath wrong.
.class.h:
$(GCJH) -cp .:/usr/share/java/libgcj.jar $<
8<---
CniTest.java:
8<---
public class CniTest {
public static native void printFromCxx(String message);
public static void main(String[] args) {
printFromCxx("Hi from C++");
}
}
8<---
CniTest_native.cc:
8<---
#include <java/io/PrintStream.h>
#include <java/lang/System.h>
#include "CniTest.h"
void CniTest::printFromCxx(::java::lang::String * arg) {
java::lang::System::out->println(arg);
}
8<---
> What files does this generate in general, can we tell in some way,
> ideally, without looking at the .java files? (If we'd have to look
> at them, then in principle, the Makefile file (or Makefile.in) would
> depend upon the .java file, which seems ugly.)
This has the usual problems with compiling java: multiple outputs from
the one input. (see the _JAVA primary.)
In fact: would it be possible to add GCJ support to the _JAVA primary?
I'm not a java expert, but I'm reasonably sure that every .java file
has either a public class or interface, so adding a rule to
Makefile.in of the form:
CniTest.class: classdir.stamp
might work. Generate one such rule for each java file in a _JAVA
primary and add them to .PHONY.
This then simplifies the Makefile.am, so the explicit .java.class rule
can go away and be replaced with a noinst_JAVA = CniTest.java entry.
The .class.h rule can then be moved into a fragment.
An autoconf test would also be needed to find and AC_SUBST a value for
JAVAC and JAVACFLAGS, and use $(GCJ) -C as one of the options.
(AM_PROG_JAVAC?)
Does this make sense?
-- Jack