dnl DBConnect API Configure Script dnl Copyright (c) Johnathan Ingram 2000, jingram@rogueware.org dnl dnl dnl dnl disable config.cache! define([AC_CACHE_LOAD], )dnl define([AC_CACHE_SAVE], )dnl dnl Custom defined MACROS dnl ----------------------- dnl dnl Obtain system information. AC_DEFUN(GET_PLATFORM, [ pl_system=`(uname -s) 2>/dev/null` || pl_system = "unknown" pl_processor=`(uname -p) 2>/dev/null` || pl_processor = "unknown" pl_machine=`(uname -m) 2>/dev/null` || pl_machine = "unknown" pl_system_release=`(uname -r) 2>/dev/null` || pl_system_release = "unknown" pl_host=`(uname -n) 2>/dev/null` || pl_host = "unknown" echo "system $pl_system" echo "system Version: $pl_system_release" ]) dnl Search for a static library. AC_DEFUN(FIND_STATIC_LIB, [ found="" AC_CHECK_FILES([/lib/$1], [LIBS="$LIBS /lib/$1" found=yes]) AC_CHECK_FILES([/usr/lib/$1], [LIBS="$LIBS /usr/lib/$1" found=yes]) AC_CHECK_FILES([/usr/local/lib/$1], [LIBS="$LIBS /usr/local/lib/$1" found=yes]) if test "$found" = ""; then AC_MSG_ERROR([Unable to find the $1 static library]) fi ]) dnl Search for a dynamic library. AC_DEFUN(FIND_DYN_LIB, [ dnl AC_CHECK_LIB will add -lxxx to the LIBS var AC_CHECK_LIB([$1], [$2], [], [AC_MSG_ERROR([Unable to find the $1 dynamic link library])]) ]) dnl ----------------------- dnl End of custom defined MACROS dnl Start the configuring dnl ----------------------- AC_INIT() AC_SUBST(dbconn_version) dbconn_version=0.3.5 echo "Configuring DBConnect API version $dbconn_version" echo GET_PLATFORM() AC_PROG_CC AC_PROG_CXX dnl General headers/libraries and checking AC_CHECK_HEADERS([time.h unistd.h string.h sys/time.h stdio.h stdlib.h ctype.h limits.h math.h sys/types.h], [], [AC_MSG_ERROR([Unable to find required header file])]) AC_CHECK_HEADERS([pthread.h], [], [AC_MSG_ERROR([Unable to find required header file])]) AC_CHECK_HEADERS([dlfcn.h], [], [AC_MSG_ERROR([Unable to find required header file])]) AC_C_BIGENDIAN dnl Checks for Programs. dnl Subdirectories to compile dnl First compile the base, dbconnect wrapper and then drivers. AC_SUBST(subdirs) subdirs="src/base src/dbconnect" dnl Naugthy Static driver linking dnl ----------------------- dnl AC_ARG_ENABLE(static_linking, [ --enable-static_linking Link database drivers against static libs if available], [static_linking=yes]) dnl if test "$static_linking" = "yes"; then dnl Static linking dnl else dnl Dynamic linking. dnl fi dnl ----------------------- dnl End of MySQL dnl MySQL Database Build Enabling dnl ----------------------- dnl AC_SUBST(mysql_include) AC_SUBST(mysql_lib) AC_SUBST(mysql_target) AC_SUBST(mysql_libfile) AC_ARG_ENABLE(mysql, [ --enable-mysql Enable Building of MySQL database support], [mysql=yes]) mysql_include="/usr/include/mysql" AC_ARG_WITH(mysql_include, [ --with-mysql_include MySQL include files (Default: /usr/include/mysql)], [mysql_include=$withval]) mysql_lib="/usr/lib/mysql" AC_ARG_WITH(mysql_lib, [ --with-mysql_lib MySQL library files (Default: /usr/lib/mysql/lib)], [mysql_lib=$withval]) if test "$mysql" = "yes"; then echo "enabled MySQL driver building..." AC_CHECK_HEADERS([$mysql_include/mysql.h $mysql_include/mysql_com.h $mysql_include/mysql_version.h], [], [AC_MSG_ERROR([Unable to find MySQL header file])]) dnl Check if static or dynamic linking enabled if test "$static_linking" = "yes"; then dnl Static dnl ------------------------ dnl MySQL driver needs to statically include the libz library. AC_SUBST(mysql_libzfile) mysql_libzfile= AC_CHECK_FILES([/lib/libz.a], [mysql_libzfile=/lib/libz.a]) AC_CHECK_FILES([/usr/lib/libz.a], [mysql_libzfile=/usr/lib/libz.a]) AC_CHECK_FILES([/usr/local/lib/libz.a], [mysql_libzfile=/usr/local/lib/libz.a]) if test "$mysql_libzfile" = ""; then AC_MSG_ERROR([Unable to find the libz.a library]) fi AC_CHECK_FILES([$mysql_lib/libmysqlclient.a], [], [AC_MSG_ERROR([Unable to find MySQL library file])]) dnl AC_MSG_ERROR([MySQL driver does not support static linking...]) mysql_target=static mysql_libfile=libmysqlclient.a else dnl Dynamic dnl ------------------------ AC_CHECK_FILES([$mysql_lib/libmysqlclient.so], [], [AC_MSG_ERROR([Unable to find MySQL library file])]) mysql_target=dynamic mysql_libfile=mysqlclient fi dnl Add the driver directory to be included for building subdirs="$subdirs src/driver_mysql" fi dnl ----------------------- dnl End of MySQL dnl mSQL Database Build Enabling dnl ----------------------- dnl AC_SUBST(msql_include) AC_SUBST(msql_lib) AC_SUBST(msql_target) AC_SUBST(msql_libfile) AC_ARG_ENABLE(msql, [ --enable-msql Enable Building of mSQL database support], [msql=yes]) msql_include="/usr/local/msql3/include" AC_ARG_WITH(msql_include, [ --with-msql_include mSQL include files (Default: /usr/local/msql3/include)], [msql_include=$withval]) msql_lib="/usr/local/msql3/lib" AC_ARG_WITH(msql_lib, [ --with-msql_lib mSQL library files (Default: /usr/local/msql3/lib)], [msql_lib=$withval]) if test "$msql" = "yes"; then echo "enabled mSQL driver building..." AC_CHECK_HEADERS([$msql_include/msql.h], [], [AC_MSG_ERROR([Unable to find mSQL header file])]) dnl Check if static or dynamic linking enabled dnl Will always need to compile with static libs for mSQL if test "$static_linking" = "yes"; then dnl Static dnl ------------------------ msql_target=static msql_libfile=libmsql.a else dnl Dynamic dnl ------------------------ echo "mSQL will be forced to use static library as no dynamic library exists" msql_target=dynamic msql_libfile=libmsql.a fi AC_CHECK_FILES([$msql_lib/libmsql.a], [], [AC_MSG_ERROR([Unable to find mSQL library file])]) dnl Add the driver directory to be included for building subdirs="$subdirs src/driver_msql" fi dnl ----------------------- dnl End of mSQL dnl PostgreSQL Database Build Enabling dnl ----------------------- dnl AC_SUBST(pgsql_include) AC_SUBST(pgsql_lib) AC_SUBST(pgsql_target) AC_SUBST(pgsql_libfile) AC_ARG_ENABLE(pgsql, [ --enable-pgsql Enable Building of PostgreSQL database support], [pgsql=yes]) pgsql_include="/usr/include" AC_ARG_WITH(pgsql_include, [ --with-pgsql_include PostgreSQL include files (Default: /usr/include)], [pgsql_include=$withval]) pgsql_lib="/usr/lib" AC_ARG_WITH(pgsql_lib, [ --with-pgsql_lib PostgreSQL library files (Default: /usr/lib)], [pgsql_lib=$withval]) if test "$pgsql" = "yes"; then echo "enabled PostgreSQL driver building..." AC_CHECK_HEADERS([$pgsql_include/libpq-fe.h], [], [AC_MSG_ERROR([Unable to find PostgreSQL header file])]) dnl Check if static or dynamic linking enabled if test "$static_linking" = "yes"; then dnl Static dnl ------------------------ AC_CHECK_FILES([$pgsql_lib/libpq.a], [], [AC_MSG_ERROR([Unable to find PostgreSQL library file])]) pgsql_target=static pgsql_libfile=libpq.a else dnl Dynamic dnl ------------------------ AC_CHECK_FILES([$pgsql_lib/libpq.so], [], [AC_MSG_ERROR([Unable to find PostgreSQL library file])]) pgsql_target=dynamic pgsql_libfile=pq fi dnl Add the driver directory to be included for building subdirs="$subdirs src/driver_pgsql-7" fi dnl ----------------------- dnl End of PostgreSQL dnl IBM DB2 Database Build Enabling dnl ----------------------- dnl AC_SUBST(db2_include) AC_SUBST(db2_lib) AC_SUBST(db2_target) AC_SUBST(db2_libfile) AC_ARG_ENABLE(db2, [ --enable-db2 Enable Building of IBM DB2 database support], [db2=yes]) db2_include="/home/db2inst1/sqllib/include" AC_ARG_WITH(db2_include, [ --with-db2_include IBM DB2 include files (Default: /home/db2inst1/sqllib/include)], [db2_include=$withval]) db2_lib="/home/db2inst1/sqllib/lib" AC_ARG_WITH(db2_lib, [ --with-db2_lib IBM DB2 library files (Default: /home/db2inst1/sqllib/lib)], [db2_lib=$withval]) if test "$db2" = "yes"; then echo "enabled IBM DB2 driver building..." AC_CHECK_HEADERS([$db2_include/sqlcli.h $db2_include/sqlutil.h $db2_include/sql.h $db2_include/sqlenv.h], [], [AC_MSG_ERROR([Unable to find IBM DB2 header file])]) dnl Check if static or dynamic linking enabled if test "$static_linking" = "yes"; then dnl Warning: Cannot do static linking with DB2 echo "warning The IBM DB2 driver cannot be linked statically" echo "warning The IBM DB2 driver will be linked dynamically" fi dnl Always link Dynamic dnl ------------------------ AC_CHECK_FILES([$db2_lib/libdb2.so], [], [AC_MSG_ERROR([Unable to find IBM DB2 library file])]) db2_target=dynamic db2_libfile=db2 dnl Add the driver directory to be included for building subdirs="$subdirs src/driver_ibmDB2" fi dnl ----------------------- dnl End of PostgreSQL dnl Alter the libs and defines according to system type. dnl ----------------------- dnl AC_SUBST(LIBS) AC_SUBST(OS_DEF) AC_SUBST(STATIC_FLAG) AC_SUBST(SO_FLAG) AC_SUBST(SO_EXT) AC_SUBST(ARCH_EXT) AC_SUBST(LINKER_FLAGS) if test "$pl_system" = "SunOS"; then LIBS="$LIBS -lposix4 -lsocket -lnsl" OS_DEF="-DSOLARIS" STATIC_FLAG="-static" SO_FLAG="-G" SO_EXT=".so" ARCH_EXT=".a" LINKER_FLAGS="" elif test "$pl_system" = "Linux"; then LIBS="$LIBS" OS_DEF="-DLINUX" STATIC_FLAG="-static" SO_FLAG="-shared" SO_EXT=".so" ARCH_EXT=".a" LINKER_FLAGS="" elif test "$pl_system" = "FreeBSD"; then LIBS="$LIBS" OS_DEF="-DFREEBSD" STATIC_FLAG="-static" SO_FLAG="-shared" SO_EXT=".so" ARCH_EXT=".a" LINKER_FLAGS="" else dnl Default LIBS="$LIBS" OS_DEF="-DUNKNOWN" STATIC_FLAG="-static" SO_FLAG="-shared" SO_EXT=".so" ARCH_EXT=".a" LINKER_FLAGS="" fi dnl ----------------------- dnl End of system customizations AC_OUTPUT(Makefile) AC_OUTPUT(src/dbconnect/Makefile) AC_OUTPUT(src/base/Makefile) AC_OUTPUT(src/base/unitTests/Makefile) AC_OUTPUT(src/driver_mysql/Makefile) AC_OUTPUT(src/driver_msql/Makefile) AC_OUTPUT(src/driver_pgsql-7/Makefile) AC_OUTPUT(src/driver_ibmDB2/Makefile) AC_OUTPUT(examples/Makefile) AC_OUTPUT(examples/postgresql/Makefile) AC_OUTPUT(examples/mysql/Makefile) AC_OUTPUT(examples/msql/Makefile) AC_OUTPUT(examples/ibmDB2/Makefile) AC_MSG_RESULT(Now Type 'make')