dnl -*- sh -*- dnl Copyright 2000, 2001, 2002 Laurent Wacrenier dnl dnl This file is part of libhome dnl dnl libhome is free software; you can redistribute it and/or modify it dnl under the terms of the GNU Lesser General Public License as dnl published by the Free Software Foundation; either version 2 of the dnl License, or (at your option) any later version. dnl dnl libhome is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU Lesser General Public License for more details. dnl dnl You should have received a copy of the GNU Lesser General Public dnl License along with libhome; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 dnl USA dnl $Id: configure.in,v 1.72 2005/09/14 08:57:00 lwa Exp $ dnl Process this file with autoconf to produce a configure script. define(VERSION, esyscmd([awk '{printf "%s", $0}' VERSION])) AC_INIT(libhome, VERSION, lwa@teaser.fr) AC_REVISION($Revision: 1.72 $) AC_CONFIG_HEADER(config.h) AC_PREREQ(2.53) AC_CANONICAL_TARGET([]) AC_DEFUN(AC_HEADER_INCLUDES, AC_MSG_CHECKING(for $1) old_prefix=${prefix} prefix=NONE && prefix=${ac_default_prefix} ac_inc="no" case "${$2}" in [no)] testinc= ;; [yes|auto)] eval testinc=\"`echo "$3"`\" ;; [*)] testinc=${$2} ;; esac inc="" xCPPFLAGS="$CPPFLAGS" for inc in $testinc do test ${ac_inc} = no || break if test "${inc}" = system -o "${inc}" = "" then [AC_TRY_CPP([#include <]$1[>], ac_inc=yes)] else CPPFLAGS="-I$inc" [AC_TRY_CPP([#include <]$inc/$1[>], ac_inc=${inc})] fi done AC_MSG_RESULT(${ac_inc}) case "${$2}" in [no|auto)] a=b ;; [*)] if test ${ac_inc} = no then AC_MSG_ERROR(must have $1) fi ;; esac prefix="$old_prefix" CPPFLAGS="$xCPPFLAGS" $2="${ac_inc}" ) dnl Checks for programs. AC_PROG_CPP AC_PROG_INSTALL AC_PROG_CC case "$GCC" in yes) CPPFLAGS=-Wall ;; esac # disable fortran and c++ checks, # ugly way, maybe AC_LIBTOOL_TAGS([]) when libtool 1.6 AC_DEFUN([_LT_AC_TAGCONFIG],) with_tags=, # cc -g may generate warnings # try tests without CFLAGS savedCFLAGS="$CFLAGS" CFLAGS= AC_PROG_LIBTOOL CFLAGS="$savedCFLAGS" dnl [VERSION]=VERSION AC_SUBST(LIBTOOL_DEPS) AC_SUBST(PACKAGE_VERSION) AC_SUBST(MYSQL_CFLAGS) AC_SUBST(PGSQL_CFLAGS) AC_SUBST(LDAP_CFLAGS) AC_SUBST(DB_CFLAGS) AC_LIBOBJ([homeuser]) AC_LIBOBJ([error]) AC_LIBOBJ([hparam]) AC_LIBOBJ([rewrite]) AC_LIBOBJ([cleanup]) AC_LIBOBJ([wrap]) AC_LIBOBJ([tools]) AC_LIBOBJ([hsystem]) AC_LIBOBJ([expand]) AC_ARG_WITH(ldap, [ --with-ldap[=DIR] use of LDAP (DIR is directory of ldap includes)], ldap_inc=$withval, ldap_inc=auto, ) AC_ARG_WITH(ldap-libdir, [ --with-ldap-libdir[=DIR] directory of LDAP shared library], ldap_lib=$withval, ldap_lib=, ) db3_inc=auto db4_inc=auto AC_ARG_WITH(db3, [ --with-db3[=DIR] use of DB3 (DIR is directory of DB3 includes)], db3_inc=$withval; test $withval != no && db4_inc=no, , ) AC_ARG_WITH(db4, [ --with-db4[=DIR] use of DB4 (DIR is directory of DB4 includes)], db4_inc=$withval; test $withval != no && db3_inc=no, , ) AC_ARG_WITH(db-libdir, [ --with-db-libdir[=DIR] directory of DB3 or DB4 shared library], db_lib=$withval, db_lib=, ) AC_ARG_WITH(mysql, [ --with-mysql[=DIR] use of MySQL (DIR is path of mysql include) default is auto-detected], mysql_inc=$withval, mysql_inc=auto, ) AC_ARG_WITH(mysql-libdir, [ --with-mysql-libdir[=DIR] directory of MySQL library], mysql_lib=$withval, mysql_lib=auto, ) AC_ARG_WITH(pgsql, [ --with-pgsql use of PostgressSQL (experimental) default is auto-detected], pgsql=$withval, pgsql=auto, ) AC_ARG_WITH(pam, [ --with-pam use of PAM (experimental, disabled by default)], hasspam=$withval, hasspam=no ) AC_ARG_WITH(proxy, [ --without-proxy disable the proxy driver], proxy=$withval, proxy=yes ) AC_ARG_WITH(nss, [ --without-nss disable NSS source for the proxy], nss=$withval, nss=yes ) AC_ARG_WITH(conffile, [ --with-conffile=path configuration file name (default $sysconfdir/home.conf)], AC_SUBST(CONFFILE, $withval), AC_SUBST(CONFFILE, $sysconfdir/home.conf), ) DO_PROXY='#' DO_NSS='#' AC_SUBST(DO_PROXY) AC_SUBST(DO_NSS) NSS_PREFIX= AC_SUBST(NSS_PREFIX) NSS_VERSION=1 AC_SUBST(NSS_VERSION) dnl Checks for libraries. dnl Replace "main" with a function in -lmysqlclient: dnl Checks for header files. dnl AC_HEADER_STDC AC_MSG_CHECKING([how to mark unused variables]) AC_COMPILE_IFELSE( [AC_LANG_SOURCE([[int a __attribute__ ((unused));]])], [AC_DEFINE(UNUSED, [__attribute__((unused))], [Attribute to mark unused variables])], [AC_DEFINE(UNUSED, [])]) AC_MSG_RESULT([]) if test "x$mysql_inc" != "xno" then AC_PATH_PROGS(MYSQL_CONFIG, mysql_config) case "$mysql_inc" in auto|yes) if test "$MYSQL_CONFIG" != "" then mysql_inc="`$MYSQL_CONFIG --cflags`" eval "mysql_inc=\"\`echo $mysql_inc\`\"" else AC_HEADER_INCLUDES(mysql.h, mysql_inc, ${includedir}/mysql ${oldincludedir}/mysql) test "x$mysql_inc" != xno && mysql_inc="-I$mysql_inc" fi ;; *) mysql_inc="-I$mysql_inc" ;; esac case "$mysql_lib" in auto|yes) if test "$MYSQL_CONFIG" != "" then MYSQL_LIBS="`$MYSQL_CONFIG --libs`" eval "MYSQL_LIBS=\"\`echo $MYSQL_LIBS\`\"" else mysql_lib=`echo $mysql_inc| sed s%/include%/lib%\;s%-I%-L%` MYSQL_LIBS="$mysql_lib -lmysqlclient" fi ;; no) ;; *) test "$mysql_lib" != "" && MYSQL_LIBS="-L${mysql_lib}" MYSQL_LIBS="$MYSQL_LIB -lmysqlclient" ;; esac savedCFLAGS="$CFLAGS" LIBS="$MYSQL_LIBS $LIBS" CFLAGS="$CFLAGS $mysql_inc" AC_CHECK_FUNC(mysql_real_connect) AC_MSG_CHECKING(if MYSQL_OPT_CONNECT_TIMEOUT is avaiable) AC_COMPILE_IFELSE([#include mysql_option = MYSQL_OPT_CONNECT_TIMEOUT; ], AC_MSG_RESULT(yes) AC_DEFINE(HAVE_MYSQL_OPT_CONNECT_TIMEOUT, 1, define if MYSQL_OPT_CONNECT_TIMEOUT is avaiable) , AC_MSG_RESULT(no)) LIBS="$savedLIBS" CFLAGS="$savedCFLAGS" fi if test "x$pgsql" != no then AC_PATH_PROGS(PG_CONFIG, pg_config) if test "$PG_CONFIG" != "" then pgsql_inc=`$PG_CONFIG --includedir` pgsql_libdir=`$PG_CONFIG --libdir` LIBS="-L$pgsql_libdir -lpq" AC_CHECK_FUNC(PQexec) LIBS="$savedLIBS" PGSQL_LIBS="-L$pgsql_libdir -lpq" else pgsql=no fi fi if test $db4_inc != no then AC_HEADER_INCLUDES(db.h, db4_inc, [${prefix}/BerkeleyDB.4.3/include] [${prefix}/BerkeleyDB.4.2/include] [${prefix}/BerkeleyDB.4.1/include] [${prefix}/BerkeleyDB.4.0/include] ${includedir}/db43 ${includedir}/db42 ${includedir}/db41 ${includedir}/db40 ${includedir}/db4 ${oldincludedir}/db4) fi if test $db3_inc != no then AC_HEADER_INCLUDES(db.h, db3_inc, ${includedir}/db3 ${oldincludedir}/db3) fi AC_HEADER_INCLUDES(ldap.h, ldap_inc, ${includedir} system) AC_CHECK_HEADERS(crypt.h) AC_CHECK_HEADERS(getopt.h stdint.h sys/select.h sys/time.h) AC_SEARCH_LIBS(crypt, crypt) AC_CHECK_FUNCS(timegm vsyslog) AC_CHECK_FUNCS(fchown fchmod) AC_CHECK_FUNCS(getspnam, [ AC_CHECK_HEADERS(shadow.h, [ AC_CHECK_MEMBERS([struct spwd.sp_pwdp, struct spwd.sp_expire],,, [#include ]) ]) ]) AC_CHECK_MEMBERS([struct passwd.pw_expire, struct passwd.pw_change, struct passwd.pw_class],,,[ #include #include ]) AC_SUBST(PRELOAD_LIB) AC_SUBST(PRELOAD_LIBS) PRELOAD_LIB= PRELOAD_LIBS= savedLIBS=${LIBS} LIBS= AC_SEARCH_LIBS(ldsym, dl) AC_CHECK_HEADERS(dlfcn.h) AC_MSG_CHECKING([for RTLD_NEXT macro]) AC_COMPILE_IFELSE( [#include main() { dlsym(RTLD_NEXT, "foo"); }], PRELOAD_LIB=libhome-preload.la PRELOAD_LIBS=${LIBS} AC_MSG_RESULT(yes), AC_MSG_RESULT(no) ) LIBS=${savedLIBS} if test $ldap_inc != no then if test "$ldap_lib" != "" then LIBS="$LIBS -L$ldap_lib" fi AC_SEARCH_LIBS(ldap_init, ldap,, [ if test $ldap_inc != yes then CPPFLAGS="$CPPFLAGS -I$ldap_inc" LDAP_CFLAGS="-I$ldap_inc" if test "$ldap_lib" = "" then ldap_lib=`echo $ldap_inc| sed s%/include%/lib%` LIBS="$LIB -L$ldap_lib" fi fi LIBS="$LIBS -lldap" ]) AC_SEARCH_LIBS(ber_init, lber) AC_LIBOBJ([hldap]) AC_DEFINE(WITH_LDAP, 1, Define to 1 if you have LDAP libraries) hasldap=yes else hasldap=no fi if test "$hasspam" = yes then AC_LIBOBJ([hpam]) AC_DEFINE(WITH_PAM, 1, Define to 1 if you want PAM support) AC_SEARCH_LIBS(pam_start, pam) fi AC_SUBST(SOCKET_LIBS) if test "$proxy" = yes then AC_LIBOBJ([hproxy]) AC_DEFINE(WITH_PROXY, 1, Define to 1 if you want proxy support) savedLIBS="$LIBS" LIBS="" AC_SEARCH_LIBS(connect, socket) SOCKET_LIBS="$LIBS" LIBS="$savedLIBS $LIBS" AC_CHECK_FUNCS(getpeereid) DO_PROXY= AC_MSG_CHECKING(for struct cmsgcred) AC_TRY_COMPILE([ #include #include ],[ struct sockcred cred; cred.sc_euid = 0; ], AC_MSG_RESULT(yes) AC_DEFINE(HAVE_STRUCT_SOCKCRED,1,[Have sockcred structure]), AC_MSG_RESULT(no) ) if test "$nss" = yes then AC_CHECK_HEADERS(nss.h, DO_NSS= , ) AC_CHECK_HEADERS(nsswitch.h, DO_NSS= , ) AC_CHECK_HEADERS(nss_common.h, DO_NSS= ) case "$target_os" in linux*) NSS_PREFIX=lib ; NSS_VERSION=2 ;; hpux*) NSS_PREFIX=lib ; DO_NSS='#' ;; # missing headers ... again ... netbsd[0-9]*|netbsdelf1.*) DO_NSS='#' ;; # apparently, nsdispatch don't load dynamic libs # but may have the headers esac fi fi if test "x$mysql_inc" != xno then CPPFLAGS="$CPPFLAGS $mysql_inc" AC_LIBOBJ([hmysql]) AC_DEFINE(WITH_MYSQL, 1, Define to 1 if you have MySQL libraries) LIBS="$LIBS $MYSQL_LIBS" MYSQL_CFLAGS=$mysql_inc hasmysql=yes else hasmysql=no fi if test "x$pgsql" != xno then AC_LIBOBJ([hpgsql]) AC_DEFINE(WITH_PGSQL, 1, Define to 1 if you have Postgresql support) LIBS="$LIBS $PGSQL_LIBS" CPPFLAGS="$CPPFLAGS -I$pgsql_inc" haspgsql=yes else haspgsql=no fi db_version=no db_inc=no if test $db4_inc != no then db_version=4 db_inc=$db4_inc else if test $db3_inc != no then db_version=3 db_inc=$db3_inc fi fi if test $db_inc != no then CPPFLAGS="$CPPFLAGS -I$db_inc" # db_obj="cache3.o rewritedb.o" AC_LIBOBJ([cache3]) AC_LIBOBJ([rewritedb]) AC_DEFINE_UNQUOTED(WITH_DB, $db_version, Define to DB major version if you have DB libraries) DB_CFLAGS="-I$db_inc" if test "x$db_lib" = "x" then db_lib1=`echo $db_inc| sed s%/include%/lib%` if test -e "$db_lib1" then for f in db${db_version} db-${db_version} do if test -e "$db_lib1/lib${f}.so" then db_lib=${db_lib1} break; fi done fi if test "x$db_lib" = "x" then # some check for FreeBSD port installation db_lib2=`echo $db_lib1|sed "s%/db${db_version}$%%"` if test -e "$db_lib2/lib${db_version}.so" then db_lib=${db_lib2} fi fi if test "x$db_lib" != "x" then LIBS="$LIBS -L${db_lib}" fi else LIBS="$LIBS -L$db_lib" fi case $db_version in 3) AC_SEARCH_LIBS(db_strerror, db-3.3 db-3.2 db-3.1 db-3.0 db-3 db3);; 4) AC_SEARCH_LIBS(db_strerror, db-4.3 db-4.2 db-4.1 db-4.0 db-4 db4,, AC_SEARCH_LIBS(db_strerror_4002, db-4.2));; esac fi AC_CHECK_HEADERS(limits.h unistd.h) AC_CHECK_FUNCS(getprogname __progname) AC_CHECK_FUNCS(setpassent) AC_CHECK_FUNCS(strptime) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_UID_T AC_TYPE_SIZE_T AC_DEFINE(_GNU_SOURCE, 1, [Define unconditionally for setting a GNU environment.]) dnl Checks for library functions. AC_CHECK_FUNCS(regcomp strdup strerror strspn strtol strtoul) AC_MSG_RESULT() AC_MSG_RESULT(* MySQL support ... $hasmysql) AC_MSG_RESULT(* PgSQL support ... $haspgsql) AC_MSG_RESULT(* LDAP support .... $hasldap) AC_MSG_RESULT(* DB support ...... $db_version) AC_MSG_RESULT(* PAM support ..... $hasspam) AC_MSG_RESULT(* Proxy support ... $proxy) AC_MSG_RESULT() LTLIBOBJS=`echo "$LIB@&t@OBJS" | sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'` AC_SUBST(LTLIBOBJS) dnl AC_CONFIG_SUBDIRS(libltdl) AC_OUTPUT(Makefile home.conf.5 libhome.sh home_version.h, echo > stamp-h)