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.

111 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. cd "$SRC"
  30. if ! [ -d proj ]; then
  31. git clone ${PROJ_URL} proj
  32. cd proj
  33. git checkout ${PROJ_REV}
  34. git submodule update --init
  35. ./autogen.sh
  36. else
  37. cd proj
  38. fi
  39. ./configure --host=${host} --prefix=${prefix} \
  40. --disable-documentation \
  41. --with-ev="$dep" \
  42. --with-mbedtls="$dep" \
  43. --with-sodium="$dep" \
  44. --with-pcre="$dep" \
  45. --with-cares="$dep" \
  46. CFLAGS="-DCARES_STATICLIB -DPCRE_STATIC"
  47. make clean
  48. make LDFLAGS="-all-static -L${dep}/lib"
  49. make install-strip
  50. # Reference SIP003 plugin (Experimental)
  51. [[ "${PLUGIN}" != "true" ]] && return 0
  52. PLUGIN_URL=https://github.com/${PROJ_SITE}/simple-obfs.git
  53. PLUGIN_REV=master
  54. cd "$SRC"
  55. if ! [ -d plugin ]; then
  56. git clone ${PLUGIN_URL} plugin
  57. cd plugin
  58. git checkout ${PLUGIN_REV}
  59. git submodule update --init
  60. ./autogen.sh
  61. else
  62. cd plugin
  63. fi
  64. ./configure --host=${host} --prefix=${prefix} \
  65. --disable-documentation \
  66. --with-ev="$dep"
  67. make clean
  68. make LDFLAGS="-all-static -L${dep}/lib"
  69. make install-strip
  70. }
  71. dk_build() {
  72. for arch in i686 x86_64; do
  73. build_proj $arch
  74. done
  75. }
  76. dk_package() {
  77. rm -rf "$BASE/pack"
  78. mkdir -p "$BASE/pack"
  79. cd "$BASE/pack"
  80. mkdir -p ss-libev-${PROJ_REV}
  81. cd ss-libev-${PROJ_REV}
  82. for bin in local server tunnel; do
  83. cp ${DIST}/i686/bin/ss-${bin}.exe ss-${bin}-x86.exe
  84. cp ${DIST}/x86_64/bin/ss-${bin}.exe ss-${bin}-x64.exe
  85. done
  86. for bin in local server; do
  87. cp ${DIST}/i686/bin/obfs-${bin}.exe obfs-${bin}-x86.exe || true
  88. cp ${DIST}/x86_64/bin/obfs-${bin}.exe obfs-${bin}-x64.exe || true
  89. done
  90. pushd "$SRC/proj"
  91. GIT_REV="$(git rev-parse --short HEAD)"
  92. popd
  93. echo "SHA1 checksum for build $(date +"%y%m%d")-${GIT_REV}" > checksum
  94. for f in *.exe; do
  95. echo " $f:" >> checksum
  96. echo " $(sha1sum $f | cut -d ' ' -f 1)" >> checksum
  97. done
  98. sed -e 's/$/\r/' checksum > checksum.txt
  99. rm -f checksum
  100. cd ..
  101. tar zcf /bin.tgz ss-libev-${PROJ_REV}
  102. }