make-release 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. git submodule update --init
  31. {
  32. git archive --prefix "$sw"/ --format tar "$tag"
  33. git submodule --quiet foreach --recursive 'git archive --prefix "'"$sw"'/$path/" --format tar HEAD'
  34. } | tar -xivp
  35. cd "$sw"
  36. NOSUBMODULES=1 \
  37. NOCONFIGURE=1 \
  38. ./autogen.sh
  39. find . -name autom4te.cache |
  40. xargs rm -r
  41. cd ..
  42. zip -r "$OUTDIR/${sw}.zip" "$sw"
  43. tar cjvpf "$OUTDIR/${sw}.tbz2" "$sw"
  44. SRCDIR="$TMPDIR/$sw"
  45. docs='
  46. AUTHORS
  47. COPYING
  48. NEWS
  49. README
  50. README.ASIC
  51. README.FPGA
  52. README.GPU
  53. README.RPC
  54. README.scrypt
  55. '
  56. for build in "${builds[@]}"; do
  57. PKGNAME="${sw}-${build}"
  58. PKGDIR="$TMPDIR/$PKGNAME"
  59. cd "$TMPDIR"
  60. mkdir -vp "$PKGDIR"
  61. for v in machine CFLAGS; do
  62. eval "${v}"="'$(eval echo "\${${build}_${v}}")'"
  63. done
  64. if test "x$DEBUG_RELEASE" = "x1"; then
  65. CFLAGS="${CFLAGS} -g"
  66. fi
  67. for doc in $docs; do
  68. sed 's/$/\r/' <"$doc" >"$PKGDIR/${doc}.txt"
  69. done
  70. NOCONFIGURE=1 \
  71. ./autogen.sh
  72. ./configure \
  73. --prefix='C:\\Program Files\\BFGMiner\\' \
  74. CFLAGS="${CFLAGS} -Wall" \
  75. --disable-cpumining \
  76. --enable-opencl \
  77. --enable-adl \
  78. --enable-bitforce \
  79. --enable-icarus \
  80. --enable-modminer \
  81. --enable-ztex \
  82. --enable-scrypt \
  83. --host="$machine"
  84. make $MAKEOPTS
  85. if test "x$DEBUG_RELEASE" != "x1"; then
  86. "$machine"-strip \
  87. libblkmaker/.libs/*.dll \
  88. *.exe
  89. fi
  90. cp -v \
  91. *.exe \
  92. libblkmaker/.libs/*.dll \
  93. *.cl \
  94. example.conf \
  95. windows-build.txt \
  96. miner.php \
  97. "$PKGDIR/"
  98. mkdir "$PKGDIR/bitstreams"
  99. ls "$PKGDIR" | grep '\.\(exe\|dll\)$' |
  100. perl -e '
  101. use strict;
  102. use warnings;
  103. use File::Basename;
  104. use File::Glob;
  105. my ($PKGDIR, $machine) = @ARGV;
  106. my @todo = map { chomp; $_ } <STDIN>;
  107. my %have = map { lc $_=>undef } (@todo, qw(
  108. advapi32.dll
  109. imagehlp.dll
  110. kernel32.dll
  111. msvcrt.dll
  112. setupapi.dll
  113. shell32.dll
  114. user32.dll
  115. winmm.dll
  116. ws2_32.dll
  117. wsock32.dll
  118. ));
  119. # Optional/dlopen libs
  120. push @todo, qw(
  121. backtrace.dll
  122. libhidapi-0.dll
  123. libfootest.dll
  124. );
  125. sub ciexist {
  126. my ($f) = @_;
  127. my $lcf = lc $f;
  128. for my $match (File::Glob::bsd_glob("${f}*", File::Glob::GLOB_CSH | File::Glob::GLOB_NOCASE)) {
  129. my $matchlc = lc $match;
  130. if ($matchlc eq $lcf) {
  131. return basename($match);
  132. }
  133. }
  134. undef
  135. }
  136. sub copydll {
  137. my ($dlllc, $opt) = @_;
  138. my $dll;
  139. my $libdir;
  140. for my $check_libdir (
  141. "/usr/$machine/usr/lib",
  142. "/usr/$machine/usr/bin",
  143. ) {
  144. $dll = ciexist "$check_libdir/${dlllc}";
  145. if ($dll) {
  146. $libdir = $check_libdir;
  147. last
  148. }
  149. }
  150. if (not defined $libdir) {
  151. return if $opt;
  152. die "Cannot find $dlllc\n"
  153. }
  154. system("cp -v -L \"$libdir/$dll\" \"$PKGDIR\"") && die "Copy $dll failed\n";
  155. system("\"${machine}-strip\" \"$PKGDIR/$dll\"") && die "Strip $dll failed\n";
  156. push @todo, $dll;
  157. $have{$dlllc} = undef;
  158. 1
  159. }
  160. while (my $c = shift @todo) {
  161. if (not ciexist "$PKGDIR/$c") {
  162. copydll $c, 1;
  163. # copydll will add it to @todo again if found
  164. next
  165. }
  166. my $found;
  167. print("Processing dependencies for ${c}...\n");
  168. my $objdump = `"${machine}-objdump" -p "${PKGDIR}/${c}"`;
  169. while ($objdump =~ /\G(?:\n|.)*?^\s*DLL Name\:\s*(.*)$/mg) {
  170. my $dlllc = lc $1;
  171. ++$found;
  172. next if exists $have{$dlllc};
  173. copydll $dlllc;
  174. }
  175. die "Failed to objdump $c\n" unless $found;
  176. }
  177. ' "$PKGDIR" "$machine"
  178. make clean
  179. cd "$PKGDIR/.."
  180. zip -r "$OUTDIR/$PKGNAME.zip" "$PKGNAME"
  181. done
  182. cd "$IDIR"