1dnl Process this file with autoconf to produce configure.
2
3AC_INIT(SQLClient.h)
4AC_CONFIG_HEADER(config.h)
5
6if test -z "$GNUSTEP_MAKEFILES"; then
7 GNUSTEP_MAKEFILES=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null`
8 export GNUSTEP_MAKEFILES
9fi
10
11if test -z "$GNUSTEP_MAKEFILES"; then
12  AC_MSG_ERROR([You must have the gnustep-make package installed and set up the GNUSTEP_MAKEFILES environment variable to contain the path to the makefiles directory before configuring!])
13else
14  . $GNUSTEP_MAKEFILES/GNUstep.sh
15fi
16
17#--------------------------------------------------------------------
18AC_ARG_WITH(additional-include, [
19--with-additional-include=flags
20   Specifies additional include compiler flags to use.
21   If configure can not find your database library headers,
22   you may want to use this flag to help it find them.  For
23   example:
24   --with-additional-include=-I/usr/local/include
25],
26  additional_include="$withval", additional_include="no")
27
28if test "$additional_include" != "no"; then
29  CPPFLAGS="$CPPFLAGS $additional_include"
30  INCD="$INCD $additional_include"
31fi
32
33AC_ARG_WITH(additional-lib, [
34--with-additional-lib=flags
35   Specifies additional library compiler flags to use.
36   If configure can not find your database libraries,
37   you may want to use this flag to help it find them.  For
38   example:
39   --with-additional-lib=-L/usr/local/lib/mysql
40],
41  additional_lib="$withval", additional_lib="no")
42
43if test "$additional_lib" != "no"; then
44  LDFLAGS="$LDFLAGS $additional_lib"
45  LIBD="$LIBD $additional_lib"
46fi
47
48AC_ARG_WITH(postgres-dir, [
49--with-postgres-dir=PATH
50   Specifies the postgres installation dir; configure
51   will add the appropriate additional include and lib
52   flags.  Useful when you installed postgres in some
53   unusual place and want to help configure find it.  For
54   example:
55   --with-postgres-dir=/usr/local/pgsql
56   (which is equivalent to
57   --with-additional-include=-L/usr/local/pgsql/include
58   --with-additional-lib=-L/usr/local/pgsql/lib)
59],
60  postgres_topdir="$withval", postgres_topdir="no")
61
62if test "$postgres_topdir" != "no"; then
63  CPPFLAGS="$CPPFLAGS -I$postgres_topdir/include -L$postgres_topdir/lib"
64  INCD="$INCD -I$postgres_topdir/include"
65  LIBD="$LIBD -L$postgres_topdir/lib"
66else
67  PGINC=`pg_config --includedir`
68  if test "$PGINC" != ""; then
69    CPPFLAGS="$CPPFLAGS -I$PGINC"
70    INCD="$INCD -I$PGINC"
71  fi
72  PGLIB=`pg_config --libdir`
73  if test "$PGLIB" != ""; then
74    CPPFLAGS="$CPPFLAGS -L$PGLIB"
75    LIBD="$LIBD -I$PGLIB"
76  fi
77fi
78
79# Call AC_CHECK_HEADERS here as a workaround for a configure bug/feature
80# which messes up all subsequent tests if the first occurrence in the
81# file does not get called ... as would otherwise be the case if jdbc
82# support is disabled.
83AC_CHECK_HEADERS(stdio.h)
84
85AC_MSG_CHECKING([if Jdbc support was manually disabled])
86AC_ARG_ENABLE(jdbc-bundle, [
87--disable-jdbc-bundle
88   Disable creating the Jdbc bundle.
89   Use this option to force the Jdbc bundle not to be built
90   even if the Jdbc libraries look like being present.
91],
92  ac_cv_jdbc_bundle=$enableval,
93  ac_cv_jdbc_bundle="yes")
94
95if test "$ac_cv_jdbc_bundle" = "no"; then
96  AC_MSG_RESULT([yes: disabled from the command-line])
97else
98  AC_MSG_RESULT([no: build if possible])
99
100# Get likely subdirectory for system specific java include
101case "$GNUSTEP_HOST_OS" in
102  bsdi*)	_JNI_SUBDIR="bsdos";;
103  linux*)	_JNI_SUBDIR="linux";;
104  osf*)		_JNI_SUBDIR="alpha";;
105  solaris*)	_JNI_SUBDIR="solaris";;
106  mingw*)	_JNI_SUBDIR="win32";;
107  cygwin*)	_JNI_SUBDIR="win32";;
108  *)		_JNI_SUBDIR="genunix";;
109esac
110
111AC_ARG_WITH(jre-architecture,  [
112--with-jre-architecture=value
113   Specifies the CPU architecture to use for the JRE
114   (only used when building the JDBC module).  Example
115   values are i386, amd64 and sparc.
116],
117  jre_architecture="$withval", jre_architecture="")
118
119save_LIBS="$LIBS"
120save_CFLAGS="$CFLAGS"
121save_CPPFLAGS="$CPPFLAGS"
122CPPFLAGS="$CPPFLAGS -I$JAVA_HOME/include -I$JAVA_HOME/include/$_JNI_SUBDIR"
123AC_CHECK_HEADERS(jni.h)
124if test "$ac_cv_header_jni_h" = "yes"; then
125  JDBC_VM_LIBS="-ljvm"
126  jre_lib="$JAVA_HOME/jre/lib"
127
128  if test "$jre_architecture" = ""; then
129
130    # If on a 32/64bit system and compiling for the 64bit model
131    # adjust the cpu type to be the 64bit version
132    case "$CFLAGS" in
133      *-m64*)
134	if test "$GNUSTEP_HOST_CPU" = "ix86"; then
135	  _CPU="x86_64"
136	else
137	  _CPU="$GNUSTEP_HOST_CPU"
138	fi;;
139      *) _CPU="$GNUSTEP_HOST_CPU";;
140    esac
141    case "$_CPU" in
142      ix86)	JAVA_CPU=i386;;
143      x86_64)	JAVA_CPU=amd64;;
144      sparc)	JAVA_CPU=sparc;;
145      *)	JAVA_CPU=i386;;
146    esac
147  else
148    JAVA_CPU="$jre_architecture"
149  fi
150
151  jre_cpu="$jre_lib/$JAVA_CPU"
152  JDBC_VM_LIBDIRS="-L$jre_cpu/server"
153  CFLAGS="$CFLAGS $JDBC_VM_LIBDIRS"
154  AC_CHECK_LIB(jvm,JNI_CreateJavaVM)
155  if test "$ac_cv_lib_jvm_JNI_CreateJavaVM" = "yes"; then
156    INCD="$INCD -I$JAVA_HOME/include -I$JAVA_HOME/include/$_JNI_SUBDIR"
157    JDBC=yes
158  else
159    JDBC=
160    JDBC_VM_LIBS=
161    JDBC_VM_LIBDIRS=
162    echo "**********************************************"
163    echo "Unable to locate jvm library (is it installed)"
164    echo "**********************************************"
165  fi
166else
167  JDBC=
168  JDBC_VM_LIBS=
169  JDBC_VM_LIBDIRS=
170  echo "*********************************************"
171  echo "Unable to locate jni header (is it installed)"
172  echo "*********************************************"
173fi
174AC_SUBST(JDBC)
175AC_SUBST(JDBC_VM_LIBS)
176AC_SUBST(JDBC_VM_LIBDIRS)
177LIBS="$save_LIBS"
178CFLAGS="$save_CFLAGS"
179CPPFLAGS="$save_CPPFLAGS"
180
181fi
182
183
184AC_MSG_CHECKING([if Mysql support was manually disabled])
185AC_ARG_ENABLE(mysql-bundle, [
186--disable-mysql-bundle
187   Disable creating the Mysql bundle.
188   Use this option to force the Mysql bundle not to be built
189   even if the Mysql libraries look like being present.
190],
191  ac_cv_mysql_bundle=$enableval,
192  ac_cv_mysql_bundle="yes")
193
194if test "$ac_cv_mysql_bundle" = "no"; then
195  AC_MSG_RESULT([yes: disabled from the command-line])
196  MYSQL=
197else
198  AC_MSG_RESULT([no: build if possible])
199
200AC_CHECK_HEADERS(mysql/mysql.h)
201if test "$ac_cv_header_mysql_mysql_h" = "yes"; then
202  MYSQL=yes
203else
204  MYSQL=
205  echo "*********************************************************"
206  echo "Unable to locate mysqlclient headers (are they installed)"
207  echo "*********************************************************"
208fi
209if test "$MYSQL" = "yes"; then
210  if test -d /usr/lib/mysql ; then
211    CPPFLAGS="$CPPFLAGS -L/usr/lib/mysql"
212    LIBD="$LIBD -L/usr/lib/mysql"
213  else
214    if test -d /usr/local/lib/mysql ; then
215      CPPFLAGS="$CPPFLAGS -L/usr/local/lib/mysql"
216      LIBD="$LIBD -L/usr/local/lib/mysql"
217    else
218      if test -d /usr/local/mysql/lib ; then
219        CPPFLAGS="$CPPFLAGS -L/usr/local/mysql/lib"
220        LIBD="$LIBD -L/usr/local/mysql/lib"
221      fi
222    fi
223  fi
224  AC_CHECK_LIB(mysqlclient,mysql_init)
225  if test "$ac_cv_lib_mysqlclient_mysql_init" != "yes"; then
226    MYSQL=
227    echo "******************************************************"
228    echo "Unable to locate mysqlclient library (is it installed)"
229    echo "******************************************************"
230  fi
231fi
232AC_SUBST(MYSQL)
233
234fi
235
236
237AC_MSG_CHECKING([if Sqllite support was manually disabled])
238AC_ARG_ENABLE(sqllite-bundle, [
239--disable-sqllite-bundle
240   Disable creating the Sqllite bundle.
241   Use this option to force the Sqllite bundle not to be built
242   even if the Sqllite libraries look like being present.
243],
244  ac_cv_sqllite_bundle=$enableval,
245  ac_cv_sqllite_bundle="yes")
246
247if test "$ac_cv_sqllite_bundle" = "no"; then
248  AC_MSG_RESULT([yes: disabled from the command-line])
249  SQLLITE=
250else
251  AC_MSG_RESULT([no: build if possible])
252
253AC_CHECK_HEADERS(sqlite3.h)
254if test "$ac_cv_header_sqlite3_h" = "yes"; then
255  SQLITE=yes
256else
257  SQLITE=
258  echo "*****************************************************"
259  echo "Unable to locate sqlite3 headers (are they installed)"
260  echo "*****************************************************"
261fi
262if test "$SQLITE" = "yes"; then
263  AC_CHECK_LIB(sqlite3,sqlite3_open)
264  if test "$ac_cv_lib_sqlite3_sqlite3_open" != "yes"; then
265    SQLITE=
266    echo "******************************************************"
267    echo "Unable to locate sqlite3 library (is it installed)"
268    echo "******************************************************"
269  fi
270fi
271AC_SUBST(SQLITE)
272
273fi
274
275AC_MSG_CHECKING([if Postgres support was manually disabled])
276AC_ARG_ENABLE(postgres-bundle, [
277--disable-postgres-bundle
278   Disable creating the Postgres bundle.
279   Use this option to force the Postgres bundle not to be built
280   even if the Postgres libraries look like being present.
281],
282  ac_cv_postgres_bundle=$enableval,
283  ac_cv_postgres_bundle="yes")
284
285if test "$ac_cv_postgres_bundle" = "no"; then
286  AC_MSG_RESULT([yes: disabled from the command-line])
287  POSTGRES=
288else
289  AC_MSG_RESULT([no: build if possible])
290
291# Start POSTGRES checks
292POSTGRES=
293
294if test "$POSTGRES" = ""; then
295  AC_CHECK_HEADERS(libpq-fe.h)
296  if test "$ac_cv_header_libpq_fe_h" = "yes"; then
297    POSTGRES=yes
298  fi
299fi
300if test "$ECPG" = ""; then
301  AC_CHECK_HEADERS(ecpglib.h)
302  if test "$ac_cv_header_ecpglib_h" = "yes"; then
303    ECPG=yes
304  fi
305fi
306
307if test "$POSTGRES" = ""; then
308  AC_CHECK_HEADERS(/usr/include/postgresql/libpq-fe.h)
309  CPPFLAGS="$save_CPPFLAGS"
310  if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
311    INCD="$INCD -I/usr/include/postgresql"
312    POSTGRES=yes
313  fi
314fi
315if test "$ECPG" = ""; then
316  AC_CHECK_HEADERS(/usr/include/postgresql/ecpglib.h)
317  if test "$ac_cv_header__usr_include_postgresql_libpq_fe_h" = "yes"; then
318    INCD="$INCD -I/usr/include/postgresql"
319    ECPG=yes
320  fi
321fi
322
323if test "$POSTGRES" = ""; then
324  AC_CHECK_HEADERS(/usr/include/postgresql/8.0/libpq-fe.h)
325  CPPFLAGS="$save_CPPFLAGS"
326  if test "$ac_cv_header__usr_include_postgresql_8_0_libpq_fe_h" = "yes"; then
327    INCD="$INCD -I/usr/include/postgresql/8.0"
328    POSTGRES=yes
329  fi
330fi
331if test "$ECPG" = ""; then
332  AC_CHECK_HEADERS(/usr/include/postgresql/8.0/ecpglib.h)
333  if test "$ac_cv_header__usr_include_postgresql_8_0_libpq_fe_h" = "yes"; then
334    INCD="$INCD -I/usr/include/postgresql/8.0"
335    ECPG=yes
336  fi
337fi
338
339if test "$POSTGRES" = ""; then
340  AC_CHECK_HEADERS(/usr/include/pgsql/libpq-fe.h)
341  CPPFLAGS="$save_CPPFLAGS"
342  if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
343    INCD="$INCD -I/usr/include/pgsql"
344    POSTGRES=yes
345  fi
346fi
347if test "$ECPG" = ""; then
348  AC_CHECK_HEADERS(/usr/include/pgsql/ecpglib.h)
349  if test "$ac_cv_header__usr_include_pgsql_libpq_fe_h" = "yes"; then
350    INCD="$INCD -I/usr/include/pgsql"
351    ECPG=yes
352  fi
353fi
354
355if test "$POSTGRES" = ""; then
356  AC_CHECK_HEADERS(/usr/local/include/pgsql/libpq-fe.h)
357  CPPFLAGS="$save_CPPFLAGS"
358  if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
359    INCD="$INCD -I/usr/local/include/pgsql"
360    POSTGRES=yes
361  fi
362fi
363if test "$ECPG" = ""; then
364  AC_CHECK_HEADERS(/usr/local/include/pgsql/ecpglib.h)
365  if test "$ac_cv_header__usr_local_include_pgsql_libpq_fe_h" = "yes"; then
366    INCD="$INCD -I/usr/local/include/pgsql"
367    ECPG=yes
368  fi
369fi
370
371if test "$POSTGRES" = ""; then
372  AC_CHECK_HEADERS(/usr/local/pgsql/include/libpq-fe.h)
373  CPPFLAGS="$save_CPPFLAGS"
374  if test "$ac_cv_header__usr_local_pgsql_include_libpq_fe_h" = "yes"; then
375    INCD="$INCD -I/usr/local/pgsql/include"
376    POSTGRES=yes
377  fi
378fi
379if test "$ECPG" = ""; then
380  AC_CHECK_HEADERS(/usr/local/pgsql/include/ecpglib.h)
381  if test "$ac_cv_header__usr_local_pgsql_include_libpq_fe_h" = "yes"; then
382    INCD="$INCD -I/usr/local/pgsql/include"
383    ECPG=yes
384  fi
385fi
386
387if test "$POSTGRES" = ""; then
388  echo "**************************************************************"
389  echo "Unable to locate libpq (postgres) headers (are they installed)"
390  echo "**************************************************************"
391fi
392if test "$ECPG" = ""; then
393  echo "*************************************************************"
394  echo "Unable to locate ecpg (postgres) headers (are they installed)"
395  echo "*************************************************************"
396fi
397
398if test "$POSTGRES" = "yes"; then
399  # NICOLA - hack
400  if test -d /usr/lib/pgsql ; then
401    CPPFLAGS="$CPPFLAGS -L/usr/lib/pgsql"
402    LIBD="$LIBD -L/usr/lib/pgsql"
403  else
404    if test -d /usr/local/lib/pgsql ; then
405      CPPFLAGS="$CPPFLAGS -L/usr/local/lib/pgsql"
406      LIBD="$LIBD -L/usr/local/lib/pgsql"
407    else
408      if test -d /usr/local/pgsql/lib ; then
409        CPPFLAGS="$CPPFLAGS -L/usr/local/pgsql/lib"
410        LIBD="$LIBD -L/usr/local/pgsql/lib"
411      fi
412    fi
413  fi
414
415  AC_CHECK_LIB(pq,PQfformat)
416  if test "$ac_cv_lib_pq_PQfformat" != "yes"; then
417      POSTGRES=
418      AC_CHECK_LIB(pq,PQclear)
419      echo "******************************************************"
420      if test "$ac_cv_lib_pq_PQclear" != "yes"; then
421	echo "Unable to locate postgres pq library (is it installed)"
422      else
423	echo "Located postgres pq library, but it is too old to use!"
424      fi
425      echo "Perhaps you can try 'configure --with-postgres=dir=path'"
426      echo "to point to the postgres version you wish to use."
427      echo "******************************************************"
428  else
429    AC_CHECK_FUNCS(PQescapeStringConn)
430  fi
431  AC_CHECK_LIB(ecpg,ECPGconnect)
432  if test "$ac_cv_lib_ecpg_ECPGconnect" != "yes"; then
433      ECPG=
434      echo "********************************************************"
435      echo "Unable to locate postgres ecpg library (is it installed)"
436      echo "Perhaps you can try 'configure --with-postgres=dir=path'"
437      echo "to point to the postgres version you wish to use."
438      echo "********************************************************"
439  fi
440fi
441
442# End POSTGRES checks
443fi
444
445AC_SUBST(POSTGRES)
446AC_SUBST(ECPG)
447
448ORACLE_HOME=
449AC_SUBST(ORACLE_HOME)
450
451AC_SUBST(INCD)
452AC_SUBST(LIBD)
453AC_SUBST(LIBS)
454
455if test "$JDBC" = "yes"; then
456  BUNDLE="The JDBC backend bundle will be built"
457else
458  BUNDLE="The JDBC backend bundle will NOT be built"
459fi
460AC_MSG_RESULT(${BUNDLE})
461
462if test "$MYSQL" = "yes"; then
463  BUNDLE="The MySQL backend bundle will be built"
464else
465  BUNDLE="The MySQL backend bundle will NOT be built"
466fi
467AC_MSG_RESULT(${BUNDLE})
468
469if test "$SQLITE" = "yes"; then
470  BUNDLE="The SQLite backend bundle will be built"
471else
472  BUNDLE="The SQLite backend bundle will NOT be built"
473fi
474AC_MSG_RESULT(${BUNDLE})
475
476if test "$POSTGRES" = "yes"; then
477  BUNDLE="The Postgres backend bundle will be built"
478else
479  BUNDLE="The Postgres backend bundle will NOT be built"
480fi
481AC_MSG_RESULT(${BUNDLE})
482
483if test "$ECPG" = "yes"; then
484  BUNDLE="The ECPG backend bundle will be built"
485else
486  BUNDLE="The ECPG backend bundle will NOT be built"
487fi
488AC_MSG_RESULT(${BUNDLE})
489
490if test "$ORACLE" = "yes"; then
491  BUNDLE="The Oracle backend bundle will be built"
492else
493  BUNDLE="The Oracle backend bundle will NOT be built"
494fi
495AC_MSG_RESULT(${BUNDLE})
496
497AC_OUTPUT(config.make)
498
499