@@ -27,13 +27,38 @@ use std::env;
27
27
28
28
fn main ( ) {
29
29
// Actual build
30
+ if cfg ! ( feature = "external-symbols" ) {
31
+ println ! ( "cargo:rustc-link-lib=static=secp256k1-zkp" ) ;
32
+ return ;
33
+ }
34
+
35
+ // Check whether we can use 64-bit compilation
36
+ let use_64bit_compilation = if env:: var ( "CARGO_CFG_TARGET_POINTER_WIDTH" ) . unwrap ( ) == "64" {
37
+ let check = cc:: Build :: new ( ) . file ( "depend/check_uint128_t.c" )
38
+ . cargo_metadata ( false )
39
+ . try_compile ( "check_uint128_t" )
40
+ . is_ok ( ) ;
41
+ if !check {
42
+ println ! ( "cargo:warning=Compiling in 32-bit mode on a 64-bit architecture due to lack of uint128_t support." ) ;
43
+ }
44
+ check
45
+ } else {
46
+ false
47
+ } ;
48
+
49
+ // Actual Build
30
50
let mut base_config = cc:: Build :: new ( ) ;
31
51
base_config. include ( "depend/secp256k1/" )
32
52
. include ( "depend/secp256k1/include" )
33
53
. include ( "depend/secp256k1/src" )
34
54
. flag_if_supported ( "-Wno-unused-function" ) // some ecmult stuff is defined but not used upstream
35
55
. define ( "SECP256K1_BUILD" , Some ( "1" ) )
36
56
. define ( "ENABLE_MODULE_ECDH" , Some ( "1" ) )
57
+ . define ( "ENABLE_MODULE_GENERATOR" , Some ( "1" ) )
58
+ . define ( "ENABLE_MODULE_RECOVERY" , Some ( "1" ) )
59
+ . define ( "ENABLE_MODULE_RANGEPROOF" , Some ( "1" ) )
60
+ . define ( "ENABLE_MODULE_BULLETPROOF" , Some ( "1" ) )
61
+ . define ( "ENABLE_MODULE_AGGSIG" , Some ( "1" ) )
37
62
. define ( "ENABLE_MODULE_SCHNORRSIG" , Some ( "1" ) )
38
63
. define ( "ENABLE_MODULE_EXTRAKEYS" , Some ( "1" ) )
39
64
. define ( "ECMULT_GEN_PREC_BITS" , Some ( "4" ) )
@@ -47,6 +72,14 @@ fn main() {
47
72
} else {
48
73
base_config. define ( "ECMULT_WINDOW_SIZE" , Some ( "15" ) ) ; // This is the default in the configure file (`auto`)
49
74
}
75
+
76
+
77
+ if let Ok ( target_endian) = env:: var ( "CARGO_CFG_TARGET_ENDIAN" ) {
78
+ if target_endian == "big" {
79
+ base_config. define ( "WORDS_BIGENDIAN" , Some ( "1" ) ) ;
80
+ }
81
+ }
82
+
50
83
base_config. define ( "USE_EXTERNAL_DEFAULT_CALLBACKS" , Some ( "1" ) ) ;
51
84
#[ cfg( feature = "recovery" ) ]
52
85
base_config. define ( "ENABLE_MODULE_RECOVERY" , Some ( "1" ) ) ;
@@ -57,6 +90,16 @@ fn main() {
57
90
_ => { } ,
58
91
}
59
92
93
+
94
+ if use_64bit_compilation {
95
+ base_config. define ( "USE_FIELD_5X52" , Some ( "1" ) )
96
+ . define ( "USE_SCALAR_4X64" , Some ( "1" ) )
97
+ . define ( "HAVE___INT128" , Some ( "1" ) ) ;
98
+ } else {
99
+ base_config. define ( "USE_FIELD_10X26" , Some ( "1" ) )
100
+ . define ( "USE_SCALAR_8X32" , Some ( "1" ) ) ;
101
+ }
102
+
60
103
// secp256k1
61
104
base_config. file ( "depend/secp256k1/contrib/lax_der_parsing.c" )
62
105
. file ( "depend/secp256k1/src/secp256k1.c" )
0 commit comments