You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.0 KiB

  1. #!/bin/bash
  2. #
  3. # Functions for building MinGW port in Docker
  4. #
  5. # This file is part of the shadowsocks-libev.
  6. #
  7. # shadowsocks-libev is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # shadowsocks-libev is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with shadowsocks-libev; see the file COPYING. If not, see
  19. # <http://www.gnu.org/licenses/>.
  20. #
  21. # Exit on error
  22. set -e
  23. . /prepare.sh
  24. build_proj() {
  25. arch=$1
  26. host=$arch-w64-mingw32
  27. prefix=${DIST}/$arch
  28. dep=${PREFIX}/$arch
  29. cpu="$(nproc --all)"
  30. cd "$SRC"
  31. if ! [ -d proj ]; then
  32. git clone ${PROJ_URL} proj
  33. cd proj
  34. git checkout ${PROJ_REV}
  35. git submodule update --init
  36. ./autogen.sh
  37. else
  38. cd proj
  39. fi
  40. ./configure --host=${host} --prefix=${prefix} \
  41. --disable-documentation \
  42. --with-ev="$dep" \
  43. --with-mbedtls="$dep" \
  44. --with-sodium="$dep" \
  45. --with-pcre="$dep" \
  46. --with-cares="$dep" \
  47. CFLAGS="-DCARES_STATICLIB -DPCRE_STATIC"
  48. make clean
  49. make -j$cpu LDFLAGS="-all-static -L${dep}/lib"
  50. make install
  51. # Reference SIP003 plugin (Experimental)
  52. [[ "${PLUGIN}" != "true" ]] && return 0
  53. PLUGIN_URL=https://github.com/${PROJ_SITE}/simple-obfs.git
  54. PLUGIN_REV=master
  55. cd "$SRC"
  56. if ! [ -d plugin ]; then
  57. git clone ${PLUGIN_URL} plugin
  58. cd plugin
  59. git checkout ${PLUGIN_REV}
  60. git submodule update --init
  61. ./autogen.sh
  62. else
  63. cd plugin
  64. fi
  65. ./configure --host=${host} --prefix=${prefix} \
  66. --disable-documentation \
  67. --with-ev="$dep"
  68. make clean
  69. make -j$cpu LDFLAGS="-all-static -L${dep}/lib"
  70. make install
  71. }
  72. dk_build() {
  73. for arch in i686 x86_64; do
  74. build_proj $arch
  75. done
  76. }
  77. dk_package() {
  78. rm -rf "$BASE/pack"
  79. mkdir -p "$BASE/pack"
  80. cd "$BASE/pack"
  81. mkdir -p ss-libev-${PROJ_REV}
  82. cd ss-libev-${PROJ_REV}
  83. for bin in local server tunnel; do
  84. cp ${DIST}/i686/bin/ss-${bin}.exe ss-${bin}-x86.exe
  85. cp ${DIST}/x86_64/bin/ss-${bin}.exe ss-${bin}-x64.exe
  86. done
  87. for bin in local server; do
  88. cp ${DIST}/i686/bin/obfs-${bin}.exe obfs-${bin}-x86.exe || true
  89. cp ${DIST}/x86_64/bin/obfs-${bin}.exe obfs-${bin}-x64.exe || true
  90. done
  91. pushd "$SRC/proj"
  92. GIT_REV="$(git rev-parse --short HEAD)"
  93. popd
  94. echo "SHA1 checksum for build $(date +"%y%m%d")-${GIT_REV}" > checksum
  95. for f in *.exe; do
  96. echo " $f:" >> checksum
  97. echo " $(sha1sum $f | cut -d ' ' -f 1)" >> checksum
  98. done
  99. sed -e 's/$/\r/' checksum > checksum.txt
  100. rm -f checksum
  101. cd ..
  102. tar zcf /bin.tgz ss-libev-${PROJ_REV}
  103. }