link with -latomic if needed

libusb unconditionally uses atomic_fetch_add since version 1.0.25 and
commit 1a08aa8 and commit eed8a37 but some architectures (e.g. sparc)
needs to link with -latomic to be able to use it. So check if -latomic
is needed and update libusb-1.0.pc accordingly to avoid the following
build failure with openocd:

/home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/10.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: /home/buildroot/autobuild/instance-0/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/ undefined reference to `__atomic_fetch_add_4'
collect2: error: ld returned 1 exit status

Full build log:

Closes #1064

Signed-off-by: Fabrice Fontaine <>
2 files changed