gcc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. # Copyright (C) Igor Sysoev
  2. # Copyright (C) Nginx, Inc.
  3. # gcc 2.7.2.3, 2.8.1, 2.95.4, egcs-1.1.2
  4. # 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4.0, 3.4.2
  5. # 4.0.0, 4.0.1, 4.1.0
  6. NGX_GCC_VER=`$CC -v 2>&1 | grep 'gcc version' 2>&1 \
  7. | sed -e 's/^.* version \(.*\)/\1/'`
  8. echo " + gcc version: $NGX_GCC_VER"
  9. have=NGX_COMPILER value="\"gcc $NGX_GCC_VER\"" . auto/define
  10. # Solaris 7's /usr/ccs/bin/as does not support "-pipe"
  11. CC_TEST_FLAGS="-pipe"
  12. ngx_feature="gcc -pipe switch"
  13. ngx_feature_name=
  14. ngx_feature_run=no
  15. ngx_feature_incs=
  16. ngx_feature_path=
  17. ngx_feature_libs=
  18. ngx_feature_test=
  19. . auto/feature
  20. CC_TEST_FLAGS=
  21. if [ $ngx_found = yes ]; then
  22. PIPE="-pipe"
  23. fi
  24. case "$NGX_MACHINE" in
  25. sun4u | sun4v | sparc | sparc64 )
  26. # "-mcpu=v9" enables the "casa" assembler instruction
  27. CFLAGS="$CFLAGS -mcpu=v9"
  28. ;;
  29. esac
  30. # optimizations
  31. #NGX_GCC_OPT="-O2"
  32. #NGX_GCC_OPT="-Os"
  33. NGX_GCC_OPT="-O"
  34. #CFLAGS="$CFLAGS -fomit-frame-pointer"
  35. case $CPU in
  36. pentium)
  37. # optimize for Pentium and Athlon
  38. CPU_OPT="-march=pentium"
  39. NGX_CPU_CACHE_LINE=32
  40. ;;
  41. pentiumpro | pentium3)
  42. # optimize for Pentium Pro, Pentium II and Pentium III
  43. CPU_OPT="-march=pentiumpro"
  44. NGX_CPU_CACHE_LINE=32
  45. ;;
  46. pentium4)
  47. # optimize for Pentium 4, gcc 3.x
  48. CPU_OPT="-march=pentium4"
  49. NGX_CPU_CACHE_LINE=128
  50. ;;
  51. athlon)
  52. # optimize for Athlon, gcc 3.x
  53. CPU_OPT="-march=athlon"
  54. NGX_CPU_CACHE_LINE=64
  55. ;;
  56. opteron)
  57. # optimize for Opteron, gcc 3.x
  58. CPU_OPT="-march=opteron"
  59. NGX_CPU_CACHE_LINE=64
  60. ;;
  61. sparc32)
  62. # build 32-bit UltraSparc binary
  63. CPU_OPT="-m32"
  64. CORE_LINK="$CORE_LINK -m32"
  65. NGX_CPU_CACHE_LINE=64
  66. ;;
  67. sparc64)
  68. # build 64-bit UltraSparc binary
  69. CPU_OPT="-m64"
  70. CORE_LINK="$CORE_LINK -m64"
  71. NGX_CPU_CACHE_LINE=64
  72. ;;
  73. ppc64)
  74. # build 64-bit PowerPC binary
  75. CPU_OPT="-m64"
  76. CPU_OPT="$CPU_OPT -falign-functions=32 -falign-labels=32"
  77. CPU_OPT="$CPU_OPT -falign-loops=32 -falign-jumps=32"
  78. CORE_LINK="$CORE_LINK -m64"
  79. NGX_CPU_CACHE_LINE=128
  80. ;;
  81. esac
  82. CC_AUX_FLAGS="$CC_AUX_FLAGS $CPU_OPT"
  83. case "$NGX_GCC_VER" in
  84. 2.7*)
  85. # batch build
  86. CPU_OPT=
  87. ;;
  88. esac
  89. CFLAGS="$CFLAGS $PIPE $CPU_OPT"
  90. if [ ".$PCRE_OPT" = "." ]; then
  91. PCRE_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
  92. else
  93. PCRE_OPT="$PCRE_OPT $PIPE"
  94. fi
  95. if [ ".$ZLIB_OPT" = "." ]; then
  96. ZLIB_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
  97. else
  98. ZLIB_OPT="$ZLIB_OPT $PIPE"
  99. fi
  100. # warnings
  101. # -W requires at least -O
  102. CFLAGS="$CFLAGS ${NGX_GCC_OPT:--O} -W"
  103. CFLAGS="$CFLAGS -Wall -Wpointer-arith"
  104. #CFLAGS="$CFLAGS -Wconversion"
  105. #CFLAGS="$CFLAGS -Winline"
  106. #CFLAGS="$CFLAGS -Wmissing-prototypes"
  107. case "$NGX_GCC_VER" in
  108. 2.*)
  109. # we have a lot of the unused function arguments
  110. CFLAGS="$CFLAGS -Wno-unused"
  111. ;;
  112. *)
  113. # we have a lot of the unused function arguments
  114. CFLAGS="$CFLAGS -Wno-unused-parameter"
  115. # 4.2.1 shows the warning in wrong places
  116. #CFLAGS="$CFLAGS -Wunreachable-code"
  117. # deprecated system OpenSSL library on OS X
  118. if [ "$NGX_SYSTEM" = "Darwin" ]; then
  119. CFLAGS="$CFLAGS -Wno-deprecated-declarations"
  120. fi
  121. ;;
  122. esac
  123. # stop on warning
  124. CFLAGS="$CFLAGS -Werror"
  125. # debug
  126. CFLAGS="$CFLAGS -g"
  127. # DragonFly's gcc3 generates DWARF
  128. #CFLAGS="$CFLAGS -g -gstabs"
  129. if [ ".$CPP" = "." ]; then
  130. CPP="$CC -E"
  131. fi