Subject: [PATCH] Re: configure: use AC_SEARCH_LIBS instead of AC_CHECK_LIB

From: Nicolas Sebrecht <[email-masked]>
Date: Sun, 19 Jul 2009 15:14:04 +0200

The 19/07/09, Nicolas Sebrecht wrote:
> 
> > and when I did "rm configure ; make configure ; ./configure"
> > it gave me
> > 
> >   NO_LIBGEN_H=
> >   NEEDS_RESOLV=
> > 
> >   SNPRINTF_RETURNS_BOGUS=UnfortunatelyYes
> > 
> > I have tried to find which commit introduced this regression.
> > 
> >  $ git bisect start origin v1.6.3 v1.6.3.2 -- configure.ac config.mak.in
> >  $ git bisect run ~/git/test.sh
> > 
> > finds ecc395c (Makefile: add NEEDS_LIBGEN to optionally add -lgen to
> > compile arguments, 2009-07-10) as a first bad commit.  But I don't see
> > how it could have changed it... Strange...

The wrong check of lib gen added a flag ' -lgen' to $LIBS (in configure).
This wrong flag then gave:

 [...]/bin/ld: cannot find -lgen collect2: ld returned 1 exit status

which made wrongly fail the next compilation test (using $LIBS).

> > CC-ed Brandon Casey, author of blamed changeset, and David Syzdek who
> > offered at some time help with maintaining autoconf.
> 
> Thank you, I did the same investigation here. :-)

I wonder if we could have some feedbacks on this patch. The change on
the whole file may make more bad than good. Works as expected here on
Linux (glibc 2.9).

Otherwise, the following lines are sufficient to correct the original
error:

>  test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv"
>  
> -AC_CHECK_LIB([gen], [basename],
> +AC_SEARCH_LIBS([basename], [gen],
>  [NEEDS_LIBGEN=],
>  [NEEDS_LIBGEN=YesPlease])
>  AC_SUBST(NEEDS_LIBGEN)

-- 
Nicolas Sebrecht