Skip to content

Commit c137ddb

Browse files
committed
Merge #200: build: automatically enable module dependencies
171b294 build: improve error message if --enable-experimental is missed (Jonas Nick) 58ab152 build: move all output concerning enabled modules at single place (Jonas Nick) 1493113 build: automatically enable module dependencies (Jonas Nick) Pull request description: ACKs for top commit: real-or-random: utACK 171b294 Tree-SHA512: 644e7d96b02c1f4f0751cf84b268f313cc0bd955ea6eacdeddb932b9ba7990be8e8aca9db8c050fd91a35d0a0173061e40fe8c1bf8bfd03107b86aa1bf85e871
2 parents 0202d83 + 171b294 commit c137ddb

File tree

1 file changed

+33
-50
lines changed

1 file changed

+33
-50
lines changed

configure.ac

Lines changed: 33 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ SECP_CFLAGS="$SECP_CFLAGS $WERROR_CFLAGS"
385385
### Handle module options
386386
###
387387

388+
# Besides testing whether modules are enabled, the following code also enables
389+
# module dependencies. The order of the tests matters: the dependency must be
390+
# tested first.
391+
388392
if test x"$enable_module_ecdh" = x"yes"; then
389393
AC_DEFINE(ENABLE_MODULE_ECDH, 1, [Define this symbol to enable the ECDH module])
390394
fi
@@ -398,30 +402,30 @@ if test x"$enable_module_recovery" = x"yes"; then
398402
AC_DEFINE(ENABLE_MODULE_RECOVERY, 1, [Define this symbol to enable the ECDSA pubkey recovery module])
399403
fi
400404

401-
if test x"$enable_module_generator" = x"yes"; then
402-
AC_DEFINE(ENABLE_MODULE_GENERATOR, 1, [Define this symbol to enable the NUMS generator module])
405+
if test x"$enable_module_whitelist" = x"yes"; then
406+
enable_module_rangeproof=yes
407+
AC_DEFINE(ENABLE_MODULE_WHITELIST, 1, [Define this symbol to enable the key whitelisting module])
408+
fi
409+
410+
if test x"$enable_module_surjectionproof" = x"yes"; then
411+
enable_module_rangeproof=yes
412+
AC_DEFINE(ENABLE_MODULE_SURJECTIONPROOF, 1, [Define this symbol to enable the surjection proof module])
403413
fi
404414

405415
if test x"$enable_module_rangeproof" = x"yes"; then
416+
enable_module_generator=yes
406417
AC_DEFINE(ENABLE_MODULE_RANGEPROOF, 1, [Define this symbol to enable the Pedersen / zero knowledge range proof module])
407418
fi
408419

409-
if test x"$enable_module_whitelist" = x"yes"; then
410-
AC_DEFINE(ENABLE_MODULE_WHITELIST, 1, [Define this symbol to enable the key whitelisting module])
420+
if test x"$enable_module_generator" = x"yes"; then
421+
AC_DEFINE(ENABLE_MODULE_GENERATOR, 1, [Define this symbol to enable the NUMS generator module])
411422
fi
412423

413-
if test x"$enable_module_surjectionproof" = x"yes"; then
414-
AC_DEFINE(ENABLE_MODULE_SURJECTIONPROOF, 1, [Define this symbol to enable the surjection proof module])
415-
fi
416-
# Test if extrakeys is set _after_ the MuSig module to allow the MuSig
417-
# module to set enable_module_schnorrsig=yes
418424
if test x"$enable_module_schnorrsig" = x"yes"; then
419425
AC_DEFINE(ENABLE_MODULE_SCHNORRSIG, 1, [Define this symbol to enable the schnorrsig module])
420426
enable_module_extrakeys=yes
421427
fi
422428

