RHEL 5: $(builddir) did not exist with this old autoconf/automake, so workaround.
[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., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 # Old RHEL 5 autoconf doesn't have builddir.
19 builddir ?= $(top_builddir)/java
20
21 java_prefix = com/redhat/et/libguestfs
22
23 java_sources = \
24         $(java_prefix)/LibGuestFSException.java \
25         $(java_prefix)/IntBool.java \
26         $(java_prefix)/PV.java \
27         $(java_prefix)/VG.java \
28         $(java_prefix)/LV.java \
29         $(java_prefix)/Stat.java \
30         $(java_prefix)/StatVFS.java \
31         $(java_prefix)/Dirent.java \
32         $(java_prefix)/GuestFS.java
33
34 java_tests = \
35         Bindtests.java \
36         t/GuestFS005Load.java \
37         t/GuestFS010Launch.java \
38         t/GuestFS050LVCreate.java
39
40 EXTRA_DIST = \
41         $(java_sources) \
42         $(java_tests) \
43         run-bindtests \
44         run-java-tests
45
46 CLEANFILES = doc-stamp
47
48 if HAVE_JAVA
49
50 # Java source.
51
52 libguestfs_jardir = $(JAR_INSTALL_DIR)
53 libguestfs_jar_DATA = libguestfs-${VERSION}.jar
54 libguestfs_jar_class_files = $(java_sources:.java=.class)
55 $(libguestfs_jar_class_files): %.class: %.java
56         $(JAVAC) $(JAVAC_FLAGS) -d $(builddir) -classpath @srcdir@:$(builddir) -sourcepath @srcdir@:$(builddir) $<
57
58 libguestfs-${VERSION}.jar: $(libguestfs_jar_class_files)
59         $(JAR) cf $@ $^
60
61 # JNI source.
62
63 lib_LTLIBRARIES = libguestfs_jni.la
64 libguestfs_jni_la_SOURCES = \
65         com_redhat_et_libguestfs_GuestFS.h \
66         com_redhat_et_libguestfs_GuestFS.c
67
68 libguestfs_jni_la_LIBADD = $(top_builddir)/src/libguestfs.la
69 libguestfs_jni_la_LDFLAGS = -version-info $(JNI_VERSION_INFO)
70 libguestfs_jni_la_CFLAGS = -Wall -I$(top_srcdir)/src -I$(top_builddir)/src $(JNI_CFLAGS)
71
72 BUILT_SOURCES = com_redhat_et_libguestfs_GuestFS.h
73
74 com_redhat_et_libguestfs_GuestFS.h: $(java_prefix)/GuestFS.class
75         $(JAVAH) -classpath @srcdir@:$(builddir) com.redhat.et.libguestfs.GuestFS
76
77 # Documentation.
78
79 noinst_SCRIPTS = doc-stamp
80
81 doc-stamp: $(java_sources)
82         $(JAVADOC) $(JAVADOC_FLAGS) -d api \
83           -sourcepath $(srcdir) \
84           -windowtitle "libguestfs java $(VERSION) API reference" \
85           -doctitle "libguestfs java $(VERSION) API reference" \
86           com.redhat.et.libguestfs
87         touch $@
88
89 install-data-hook:
90         mkdir -p $(DESTDIR)$(datadir)/javadoc/$(PACKAGE_NAME)-java-$(PACKAGE_VERSION)
91         cp -a api/* $(DESTDIR)$(datadir)/javadoc/$(PACKAGE_NAME)-java-$(PACKAGE_VERSION)
92
93 # Tests (not comprehensive).
94
95 TESTS = run-bindtests run-java-tests
96 TESTS_ENVIRONMENT = \
97         JAVA=$(JAVA) \
98         CLASSPATH=.:t:libguestfs-$(VERSION).jar \
99         LIBGUESTFS_PATH=$(top_builddir)/appliance
100
101 noinst_DATA = Bindtests.class $(java_tests:.java=.class)
102
103 t/%.class: t/%.java
104         $(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar $<
105
106 Bindtests.class: Bindtests.java
107         $(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar $<
108
109 endif
110
111 # Tell version 3.79 and up of GNU make to not build goals in this
112 # directory in parallel.
113 .NOTPARALLEL: