On Tue, Sep 21, 2010 at 06:32:20PM +0200, Tamas TEVESZ wrote:
> On Tue, 21 Sep 2010, Brad Jorsch wrote:
> 
>  > Is there really a need to define HAVE_LIBBSD? All we care about is
>  > HAVE_STRLCAT, no matter how it is available.
> 
> on the bsds (where these functions are in libc), they can be had by 
> simply including <string.h>. on linux with libbsd, <bsd/string.h> is 
> needed too (in addition to the "normal" string.h), so some sort of 
> marker is needed to decide whether or not to include <bsd/string.h>. 
> am i wrong thinking this?

Maybe. What you'll probably end up doing is providing fallback
implementations if HAVE_STRLCAT is not defined, so no matter what the
functions will exist. And in that case, the prototypes will have to be
provided in some local .h file.

Rather than making that .h file conditional on HAVE_STRLCAT as well, you
might just provide the prototypes unconditionally. OTOH, if it is
somehow likely that the bsd or libbsd headers will use different types
(e.g. int instead of size_t, or something like that) you wouldn't want
to do that.

> also, in the libbsd case, -lbsd needs to be added to the wutil/wings 
> libs (XXX clean up where and how), whereas on a real bsd, no 
> additional nothing is needed, it just comes with libc.

That is automatically taken care of by AC_SEARCH_LIBS.

BTW, you may want to provide a configure option to skip the check for
libbsd, in case a distro wants to make sure they don't pull in a
dependency on libbsd. Something like this:

AC_ARG_WITH([libbsd],
  [AS_HELP_STRING([--without-libbsd], [do not use libbsd for strlcat and 
strlcpy [default=check]])],
  [],
  [with_libbsd=check])

AS_IF([test "x$with_libbsd" != "xno"],
  [AC_SEARCH_LIBS([strlcat],[bsd],
     [AC_DEFINE(HAVE_STRLCAT, 1, [Define if strlcat is available])],
     [if test "x$with_libbsd" != xcheck; then
       AC_MSG_FAILURE([--with-libbsd was given, but test for libbsd failed])
      fi
     ]
  )]
)


-- 
To unsubscribe, send mail to [email protected].

Reply via email to