1 | dnl Process this file with autoconf to produce a configure script.
|
---|
2 |
|
---|
3 | dnl autoconf configuration script for the JNI part of the
|
---|
4 | dnl au.com.pharos.gdbm Java package
|
---|
5 | dnl $Id: configure.in 18343 2009-01-11 06:39:56Z davidb $
|
---|
6 |
|
---|
7 | AC_REVISION($Revision: 18343 $)
|
---|
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 |
|
---|
25 | AC_INIT(jni/gdbmjava.c)
|
---|
26 |
|
---|
27 | dnl
|
---|
28 | dnl look for libgdbm if not in standard location
|
---|
29 | dnl
|
---|
30 | AC_ARG_WITH(gdbm, [ --with-gdbm=dir Use local gdbm library and headers], gdbmdir=$withval)
|
---|
31 |
|
---|
32 | dnl get $target_cpu, $target_vendor, and $target_os
|
---|
33 | dnl (as well as host_*)
|
---|
34 | AC_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
|
---|
40 | AC_PROG_CC
|
---|
41 | AC_PROG_INSTALL
|
---|
42 | AC_PROG_LN_S
|
---|
43 |
|
---|
44 | AC_MSG_CHECKING(to see if architecture is 64-bit)
|
---|
45 | arch_64bit=no
|
---|
46 | case "$host_cpu" in
|
---|
47 | x86_64) arch_64bit=yes ;;
|
---|
48 | esac
|
---|
49 |
|
---|
50 | if test "$arch_64bit" = yes; then
|
---|
51 | AC_MSG_RESULT(yes)
|
---|
52 | if test -z "$COMPAT32BITFLAGS" ; then
|
---|
53 | COMPAT32BITFLAGS="-m32"
|
---|
54 | fi
|
---|
55 | else
|
---|
56 | AC_MSG_RESULT(no)
|
---|
57 | if test -z "$COMPAT32BITFLAGS" ; then
|
---|
58 | COMPAT32BITFLAGS=
|
---|
59 | fi
|
---|
60 | fi
|
---|
61 | export COMPAT32BITFLAGS
|
---|
62 | AC_SUBST(COMPAT32BITFLAGS)
|
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|
66 | AC_CHECK_SIZEOF(void *)
|
---|
67 | AC_CHECK_SIZEOF(int)
|
---|
68 | AC_CHECK_SIZEOF(long)
|
---|
69 |
|
---|
70 | ######## check for the JDK and tools within the JDK
|
---|
71 | ######## look in the JAVA_HOME environment variable at configure-time
|
---|
72 | AC_MSG_CHECKING([for the JDK])
|
---|
73 | if test "z$JAVA_HOME" != z &&
|
---|
74 | test -d $JAVA_HOME &&
|
---|
75 | test -d $JAVA_HOME/include
|
---|
76 | then
|
---|
77 | AC_SUBST(JAVA_HOME)
|
---|
78 | AC_MSG_RESULT([found in $JAVA_HOME])
|
---|
79 | else
|
---|
80 | AC_MSG_ERROR([not found in \$JAVA_HOME])
|
---|
81 | fi
|
---|
82 |
|
---|
83 | # TODO: Check for specific header files in the JDK, or
|
---|
84 | # functions/definitions within those headers?
|
---|
85 |
|
---|
86 | # TODO: guess which include directory to use under the JDK
|
---|
87 |
|
---|
88 | AC_PATH_PROG(javagdbm_cv_path_javah, javah, missing_javah)
|
---|
89 | if test "$javagdbm_cv_path_javah" = missing_javah; then
|
---|
90 | AC_MSG_ERROR([javah not found.])
|
---|
91 | fi
|
---|
92 |
|
---|
93 | AC_PATH_PROG(javagdbm_cv_path_java, java, missing)
|
---|
94 | if test "$javagdbm_cv_path_java" = missing; then
|
---|
95 | AC_MSG_ERROR([java not found.])
|
---|
96 | fi
|
---|
97 |
|
---|
98 | # check for gdbm library
|
---|
99 | #AC_CHECK_LIB(gdbm, gdbm_open, [javagdbm_cv_lib_gdbm="-lgdbm"],
|
---|
100 | # [javagdbm_cv_lib_gdbm=no])
|
---|
101 | #if test "$javagdbm_cv_lib_gdbm" = "no"; then
|
---|
102 | # AC_MSG_ERROR([no native gdbm library found.])
|
---|
103 | #fi
|
---|
104 | #LIBS="$javagdbm_cv_lib_gdbm"
|
---|
105 |
|
---|
106 | # gdbm stuff copied from gsdl [kjdon]
|
---|
107 |
|
---|
108 | dnl
|
---|
109 | dnl Check that the GDBM library is available
|
---|
110 | dnl
|
---|
111 | dnl check libgdbm manually, in case it's not in the standard location.
|
---|
112 |
|
---|
113 | AC_MSG_CHECKING(that the GDBM library is available)
|
---|
114 | if test ! -z "$gdbmdir" ; then
|
---|
115 | # look in given directory for header file
|
---|
116 | if test -r $gdbmdir/include/gdbm.h ; then
|
---|
117 | GDBM_INCLUDE="-I$gdbmdir/include" ;
|
---|
118 | elif test -r $gdbmdir/gdbm.h ; then
|
---|
119 | GDBM_INCLUDE="-I$gdbmdir" ;
|
---|
120 | fi
|
---|
121 |
|
---|
122 | # look in given directory for library
|
---|
123 | if test -r $gdbmdir/libgdbm.a ; then
|
---|
124 | GDBM_LIBPATH="-L$gdbmdir" ;
|
---|
125 | elif test -r $gdbmdir/lib/libgdbm.a ; then
|
---|
126 | GDBM_LIBPATH="-L$gdbmdir/lib" ;
|
---|
127 | elif test -r $gdbmdir/.libs/libgdbm.a ; then
|
---|
128 | GDBM_LIBPATH="-L$gdbmdir/.libs" ;
|
---|
129 | fi
|
---|
130 |
|
---|
131 | if test ! -z "$GDBM_LIBPATH" -a ! -z "$GDBM_INCLUDE" ; then
|
---|
132 | AC_MSG_RESULT($gdbmdir) ;
|
---|
133 | else
|
---|
134 | AC_MSG_RESULT(can't find gdbm.h and libgdbm.a in $gdbmdir);
|
---|
135 | AC_MSG_CHECKING( looking for GDBM library in default locations)
|
---|
136 | fi
|
---|
137 | fi
|
---|
138 |
|
---|
139 | # look in default path and in /usr/local
|
---|
140 | if test -z "$GDBM_INCLUDE" ; then
|
---|
141 | # try in system directory
|
---|
142 | AC_TRY_COMPILE(
|
---|
143 | [#include <gdbm.h>
|
---|
144 | ],
|
---|
145 | [],
|
---|
146 | success=yes,
|
---|
147 | success=no
|
---|
148 | )
|
---|
149 |
|
---|
150 | if test $success = "no"; then
|
---|
151 | # last chance - look in /usr/local (eg FreeBSD)
|
---|
152 | GDBM_LIBPATH=-L/usr/local/lib
|
---|
153 | GDBM_INCLUDE=-I/usr/local/include
|
---|
154 | ac_save_CXXFLAGS="$CXXFLAGS"
|
---|
155 | ac_save_LIBS="$LIBS"
|
---|
156 | CXXFLAGS="$CXXFLAGS -I/usr/local/include"
|
---|
157 | LIBS="$LIBS -L/usr/local/lib -lgdbm"
|
---|
158 | AC_TRY_LINK(
|
---|
159 | [#include <gdbm.h>
|
---|
160 | #include <stdio.h>
|
---|
161 | ],
|
---|
162 | [printf("%s",gdbm_version);],
|
---|
163 | success=/usr/local,
|
---|
164 | success=no
|
---|
165 | )
|
---|
166 | CXXFLAGS=$ac_save_CXXFLAGS
|
---|
167 | LIBS=$ac_save_LIBS
|
---|
168 | fi
|
---|
169 |
|
---|
170 | AC_MSG_RESULT($success)
|
---|
171 | if test $success = "no"; then
|
---|
172 | AC_MSG_ERROR(GDBM Library not available - cannot install)
|
---|
173 | fi
|
---|
174 | fi
|
---|
175 | dnl I don't think anything actually checks this define, but...
|
---|
176 | AC_DEFINE(HAVE_LIBGDBM , 1)
|
---|
177 |
|
---|
178 | AC_SUBST(GDBM_LIBPATH)
|
---|
179 | AC_SUBST(GDBM_INCLUDE)
|
---|
180 |
|
---|
181 | ########## set compiler options
|
---|
182 | # TODO: is there a more appropriate way to guess which switches to use
|
---|
183 | # with which systems/compilers?
|
---|
184 | CFLAGS="-Wall -O2 -fpic"
|
---|
185 | PKG="au.com.pharos.gdbm"
|
---|
186 | AC_SUBST(CFLAGS)
|
---|
187 | AC_SUBST(PKG)
|
---|
188 | AC_SUBST(LIBS)
|
---|
189 |
|
---|
190 | # we need to set an extended JNI path for Mac OS/Darwin, as jni.h is on
|
---|
191 | # a non-standard Path
|
---|
192 | # is there a better way to do this??
|
---|
193 | AC_MSG_CHECKING(for OS to set JNI options)
|
---|
194 | # set defaults
|
---|
195 | JNIINC=""
|
---|
196 | JNISUFFIX="so"
|
---|
197 | JNIFLAGS="-shared"
|
---|
198 |
|
---|
199 | if test "`(uname -s) 2> /dev/null`" = 'Darwin'; then
|
---|
200 | AC_MSG_RESULT(Darwin)
|
---|
201 | JNIINC="-I/System/Library/Frameworks/JavaVM.framework/Headers/ "
|
---|
202 | JNISUFFIX="jnilib"
|
---|
203 | JNIFLAGS="-dynamiclib -fno-common -single_module -framework JavaVM"
|
---|
204 | fi
|
---|
205 | if test "`(uname -s) 2> /dev/null`" = 'SunOS'; then
|
---|
206 | AC_MSG_RESULT(Solaris)
|
---|
207 | JNIINC="-I\$(JAVA_HOME)/include/solaris "
|
---|
208 | fi
|
---|
209 | if test "`(uname -s) 2> /dev/null`" = 'Linux'; then
|
---|
210 | AC_MSG_RESULT(Linux)
|
---|
211 | JNIINC="-I\$(JAVA_HOME)/include/linux "
|
---|
212 | fi
|
---|
213 |
|
---|
214 | AC_SUBST(JNIINC)
|
---|
215 | AC_SUBST(JNISUFFIX)
|
---|
216 | AC_SUBST(JNIFLAGS)
|
---|
217 |
|
---|
218 | # write the output
|
---|
219 | AC_OUTPUT([Makefile jni/Makefile java/Makefile])
|
---|