make-release 4.4 KB

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