From: Baruch Siach Date: Mon, 9 Oct 2017 05:49:44 +0000 (+0300) Subject: lib: fix multiple strlcpy definition X-Git-Tag: v4.14.0~25^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f6b73380d2c84b98b7beffe6ca73f635ab72a06;p=thirdparty%2Fiproute2.git 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 Signed-off-by: Baruch Siach --- diff --git a/configure b/configure index 7be8fb113..f0668ab3f 100755 --- a/configure +++ b/configure @@ -326,6 +326,27 @@ EOF rm -f $TMPDIR/dbtest.c $TMPDIR/dbtest } +check_strlcpy() +{ + cat >$TMPDIR/strtest.c < +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 <