make-release 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. #!/bin/bash
  2. # Copyright 2012-2013 Luke Dashjr
  3. #
  4. # This program is free software; you can redistribute it and/or modify it
  5. # under the terms of the GNU General Public License as published by the Free
  6. # Software Foundation; either version 3 of the License, or (at your option)
  7. # any later version. See COPYING for more details.
  8. set -e
  9. set -x
  10. tag="$1"; shift
  11. [ -n "$tag" ] || exit 1
  12. sw="$1"; shift || true
  13. [ -n "$sw" ] || sw="$tag"
  14. test -n "$DEBUG_RELEASE" || DEBUG_RELEASE=1
  15. builds=(win32 win64)
  16. win32_machine='i686-pc-mingw32'
  17. win32_CFLAGS='-march=i686'
  18. win64_machine='x86_64-w64-mingw32'
  19. win64_CFLAGS=''
  20. IDIR="$PWD"
  21. OUTDIR="$PWD"
  22. TMPROOT="$PWD/make-release-tmp"
  23. TMPDIR="${TMPROOT}/${sw}-tmp"
  24. mkdir -vp "$TMPDIR"
  25. # Source release
  26. git branch TMP "$tag"
  27. git clone . "$TMPDIR" -b TMP --depth 1
  28. git branch -D TMP
  29. cd "$TMPDIR"
  30. sed 's/^\[submodule "\(.*\)"\]$/\1/;t;d' .gitmodules |
  31. while read submodule; do
  32. git config submodule.$submodule.url "$IDIR/.git/modules/$submodule"
  33. done
  34. git submodule update --init
  35. {
  36. git archive --prefix "$sw"/ --format tar "$tag"
  37. git submodule --quiet foreach --recursive 'test x$name = xccan-upstream || git archive --prefix "'"$sw"'/$path/" --format tar HEAD'
  38. (
  39. cd ccan-upstream
  40. git archive --prefix "'"$sw"'/$path/" --format tar HEAD ccan/{build_assert,cast,compiler,opt,typesafe_cb}
  41. )
  42. } | tar -xivp
  43. cd "$sw"
  44. NOSUBMODULES=1 \
  45. NOCONFIGURE=1 \
  46. ./autogen.sh
  47. find . -name autom4te.cache |
  48. xargs rm -r
  49. cd ..
  50. zip -r "$OUTDIR/${sw}.zip" "$sw"
  51. tar -cJvpf "$OUTDIR/${sw}.txz" "$sw"
  52. SRCDIR="$TMPDIR/$sw"
  53. docs='
  54. AUTHORS
  55. COPYING
  56. NEWS
  57. README
  58. README.ASIC
  59. README.FPGA
  60. README.GPU
  61. README.RPC
  62. README.scrypt
  63. '
  64. for build in "${builds[@]}"; do
  65. PKGNAME="${sw}-${build}"
  66. PKGDIR="$TMPDIR/$PKGNAME"
  67. cd "$TMPDIR"
  68. mkdir -vp "$PKGDIR"
  69. for v in machine CFLAGS; do
  70. eval "${v}"="'$(eval echo "\${${build}_${v}}")'"
  71. done
  72. if test "x$DEBUG_RELEASE" = "x1"; then
  73. CFLAGS="${CFLAGS} -g"
  74. fi
  75. for doc in $docs; do
  76. sed 's/$/\r/' <"$doc" >"$PKGDIR/${doc}.txt"
  77. done
  78. NOCONFIGURE=1 \
  79. ./autogen.sh
  80. ./configure \
  81. --prefix='C:\\Program Files\\BFGMiner\\' \
  82. CFLAGS="${CFLAGS} -Wall" \
  83. --disable-cpumining \
  84. --enable-opencl \
  85. --enable-adl \
  86. --enable-bitforce \
  87. --enable-icarus \
  88. --enable-modminer \
  89. --enable-ztex \
  90. --enable-scrypt \
  91. --host="$machine"
  92. make $MAKEOPTS
  93. if test "x$DEBUG_RELEASE" != "x1"; then
  94. "$machine"-strip \
  95. libblkmaker/.libs/*.dll \
  96. *.exe
  97. fi
  98. cp -vr \
  99. *.exe \
  100. libblkmaker/.libs/*.dll \
  101. opencl \
  102. example.conf \
  103. windows-build.txt \
  104. miner.php \
  105. "$PKGDIR/"
  106. mkdir "$PKGDIR/bitstreams"
  107. ls "$PKGDIR" | grep '\.\(exe\|dll\)$' |
  108. perl -e '
  109. use strict;
  110. use warnings;
  111. use File::Basename;
  112. use File::Glob;
  113. my ($PKGDIR, $machine) = @ARGV;
  114. my @todo = map { chomp; $_ } <STDIN>;
  115. my %have = map { lc $_=>undef } (@todo, qw(
  116. advapi32.dll
  117. imagehlp.dll
  118. kernel32.dll
  119. msvcrt.dll
  120. setupapi.dll
  121. shell32.dll
  122. user32.dll
  123. winmm.dll
  124. ws2_32.dll
  125. wsock32.dll
  126. ));
  127. # Optional/dlopen libs
  128. push @todo, qw(
  129. backtrace.dll
  130. libhidapi-0.dll
  131. libfootest.dll
  132. );
  133. sub ciexist {
  134. my ($f) = @_;
  135. my $lcf = lc $f;
  136. for my $match (File::Glob::bsd_glob("${f}*", File::Glob::GLOB_CSH | File::Glob::GLOB_NOCASE)) {
  137. my $matchlc = lc $match;
  138. if ($matchlc eq $lcf) {
  139. return basename($match);
  140. }
  141. }
  142. undef
  143. }
  144. sub copydll {
  145. my ($dlllc, $opt) = @_;
  146. my $dll;
  147. my $libdir;
  148. for my $check_libdir (
  149. "/usr/$machine/usr/lib",
  150. "/usr/$machine/usr/bin",
  151. ) {
  152. $dll = ciexist "$check_libdir/${dlllc}";
  153. if ($dll) {
  154. $libdir = $check_libdir;
  155. last
  156. }
  157. }
  158. if (not defined $libdir) {
  159. return if $opt;
  160. die "Cannot find $dlllc\n"
  161. }
  162. system("cp -v -L \"$libdir/$dll\" \"$PKGDIR\"") && die "Copy $dll failed\n";
  163. system("\"${machine}-strip\" \"$PKGDIR/$dll\"") && die "Strip $dll failed\n";
  164. push @todo, $dll;
  165. $have{$dlllc} = undef;
  166. 1
  167. }
  168. while (my $c = shift @todo) {
  169. if (not ciexist "$PKGDIR/$c") {
  170. copydll $c, 1;
  171. # copydll will add it to @todo again if found
  172. next
  173. }
  174. my $found;
  175. print("Processing dependencies for ${c}...\n");
  176. my $objdump = `"${machine}-objdump" -p "${PKGDIR}/${c}"`;
  177. while ($objdump =~ /\G(?:\n|.)*?^\s*DLL Name\:\s*(.*)$/mg) {
  178. my $dlllc = lc $1;
  179. ++$found;
  180. next if exists $have{$dlllc};
  181. copydll $dlllc;
  182. }
  183. die "Failed to objdump $c\n" unless $found;
  184. }
  185. ' "$PKGDIR" "$machine"
  186. make clean
  187. cd "$PKGDIR/.."
  188. zip -r "$OUTDIR/$PKGNAME.zip" "$PKGNAME"
  189. done
  190. cd "$IDIR"