source: main/trunk/greenstone3/src/packages/javagdbm/configure.in@ 26707

Last change on this file since 26707 was 26707, checked in by davidb, 11 years ago

Minor adjustment to JDK test

  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 KB
Line 
1dnl Process this file with autoconf to produce a configure script.
2
3dnl autoconf configuration script for the JNI part of the
4dnl au.com.pharos.gdbm Java package
5dnl $Id: configure.in 26707 2013-01-13 01:49:59Z davidb $
6
7AC_REVISION($Revision: 26707 $)
8
9# Copyright (C) 1997 by Pharos IP Pty Ltd
10#
11# This program is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version 2 of the License, or
14# (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program; if not, write to the Free Software
23# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
25AC_INIT(jni/gdbmjava.c)
26
27dnl
28dnl look for libgdbm if not in standard location
29dnl
30AC_ARG_WITH(gdbm, [ --with-gdbm=dir Use local gdbm library and headers], gdbmdir=$withval)
31
32dnl get $target_cpu, $target_vendor, and $target_os
33dnl (as well as host_*)
34AC_CANONICAL_SYSTEM
35
36# TODO: allow the user to specify whether they want a debugging
37# library or not?
38
39# check for compilers and other tools
40AC_PROG_CC
41AC_PROG_INSTALL
42AC_PROG_LN_S
43
44AC_MSG_CHECKING(to see if architecture is 64-bit)
45arch_64bit=no
46case "$host_cpu" in
47x86_64) arch_64bit=yes ;;
48esac
49
50if test "$arch_64bit" = yes; then
51 AC_MSG_RESULT(yes)
52 if test -z "$ARCH_DEP_FLAGS" ; then
53 ARCH_DEP_FLAGS="-fPIC"
54 gsdlarch='64'
55 fi
56else
57 AC_MSG_RESULT(no)
58 if test -z "$ARCH_DEP_FLAGS" ; then
59 ARCH_DEP_FLAGS=
60 gsdlarch='32'
61 fi
62fi
63
64export ARCH_DEP_FLAGS
65AC_SUBST(ARCH_DEP_FLAGS)
66
67AC_CHECK_SIZEOF(void *)
68AC_CHECK_SIZEOF(int)
69AC_CHECK_SIZEOF(long)
70
71######## check for the JDK and tools within the JDK
72######## look in the JAVA_HOME environment variable at configure-time
73AC_MSG_CHECKING([for the JDK])
74if test "z$JAVA_HOME" != z &&
75 test -d $JAVA_HOME &&
76 (test -d $JAVA_HOME/bin)
77# The following used to be the test, but failed on newer versions of MacOS
78# Cut back to something simpler, and rely on the later tests for JNIINC to confirm
79# files like 'jni.h' can be found
80# test -d $JAVA_HOME &&
81# (test -d $JAVA_HOME/include || test -d $JAVA_HOME/../Headers)
82then
83 AC_SUBST(JAVA_HOME)
84 AC_MSG_RESULT([found in $JAVA_HOME])
85else
86 AC_MSG_ERROR([not found in \$JAVA_HOME])
87fi
88
89# TODO: Check for specific header files in the JDK, or
90# functions/definitions within those headers?
91
92# TODO: guess which include directory to use under the JDK
93
94AC_PATH_PROG(javagdbm_cv_path_javah, javah, missing_javah)
95if test "$javagdbm_cv_path_javah" = missing_javah; then
96 AC_MSG_ERROR([javah not found.])
97fi
98
99AC_PATH_PROG(javagdbm_cv_path_java, java, missing)
100if test "$javagdbm_cv_path_java" = missing; then
101 AC_MSG_ERROR([java not found.])
102fi
103
104# check for gdbm library
105#AC_CHECK_LIB(gdbm, gdbm_open, [javagdbm_cv_lib_gdbm="-lgdbm"],
106# [javagdbm_cv_lib_gdbm=no])
107#if test "$javagdbm_cv_lib_gdbm" = "no"; then
108# AC_MSG_ERROR([no native gdbm library found.])
109#fi
110#LIBS="$javagdbm_cv_lib_gdbm"
111
112# gdbm stuff copied from gsdl [kjdon]
113
114dnl
115dnl Check that the GDBM library is available
116dnl
117dnl check libgdbm manually, in case it's not in the standard location.
118
119AC_MSG_CHECKING(that the GDBM library is available)
120if test ! -z "$gdbmdir" ; then
121 # look in given directory for header file
122 if test -r $gdbmdir/include/gdbm.h ; then
123 GDBM_INCLUDE="-I$gdbmdir/include" ;
124 elif test -r $gdbmdir/gdbm.h ; then
125 GDBM_INCLUDE="-I$gdbmdir" ;
126 fi
127
128 # look in given directory for library
129 if test -r $gdbmdir/libgdbm.a ; then
130 GDBM_LIBPATH="-L$gdbmdir" ;
131 elif test -r $gdbmdir/lib/libgdbm.a ; then
132 GDBM_LIBPATH="-L$gdbmdir/lib" ;
133 elif test -r $gdbmdir/.libs/libgdbm.a ; then
134 GDBM_LIBPATH="-L$gdbmdir/.libs" ;
135 fi
136
137 if test ! -z "$GDBM_LIBPATH" -a ! -z "$GDBM_INCLUDE" ; then
138 AC_MSG_RESULT($gdbmdir) ;
139 else
140 AC_MSG_RESULT(can't find gdbm.h and libgdbm.a in $gdbmdir);
141 AC_MSG_CHECKING( looking for GDBM library in default locations)
142 fi
143fi
144
145# look in default path and in /usr/local
146if test -z "$GDBM_INCLUDE" ; then
147 # try in system directory
148 AC_TRY_COMPILE(
149 [#include <gdbm.h>
150],
151 [],
152 success=yes,
153 success=no
154 )
155
156 if test $success = "no"; then
157# last chance - look in /usr/local (eg FreeBSD)
158 GDBM_LIBPATH=-L/usr/local/lib
159 GDBM_INCLUDE=-I/usr/local/include
160 ac_save_CXXFLAGS="$CXXFLAGS"
161 ac_save_LIBS="$LIBS"
162 CXXFLAGS="$CXXFLAGS -I/usr/local/include"
163 LIBS="$LIBS -L/usr/local/lib -lgdbm"
164 AC_TRY_LINK(
165 [#include <gdbm.h>
166#include <stdio.h>
167 ],
168 [printf("%s",gdbm_version);],
169 success=/usr/local,
170 success=no
171 )
172 CXXFLAGS=$ac_save_CXXFLAGS
173 LIBS=$ac_save_LIBS
174 fi
175
176 AC_MSG_RESULT($success)
177 if test $success = "no"; then
178 AC_MSG_ERROR(GDBM Library not available - cannot install)
179 fi
180fi
181dnl I don't think anything actually checks this define, but...
182AC_DEFINE(HAVE_LIBGDBM , 1)
183
184AC_SUBST(GDBM_LIBPATH)
185AC_SUBST(GDBM_INCLUDE)
186
187########## set compiler options
188# TODO: is there a more appropriate way to guess which switches to use
189# with which systems/compilers?
190CFLAGS="-Wall -O2 -fpic"
191PKG="au.com.pharos.gdbm"
192AC_SUBST(CFLAGS)
193AC_SUBST(PKG)
194AC_SUBST(LIBS)
195
196# we need to set an extended JNI path for Mac OS/Darwin, as jni.h is on
197# a non-standard Path
198# is there a better way to do this??
199AC_MSG_CHECKING(for OS to set JNI options)
200# set defaults
201JNIINC=""
202JNIPREFIX="lib"
203JNISUFFIX="so"
204JNICFLAGS=""
205JNILDFLAGS="-shared"
206
207if test "`(uname -s) 2> /dev/null`" = 'Darwin'; then
208 AC_MSG_RESULT(Darwin)
209 JNIINC="-I/System/Library/Frameworks/JavaVM.framework/Headers/ "
210 JNISUFFIX="jnilib"
211 JNILDFLAGS="-dynamiclib -fno-common -single_module -framework JavaVM"
212fi
213if test "`(uname -s) 2> /dev/null`" = 'SunOS'; then
214 AC_MSG_RESULT(Solaris)
215 JNIINC="-I\$(JAVA_HOME)/include/solaris "
216fi
217if test "`(uname -s) 2> /dev/null`" = 'Linux'; then
218 AC_MSG_RESULT(Linux)
219 JNIINC="-I\$(JAVA_HOME)/include/linux -I\$(JAVA_HOME)/include "
220fi
221
222if test "x$crossOS" != "x" ; then
223 if test "$crossOS" = "windows" ; then
224 JNIINC="-I../java-windows-include/win32 -I../java-windows-include "
225 JNICFLAGS="-Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at"
226 JNIPREFIX=""
227 JNISUFFIX="dll"
228 fi
229fi
230
231AC_SUBST(JNIINC)
232AC_SUBST(JNIPREFIX)
233AC_SUBST(JNISUFFIX)
234AC_SUBST(JNICFLAGS)
235AC_SUBST(JNILDFLAGS)
236
237# write the output
238AC_OUTPUT([Makefile jni/Makefile java/Makefile])
Note: See TracBrowser for help on using the repository browser.