Commit 7f9fbb648bbd41ad617b0a8df586c0a7e4e56247

Steffen Jaeckel 2020-01-16T15:21:30

helper.pl: add support to update sources.cmake

diff --git a/helper.pl b/helper.pl
index 20b0dc9..ac87556 100755
--- a/helper.pl
+++ b/helper.pl
@@ -221,6 +221,16 @@ sub patch_file {
   return $content;
 }
 
+sub make_sources_cmake {
+  my @list = @_;
+  my $output = "set(SOURCES\n";
+  foreach my $obj (sort @list) {
+    $output .= $obj . "\n";
+  }
+  $output .= ")\n\nset(HEADERS\ntommath.h\n)\n";
+  return $output;
+}
+
 sub process_makefiles {
   my $write = shift;
   my $changed_count = 0;
@@ -244,10 +254,12 @@ sub process_makefiles {
   }
 
   # update OBJECTS + HEADERS in makefile*
-  for my $m (qw/ makefile makefile.shared makefile_include.mk makefile.msvc makefile.unix makefile.mingw /) {
+  for my $m (qw/ makefile makefile.shared makefile_include.mk makefile.msvc makefile.unix makefile.mingw sources.cmake /) {
     my $old = read_file($m);
     my $new = $m eq 'makefile.msvc' ? patch_file($old, $var_obj)
-                                    : patch_file($old, $var_o);
+            : $m eq 'sources.cmake' ? make_sources_cmake(bsd_glob("*.c"))
+            :                         patch_file($old, $var_o);
+
     if ($old ne $new) {
       write_file($m, $new) if $write;
       warn "changed: $m\n";
diff --git a/sources.cmake b/sources.cmake
index 503a13c..fd353c0 100644
--- a/sources.cmake
+++ b/sources.cmake
@@ -16,18 +16,17 @@ mp_complement.c
 mp_copy.c
 mp_count_bits.c
 mp_cutoffs.c
+mp_div.c
 mp_div_2.c
 mp_div_2d.c
-mp_div_3.c
-mp_div.c
 mp_div_d.c
 mp_dr_is_modulus.c
 mp_dr_reduce.c
 mp_dr_setup.c
 mp_error_to_string.c
 mp_exch.c
+mp_expt_n.c
 mp_exptmod.c
-mp_expt_u32.c
 mp_exteuclid.c
 mp_fread.c
 mp_from_sbin.c
@@ -38,39 +37,35 @@ mp_get_double.c
 mp_get_i32.c
 mp_get_i64.c
 mp_get_l.c
-mp_get_ll.c
 mp_get_mag_u32.c
 mp_get_mag_u64.c
 mp_get_mag_ul.c
-mp_get_mag_ull.c
 mp_grow.c
 mp_init.c
 mp_init_copy.c
 mp_init_i32.c
 mp_init_i64.c
 mp_init_l.c
-mp_init_ll.c
 mp_init_multi.c
 mp_init_set.c
 mp_init_size.c
 mp_init_u32.c
 mp_init_u64.c
 mp_init_ul.c
-mp_init_ull.c
 mp_invmod.c
 mp_is_square.c
 mp_kronecker.c
 mp_lcm.c
-mp_log_u32.c
+mp_log_n.c
 mp_lshd.c
-mp_mod_2d.c
 mp_mod.c
+mp_mod_2d.c
 mp_montgomery_calc_normalization.c
 mp_montgomery_reduce.c
 mp_montgomery_setup.c
+mp_mul.c
 mp_mul_2.c
 mp_mul_2d.c
-mp_mul.c
 mp_mul_d.c
 mp_mulmod.c
 mp_neg.c
@@ -86,17 +81,18 @@ mp_prime_rabin_miller_trials.c
 mp_prime_rand.c
 mp_prime_strong_lucas_selfridge.c
 mp_radix_size.c
+mp_radix_size_overestimate.c
 mp_rand.c
 mp_read_radix.c
+mp_reduce.c
 mp_reduce_2k.c
 mp_reduce_2k_l.c
 mp_reduce_2k_setup.c
 mp_reduce_2k_setup_l.c
-mp_reduce.c
 mp_reduce_is_2k.c
 mp_reduce_is_2k_l.c
 mp_reduce_setup.c
-mp_root_u32.c
+mp_root_n.c
 mp_rshd.c
 mp_sbin_size.c
 mp_set.c
@@ -104,14 +100,11 @@ mp_set_double.c
 mp_set_i32.c
 mp_set_i64.c
 mp_set_l.c
-mp_set_ll.c
 mp_set_u32.c
 mp_set_u64.c
 mp_set_ul.c
-mp_set_ull.c
 mp_shrink.c
 mp_signed_rsh.c
-mp_sqr.c
 mp_sqrmod.c
 mp_sqrt.c
 mp_sqrtmod_prime.c
@@ -127,6 +120,7 @@ mp_xor.c
 mp_zero.c
 s_mp_add.c
 s_mp_copy_digs.c
+s_mp_div_3.c
 s_mp_div_recursive.c
 s_mp_div_school.c
 s_mp_div_small.c
@@ -136,11 +130,11 @@ s_mp_get_bit.c
 s_mp_invmod.c
 s_mp_invmod_odd.c
 s_mp_log.c
+s_mp_log_2expt.c
 s_mp_log_d.c
-s_mp_log_pow2.c
 s_mp_montgomery_reduce_comba.c
-s_mp_mul_balance.c
 s_mp_mul.c
+s_mp_mul_balance.c
 s_mp_mul_comba.c
 s_mp_mul_high.c
 s_mp_mul_high_comba.c
@@ -149,6 +143,7 @@ s_mp_mul_toom.c
 s_mp_prime_is_divisible.c
 s_mp_prime_tab.c
 s_mp_radix_map.c
+s_mp_radix_size_overestimate.c
 s_mp_rand_jenkins.c
 s_mp_rand_platform.c
 s_mp_sqr.c