sunc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. # Copyright (C) Igor Sysoev
  2. # Copyright (C) Nginx, Inc.
  3. # Sun C 5.7 Patch 117837-04 2005/05/11 Sun Studio 10
  4. # Sun C 5.8 2005/10/13 Sun Studio 11
  5. # Sun C 5.9 SunOS_i386 2007/05/03 Sun Studio 12
  6. # Sun C 5.9 SunOS_sparc 2007/05/03
  7. # Sun C 5.10 SunOS_i386 2009/06/03 Sun Studio 12.1
  8. # Sun C 5.11 SunOS_i386 2010/08/13 Oracle Solaris Studio 12.2
  9. # Sun C 5.12 SunOS_i386 2011/11/16 Oracle Solaris Studio 12.3
  10. # Sun C 5.13 SunOS_i386 2014/10/20 Oracle Solaris Studio 12.4
  11. # Sun C 5.14 SunOS_i386 2016/05/31 Oracle Developer Studio 12.5
  12. NGX_SUNC_VER=`$CC -V 2>&1 | grep 'Sun C' 2>&1 \
  13. | sed -e 's/^.* Sun C \(.*\)/\1/'`
  14. echo " + Sun C version: $NGX_SUNC_VER"
  15. have=NGX_COMPILER value="\"Sun C $NGX_SUNC_VER\"" . auto/define
  16. cat << END > $NGX_AUTOTEST.c
  17. int main(void) {
  18. printf("%d", __SUNPRO_C);
  19. return 0;
  20. }
  21. END
  22. eval "$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1"
  23. if [ -x $NGX_AUTOTEST ]; then
  24. ngx_sunc_ver=`$NGX_AUTOTEST`
  25. fi
  26. rm -rf $NGX_AUTOTEST*
  27. # 1424 == 0x590, Sun Studio 12
  28. if [ "$ngx_sunc_ver" -ge 1424 ]; then
  29. ngx_sparc32="-m32"
  30. ngx_sparc64="-m64"
  31. ngx_amd64="-m64"
  32. else
  33. ngx_sparc32="-xarch=v8plus"
  34. ngx_sparc64="-xarch=v9"
  35. ngx_amd64="-xarch=amd64"
  36. fi
  37. case "$NGX_MACHINE" in
  38. i86pc)
  39. NGX_AUX=" src/os/unix/ngx_sunpro_x86.il"
  40. ;;
  41. sun4u | sun4v)
  42. NGX_AUX=" src/os/unix/ngx_sunpro_sparc64.il"
  43. ;;
  44. esac
  45. MAIN_LINK=
  46. MODULE_LINK="-G"
  47. # optimizations
  48. # 20736 == 0x5100, Sun Studio 12.1
  49. if [ "$ngx_sunc_ver" -ge 20736 ]; then
  50. ngx_fast="-fast"
  51. else
  52. # older versions had problems with bit-fields
  53. ngx_fast="-fast -xalias_level=any"
  54. fi
  55. IPO=-xipo
  56. CFLAGS="$CFLAGS $ngx_fast $IPO"
  57. CORE_LINK="$CORE_LINK $ngx_fast $IPO"
  58. case $CPU in
  59. pentium)
  60. # optimize for Pentium and Athlon
  61. CPU_OPT="-xchip=pentium"
  62. ;;
  63. pentiumpro)
  64. # optimize for Pentium Pro, Pentium II
  65. CPU_OPT="-xchip=pentium_pro"
  66. ;;
  67. pentium3)
  68. # optimize for Pentium III
  69. CPU_OPT="-xchip=pentium3"
  70. #CPU_OPT="$CPU_OPT -xarch=sse"
  71. CPU_OPT="$CPU_OPT -xcache=16/32/4:256/32/4"
  72. ;;
  73. pentium4)
  74. # optimize for Pentium 4
  75. CPU_OPT="-xchip=pentium4"
  76. #CPU_OPT="$CPU_OPT -xarch=sse2"
  77. CPU_OPT="$CPU_OPT -xcache=8/64/4:256/128/8"
  78. ;;
  79. opteron)
  80. # optimize for Opteron
  81. CPU_OPT="-xchip=opteron"
  82. #CPU_OPT="$CPU_OPT -xarch=sse2"
  83. CPU_OPT="$CPU_OPT -xcache=64/64/2:1024/64/16"
  84. ;;
  85. sparc32)
  86. # build 32-bit UltraSparc binary
  87. CPU_OPT="$ngx_sparc32"
  88. CORE_LINK="$CORE_LINK $ngx_sparc32"
  89. CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_sparc32"
  90. NGX_CPU_CACHE_LINE=64
  91. ;;
  92. sparc64)
  93. # build 64-bit UltraSparc binary
  94. CPU_OPT="$ngx_sparc64"
  95. CORE_LINK="$CORE_LINK $ngx_sparc64"
  96. CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_sparc64"
  97. NGX_CPU_CACHE_LINE=64
  98. ;;
  99. amd64)
  100. # build 64-bit amd64 binary
  101. CPU_OPT="$ngx_amd64"
  102. CORE_LINK="$CORE_LINK $ngx_amd64"
  103. CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_amd64"
  104. NGX_AUX=" src/os/unix/ngx_sunpro_amd64.il"
  105. NGX_CPU_CACHE_LINE=64
  106. ;;
  107. esac
  108. CFLAGS="$CFLAGS $CPU_OPT"
  109. if [ ".$PCRE_OPT" = "." ]; then
  110. PCRE_OPT="$ngx_fast $IPO $CPU_OPT"
  111. fi
  112. if [ ".$ZLIB_OPT" = "." ]; then
  113. ZLIB_OPT="$ngx_fast $IPO $CPU_OPT"
  114. fi
  115. # stop on warning
  116. CFLAGS="$CFLAGS -errwarn=%all"
  117. # debug
  118. CFLAGS="$CFLAGS -g"