From 7de2166d97c1b729e2227304b60df3362ce4f888 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Thu, 27 Oct 2011 18:38:29 -0400 Subject: [PATCH] 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