Bug 1296455

Summary: AC_CHECK_LIB() modifies LIBS if if-found action is []
Product: [Fedora] Fedora Reporter: Petr Pisar <ppisar>
Component: autoconfAssignee: Pavel Raiskup <praiskup>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: phracek, praiskup
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-01-09 18:54:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Petr Pisar 2016-01-07 10:02:35 UTC
When upgrading quota to 4.03, I discovered all executables are linked to a library whose presence is checked by:

    AC_CHECK_LIB([ldap], [ldap_initialize], [], [
        build_ldap=no
        AS_IF([test "x$enable_ldapmail" = "xyes"], [
            AC_MSG_ERROR([LDAP support required but library not found.]);
        ])
    ])

Because third argument (if-found action) is defined to empty literal, it should not fall back to default implementation (adding -lldap to LIBS etc.). Documentation reads:

     [..] If ACTION-IF-FOUND is not
     specified, the default action prepends `-lLIBRARY' to `LIBS' and
     defines `HAVE_LIBLIBRARY' (in all capitals).

But autoconf-2.69-21.fc23.noarch seems breaking this rule and modifies LIBS.

I had to work around the bug with this change in quota's configure.ac:

-    AC_CHECK_LIB([ldap], [ldap_initialize], [], [
+    AC_CHECK_LIB([ldap], [ldap_initialize], [:;], [

I believe this is a bug in Autoconf.

Comment 1 Pavel Raiskup 2016-01-07 10:27:46 UTC
If I understand this right, you think that '[]' makes it a explicitly defined
value, but it does not.  M4 compares against empty string and thus
having 'macro(a,,c)' is equivalent to 'macro(a,[],c)'.

Comment 2 Pavel Raiskup 2016-01-07 10:36:32 UTC
You can avoid changing the LIBS variable by:

  old_LIBS=$LIBS
  AC_CHECK_LIB([ldap], [ldap_initialize], , [
  ...
  LIBS=$old_LIBS

.. or more likely, properly specify the ACTION-IF-FOUND.  Having 'true' there
does not look much like work-around to me.  But for really qualified answer
this should be discussed upstream.

Comment 3 Petr Pisar 2016-01-07 11:22:40 UTC
Thank you for the explanation. I will alert quota upstream to rework the configure.ac.