make-release 4.3 KB

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