You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
823 B

2 months ago
  1. #!/bin/bash
  2. # Auxiliary script for CoCoALib configuration process.
  3. # Script to see whether compiler is clang, and then link with
  4. # If no warning is produced, the script prints -fPIC; otherwise it prints nothing.
  5. if [ $# -ne 1 ]
  6. then
  7. echo "***ERROR*** $0 needs 1 arg (name of C++ compiler)"
  8. exit 1
  9. fi
  10. CXX="$1"
  11. umask 22
  12. TMP_DIR=fpic-check-$HOSTNAME-$UID-$$
  13. /bin/rm -rf "$TMP_DIR" && mkdir "$TMP_DIR"
  14. if [ $? -ne 0 ]
  15. then
  16. echo "***ERROR*** $0: unable to create temp directory $TMP_DIR"
  17. exit 2
  18. fi
  19. cd "$TMP_DIR"
  20. # test if it is clang: .... a bit harsh, maybe...
  21. cat > TestProg.C <<EOF
  22. int main()
  23. {
  24. #ifdef __clang__
  25. exit(1);
  26. #endif
  27. }
  28. EOF
  29. COMPILER_MESG2=`"$CXX" $FPIC_FLAG -c -o TestProg.o TestProg.C 2>& 1`
  30. if [ $? -ne 0 ]
  31. then
  32. FPIC_LDFLAG="-Wl,-no_pie";
  33. fi
  34. cd ..
  35. /bin/rm -rf "$TMP_DIR"
  36. echo $FPIC_LDFLAG