diff --git a/.gitignore b/.gitignore
index 8d9b565..8675ec9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,7 @@ ic3/ic3_asan
ic3/ic3_cov
ic3/ic3_debug
*.la
+libc3/config.h
.libs/
*.lo
*.o
diff --git a/config.subr b/config.subr
index f5160ce..ad8a521 100644
--- a/config.subr
+++ b/config.subr
@@ -80,7 +80,9 @@ config_include() {
done
echo "int main () { return 0; }" >> "$OUT"
if ${CC} ${CPPFLAGS} ${CFLAGS} "$OUT" -o /dev/null 2>/dev/null; then
- CPPFLAGS="$CPPFLAGS -D$1=1"
+ echo "#define $1 1" >> "${CONFIG_H}"
+ else
+ echo "#define $1 0" >> "${CONFIG_H}"
fi
rm "$OUT"
}
@@ -99,6 +101,16 @@ require_pkg_config() {
fi
}
+update_config_h() {
+ echo "#endif" >> "${CONFIG_H}"
+ if ! cmp "${CONFIG_H}" config.h >/dev/null 2>&1; then
+ mv "${CONFIG_H}" config.h
+ echo "-> $(basename "$PWD")/config.h"
+ else
+ rm "${CONFIG_H}"
+ fi
+}
+
update_config_mk() {
if ! cmp "${CONFIG_MK}" config.mk >/dev/null 2>&1; then
mv "${CONFIG_MK}" config.mk
@@ -126,6 +138,12 @@ update_sources_sh() {
fi
}
+CONFIG_H=config.h
+CONFIG_H=".config.h.tmp"
+echo "/* config.h generated by configure */" > ${CONFIG_H}
+echo "#ifndef CONFIG_H" >> "${CONFIG_H}"
+echo "#define CONFIG_H" >> "${CONFIG_H}"
+
CONFIG_MK=config.mk
CONFIG_MK=".config.mk.tmp"
echo "# config.mk generated by configure" > ${CONFIG_MK}
diff --git a/libc3/configure b/libc3/configure
index ce8512c..b587afa 100755
--- a/libc3/configure
+++ b/libc3/configure
@@ -130,4 +130,5 @@ for SRC in $SOURCES; do
echo " ${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_DEBUG} -c $SRC -o $SRC_DEBUG_LO" >> ${CONFIG_MK}
done
+update_config_h
update_config_mk
diff --git a/libc3/sources.mk b/libc3/sources.mk
index 1aa6e22..0d06a05 100644
--- a/libc3/sources.mk
+++ b/libc3/sources.mk
@@ -1,4 +1,4 @@
# sources.mk generated by update_sources
-HEADERS = arg.h binding.h bool.h buf.h buf_file.h buf_inspect.h buf_parse.h buf_parse_c.h buf_save.h c3.h c_types.h call.h character.h compare.h debug.h env.h error.h error_handler.h eval.h fact.h facts.h facts_cursor.h facts_spec.h facts_spec_cursor.h facts_with.h facts_with_cursor.h fn.h frame.h hash.h ident.h integer.h list.h log.h module.h quote.h set__fact.h set__tag.h set_cursor__fact.h set_cursor__tag.h set_item__fact.h set_item__tag.h skiplist__fact.h skiplist_node__fact.h str.h sym.h tag.h tuple.h types.h ucd.h
+HEADERS = arg.h binding.h bool.h buf.h buf_file.h buf_inspect.h buf_parse.h buf_parse_c.h buf_save.h c3.h c_types.h call.h character.h compare.h config.h debug.h env.h error.h error_handler.h eval.h fact.h facts.h facts_cursor.h facts_spec.h facts_spec_cursor.h facts_with.h facts_with_cursor.h fn.h frame.h hash.h ident.h integer.h list.h log.h module.h quote.h set__fact.h set__tag.h set_cursor__fact.h set_cursor__tag.h set_item__fact.h set_item__tag.h skiplist__fact.h skiplist_node__fact.h str.h sym.h tag.h tuple.h types.h ucd.h
SOURCES = arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c log.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c
LO_SOURCES = arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c log.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c ../libtommath/bn_cutoffs.c ../libtommath/bn_deprecated.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_addmod.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_decr.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_expt_u32.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_exteuclid.c ../libtommath/bn_mp_fread.c ../libtommath/bn_mp_from_sbin.c ../libtommath/bn_mp_from_ubin.c ../libtommath/bn_mp_fwrite.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_l.c ../libtommath/bn_mp_get_ll.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_get_mag_ul.c ../libtommath/bn_mp_get_mag_ull.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_incr.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_i32.c ../libtommath/bn_mp_init_i64.c ../libtommath/bn_mp_init_l.c ../libtommath/bn_mp_init_ll.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_set.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_init_u32.c ../libtommath/bn_mp_init_u64.c ../libtommath/bn_mp_init_ul.c ../libtommath/bn_mp_init_ull.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_is_square.c ../libtommath/bn_mp_iseven.c ../libtommath/bn_mp_isodd.c ../libtommath/bn_mp_kronecker.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_log_u32.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_mod_d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_pack.c ../libtommath/bn_mp_pack_count.c ../libtommath/bn_mp_prime_fermat.c ../libtommath/bn_mp_prime_frobenius_underwood.c ../libtommath/bn_mp_prime_is_prime.c ../libtommath/bn_mp_prime_miller_rabin.c ../libtommath/bn_mp_prime_next_prime.c ../libtommath/bn_mp_prime_rabin_miller_trials.c ../libtommath/bn_mp_prime_rand.c ../libtommath/bn_mp_prime_strong_lucas_selfridge.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_radix_smap.c ../libtommath/bn_mp_rand.c ../libtommath/bn_mp_read_radix.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_root_u32.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_sbin_size.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_ll.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_set_ull.c ../libtommath/bn_mp_shrink.c ../libtommath/bn_mp_signed_rsh.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrmod.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sqrtmod_prime.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_submod.c ../libtommath/bn_mp_to_radix.c ../libtommath/bn_mp_to_sbin.c ../libtommath/bn_mp_to_ubin.c ../libtommath/bn_mp_ubin_size.c ../libtommath/bn_mp_unpack.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_prime_tab.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_get_bit.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_prime_is_divisible.c ../libtommath/bn_s_mp_rand_jenkins.c ../libtommath/bn_s_mp_reverse.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c
diff --git a/libc3/sources.sh b/libc3/sources.sh
index f6ce2ca..2e858d2 100644
--- a/libc3/sources.sh
+++ b/libc3/sources.sh
@@ -1,4 +1,4 @@
# sources.sh generated by update_sources
-HEADERS='arg.h binding.h bool.h buf.h buf_file.h buf_inspect.h buf_parse.h buf_parse_c.h buf_save.h c3.h c_types.h call.h character.h compare.h debug.h env.h error.h error_handler.h eval.h fact.h facts.h facts_cursor.h facts_spec.h facts_spec_cursor.h facts_with.h facts_with_cursor.h fn.h frame.h hash.h ident.h integer.h list.h log.h module.h quote.h set__fact.h set__tag.h set_cursor__fact.h set_cursor__tag.h set_item__fact.h set_item__tag.h skiplist__fact.h skiplist_node__fact.h str.h sym.h tag.h tuple.h types.h ucd.h '
+HEADERS='arg.h binding.h bool.h buf.h buf_file.h buf_inspect.h buf_parse.h buf_parse_c.h buf_save.h c3.h c_types.h call.h character.h compare.h config.h debug.h env.h error.h error_handler.h eval.h fact.h facts.h facts_cursor.h facts_spec.h facts_spec_cursor.h facts_with.h facts_with_cursor.h fn.h frame.h hash.h ident.h integer.h list.h log.h module.h quote.h set__fact.h set__tag.h set_cursor__fact.h set_cursor__tag.h set_item__fact.h set_item__tag.h skiplist__fact.h skiplist_node__fact.h str.h sym.h tag.h tuple.h types.h ucd.h '
SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c log.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c '
LO_SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c debug.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c list.c log.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c ../libtommath/bn_cutoffs.c ../libtommath/bn_deprecated.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_addmod.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_decr.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_expt_u32.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_exteuclid.c ../libtommath/bn_mp_fread.c ../libtommath/bn_mp_from_sbin.c ../libtommath/bn_mp_from_ubin.c ../libtommath/bn_mp_fwrite.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_double.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_l.c ../libtommath/bn_mp_get_ll.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_get_mag_ul.c ../libtommath/bn_mp_get_mag_ull.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_incr.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_i32.c ../libtommath/bn_mp_init_i64.c ../libtommath/bn_mp_init_l.c ../libtommath/bn_mp_init_ll.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_set.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_init_u32.c ../libtommath/bn_mp_init_u64.c ../libtommath/bn_mp_init_ul.c ../libtommath/bn_mp_init_ull.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_is_square.c ../libtommath/bn_mp_iseven.c ../libtommath/bn_mp_isodd.c ../libtommath/bn_mp_kronecker.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_log_u32.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_mod_d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_pack.c ../libtommath/bn_mp_pack_count.c ../libtommath/bn_mp_prime_fermat.c ../libtommath/bn_mp_prime_frobenius_underwood.c ../libtommath/bn_mp_prime_is_prime.c ../libtommath/bn_mp_prime_miller_rabin.c ../libtommath/bn_mp_prime_next_prime.c ../libtommath/bn_mp_prime_rabin_miller_trials.c ../libtommath/bn_mp_prime_rand.c ../libtommath/bn_mp_prime_strong_lucas_selfridge.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_radix_smap.c ../libtommath/bn_mp_rand.c ../libtommath/bn_mp_read_radix.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_root_u32.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_sbin_size.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_set_i32.c ../libtommath/bn_mp_set_i64.c ../libtommath/bn_mp_set_l.c ../libtommath/bn_mp_set_ll.c ../libtommath/bn_mp_set_u32.c ../libtommath/bn_mp_set_u64.c ../libtommath/bn_mp_set_ul.c ../libtommath/bn_mp_set_ull.c ../libtommath/bn_mp_shrink.c ../libtommath/bn_mp_signed_rsh.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrmod.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sqrtmod_prime.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_submod.c ../libtommath/bn_mp_to_radix.c ../libtommath/bn_mp_to_sbin.c ../libtommath/bn_mp_to_ubin.c ../libtommath/bn_mp_ubin_size.c ../libtommath/bn_mp_unpack.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_prime_tab.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_get_bit.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_prime_is_divisible.c ../libtommath/bn_s_mp_rand_jenkins.c ../libtommath/bn_s_mp_reverse.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c '
diff --git a/libc3/types.h b/libc3/types.h
index d5728fa..b792d80 100644
--- a/libc3/types.h
+++ b/libc3/types.h
@@ -18,10 +18,11 @@
#include <setjmp.h>
#include <stdio.h>
#include <sys/types.h>
-#ifdef HAVE_SHA1_H
+#include "config.h"
+#if HAVE_SHA1_H
# include <sha1.h>
#else
-# ifdef HAVE_SHA_H
+# if HAVE_SHA_H
# include <sha.h>
# endif
#endif
diff --git a/update_sources b/update_sources
index 2d89299..5a1284f 100755
--- a/update_sources
+++ b/update_sources
@@ -19,6 +19,7 @@ echo "C3_MAKEFILES = $C3_MAKEFILES" >> ${SOURCES_MK}
echo "C3_MAKEFILES='$C3_MAKEFILES'" >> ${SOURCES_SH}
C3_C_SOURCES="$(find c3c c3s ic3 libc3 test -name "[a-z]*.c" -or -name "[a-z]*.h" -or -name "[a-z]*.c.in" -or -name "[a-z]*.h.in")"
+C3_C_SOURCES="$(echo "${C3_C_SOURCES}" | grep -Ev '^libc3/config[.]h$')"
C3_C_SOURCES="$(echo "${C3_C_SOURCES}" | tr '\n' ' ')"
C3_C_SOURCES="$C3_C_SOURCES ucd2c/ucd.h ucd2c/ucd2c.c"
echo "C3_C_SOURCES = $C3_C_SOURCES" >> ${SOURCES_MK}