423-
# Test if extrakeys is set after the schnorrsig module to allow the schnorrsig
424-
# module to set enable_module_extrakeys=yes
425429
if test x"$enable_module_extrakeys" = x"yes"; then
426430
AC_DEFINE(ENABLE_MODULE_EXTRAKEYS, 1, [Define this symbol to enable the extrakeys module])
427431
fi
@@ -450,37 +454,24 @@ if test x"$enable_experimental" = x"yes"; then
450454
AC_MSG_NOTICE([******])
451455
AC_MSG_NOTICE([WARNING: experimental build])
452456
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
453-
AC_MSG_NOTICE([Building NUMS generator module: $enable_module_generator])
454-
AC_MSG_NOTICE([Building range proof module: $enable_module_rangeproof])
455-
AC_MSG_NOTICE([Building key whitelisting module: $enable_module_whitelist])
456-
AC_MSG_NOTICE([Building surjection proof module: $enable_module_surjectionproof])
457-
AC_MSG_NOTICE([Building MuSig module: $enable_module_musig])
458-
AC_MSG_NOTICE([Building ECDSA sign-to-contract module: $enable_module_ecdsa_s2c])
459-
AC_MSG_NOTICE([Building ECDSA adaptor signatures module: $enable_module_ecdsa_adaptor])
460457
AC_MSG_NOTICE([******])
461-
462-
463-
if test x"$enable_module_schnorrsig" != x"yes"; then
464-
if test x"$enable_module_musig" = x"yes"; then
465-
AC_MSG_ERROR([MuSig module requires the schnorrsig module. Use --enable-module-schnorrsig to allow.])
466-
fi
458+
else
459+
# The order of the following tests matters. If the user enables a dependent
460+
# module (which automatically enables the module dependencies) we want to
461+
# print an error for the dependent module, not the module dependency. Hence,
462+
# we first test dependent modules.
463+
if test x"$enable_module_whitelist" = x"yes"; then
464+
AC_MSG_ERROR([Key whitelisting module is experimental. Use --enable-experimental to allow.])
467465
fi
468-
469-
if test x"$enable_module_generator" != x"yes"; then
470-
if test x"$enable_module_rangeproof" = x"yes"; then
471-
AC_MSG_ERROR([Rangeproof module requires the generator module. Use --enable-module-generator to allow.])
472-
fi
466+
if test x"$enable_module_surjectionproof" = x"yes"; then
467+
AC_MSG_ERROR([Surjection proof module is experimental. Use --enable-experimental to allow.])
473468
fi
474-
475-
if test x"$enable_module_rangeproof" != x"yes"; then
476-
if test x"$enable_module_whitelist" = x"yes"; then
477-
AC_MSG_ERROR([Whitelist module requires the rangeproof module. Use --enable-module-rangeproof to allow.])
478-
fi
479-
if test x"$enable_module_surjectionproof" = x"yes"; then
480-
AC_MSG_ERROR([Surjection proof module requires the rangeproof module. Use --enable-module-rangeproof to allow.])
481-
fi
469+
if test x"$enable_module_rangeproof" = x"yes"; then
470+
AC_MSG_ERROR([Range proof module is experimental. Use --enable-experimental to allow.])
471+
fi
472+
if test x"$enable_module_generator" = x"yes"; then
473+
AC_MSG_ERROR([NUMS generator module is experimental. Use --enable-experimental to allow.])
482474
fi
483-
else
484475
if test x"$enable_module_musig" = x"yes"; then
485476
AC_MSG_ERROR([MuSig module is experimental. Use --enable-experimental to allow.])
486477
fi
@@ -493,18 +484,6 @@ else
493484
if test x"$set_asm" = x"arm"; then
494485
AC_MSG_ERROR([ARM assembly optimization is experimental. Use --enable-experimental to allow.])
495486
fi
496-
if test x"$enable_module_generator" = x"yes"; then
497-
AC_MSG_ERROR([NUMS generator module is experimental. Use --enable-experimental to allow.])
498-
fi
499-
if test x"$enable_module_rangeproof" = x"yes"; then
500-
AC_MSG_ERROR([Range proof module is experimental. Use --enable-experimental to allow.])
501-
fi
502-
if test x"$enable_module_whitelist" = x"yes"; then
503-
AC_MSG_ERROR([Key whitelisting module is experimental. Use --enable-experimental to allow.])
504-
fi
505-
if test x"$enable_module_surjectionproof" = x"yes"; then
506-
AC_MSG_ERROR([Surjection proof module is experimental. Use --enable-experimental to allow.])
507-
fi
508487
fi
509488

510489
###
@@ -555,6 +534,10 @@ echo " module ecdh = $enable_module_ecdh"
555534
echo " module recovery = $enable_module_recovery"
556535
echo " module extrakeys = $enable_module_extrakeys"
557536
echo " module schnorrsig = $enable_module_schnorrsig"
537+
echo " module generator = $enable_module_generator"
538+
echo " module rangeproof = $enable_module_rangeproof"
539+
echo " module surjectionproof = $enable_module_surjectionproof"
540+
echo " module whitelist = $enable_module_whitelist"
558541
echo " module musig = $enable_module_musig"
559542
echo " module ecdsa-s2c = $enable_module_ecdsa_s2c"
560543
echo " module ecdsa-adaptor = $enable_module_ecdsa_adaptor"

0 commit comments

Comments
 (0)