From 7de2166d97c1b729e2227304b60df3362ce4f888 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Thu, 27 Oct 2011 18:38:29 -0400 Subject: [PATCH 01/11] Autotoolize Makefile --- .gitignore | 19 ++++++++++++++++-- Makefile | 19 ------------------ Makefile.am | 39 +++++++++++++++++++++++++++++++++++ acinclude.m4 | 33 ++++++++++++++++++++++++++++++ configure.ac | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 146 insertions(+), 21 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100644 acinclude.m4 create mode 100644 configure.ac diff --git a/.gitignore b/.gitignore index 9dbcc6b..7873cdd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,19 @@ +/aclocal.m4 +/autom4te.cache /bin +/build-aux +/configure +/config.h +/config.h.in +/config.log +/config.status +/libtool +/stamp-h1 + +.deps +.libs +Makefile +Makefile.in *.jar -*.so -*.dll +*.la +*.lo diff --git a/Makefile b/Makefile deleted file mode 100644 index 0fc296f..0000000 --- a/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# simple makefile for now - -CC = gcc -JAVAC = javac -JAVA_HOME = /usr/lib/jvm/java -JAVA_PLATFORM = linux - -all: libopenslide-jni.so - ant - -libopenslide-jni.so: openslide-jni.c - $(CC) $(CFLAGS) -fPIC -shared -g -O2 -Wall -o $@ $< -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/$(JAVA_PLATFORM) $$(pkg-config openslide --cflags --libs) - -clean: - ant clean - $(RM) libopenslide-jni.so openslide_wrap.c *~ bin - - -.PHONY: all clean diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..9586d7d --- /dev/null +++ b/Makefile.am @@ -0,0 +1,39 @@ +ACLOCAL_AMFLAGS = -I m4 + +pkglib_LTLIBRARIES = libopenslide-jni.la +libopenslide_jni_la_SOURCES = openslide-jni.c +libopenslide_jni_la_CFLAGS = -Wall $(JNI_CFLAGS) $(OPENSLIDE_CFLAGS) +libopenslide_jni_la_LDFLAGS = -avoid-version $(OPENSLIDE_LIBS) + +pkglib_DATA = openslide.jar +JAVA_SRC = build.xml \ + src/edu/cmu/cs/openslide/AssociatedImageMap.java \ + src/edu/cmu/cs/openslide/OpenSlideDisposedException.java \ + src/edu/cmu/cs/openslide/OpenSlide.java \ + src/edu/cmu/cs/openslide/OpenSlideJNI.java \ + src/edu/cmu/cs/openslide/TestCLI.java \ + src/edu/cmu/cs/openslide/gui/Annotation.java \ + src/edu/cmu/cs/openslide/gui/DefaultAnnotation.java \ + src/edu/cmu/cs/openslide/gui/DefaultSelectionListModel.java \ + src/edu/cmu/cs/openslide/gui/Demo.java \ + src/edu/cmu/cs/openslide/gui/OpenSlideView.java \ + src/edu/cmu/cs/openslide/gui/SelectionListModel.java \ + src/org/openslide/dzi/DeepZoomGenerator.java + +openslide.jar: $(JAVA_SRC) + @$(ANT) + +mostlyclean-local: + @$(ANT) clean + +install-exec-hook: + chmod -x $(DESTDIR)$(pkglibdir)/libopenslide-jni.so + rm -f $(DESTDIR)$(pkglibdir)/libopenslide-jni.la + +EXTRA_DIST = \ + CHANGELOG.txt \ + LICENSE.txt \ + TODO.txt \ + lgpl-2.1.txt \ + mingw32-cheatsheet.txt \ + $(JAVA_SRC) diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..120af64 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,33 @@ +# FIND_FILE([OUTPUT], [FILE_NAME], [SEARCH_PATHS]) +# The paths in SEARCH_PATHS are searched to determine whether they contain +# the file FILE_NAME. If so, OUTPUT is set to the directory containing +# the file. Otherwise, an error is produced. +# ------------------------------------------------------------------------ +AC_DEFUN([FIND_FILE], [ + AC_MSG_CHECKING([for $2]) + $1= + for ac__path in $3 + do + if test -r $ac__path/$2 ; then + AC_MSG_RESULT([$ac__path]) + $1=$ac__path + break + fi + done + if test z$$1 = z ; then + AC_MSG_RESULT([not found]) + AC_MSG_ERROR([cannot find $2 in $3]) + fi +]) + + +# JOIN_EACH([OUTPUT], [PATHS], [SUBDIR]) +# Append SUBDIR to each of the PATHS and put the result in OUTPUT. +# ---------------------------------------------------------------- +AC_DEFUN([JOIN_EACH], [ + $1= + for dir in $2 + do + $1="$$1 $dir/$3" + done +]) diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..abe5f95 --- /dev/null +++ b/configure.ac @@ -0,0 +1,57 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.66]) +AC_INIT([OpenSlide Java], [0.9.2], [openslide-users@lists.andrew.cmu.edu]) +AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_SRCDIR([openslide-jni.c]) +AC_CONFIG_HEADERS([config.h]) +AM_INIT_AUTOMAKE([foreign dist-xz]) +AM_SILENT_RULES([yes]) +LT_INIT([disable-static]) + +# Checks for programs. + +PKG_PROG_PKG_CONFIG() +AC_PROG_CC + +AC_PATH_PROG([ANT], [ant]) +AC_ARG_VAR([ANT], [path to ant]) +if test z$ANT = z ; then + AC_MSG_ERROR([ant not found]) +fi + +# Checks for libraries. + +PKG_CHECK_MODULES([OPENSLIDE], [openslide]) + +# Checks for header files. + +AC_ARG_VAR([JAVA_HOME], [path to JDK]) +AC_ARG_WITH([java], [AS_HELP_STRING([--with-java], [path to JDK])], [], + [with_java="$JAVA_HOME /usr/lib/jvm/java"]) +# Find jni.h +JOIN_EACH([include_paths], [$with_java], [include]) +FIND_FILE([jni_h_dir], [jni.h], [$include_paths]) +# Find jni_md.h +AS_CASE([$host], + [*-*-linux-gnu], [include_subdir=linux], + [*-*-mingw32], [include_subdir=win32], + [include_subdir=] +) +JOIN_EACH([platform_include_paths], [$include_paths], [$include_subdir]) +FIND_FILE([jni_md_h_dir], [jni_md.h], + [$platform_include_paths $include_paths]) +JNI_CFLAGS="-I$jni_h_dir -I$jni_md_h_dir" +AC_SUBST([JNI_CFLAGS]) + +# Checks for typedefs, structures, and compiler characteristics. + +AC_TYPE_INT64_T +AC_TYPE_UINT32_T + +# Checks for library functions. + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT From b828c8708bbec325cae9e15f2c06281d0d1941d9 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Thu, 27 Oct 2011 18:49:10 -0400 Subject: [PATCH 02/11] Fix VPATH builds with Ant --- Makefile.am | 4 ++-- build.xml | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9586d7d..79c51ae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,10 +21,10 @@ JAVA_SRC = build.xml \ src/org/openslide/dzi/DeepZoomGenerator.java openslide.jar: $(JAVA_SRC) - @$(ANT) + @$(ANT) -f $(srcdir)/build.xml -Dbuilddir=$(abs_builddir) mostlyclean-local: - @$(ANT) clean + @$(ANT) -f $(srcdir)/build.xml -Dbuilddir=$(abs_builddir) clean install-exec-hook: chmod -x $(DESTDIR)$(pkglibdir)/libopenslide-jni.so diff --git a/build.xml b/build.xml index ab4cc91..d1f5985 100644 --- a/build.xml +++ b/build.xml @@ -4,22 +4,23 @@ + - + - - + + - - + + - + @@ -30,7 +31,7 @@ - + From 843ec6c0c318c057d0a2d2dada482d640291343a Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Thu, 27 Oct 2011 21:51:22 -0400 Subject: [PATCH 03/11] Avoid compiler warnings on 32-bit systems The JNI code stores a pointer inside a jlong, causing warnings on 32-bit systems. Silence these. --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 79c51ae..56a7fe5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,6 +3,7 @@ ACLOCAL_AMFLAGS = -I m4 pkglib_LTLIBRARIES = libopenslide-jni.la libopenslide_jni_la_SOURCES = openslide-jni.c libopenslide_jni_la_CFLAGS = -Wall $(JNI_CFLAGS) $(OPENSLIDE_CFLAGS) +libopenslide_jni_la_CFLAGS += -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast libopenslide_jni_la_LDFLAGS = -avoid-version $(OPENSLIDE_LIBS) pkglib_DATA = openslide.jar From fa64d207abd873d4846b62cd1f24c313fdc9f5a8 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Fri, 28 Oct 2011 00:19:46 -0400 Subject: [PATCH 04/11] Add Autotools support for Windows cross compiles --- Makefile.am | 25 +++++++++++++----- configure.ac | 60 ++++++++++++++++++++++++++++++++---------- mingw32-cheatsheet.txt | 5 ---- 3 files changed, 64 insertions(+), 26 deletions(-) delete mode 100644 mingw32-cheatsheet.txt diff --git a/Makefile.am b/Makefile.am index 56a7fe5..d4619a8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,10 +1,21 @@ ACLOCAL_AMFLAGS = -I m4 -pkglib_LTLIBRARIES = libopenslide-jni.la +AM_CFLAGS = -Wall $(JNI_CFLAGS) $(OPENSLIDE_CFLAGS) +AM_CFLAGS += -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast +AM_LDFLAGS = -avoid-version -no-undefined -module $(OPENSLIDE_LIBS) + +if DLL +# JNI uses stdcall without @ +AM_LDFLAGS += -Wl,--kill-at +JNI_LA = openslide-jni.la +JNI_SO = openslide-jni.dll +else +JNI_LA = libopenslide-jni.la +JNI_SO = libopenslide-jni.so +endif + +pkglib_LTLIBRARIES = $(JNI_LA) libopenslide_jni_la_SOURCES = openslide-jni.c -libopenslide_jni_la_CFLAGS = -Wall $(JNI_CFLAGS) $(OPENSLIDE_CFLAGS) -libopenslide_jni_la_CFLAGS += -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -libopenslide_jni_la_LDFLAGS = -avoid-version $(OPENSLIDE_LIBS) pkglib_DATA = openslide.jar JAVA_SRC = build.xml \ @@ -28,13 +39,13 @@ mostlyclean-local: @$(ANT) -f $(srcdir)/build.xml -Dbuilddir=$(abs_builddir) clean install-exec-hook: - chmod -x $(DESTDIR)$(pkglibdir)/libopenslide-jni.so - rm -f $(DESTDIR)$(pkglibdir)/libopenslide-jni.la + chmod -x $(DESTDIR)$(pkglibdir)/$(JNI_SO) + rm -f $(DESTDIR)$(pkglibdir)/$(JNI_LA) \ + $(DESTDIR)$(pkglibdir)/$(JNI_SO).a EXTRA_DIST = \ CHANGELOG.txt \ LICENSE.txt \ TODO.txt \ lgpl-2.1.txt \ - mingw32-cheatsheet.txt \ $(JAVA_SRC) diff --git a/configure.ac b/configure.ac index abe5f95..22387fe 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ AC_CONFIG_SRCDIR([openslide-jni.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign dist-xz]) AM_SILENT_RULES([yes]) -LT_INIT([disable-static]) +LT_INIT([win32-dll disable-static]) # Checks for programs. @@ -31,19 +31,43 @@ PKG_CHECK_MODULES([OPENSLIDE], [openslide]) AC_ARG_VAR([JAVA_HOME], [path to JDK]) AC_ARG_WITH([java], [AS_HELP_STRING([--with-java], [path to JDK])], [], [with_java="$JAVA_HOME /usr/lib/jvm/java"]) -# Find jni.h -JOIN_EACH([include_paths], [$with_java], [include]) -FIND_FILE([jni_h_dir], [jni.h], [$include_paths]) -# Find jni_md.h -AS_CASE([$host], - [*-*-linux-gnu], [include_subdir=linux], - [*-*-mingw32], [include_subdir=win32], - [include_subdir=] -) -JOIN_EACH([platform_include_paths], [$include_paths], [$include_subdir]) -FIND_FILE([jni_md_h_dir], [jni_md.h], - [$platform_include_paths $include_paths]) -JNI_CFLAGS="-I$jni_h_dir -I$jni_md_h_dir" +if test $host = $build; then + # Find jni.h + JOIN_EACH([include_paths], [$with_java], [include]) + FIND_FILE([jni_h_dir], [jni.h], [$include_paths]) + # Find jni_md.h + AS_CASE([$host], + [*-*-linux-gnu], [include_subdir=linux], + [*-*-mingw32], [include_subdir=win32], + [include_subdir=] + ) + JOIN_EACH([platform_include_paths], [$include_paths], [$include_subdir]) + FIND_FILE([jni_md_h_dir], [jni_md.h], + [$platform_include_paths $include_paths]) + JNI_CFLAGS="-I$jni_h_dir -I$jni_md_h_dir" +else + # For cross builds, we don't have the OpenJDK jni_md.h for the target + # platform, so use the GNU Classpath JNI headers in the build system's + # gcj include directory instead. Autoconf doesn't give us a variable + # for the build compiler, which is okay because anything other than + # GCC probably won't support this syntax. + # + # This is terrible. + JNI_CFLAGS= + AC_MSG_CHECKING([for cross jni.h and jni_md.h]) + for word in $(gcc - -v -E < /dev/null 2>&1) + do + if test -r "$word/jni.h" -a -r "$word/jni_md.h" ; then + AC_MSG_RESULT([$word]) + JNI_CFLAGS="-I$word" + break + fi + done + if test x$JNI_CFLAGS = x ; then + AC_MSG_RESULT([not found]) + AC_MSG_ERROR([cannot find JNI headers]) + fi +fi AC_SUBST([JNI_CFLAGS]) # Checks for typedefs, structures, and compiler characteristics. @@ -51,6 +75,14 @@ AC_SUBST([JNI_CFLAGS]) AC_TYPE_INT64_T AC_TYPE_UINT32_T +AC_MSG_CHECKING([JNI library name]) +if test x$shrext_cmds = x.dll ; then + AC_MSG_RESULT([openslide-jni.dll]) +else + AC_MSG_RESULT([libopenslide-jni.so]) +fi +AM_CONDITIONAL([DLL], [test x$shrext_cmds = x.dll]) + # Checks for library functions. AC_CONFIG_FILES([Makefile]) diff --git a/mingw32-cheatsheet.txt b/mingw32-cheatsheet.txt deleted file mode 100644 index 1ace2e4..0000000 --- a/mingw32-cheatsheet.txt +++ /dev/null @@ -1,5 +0,0 @@ -* kill-at is required because JNI uses stdcall without @ -* Use classpath's jni.h instead of OpenJDK's, because it has all the - win32 conditionals - -i686-pc-mingw32-gcc -Wl,--kill-at -shared -g -O2 -Wall -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -o openslide-jni.dll openslide-jni.c -I/tmp/zzzzz/usr/i686-pc-mingw32/sys-root/mingw/include/openslide -I/usr/lib/gcc/x86_64-redhat-linux/4.4.0/include -lopenslide -L/tmp/zzzzz/usr/i686-pc-mingw32/sys-root/mingw/lib From b380dd1e71e333f857c3f2be66f1abe5f1b9a772 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Fri, 28 Oct 2011 00:32:04 -0400 Subject: [PATCH 05/11] Add initial README.txt --- Makefile.am | 1 + README.txt | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 README.txt diff --git a/Makefile.am b/Makefile.am index d4619a8..22b72a9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,6 +46,7 @@ install-exec-hook: EXTRA_DIST = \ CHANGELOG.txt \ LICENSE.txt \ + README.txt \ TODO.txt \ lgpl-2.1.txt \ $(JAVA_SRC) diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..a163f19 --- /dev/null +++ b/README.txt @@ -0,0 +1,28 @@ +Build requirements +------------------ + +- POSIX shell +- Make +- C compiler +- JDK +- Apache Ant +- OpenSlide + +Building on Linux +----------------- + +./configure +make +make install + +Cross-compiling for Windows with mingw32 +---------------------------------------- + +You will need the GNU Classpath version of jni.h installed. (On Fedora +this is in the libgcj-devel package.) + +PKG_CONFIG=pkg-config \ + PKG_CONFIG_PATH=/path/to/cross/compiled/openslide/lib/pkgconfig \ + ./configure --host=i686-pc-mingw32 +make +make install From 4f71df19ff40f3cc343fdc9509e7eec9b2b1fdc3 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sat, 29 Oct 2011 00:32:53 -0400 Subject: [PATCH 06/11] Add empty m4 directory to repository Fixes autoreconf failure. --- m4/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 m4/.gitignore diff --git a/m4/.gitignore b/m4/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/m4/.gitignore @@ -0,0 +1 @@ +* From 11aa8391c445ea6ee3bc1c606faa5e12c8ed7ecf Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sat, 29 Oct 2011 23:05:31 -0400 Subject: [PATCH 07/11] Embed JNI library path in JAR, except on Windows On Linux, the JNI library will likely not be in the library search path. Load it by its full path in this case. --- Makefile.am | 9 +++++-- build.xml | 6 ++++- configure.ac | 8 ++++++ src/edu/cmu/cs/openslide/OpenSlideJNI.java | 29 +++++++++++++++++++++- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 22b72a9..eeed224 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,6 +14,10 @@ JNI_LA = libopenslide-jni.la JNI_SO = libopenslide-jni.so endif +if EMBED_PATH +JNI_EMBED_PATH = $(pkglibdir)/$(JNI_SO) +endif + pkglib_LTLIBRARIES = $(JNI_LA) libopenslide_jni_la_SOURCES = openslide-jni.c @@ -32,8 +36,9 @@ JAVA_SRC = build.xml \ src/edu/cmu/cs/openslide/gui/SelectionListModel.java \ src/org/openslide/dzi/DeepZoomGenerator.java -openslide.jar: $(JAVA_SRC) - @$(ANT) -f $(srcdir)/build.xml -Dbuilddir=$(abs_builddir) +openslide.jar: $(JAVA_SRC) config.h + @$(ANT) -f $(srcdir)/build.xml -Dbuilddir=$(abs_builddir) \ + -Dopenslide.jni.path=$(JNI_EMBED_PATH) mostlyclean-local: @$(ANT) -f $(srcdir)/build.xml -Dbuilddir=$(abs_builddir) clean diff --git a/build.xml b/build.xml index d1f5985..82b3853 100644 --- a/build.xml +++ b/build.xml @@ -5,11 +5,12 @@ + - + @@ -35,6 +36,9 @@ + + + diff --git a/configure.ac b/configure.ac index 22387fe..8502103 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,14 @@ else fi AM_CONDITIONAL([DLL], [test x$shrext_cmds = x.dll]) +AC_MSG_CHECKING([whether to embed library path in JAR]) +if test x$shrext_cmds = x.dll ; then + AC_MSG_RESULT([no]) +else + AC_MSG_RESULT([yes]) +fi +AM_CONDITIONAL([EMBED_PATH], [test x$shrext_cmds != x.dll]) + # Checks for library functions. AC_CONFIG_FILES([Makefile]) diff --git a/src/edu/cmu/cs/openslide/OpenSlideJNI.java b/src/edu/cmu/cs/openslide/OpenSlideJNI.java index 7c956b0..aea7d4a 100644 --- a/src/edu/cmu/cs/openslide/OpenSlideJNI.java +++ b/src/edu/cmu/cs/openslide/OpenSlideJNI.java @@ -21,12 +21,39 @@ package edu.cmu.cs.openslide; +import java.io.InputStream; +import java.io.IOException; +import java.util.Properties; + class OpenSlideJNI { private OpenSlideJNI() { } static { - System.loadLibrary("openslide-jni"); + String libraryPath = null; + + try { + InputStream is = OpenSlideJNI.class.getClassLoader(). + getResourceAsStream("resources/openslide.properties"); + if (is != null) { + Properties p = new Properties(); + p.load(is); + libraryPath = p.getProperty("openslide.jni.path"); + if (libraryPath.equals("")) { + libraryPath = null; + } + } + } catch (SecurityException e1) { + e1.printStackTrace(); + } catch (IOException e2) { + e2.printStackTrace(); + } + + if (libraryPath != null) { + System.load(libraryPath); + } else { + System.loadLibrary("openslide-jni"); + } } native static boolean openslide_can_open(String file); From 43be856cd378f85f006281517a70221cdf02dd44 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sat, 29 Oct 2011 23:20:17 -0400 Subject: [PATCH 08/11] README: Set --build when cross-compiling If --host is passed to configure but --build is not, configure will guess whether we are cross-compiling based on whether it can run a compiled executable. If the build system is configured to run Windows executables via Wine, this test can fail. --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index a163f19..4d55a09 100644 --- a/README.txt +++ b/README.txt @@ -23,6 +23,6 @@ this is in the libgcj-devel package.) PKG_CONFIG=pkg-config \ PKG_CONFIG_PATH=/path/to/cross/compiled/openslide/lib/pkgconfig \ - ./configure --host=i686-pc-mingw32 + ./configure --host=i686-pc-mingw32 --build=$(build-aux/config.guess) make make install From 052d2d2c54af23c9643fb7d8ecd3a89592e2e85b Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sun, 30 Oct 2011 14:43:31 -0400 Subject: [PATCH 09/11] Pass ANT_HOME and JAVA_HOME configure variables to ant --- Makefile.am | 3 +++ configure.ac | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index eeed224..03db8ee 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,6 +18,9 @@ if EMBED_PATH JNI_EMBED_PATH = $(pkglibdir)/$(JNI_SO) endif +export JAVA_HOME +export ANT_HOME + pkglib_LTLIBRARIES = $(JNI_LA) libopenslide_jni_la_SOURCES = openslide-jni.c diff --git a/configure.ac b/configure.ac index 8502103..f5af812 100644 --- a/configure.ac +++ b/configure.ac @@ -16,8 +16,14 @@ LT_INIT([win32-dll disable-static]) PKG_PROG_PKG_CONFIG() AC_PROG_CC +# For distribution-packaged Ant, $ANT may not be $ANT_HOME/bin/ant. +# Use and pass through ANT_HOME if we receive it; otherwise, focus on ANT. +AC_ARG_VAR([ANT], [path to ant program]) +AC_ARG_VAR([ANT_HOME], [path to ant installation directory]) +if test z$ANT = z -a z$ANT_HOME != z ; then + ANT=$ANT_HOME/bin/ant +fi AC_PATH_PROG([ANT], [ant]) -AC_ARG_VAR([ANT], [path to ant]) if test z$ANT = z ; then AC_MSG_ERROR([ant not found]) fi @@ -35,6 +41,7 @@ if test $host = $build; then # Find jni.h JOIN_EACH([include_paths], [$with_java], [include]) FIND_FILE([jni_h_dir], [jni.h], [$include_paths]) + JAVA_HOME=$(dirname $jni_h_dir) # Find jni_md.h AS_CASE([$host], [*-*-linux-gnu], [include_subdir=linux], @@ -52,6 +59,8 @@ else # for the build compiler, which is okay because anything other than # GCC probably won't support this syntax. # + # Don't set JAVA_HOME unless it was specified on the command line. + # # This is terrible. JNI_CFLAGS= AC_MSG_CHECKING([for cross jni.h and jni_md.h]) From f49b661484907a2a48db44b944858e6cb09ff07a Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sun, 30 Oct 2011 14:54:51 -0400 Subject: [PATCH 10/11] README: Document native Windows builds --- README.txt | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/README.txt b/README.txt index 4d55a09..5a5262c 100644 --- a/README.txt +++ b/README.txt @@ -1,9 +1,6 @@ Build requirements ------------------ -- POSIX shell -- Make -- C compiler - JDK - Apache Ant - OpenSlide @@ -26,3 +23,23 @@ PKG_CONFIG=pkg-config \ ./configure --host=i686-pc-mingw32 --build=$(build-aux/config.guess) make make install + +Building on Windows +------------------- + +Install a JDK, Apache Ant, MinGW, and MSYS. Edit the MSYS fstab file +(e.g. C:\MinGW\msys\1.0\etc\fstab) to mount your JDK and Apache Ant +installations within the MSYS directory tree: + +C:\Progra~1\Java\jdk1.6.0_29 /java +C:\ant /ant + +You must use 8.3 short file names for path elements that contain spaces. + +Then: + +./configure --prefix=/path/to/install/dir JAVA_HOME=/java \ + ANT_HOME=/ant OPENSLIDE_CFLAGS=-I/path/to/openslide/include \ + OPENSLIDE_LIBS="-L/path/to/openslide/lib -lopenslide" +make +make install From 7db758657bbc949365c4aabff0322b9f7d96b736 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sun, 30 Oct 2011 14:56:10 -0400 Subject: [PATCH 11/11] Fix build warning with Ant 1.8 --- build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.xml b/build.xml index 82b3853..54341e3 100644 --- a/build.xml +++ b/build.xml @@ -32,7 +32,7 @@ - +