posix-l.sh 718 B

12345678910111213141516171819202122232425262728293031
  1. # Should be sourced by
  2. # command -p sh posix-l.sh "$PATH"
  3. # from within a Makefile.
  4. # Sanity check environment variables
  5. if [ -z "${CC}" ]; then
  6. echo "\$CC is not defined! Cannot run any compiler tests." 1>&2
  7. exit 1
  8. fi
  9. if ! [ "${PATH}" = "$1" ]; then
  10. echo "WARNING: POSIX violation: ${SHELL}'s command -p resets \$PATH" 1>&2
  11. PATH=$1
  12. fi
  13. # Find directory of this script and the source files
  14. D=$(dirname "$0")
  15. FIRST=YES
  16. for LIB in rt xnet; do
  17. if ${CC} ${CFLAGS} -l"${LIB}" "${D}/posix-trivial.c" 2>/dev/null; then
  18. if [ "${FIRST}" = "NO" ]; then
  19. printf " ";
  20. fi
  21. printf "%s" "-l${LIB}";
  22. FIRST=NO;
  23. else
  24. echo "WARNING: POSIX violation: ${CC} does not understand -l${LIB}" 1>&2
  25. fi
  26. rm -f a.out
  27. done