clang 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Copyright (C) Nginx, Inc.
  2. # clang
  3. NGX_CLANG_VER=`$CC -v 2>&1 | grep 'version' 2>&1 \
  4. | sed -n -e 's/^.*clang version \(.*\)/\1/p' \
  5. -e 's/^.*LLVM version \(.*\)/\1/p'`
  6. echo " + clang version: $NGX_CLANG_VER"
  7. have=NGX_COMPILER value="\"clang $NGX_CLANG_VER\"" . auto/define
  8. CC_TEST_FLAGS="-pipe"
  9. # optimizations
  10. #NGX_CLANG_OPT="-O2"
  11. #NGX_CLANG_OPT="-Oz"
  12. NGX_CLANG_OPT="-O"
  13. case $CPU in
  14. pentium)
  15. # optimize for Pentium
  16. CPU_OPT="-march=pentium"
  17. NGX_CPU_CACHE_LINE=32
  18. ;;
  19. pentiumpro | pentium3)
  20. # optimize for Pentium Pro, Pentium II and Pentium III
  21. CPU_OPT="-march=pentiumpro"
  22. NGX_CPU_CACHE_LINE=32
  23. ;;
  24. pentium4)
  25. # optimize for Pentium 4
  26. CPU_OPT="-march=pentium4"
  27. NGX_CPU_CACHE_LINE=128
  28. ;;
  29. athlon)
  30. # optimize for Athlon
  31. CPU_OPT="-march=athlon"
  32. NGX_CPU_CACHE_LINE=64
  33. ;;
  34. opteron)
  35. # optimize for Opteron
  36. CPU_OPT="-march=opteron"
  37. NGX_CPU_CACHE_LINE=64
  38. ;;
  39. esac
  40. CC_AUX_FLAGS="$CC_AUX_FLAGS $CPU_OPT"
  41. CFLAGS="$CFLAGS -pipe $CPU_OPT"
  42. if [ ".$PCRE_OPT" = "." ]; then
  43. PCRE_OPT="-O2 -pipe $CPU_OPT"
  44. else
  45. PCRE_OPT="$PCRE_OPT -pipe"
  46. fi
  47. if [ ".$ZLIB_OPT" = "." ]; then
  48. ZLIB_OPT="-O2 -pipe $CPU_OPT"
  49. else
  50. ZLIB_OPT="$ZLIB_OPT -pipe"
  51. fi
  52. # warnings
  53. CFLAGS="$CFLAGS $NGX_CLANG_OPT -Wall -Wextra -Wpointer-arith"
  54. CFLAGS="$CFLAGS -Wconditional-uninitialized"
  55. #CFLAGS="$CFLAGS -Wmissing-prototypes"
  56. # we have a lot of unused function arguments
  57. CFLAGS="$CFLAGS -Wno-unused-parameter"
  58. # deprecated system OpenSSL library on OS X
  59. if [ "$NGX_SYSTEM" = "Darwin" ]; then
  60. CFLAGS="$CFLAGS -Wno-deprecated-declarations"
  61. fi
  62. # stop on warning
  63. CFLAGS="$CFLAGS -Werror"
  64. # debug
  65. CFLAGS="$CFLAGS -g"
  66. if [ ".$CPP" = "." ]; then
  67. CPP="$CC -E"
  68. fi