make-release 4.5 KB

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