java: out-of-tree build, don't build static library
[libguestfs.git] / java / Makefile.am
1 # libguestfs Java bindings
2 # Copyright (C) 2009 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 include $(top_srcdir)/subdir-rules.mk
19
20 # Old RHEL 5 autoconf doesn't have builddir.
21 builddir ?= $(top_builddir)/java
22
23 # XXX: Need to fix generator.ml dependencies
24 #
25 # Files generated by generator.ml:
26 #   Makefile.inc
27 #   All files listed in Makefile.inc
28 #   com_redhat_et_libguestfs_GuestFS.c
29 #   Bindtests.java
30
31 java_prefix = com/redhat/et/libguestfs
32
33 # Pull in automatically generated built sources
34 include $(srcdir)/Makefile.inc
35
36 java_sources = \
37         $(java_built_sources) \
38         com/redhat/et/libguestfs/LibGuestFSException.java
39
40 java_tests = \
41         Bindtests.java \
42         t/GuestFS005Load.java \
43         t/GuestFS010Basic.java \
44         t/GuestFS080OptArgs.java
45
46 EXTRA_DIST = \
47         $(java_sources) \
48         $(java_tests) \
49         run-bindtests \
50         run-java-tests \
51         Makefile.inc
52
53 CLEANFILES = doc-stamp $(builddir)/com/redhat/et/libguestfs/*.class com_redhat_et_libguestfs_GuestFS.h *.class *.jar api/com/redhat/et/libguestfs/*.html api/*
54
55 if HAVE_JAVA
56
57 # Java source.
58
59 libguestfs_jardir = $(JAR_INSTALL_DIR)
60 libguestfs_jar_DATA = libguestfs-${VERSION}.jar
61 libguestfs_jar_class_files = $(java_sources:.java=.class)
62 $(libguestfs_jar_class_files): %.class: %.java
63         $(JAVAC) $(JAVAC_FLAGS) -d $(builddir) -classpath @srcdir@:$(builddir) -sourcepath @srcdir@:$(builddir) $<
64
65 libguestfs-${VERSION}.jar: $(libguestfs_jar_class_files)
66         $(JAR) cf $@ $^
67
68 # JNI source.
69
70 lib_LTLIBRARIES = libguestfs_jni.la
71 libguestfs_jni_la_SOURCES = \
72         com_redhat_et_libguestfs_GuestFS.h \
73         com_redhat_et_libguestfs_GuestFS.c
74
75 libguestfs_jni_la_LIBADD = $(top_builddir)/src/libguestfs.la
76 libguestfs_jni_la_LDFLAGS = -version-info $(JNI_VERSION_INFO) -shared
77 libguestfs_jni_la_CFLAGS = \
78   $(WARN_CFLAGS) $(WERROR_CFLAGS) \
79   -I$(top_srcdir)/src -I$(top_builddir)/src \
80   $(JNI_CFLAGS)
81
82 BUILT_SOURCES = com_redhat_et_libguestfs_GuestFS.h
83
84 com_redhat_et_libguestfs_GuestFS.h: $(java_prefix)/GuestFS.class
85         $(JAVAH) -classpath @srcdir@:$(builddir) com.redhat.et.libguestfs.GuestFS
86
87 # Documentation.
88
89 noinst_SCRIPTS = doc-stamp
90
91 doc-stamp: $(java_sources)
92         $(JAVADOC) $(JAVADOC_FLAGS) -d api \
93           -sourcepath $(srcdir) \
94           -windowtitle "libguestfs java $(VERSION) API reference" \
95           -doctitle "libguestfs java $(VERSION) API reference" \
96           com.redhat.et.libguestfs
97         touch $@
98
99 install-data-hook:
100         mkdir -p $(DESTDIR)$(datadir)/javadoc/$(PACKAGE_NAME)-java-$(PACKAGE_VERSION)
101         cp -a api/* $(DESTDIR)$(datadir)/javadoc/$(PACKAGE_NAME)-java-$(PACKAGE_VERSION)
102
103 # Tests (not comprehensive).
104
105 TESTS = run-bindtests run-java-tests
106 TESTS_ENVIRONMENT = \
107         JAVA=$(JAVA) \
108         CLASSPATH=.:t:libguestfs-$(VERSION).jar \
109         LIBGUESTFS_PATH=$(top_builddir)/appliance \
110         TMPDIR=$(top_builddir)
111
112 noinst_DATA = Bindtests.class $(java_tests:.java=.class)
113
114 t/%.class: t/%.java
115         mkdir -p t
116         $(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar -d $(builddir)/t $<
117
118 Bindtests.class: Bindtests.java
119         $(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar -d $(builddir) $<
120
121 endif
122
123 # Tell version 3.79 and up of GNU make to not build goals in this
124 # directory in parallel.
125 .NOTPARALLEL: