Repository navigation
Expand file tree
/
Copy pathconfigure.ac
More file actions
233 lines (208 loc) · 7.47 KB
/
Copy pathconfigure.ac
File metadata and controls
233 lines (208 loc) · 7.47 KB
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
AC_INIT([ckpool],[1.2.0],[kernel@kolivas.org])
dnl Must come before anything that expands AC_PROG_CC/AC_PROG_CXX, which is as
dnl early as AC_USE_SYSTEM_EXTENSIONS below. Autoconf fills in a bare "-g -O2"
dnl the moment it detects a compiler, and a later "test -z" then sees a
dnl non-empty value and never applies these.
AC_MSG_CHECKING([whether to set default CFLAGS])
if test -z "$CFLAGS"; then
CFLAGS="-g -O2 -Wall -march=native"
AC_MSG_RESULT([yes, setting default CFLAGS to $CFLAGS])
else
AC_MSG_RESULT([no, using user-provided CFLAGS])
fi
AC_MSG_CHECKING([whether to set default CXXFLAGS])
if test -z "$CXXFLAGS"; then
CXXFLAGS="-g -O2 -Wall -march=native"
AC_MSG_RESULT([yes, setting default CXXFLAGS to $CXXFLAGS])
else
AC_MSG_RESULT([no, using user-provided CXXFLAGS])
fi
AC_CANONICAL_TARGET
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src/ckpool.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_USE_SYSTEM_EXTENSIONS
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
dnl Make sure anyone changing configure.ac/Makefile.am has a clue
AM_MAINTAINER_MODE
dnl Checks for programs
AC_PROG_CC
dnl C++ compiler required for the optional Cap'n Proto mining IPC shim
AC_PROG_CXX
# gl_EARLY - maybe later
AM_PROG_CC_C_O
LT_INIT([disable-shared])
# gl_INIT - maybe later
dnl Checks for header files.
AC_FUNC_ALLOCA
PKG_PROG_PKG_CONFIG()
AC_CHECK_HEADERS(stdio.h stdlib.h fcntl.h sys/time.h unistd.h dirent.h)
AC_CHECK_HEADERS(ctype.h errno.h byteswap.h string.h time.h fenv.h)
AC_CHECK_HEADERS(endian.h sys/endian.h arpa/inet.h sys/poll.h syslog.h)
AC_CHECK_HEADERS(alloca.h pthread.h stdio.h math.h signal.h sys/prctl.h)
AC_CHECK_HEADERS(sys/types.h sys/socket.h sys/stat.h linux/un.h netdb.h)
AC_CHECK_HEADERS(stdint.h netinet/in.h netinet/tcp.h sys/ioctl.h getopt.h)
AC_CHECK_HEADERS(sys/epoll.h libpq-fe.h postgresql/libpq-fe.h grp.h)
AC_CHECK_HEADERS(gsl/gsl_math.h gsl/gsl_cdf.h)
AC_CHECK_HEADERS(openssl/x509.h openssl/hmac.h)
AC_CHECK_HEADERS(zmq.h)
AC_CHECK_PROG(YASM, yasm, yes)
AM_CONDITIONAL([HAVE_YASM], [test x$YASM = xyes])
x86_shani=
rorx=
avx1=
sse4=
sha2=
if test $host_cpu = 'x86_64'; then
cpuinfo=$(cat /proc/cpuinfo 2>/dev/null)
dnl Match complete feature names, including at line boundaries.
AS_CASE([" $cpuinfo "],
[*[[[:space:]]]sha_ni[[[:space:]]]*], [
CFLAGS="$CFLAGS -msse4.1 -msha"
x86_shani="sha_ni"
], [*[[[:space:]]]avx2[[[:space:]]]*], [
rorx="avx2"
], [*[[[:space:]]]avx[[[:space:]]]*], [
avx1="avx"
], [*[[[:space:]]]sse4_1[[[:space:]]]*], [
sse4="sse4_1"
])
dnl SHA-NI uses C intrinsics; only the AVX/SSE implementations need YASM.
AS_IF([test x$YASM != xyes], [
rorx=
avx1=
sse4=
])
fi
if test $host_cpu = 'aarch64'; then
CFLAGS="$CFLAGS -march=armv8-a+crypto"
sha2=`cat /proc/cpuinfo | grep -o -m 1 sha2`
fi
AM_CONDITIONAL([HAVE_X86_SHANI], [test x$x86_shani = xsha_ni])
AM_CONDITIONAL([HAVE_AVX2], [test x$rorx = xavx2])
AM_CONDITIONAL([HAVE_AVX1], [test x$avx1 = xavx])
AM_CONDITIONAL([HAVE_SSE4], [test x$sse4 = xsse4_1])
AM_CONDITIONAL([HAVE_ARM_SHA2], [test x$sha2 = xsha2])
if test x$x86_shani = xsha_ni; then
AC_DEFINE([USE_X86_SHANI], [1], [Use x86 SHA-NI assembly instructions for sha256])
fi
if test x$rorx = xavx2; then
AC_DEFINE([USE_AVX2], [1], [Use avx2 assembly instructions for sha256])
fi
if test x$avx1 = xavx; then
AC_DEFINE([USE_AVX1], [1], [Use avx1 assembly instructions for sha256])
fi
if test x$sse4 = xsse4_1; then
AC_DEFINE([USE_SSE4], [1], [Use sse4 assembly instructions for sha256])
fi
if test x$sha2 = xsha2; then
AC_DEFINE([USE_ARM_SHA2], [1], [Use ARMv8 instructions for sha256])
fi
AC_SEARCH_LIBS(clock_nanosleep, rt, , echo "Error: Required library rt not found." && exit 1)
AC_SEARCH_LIBS(exp, m, , echo "Error: Required library math not found." && exit 1)
AC_SEARCH_LIBS(pthread_mutex_trylock, pthread, , echo "Error: Required library pthreads not found." && exit 1)
AC_SEARCH_LIBS(zmq_socket, zmq, ZMQ=yes, ZMQ=no)
dnl Optional Cap'n Proto (capnp-rpc) for the Bitcoin Core mining IPC interface.
dnl When present, ckpool builds the C++ IPC shim (ipc/mining) and prefers the
dnl IPC interface for block notifications, falling back to ZMQ otherwise.
CAPNP_CFLAGS=""
CAPNP_LIBS=""
CAPNP_REQ="pkg-config package capnp-rpc (e.g. libcapnp-dev), C++ compiler"
PKG_CHECK_MODULES([CAPNP], [capnp-rpc],
[CAPNP=yes
AC_DEFINE([HAVE_CAPNP], [1], [Have Cap'n Proto (capnp-rpc) for the mining IPC interface])],
[CAPNP=no])
AC_SUBST(CAPNP_CFLAGS)
AC_SUBST(CAPNP_LIBS)
AM_CONDITIONAL([HAVE_CAPNP], [test x$CAPNP = xyes])
dnl Optional Stratum V2 (Mining Protocol) — requires libsodium and bundled
dnl libsecp256k1 with ellswift + schnorrsig (see src/secp256k1).
AC_ARG_ENABLE([sv2],
[AS_HELP_STRING([--enable-sv2], [build Stratum V2 support (default: check deps)])],
[enable_sv2=$enableval], [enable_sv2=auto])
SV2=no
SV2_CFLAGS=""
SV2_LIBS=""
have_sodium=no
have_secp_src=no
SV2_MISSING=""
if test "x$enable_sv2" = "xno"; then
SV2_MISSING="disabled (--disable-sv2)"
else
PKG_CHECK_MODULES([SODIUM], [libsodium], [have_sodium=yes], [have_sodium=no])
if test "x$have_sodium" = "xno"; then
AC_CHECK_HEADER([sodium.h], [have_sodium=yes], [have_sodium=no])
if test "x$have_sodium" = "xyes"; then
SODIUM_LIBS="-lsodium"
fi
fi
if test -f "$srcdir/src/secp256k1/include/secp256k1_ellswift.h" && \
test -f "$srcdir/src/secp256k1/include/secp256k1_schnorrsig.h"; then
have_secp_src=yes
else
have_secp_src=no
fi
if test "x$have_sodium" = "xyes" && test "x$have_secp_src" = "xyes"; then
SV2=yes
AC_DEFINE([HAVE_SV2], [1], [Build Stratum V2 support])
SV2_CFLAGS="$SODIUM_CFLAGS -I\$(top_srcdir)/src/secp256k1/include"
SV2_LIBS="$SODIUM_LIBS \$(top_builddir)/src/secp256k1/.libs/libsecp256k1.a"
else
missing=""
if test "x$have_sodium" != "xyes"; then
missing="libsodium (pkg-config libsodium or sodium.h + -lsodium)"
fi
if test "x$have_secp_src" != "xyes"; then
if test -n "$missing"; then
missing="$missing; "
fi
missing="${missing}src/secp256k1 with ellswift+schnorrsig (secp256k1_ellswift.h, secp256k1_schnorrsig.h)"
fi
SV2_MISSING="$missing"
if test "x$enable_sv2" = "xyes"; then
AC_MSG_ERROR([--enable-sv2 requires: $SV2_MISSING])
fi
SV2=no
fi
fi
AC_SUBST(SV2_CFLAGS)
AC_SUBST(SV2_LIBS)
AM_CONDITIONAL([HAVE_SV2], [test x$SV2 = xyes])
AC_CONFIG_FILES([Makefile src/Makefile test/Makefile])
AC_OUTPUT
LDFLAGS="${LDFLAGS} -Wl,--as-needed"
echo
echo "Compilation............: make (or gmake)"
echo " YASM (Intel ASM).....: $YASM"
echo " ZMQ..................: $ZMQ"
if test "x$CAPNP" = "xyes"; then
echo " IPC (mining Cap'n)...: yes"
else
echo " IPC (mining Cap'n)...: no"
echo " requires...........: $CAPNP_REQ"
fi
if test "x$SV2" = "xyes"; then
echo " SV2 (Stratum V2).....: yes"
else
echo " SV2 (Stratum V2).....: no"
if test -n "$SV2_MISSING"; then
echo " requires...........: $SV2_MISSING"
else
echo " requires...........: libsodium; src/secp256k1 with ellswift+schnorrsig"
fi
fi
echo " CPPFLAGS.............: $CPPFLAGS"
echo " CFLAGS...............: $CFLAGS"
if test "x$CAPNP" = "xyes"; then
echo " CXXFLAGS.............: $CXXFLAGS"
fi
echo " LDFLAGS..............: $LDFLAGS"
echo " LDADD................: $LIBS"
echo " ARCHITECTURE.........: $host_cpu $x86_shani$rorx$avx1$sse4$sha2"
echo
echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')"
echo " prefix...............: $prefix"
echo