File: make-release

package info (click to toggle)
bfgminer 4.7.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,116 kB
  • ctags: 9,129
  • sloc: ansic: 62,470; lisp: 5,221; sh: 4,572; php: 2,645; asm: 667; makefile: 427; python: 85; ruby: 23
file content (204 lines) | stat: -rwxr-xr-x 4,555 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/bin/bash
# Copyright 2012-2014 Luke Dashjr
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option)
# any later version.  See COPYING for more details.

set -e
set -x
tag="$1"; shift
[ -n "$tag" ] || exit 1
sw="$1"; shift || true
[ -n "$sw" ] || sw="$tag"

test -n "$DEBUG_RELEASE" || DEBUG_RELEASE=1

builds=(win32 win64)

win32_machine='i686-pc-mingw32'
win32_CFLAGS='-march=i686'

win64_machine='x86_64-w64-mingw32'
win64_CFLAGS=''

IDIR="$PWD"
OUTDIR="$PWD"
TMPROOT="$PWD/make-release-tmp"
TMPDIR="${TMPROOT}/${sw}-tmp"

mkdir -vp "$TMPDIR"

# Source release
git branch TMP "$tag"
git clone . "$TMPDIR" -b TMP --depth 1
git branch -D TMP
cd "$TMPDIR"
sed 's/^\[submodule "\(.*\)"\]$/\1/;t;d' .gitmodules |
 while read submodule; do
	git config submodule.$submodule.url "$IDIR/.git/modules/$submodule"
done
git submodule update --init
{
	git archive --prefix "$sw"/ --format tar "$tag"
	git submodule --quiet foreach --recursive 'test x$name = xccan || git archive --prefix "'"$sw"'/$path/" --format tar HEAD'
	(
		cd ccan-upstream
		git archive --prefix "$sw/ccan-upstream/" --format tar HEAD ccan/{build_assert,cast,compiler,opt,typesafe_cb} licenses/{CC0,GPL-3,LGPL-2.1}
	)
} | tar -xivp
./gen-version.sh >"$sw"/version.h
cd "$sw"
NOSUBMODULES=1 \
NOCONFIGURE=1 \
./autogen.sh
find . -name autom4te.cache |
 xargs rm -r
cd ..
zip -y -r "$OUTDIR/${sw}.zip" "$sw"
tar -cJvpf "$OUTDIR/${sw}.txz" "$sw"
SRCDIR="$TMPDIR/$sw"

docs='
	AUTHORS
	COPYING
	NEWS
	README
	README.ASIC
	README.FPGA
	README.GPU
	README.RPC
	README.scrypt
'
for build in "${builds[@]}"; do
	PKGNAME="${sw}-${build}"
	PKGDIR="$TMPDIR/$PKGNAME"
	cd "$SRCDIR"
	mkdir -vp "$PKGDIR"
	for v in machine CFLAGS; do
		eval "${v}"="'$(eval echo "\${${build}_${v}}")'"
	done
	if test "x$DEBUG_RELEASE" = "x1"; then
		CFLAGS="${CFLAGS} -g"
	fi
	for doc in $docs; do
		sed 's/$/\r/' <"$doc" >"$PKGDIR/${doc}.txt"
	done
	
	./configure \
		--prefix='C:\\Program Files\\BFGMiner\\' \
		CFLAGS="${CFLAGS} -Wall" \
		--disable-cpumining \
		--enable-opencl \
		--enable-adl \
		--enable-bitforce \
		--enable-icarus \
		--enable-modminer \
		--enable-ztex \
		--enable-scrypt \
		--host="$machine"
	make $MAKEOPTS
	if test "x$DEBUG_RELEASE" != "x1"; then
		"$machine"-strip \
			libblkmaker/.libs/*.dll \
			*.exe
	fi
	cp -vr \
		*.exe \
		libblkmaker/.libs/*.dll \
		opencl \
		example.conf \
		windows-build.txt \
		miner.php \
		"$PKGDIR/"
	mkdir "$PKGDIR/bitstreams"
	
	ls "$PKGDIR" | grep '\.\(exe\|dll\)$' |
	 perl -e '
		use strict;
		use warnings;
		use File::Basename;
		use File::Glob;
		
		my ($PKGDIR, $machine) = @ARGV;
		my @todo = map { chomp; $_ } <STDIN>;
		my %have = map { lc $_=>undef } (@todo, qw(
			advapi32.dll
			imagehlp.dll
			kernel32.dll
			msvcrt.dll
			setupapi.dll
			shell32.dll
			user32.dll
			winmm.dll
			ws2_32.dll
			wsock32.dll
		));
		# Optional/dlopen libs
		push @todo, qw(
			backtrace.dll
			libhidapi-0.dll
			libfootest.dll
		);
		sub ciexist {
			my ($f) = @_;
			my $lcf = lc $f;
			for my $match (File::Glob::bsd_glob("${f}*", File::Glob::GLOB_CSH | File::Glob::GLOB_NOCASE)) {
				my $matchlc = lc $match;
				if ($matchlc eq $lcf) {
					return basename($match);
				}
			}
			undef
		}
		sub copydll {
			my ($dlllc, $opt) = @_;
			my $dll;
			my $libdir;
			for my $check_libdir (
				"/usr/$machine/usr/lib",
				"/usr/$machine/usr/bin",
			) {
				$dll = ciexist "$check_libdir/${dlllc}";
				if ($dll) {
					$libdir = $check_libdir;
					last
				}
			}
			if (not defined $libdir) {
				return if $opt;
				die "Cannot find $dlllc\n"
			}
			system("cp -v -L \"$libdir/$dll\" \"$PKGDIR\"") && die "Copy $dll failed\n";
			system("\"${machine}-strip\" \"$PKGDIR/$dll\"") && die "Strip $dll failed\n";
			push @todo, $dll;
			$have{$dlllc} = undef;
			1
		}
		while (my $c = shift @todo) {
			if (not ciexist "$PKGDIR/$c") {
				copydll $c, 1;
				# copydll will add it to @todo again if found
				next
			}
			
			my $found;
			print("Processing dependencies for ${c}...\n");
			my $objdump = `"${machine}-objdump" -p "${PKGDIR}/${c}"`;
			while ($objdump =~ /\G(?:\n|.)*?^\s*DLL Name\:\s*(.*)$/mg) {
				my $dlllc = lc $1;
				++$found;
				next if exists $have{$dlllc};
				
				copydll $dlllc;
			}
			die "Failed to objdump $c\n" unless $found;
		}
' "$PKGDIR" "$machine"
	
	make clean
	cd "$PKGDIR/.."
	zip -r "$OUTDIR/$PKGNAME.zip" "$PKGNAME"
done
cd "$IDIR"