build.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #!/usr/bin/env bash
  2. CMD="$1"
  3. MAKE=make
  4. if [[ -z "${CMD}" ]]; then
  5. export CMD="default"
  6. fi
  7. if [ -x "/usr/bin/mariadb_config" ]; then
  8. export SQL=" --with-mysql=/usr/bin/mariadb_config"
  9. elif [ -x "/usr/bin/mysql_config" ]; then
  10. export SQL=" --with-mysql=/usr/bin/mysql_config"
  11. elif [ -x "/usr/local/bin/mysql_config" ]; then
  12. export SQL=" --with-mysql=/usr/local/bin/mysql_config"
  13. else
  14. export SQL=""
  15. fi
  16. source src/evol/tools/vars.sh
  17. COMMON="--enable-packetver=20170517 --enable-debug=gdb${SQL}"
  18. if [[ "$(uname)" == "FreeBSD" ]]; then
  19. MAKE=gmake
  20. export CORES=$(sysctl hw.ncpu | awk '{print $2}')
  21. elif [[ "$(uname)" == "Darwin" ]]; then
  22. export CORES=$(sysctl hw.ncpu | awk '{print $2}')
  23. else
  24. COMMON+=" --enable-epoll"
  25. export CORES=$(cat /proc/cpuinfo|grep processor|wc -l)
  26. fi
  27. export COMMON
  28. export MAKE
  29. autoreconf
  30. if [ "$?" != 0 ]; then
  31. exit 1
  32. fi
  33. if [[ "${CMD}" == "default" || "${CMD}" == "all" ]]; then
  34. export CC=gcc
  35. ./configure --enable-manager=no --enable-sanitize=full ${COMMON} CPPFLAGS="${VARS}"
  36. if [ "$?" != 0 ]; then
  37. exit 1
  38. fi
  39. ${MAKE} -j${CORES}
  40. if [ "$?" != 0 ]; then
  41. exit 1
  42. fi
  43. ${MAKE} install
  44. if [ "$?" != 0 ]; then
  45. exit 1
  46. fi
  47. cd src/evol
  48. if [ "$?" != 0 ]; then
  49. exit 1
  50. fi
  51. ./build.sh
  52. if [ "$?" != 0 ]; then
  53. exit 1
  54. fi
  55. elif [[ "${CMD}" == "old" ]]; then
  56. ./configure --disable-lto ${COMMON} CPPFLAGS="${VARS}"
  57. if [ "$?" != 0 ]; then
  58. exit 1
  59. fi
  60. ${MAKE} -j${CORES}
  61. if [ "$?" != 0 ]; then
  62. exit 1
  63. fi
  64. ${MAKE} install
  65. if [ "$?" != 0 ]; then
  66. exit 1
  67. fi
  68. cd src/evol
  69. if [ "$?" != 0 ]; then
  70. exit 1
  71. fi
  72. ./build.sh old
  73. if [ "$?" != 0 ]; then
  74. exit 1
  75. fi
  76. elif [[ "${CMD}" == "valgrind" ]]; then
  77. ./configure --enable-manager=no ${COMMON} CPPFLAGS="${VARS}"
  78. if [ "$?" != 0 ]; then
  79. exit 1
  80. fi
  81. ${MAKE} -j${CORES}
  82. if [ "$?" != 0 ]; then
  83. exit 1
  84. fi
  85. ${MAKE} install
  86. if [ "$?" != 0 ]; then
  87. exit 1
  88. fi
  89. cd src/evol
  90. if [ "$?" != 0 ]; then
  91. exit 1
  92. fi
  93. ./build.sh old
  94. if [ "$?" != 0 ]; then
  95. exit 1
  96. fi
  97. elif [[ "${CMD}" == "gprof" ]]; then
  98. ./configure --enable-manager=no --enable-profiler=gprof ${COMMON} CPPFLAGS="${VARS}"
  99. if [ "$?" != 0 ]; then
  100. exit 1
  101. fi
  102. ${MAKE} -j${CORES}
  103. if [ "$?" != 0 ]; then
  104. exit 1
  105. fi
  106. ${MAKE} install
  107. if [ "$?" != 0 ]; then
  108. exit 1
  109. fi
  110. cd src/evol
  111. if [ "$?" != 0 ]; then
  112. exit 1
  113. fi
  114. ./build.sh gprof
  115. if [ "$?" != 0 ]; then
  116. exit 1
  117. fi
  118. elif [[ "${CMD}" == "server" ]]; then
  119. ./configure --enable-sanitize ${COMMON} CPPFLAGS="${VARS}"
  120. if [ "$?" != 0 ]; then
  121. exit 1
  122. fi
  123. ${MAKE} -j${CORES}
  124. if [ "$?" != 0 ]; then
  125. exit 1
  126. fi
  127. ${MAKE} install
  128. if [ "$?" != 0 ]; then
  129. exit 1
  130. fi
  131. elif [[ "${CMD}" == "static" ]]; then
  132. ./configure LIBS="-lmysqlclient -lssl -lcrypto -pthread -lm -lz" --disable-64bit --enable-static ${COMMON}
  133. if [ "$?" != 0 ]; then
  134. exit 1
  135. fi
  136. ${MAKE} -j${CORES}
  137. if [ "$?" != 0 ]; then
  138. exit 1
  139. fi
  140. elif [[ "${CMD}" == "static64" ]]; then
  141. ./configure --enable-static ${COMMON} CPPFLAGS="${VARS}"
  142. if [ "$?" != 0 ]; then
  143. exit 1
  144. fi
  145. ${MAKE} -j${CORES}
  146. if [ "$?" != 0 ]; then
  147. exit 1
  148. fi
  149. fi
  150. echo "OK"