autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About AC_CHECK_HEADERS and different locations


From: Andrew W. Nosenko
Subject: Re: About AC_CHECK_HEADERS and different locations
Date: Tue, 28 Sep 2010 18:10:25 +0300

On Tue, Sep 28, 2010 at 17:52, Andrew W. Nosenko
<address@hidden> wrote:
> On Tue, Sep 28, 2010 at 06:13, Sergio Belkin <address@hidden> wrote:
>> Hi,
>>
>> I am autoconfiscating a project that has a header file with a line:
>>
>> #include <postgresql/libpq-fe.h>
>>
>> configure.ac has:
>>
>> AC_CHECK_HEADERS(postgresql/libpq-fe.h)
>>
>> The problem is that Ubuntu has such a header file on
>> /usr/include/postgresq  but fedora has it on  /usr/include. So how can
>> I make that configure script checks  for differents paths?
>
> Assuming that
>  o  Fedora has requested header as /usr/include/libpq-fe.h
>  o  Ubuntu has requested header as /usr/include/postgresql/libpq-fe.h
>      (otherwise I see no problems at all, just use CPPFLAGS approrach
> as already suggested)
>
> Then you can to check both in configure.ac and use result in the source code:
>
> configure.ac:
>
> AC_CHECK_HEADERS([postgresql/libpq-fe.h libpq-fe.h],
>                 [break],
>                 [AC_MSG_ERROR([PostgreSQL headers not found or not usable])])
>

Sorry, [action-if-not-found] executed if either header not found
instead of expected by me "neither header found"...  Therefore,
appropriate check shouldbe rewritten for keep semantics expected by
me:

AC_CHECK_HEADERS([postgresql/libpq-fe.h libpq-fe.h], [break])

if test x"$ac_cv_header_postgresql_libpq_fe_h" != xyes -a
x"$ac_cv_header_libpq_fe_h" != xyes
then
    AC_MSG_ERROR([PostgreSQL headers not found or not usable])
fi

> Source code:
>
> #if defined(POSTGRESQL_LIBPQ_FE_H)
> #  include <postgresql/libpq-fe.h>
> #elif defined(LIBPQ_FE_H)
> #  include <libpq-fe.h>
> #else
> #  error impossible because of AC_MSG_ERROR(), but...
> #endif
>
> Of cource you can play with [action-not-found] (for example remove
> AC_MSG_ERROR() completely and don't abort configure if nither header
> found), and simplify "#include" dance to
>
> #if defined(POSTGRESQL_LIBPQ_FE_H)
> #  include <postgresql/libpq-fe.h>
> #else
> #  include <libpq-fe.h>
> #endif
>
> for allow tuning CPPFLAGS by hands at the make(1) invocation, for
> example...  Or anything what you want.
>
> PS.  Untested, I didn't compile actually these examples, but hope you
> get the idea.
>
> --
> Andrew W. Nosenko <address@hidden>
>



-- 
Andrew W. Nosenko <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]