[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:20:02 +0300 |
On Tue, Sep 28, 2010 at 18:01, Ralf Corsepius <address@hidden> wrote:
> On 09/28/2010 04:52 PM, Andrew W. Nosenko 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])])
>>
>> 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.
>
> Much easier than this is modifying the source code to
> #include <libpq-fe.h>
> instead of
> #include <postresql/libpq-fe.h>
> and to rely on the user passing appropriate CPPFLAGS.
Yes, you right. And if user didn't specified anything, then proper
flags may be obtained using the 'pg_config' utility.
--
Andrew W. Nosenko <address@hidden>