make-release 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 "$SRCDIR"
  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. ./configure \
  79. --prefix='C:\\Program Files\\BFGMiner\\' \
  80. CFLAGS="${CFLAGS} -Wall" \
  81. --disable-cpumining \
  82. --enable-opencl \
  83. --enable-adl \
  84. --enable-bitforce \
  85. --enable-icarus \
  86. --enable-modminer \
  87. --enable-ztex \
  88. --enable-scrypt \
  89. --host="$machine"
  90. make $MAKEOPTS
  91. if test "x$DEBUG_RELEASE" != "x1"; then
  92. "$machine"-strip \
  93. libblkmaker/.libs/*.dll \
  94. *.exe
  95. fi
  96. cp -vr \
  97. *.exe \
  98. libblkmaker/.libs/*.dll \
  99. opencl \
  100. example.conf \
  101. windows-build.txt \
  102. miner.php \
  103. "$PKGDIR/"
  104. mkdir "$PKGDIR/bitstreams"
  105. ls "$PKGDIR" | grep '\.\(exe\|dll\)$' |
  106. perl -e '
  107. use strict;
  108. use warnings;
  109. use File::Basename;
  110. use File::Glob;
  111. my ($PKGDIR, $machine) = @ARGV;
  112. my @todo = map { chomp; $_ } <STDIN>;
  113. my %have = map { lc $_=>undef } (@todo, qw(
  114. advapi32.dll
  115. imagehlp.dll
  116. kernel32.dll
  117. msvcrt.dll
  118. setupapi.dll
  119. shell32.dll
  120. user32.dll
  121. winmm.dll
  122. ws2_32.dll
  123. wsock32.dll
  124. ));
  125. # Optional/dlopen libs
  126. push @todo, qw(
  127. backtrace.dll
  128. libhidapi-0.dll
  129. libfootest.dll
  130. );
  131. sub ciexist {
  132. my ($f) = @_;
  133. my $lcf = lc $f;
  134. for my $match (File::Glob::bsd_glob("${f}*", File::Glob::GLOB_CSH | File::Glob::GLOB_NOCASE)) {
  135. my $matchlc = lc $match;
  136. if ($matchlc eq $lcf) {
  137. return basename($match);
  138. }
  139. }
  140. undef
  141. }
  142. sub copydll {
  143. my ($dlllc, $opt) = @_;
  144. my $dll;
  145. my $libdir;
  146. for my $check_libdir (
  147. "/usr/$machine/usr/lib",
  148. "/usr/$machine/usr/bin",
  149. ) {
  150. $dll = ciexist "$check_libdir/${dlllc}";
  151. if ($dll) {
  152. $libdir = $check_libdir;
  153. last
  154. }
  155. }
  156. if (not defined $libdir) {
  157. return if $opt;
  158. die "Cannot find $dlllc\n"
  159. }
  160. system("cp -v -L \"$libdir/$dll\" \"$PKGDIR\"") && die "Copy $dll failed\n";
  161. system("\"${machine}-strip\" \"$PKGDIR/$dll\"") && die "Strip $dll failed\n";
  162. push @todo, $dll;
  163. $have{$dlllc} = undef;
  164. 1
  165. }
  166. while (my $c = shift @todo) {
  167. if (not ciexist "$PKGDIR/$c") {
  168. copydll $c, 1;
  169. # copydll will add it to @todo again if found
  170. next
  171. }
  172. my $found;
  173. print("Processing dependencies for ${c}...\n");
  174. my $objdump = `"${machine}-objdump" -p "${PKGDIR}/${c}"`;
  175. while ($objdump =~ /\G(?:\n|.)*?^\s*DLL Name\:\s*(.*)$/mg) {
  176. my $dlllc = lc $1;
  177. ++$found;
  178. next if exists $have{$dlllc};
  179. copydll $dlllc;
  180. }
  181. die "Failed to objdump $c\n" unless $found;
  182. }
  183. ' "$PKGDIR" "$machine"
  184. make clean
  185. cd "$PKGDIR/.."
  186. zip -r "$OUTDIR/$PKGNAME.zip" "$PKGNAME"
  187. done
  188. cd "$IDIR"