@@ -21,16 +21,22 @@ fn main() {
2121 let is_big_endian = env:: var ( "CARGO_CFG_TARGET_ENDIAN" ) . expect ( "No endian is set" ) == "big" ;
2222 let mut base_config = cc:: Build :: new ( ) ;
2323 base_config
24- . cpp ( true )
25- . include ( "depend/bitcoin/src" )
2624 . include ( "depend/bitcoin/src/secp256k1/include" )
2725 . define ( "__STDC_FORMAT_MACROS" , None )
2826 . flag_if_supported ( "-Wno-implicit-fallthrough" ) ;
2927
28+ if target. contains ( "windows" ) {
29+ base_config. define ( "WIN32" , "1" ) ;
30+ }
31+
32+ let mut secp_config = base_config. clone ( ) ;
33+ let mut consensus_config = base_config;
34+
3035 // **Secp256k1**
3136 if !cfg ! ( feature = "external-secp" ) {
32- base_config
37+ secp_config
3338 . include ( "depend/bitcoin/src/secp256k1" )
39+ . include ( "depend/bitcoin/src/secp256k1/src" )
3440 . flag_if_supported ( "-Wno-unused-function" ) // some ecmult stuff is defined but not used upstream
3541 . define ( "SECP256K1_BUILD" , "1" )
3642 // Bitcoin core defines libsecp to *not* use libgmp.
@@ -39,34 +45,40 @@ fn main() {
3945 . define ( "USE_SCALAR_INV_BUILTIN" , "1" )
4046 // Technically libconsensus doesn't require the recovery feautre, but `pubkey.cpp` does.
4147 . define ( "ENABLE_MODULE_RECOVERY" , "1" )
48+ . define ( "ECMULT_WINDOW_SIZE" , "15" )
49+ . define ( "ECMULT_GEN_PREC_BITS" , "4" )
50+ . define ( "ENABLE_MODULE_SCHNORRSIG" , "1" )
51+ . define ( "ENABLE_MODULE_EXTRAKEYS" , "1" )
4252 // The actual libsecp256k1 C code.
4353 . file ( "depend/bitcoin/src/secp256k1/src/secp256k1.c" ) ;
4454
4555 if is_big_endian {
46- base_config . define ( "WORDS_BIGENDIAN" , "1" ) ;
56+ secp_config . define ( "WORDS_BIGENDIAN" , "1" ) ;
4757 }
4858
4959 if use_64bit_compilation {
50- base_config
60+ secp_config
5161 . define ( "USE_FIELD_5X52" , "1" )
5262 . define ( "USE_SCALAR_4X64" , "1" )
5363 . define ( "HAVE___INT128" , "1" ) ;
5464 } else {
55- base_config . define ( "USE_FIELD_10X26" , "1" ) . define ( "USE_SCALAR_8X32" , "1" ) ;
65+ secp_config . define ( "USE_FIELD_10X26" , "1" ) . define ( "USE_SCALAR_8X32" , "1" ) ;
5666 }
67+
68+ secp_config. compile ( "libsecp256k1.a" ) ;
5769 }
5870
59- let tool = base_config . get_compiler ( ) ;
71+ let tool = consensus_config . get_compiler ( ) ;
6072 if tool. is_like_msvc ( ) {
61- base_config . flag ( "/std:c++14 " ) . flag ( "/wd4100" ) ;
73+ consensus_config . flag ( "/std:c++17 " ) . flag ( "/wd4100" ) ;
6274 } else if tool. is_like_clang ( ) || tool. is_like_gnu ( ) {
63- base_config . flag ( "-std=c++11 " ) . flag ( "-Wno-unused-parameter" ) ;
75+ consensus_config . flag ( "-std=c++17 " ) . flag ( "-Wno-unused-parameter" ) ;
6476 }
6577
66- if target . contains ( "windows" ) {
67- base_config . define ( "WIN32" , "1" ) ;
68- }
69- base_config
78+ consensus_config
79+ . cpp ( true )
80+ . include ( "depend/bitcoin/src" )
81+ . include ( "depend/bitcoin/src/secp256k1/include" )
7082 . file ( "depend/bitcoin/src/util/strencodings.cpp" )
7183 . file ( "depend/bitcoin/src/uint256.cpp" )
7284 . file ( "depend/bitcoin/src/pubkey.cpp" )
0 commit comments