Build system: Build and install .java files in bindings/java/ automatically.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 11 May 2009 08:12:46 +0000 (10:12 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 11 May 2009 08:12:46 +0000 (10:12 +0200)
bindings/Makefile.am
bindings/java/Makefile.am [new file with mode: 0644]
configure.in

index 3ab4c87..fb68657 100644 (file)
@@ -1,5 +1,10 @@
-EXTRA_DIST = java/org/collectd/java/*.java java/org/collectd/api/*.java \
-               perl/Collectd.pm perl/Makefile.PL perl/Collectd/Makefile.PL \
+SUBDIRS =
+
+if BUILD_WITH_JAVA
+SUBDIRS += java
+endif
+
+EXTRA_DIST = perl/Collectd.pm perl/Makefile.PL perl/Collectd/Makefile.PL \
                perl/Collectd/Unixsock.pm
 
 all-local: @PERL_BINDINGS@
diff --git a/bindings/java/Makefile.am b/bindings/java/Makefile.am
new file mode 100644 (file)
index 0000000..6eead28
--- /dev/null
@@ -0,0 +1,35 @@
+EXTRA_DIST = org/collectd/api/CollectdConfigInterface.java \
+            org/collectd/api/CollectdFlushInterface.java \
+            org/collectd/api/CollectdInitInterface.java \
+            org/collectd/api/Collectd.java \
+            org/collectd/api/CollectdLogInterface.java \
+            org/collectd/api/CollectdMatchFactoryInterface.java \
+            org/collectd/api/CollectdMatchInterface.java \
+            org/collectd/api/CollectdNotificationInterface.java \
+            org/collectd/api/CollectdReadInterface.java \
+            org/collectd/api/CollectdShutdownInterface.java \
+            org/collectd/api/CollectdTargetFactoryInterface.java \
+            org/collectd/api/CollectdTargetInterface.java \
+            org/collectd/api/CollectdWriteInterface.java \
+            org/collectd/api/DataSet.java \
+            org/collectd/api/DataSource.java \
+            org/collectd/api/Notification.java \
+            org/collectd/api/OConfigItem.java \
+            org/collectd/api/OConfigValue.java \
+            org/collectd/api/PluginData.java \
+            org/collectd/api/ValueList.java
+
+java-build-stamp: org/collectd/api/*.java
+       $(JAVAC) -d "$(builddir)" "$(srcdir)/org/collectd/api"/*.java
+       touch "$@"
+
+all-local: java-build-stamp
+
+install-exec-local: java-build-stamp
+       mkdir -p "$(pkglibdir)/java/org/collectd/api"
+       $(INSTALL) -m 644 "$(builddir)/org/collectd/api"/*.class \
+               "$(DESTDIR)$(pkglibdir)/java/org/collectd/api/"
+
+clean-local:
+       rm -f "$(builddir)/org/collectd/api"/*.class
+       rm -f "$(builddir)/java-build-stamp"
index bed0c5d..e37a8ab 100644 (file)
@@ -1481,6 +1481,7 @@ with_java_home="$JAVA_HOME"
 with_java_vmtype="client"
 with_java_cflags=""
 with_java_libs=""
+JAVAC="$JAVAC"
 AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
 [
        if test "x$withval" = "xno"
@@ -1528,6 +1529,19 @@ then
                else
                        AC_MSG_RESULT([not found])
                fi
+
+               if test "x$JAVAC" = "x"
+               then
+                       AC_MSG_CHECKING([for javac])
+                       TMPDIR=`find -L "$with_java_home" -name javac | head -n 1`
+                       if test "x$TMPDIR" != "x"
+                       then
+                               JAVAC="$TMPDIR"
+                               AC_MSG_RESULT([$JAVAC])
+                       else
+                               AC_MSG_RESULT([not found])
+                       fi
+               fi
        else if test "x$with_java_home" != "x"
        then
                AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
@@ -1546,6 +1560,24 @@ if test "x$JAVA_LDFLAGS" != "x"
 then
        AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
 fi
+if test "x$JAVAC" = "x"
+then
+       with_javac_path="$PATH"
+       if test "x$with_java_home" != "x"
+       then
+               with_javac_path="$with_java_home:with_javac_path"
+               if test -d "$with_java_home/bin"
+               then
+                       with_javac_path="$with_java_home/bin:with_javac_path"
+               fi
+       fi
+
+       AC_PATH_PROG(JAVAC, javac, [], "$with_javac_path")
+fi
+if test "x$JAVAC" = "x"
+then
+       with_java="no (javac not found)"
+fi
 
 SAVE_CPPFLAGS="$CPPFLAGS"
 SAVE_CFLAGS="$CFLAGS"
@@ -3691,7 +3723,7 @@ AC_SUBST(LCC_VERSION_STRING)
 
 AC_CONFIG_FILES(src/libcollectdclient/lcc_features.h)
 
-AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile)
+AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile bindings/java/Makefile)
 
 if test "x$with_librrd" = "xyes" \
        && test "x$librrd_threadsafe" != "xyes"