Skip to Content.
Sympa Menu

freetds - Re: is there an autoconf guru in the house?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Steve Langasek <vorlon AT netexpress.net>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: is there an autoconf guru in the house?
  • Date: Sat, 3 Mar 2001 17:29:29 -0600 (CST)


Hi Brian,

On Sat, 3 Mar 2001, Brian Bruns wrote:

> I got the notion to allow the odbc bits to compile with either iODBC or
> unixODBC, so I added two options to configure.in like such:

> AC_ARG_WITH(iodbc,
> [ --with-iodbc=/path/to/iodbc build odbc driver against iODBC])
> if test "$with_iodbc"; then
> CFLAGS="$CFLAGS -DIODBC";
> ODBC_INC=$with_iodbc/include;
> odbc=true
> fi

> AC_ARG_WITH(iodbc,
> [ --with-unixodbc=/path/to/unixodbc build odbc driver against unixODBC])
> if test "$with_unixodbc"; then
> CFLAGS="$CFLAGS -DUNIXODBC"
> ODBC_INC=$with_unixodbc/include
> odbc=true
> fi
> AM_CONDITIONAL(ODBC, test x$odbc = xtrue)

> So the problem is with AM_CONDITIONAL...running the configure script with
> sh -x configure or sh -x configure --with-iodbc=/usr/local sets ODBC_TRUE
> and ODBC_FALSE as expected. I then added this to the src/Makefile.am

> if ODBC
> SUBDIRS = tds ctlib dblib odbc server
> else
> SUBDIRS = tds ctlib dblib server
> endif

> so that odbc would only get compiled if a driver manager was
> specified. Problem is that 'ODBC' alway evaluates to true. Anyone have
> any clues?

I'd never heard of AM_CONDITIONAL before, but I tracked down the macro in the
libltdl aclocal.m4 file:

AC_DEFUN(AM_CONDITIONAL,
[AC_SUBST($1_TRUE)
AC_SUBST($1_FALSE)
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi])


This is going to define the Makefile variables ODBC_TRUE and ODBC_FALSE, yes.
So you should only need to use these variables in the makefile:

if $(ODBC_TRUE)
SUBDIRS = tds ctlib dblib odbc server
else
SUBDIRS = tds ctlib dblib server
endif


Of course, many versions of make (GNU make being the notable exception) don't
allow conditionals in makefiles. Since you already have autoconf/automake at
your disposal, I'd suggest a more portable way of doing this. Instead of
using AM_CONDITIONAL in configure.in:

AC_SUBST(ODBCDIR)
if test x$odbc = xtrue
then
ODBCDIR="odbc"
else
ODBCDIR=
endif

and in Makefile.am, you would have the single line:

SUBDIRS = tds ctlib dblib $(ODBCDIR) server


HTH,
Steve Langasek
postmodern programmer





Archive powered by MHonArc 2.6.24.

Top of Page