diff options
author | Baruch Siach <baruch@tkos.co.il> | 2017-10-09 08:49:44 +0300 |
---|---|---|
committer | Stephen Hemminger <stephen@networkplumber.org> | 2017-10-11 11:02:13 -0700 |
commit | 4f6b73380d2c84b98b7beffe6ca73f635ab72a06 (patch) | |
tree | 7ae61e1e978822438607a674e8ec9b208d6b145c /configure | |
parent | ecd44e680576c793f2a943d00301215f09882c59 (diff) |
lib: fix multiple strlcpy definition
Some C libraries, like uClibc and musl, provide BSD compatible
strlcpy(). Add check_strlcpy() to configure, and avoid defining strlcpy
and strlcat when the C library provides them.
This fixes the following static link error with uClibc-ng:
.../sysroot/usr/lib/libc.a(strlcpy.os): In function `strlcpy':
strlcpy.c:(.text+0x0): multiple definition of `strlcpy'
../lib/libutil.a(utils.o):utils.c:(.text+0x1ddc): first defined here
collect2: error: ld returned 1 exit status
Acked-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -326,6 +326,27 @@ EOF rm -f $TMPDIR/dbtest.c $TMPDIR/dbtest } +check_strlcpy() +{ + cat >$TMPDIR/strtest.c <<EOF +#include <string.h> +int main(int argc, char **argv) { + char dst[10]; + strlcpy(dst, "test", sizeof(dst)); + return 0; +} +EOF + $CC -I$INCLUDE -o $TMPDIR/strtest $TMPDIR/strtest.c >/dev/null 2>&1 + if [ $? -eq 0 ] + then + echo "no" + else + echo 'CFLAGS += -DNEED_STRLCPY' >>$CONFIG + echo "yes" + fi + rm -f $TMPDIR/strtest.c $TMPDIR/strtest +} + quiet_config() { cat <<EOF @@ -397,6 +418,9 @@ check_mnl echo -n "Berkeley DB: " check_berkeley_db +echo -n "need for strlcpy: " +check_strlcpy + echo echo -n "docs:" check_docs |