| 1 | #!/bin/sh |
| 2 | |
| 3 | echo "Running configure script" |
| 4 | |
| 5 | # Find compiler |
| 6 | CC=`"${R_HOME}"/bin/R CMD config CC` |
| 7 | |
| 8 | # Detect whether -latomic is needed during linking. This is needed on some |
| 9 | # platforms, notably ARM (Raspberry Pi). |
| 10 | echo "#include <stdint.h> |
| 11 | uint64_t v; |
| 12 | int main() { |
| 13 | return (int)__atomic_load_n(&v, __ATOMIC_ACQUIRE); |
| 14 | }" | ${CC} -x c - -o /dev/null > /dev/null 2>&1 |
| 15 | |
| 16 | if [ $? -eq 0 ]; then |
| 17 | echo "-latomic linker flag not needed." |
| 18 | else |
| 19 | echo "-latomic linker flag needed." |
| 20 | EXTRA_PKG_LIBS=-latomic |
| 21 | fi |
| 22 | |
| 23 | case "$CC" in |
| 24 | *undefined*) |
| 25 | echo "Found UBSAN. Will skip tests that raise false positives." |
| 26 | PKG_CPPFLAGS="$PKG_CPPFLAGS -DUSING_UBSAN" |
| 27 | ;; |
| 28 | esac |
| 29 | |
| 30 | # Write to Makevars |
| 31 | sed -e "s|@extra_pkg_libs@|$EXTRA_PKG_LIBS|" -e "s|@pkg_cppflags@|$PKG_CPPFLAGS|" \ |
| 32 | src/Makevars.in > src/Makevars |
| 33 | |
| 34 | # Success |
| 35 | exit 0 |