You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Graham Leggett <mi...@sharp.fm> on 2001/08/08 21:22:33 UTC

Autoconf question: conditional compile

Hi all,

I have an autoconf question, I need to know the "right" way to do this:

In apr-util, the LDAP libraries are configured using the --with-ldap
flag. If the libraries are found and built correctly, then a symbol
called APU_HAS_LDAP is defined.

Now - when I compile code in Apache, which uses apr-util, how can I
detect whether this APU_HAS_LDAP symbol exists in apr-util or not?

Regards,
Graham 
-- 
-----------------------------------------
minfrin@sharp.fm		"There's a moon
					over Bourbon Street
						tonight..."

Re: Autoconf question: conditional compile

Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Wed, Aug 08, 2001 at 10:12:34PM +0200, Graham Leggett wrote:
> Justin Erenkrantz wrote:
> 
> > I think you'd want:
> > 
> > #include <apu.h>
> > ...
> > #if APU_HAS_LDAP
> > /* LDAP code here. */
> > #else
> > /* You don't have LDAP, so don't do anything. */
> > #endif
> > 
> > The trick is that APU_HAS_LDAP should be a 0 or 1 value not a simple
> > define.  And, I think rbb (or Doug?) pointed out that it should be
> > APR_HAS_LDAP since that symbol doesn't conflict with APR.
> 
> Would it be a good idea to use the AC_CONFIG_HEADER(include/apr_ldap.h)
> macro for this?
> 
> Can this macro be used more than once? (it is used already in
> configure.in for include/private/apu_config.h)

In apu.h.in, you can add:

#define APU_HAS_LDAP @ldap@

That's how I see it anyway.  This mimics the apr.h.in feature macros.
ldap would be 0 or 1 depending upon if you found LDAP libraries.

(rbb says to use APU, so use APU...)  -- justin


Re: Autoconf question: conditional compile

Posted by Graham Leggett <mi...@sharp.fm>.
Justin Erenkrantz wrote:

> I think you'd want:
> 
> #include <apu.h>
> ...
> #if APU_HAS_LDAP
> /* LDAP code here. */
> #else
> /* You don't have LDAP, so don't do anything. */
> #endif
> 
> The trick is that APU_HAS_LDAP should be a 0 or 1 value not a simple
> define.  And, I think rbb (or Doug?) pointed out that it should be
> APR_HAS_LDAP since that symbol doesn't conflict with APR.

Would it be a good idea to use the AC_CONFIG_HEADER(include/apr_ldap.h)
macro for this?

Can this macro be used more than once? (it is used already in
configure.in for include/private/apu_config.h)

Regards,
Graham
-- 
-----------------------------------------
minfrin@sharp.fm		"There's a moon
					over Bourbon Street
						tonight..."

Re: Autoconf question: conditional compile

Posted by Ryan Bloom <rb...@covalent.net>.
On Wednesday 08 August 2001 14:26, Justin Erenkrantz wrote:
> On Wed, Aug 08, 2001 at 09:22:33PM +0200, Graham Leggett wrote:
> > Hi all,
> >
> > I have an autoconf question, I need to know the "right" way to do this:
> >
> > In apr-util, the LDAP libraries are configured using the --with-ldap
> > flag. If the libraries are found and built correctly, then a symbol
> > called APU_HAS_LDAP is defined.
> >
> > Now - when I compile code in Apache, which uses apr-util, how can I
> > detect whether this APU_HAS_LDAP symbol exists in apr-util or not?
>
> I think you'd want:
>
> #include <apu.h>
> ...
> #if APU_HAS_LDAP
> /* LDAP code here. */
> #else
> /* You don't have LDAP, so don't do anything. */
> #endif
>
> The trick is that APU_HAS_LDAP should be a 0 or 1 value not a simple
> define.  And, I think rbb (or Doug?) pointed out that it should be
> APR_HAS_LDAP since that symbol doesn't conflict with APR.

I didn't suggest that, because it should be APU_HAS_LDAP.  The symbol is for apr-util.

Ryan

_____________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
Covalent Technologies			rbb@covalent.net
-----------------------------------------------------------------------------

Re: Autoconf question: conditional compile

Posted by Graham Leggett <mi...@sharp.fm>.
Justin Erenkrantz wrote:

> I think you'd want:
> 
> #include <apu.h>
> ...
> #if APU_HAS_LDAP
> /* LDAP code here. */
> #else
> /* You don't have LDAP, so don't do anything. */
> #endif
> 
> The trick is that APU_HAS_LDAP should be a 0 or 1 value not a simple
> define.  And, I think rbb (or Doug?) pointed out that it should be
> APR_HAS_LDAP since that symbol doesn't conflict with APR.

So I would create an apr_ldap.h.in, and use a substitution to insert a 1
or a 0? Or is there another way?

Regards,
Graham
-- 
-----------------------------------------
minfrin@sharp.fm		"There's a moon
					over Bourbon Street
						tonight..."

Re: Autoconf question: conditional compile

Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Wed, Aug 08, 2001 at 09:22:33PM +0200, Graham Leggett wrote:
> Hi all,
> 
> I have an autoconf question, I need to know the "right" way to do this:
> 
> In apr-util, the LDAP libraries are configured using the --with-ldap
> flag. If the libraries are found and built correctly, then a symbol
> called APU_HAS_LDAP is defined.
> 
> Now - when I compile code in Apache, which uses apr-util, how can I
> detect whether this APU_HAS_LDAP symbol exists in apr-util or not?

I think you'd want:

#include <apu.h>
...
#if APU_HAS_LDAP
/* LDAP code here. */
#else
/* You don't have LDAP, so don't do anything. */
#endif

The trick is that APU_HAS_LDAP should be a 0 or 1 value not a simple
define.  And, I think rbb (or Doug?) pointed out that it should be
APR_HAS_LDAP since that symbol doesn't conflict with APR.  

HTH.  -- justin