From 5cdd2fd5ff14c113b867df969779c75fca79932e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 29 Nov 2013 06:15:05 -0800 Subject: * configure (config_flags): New variable, allowing us to have stricter diagnosis for configure tests. (have_timegm, need_svid_source, need_bsd_source): New variables. sys/stat.h test only declares static data and compiles an object file. Adding tests for timegm, tzset, setenv and unsetenv. * eval.c (eval_init): Register new intrinsic, make_time_utc. * lib.c (make_time_impl): New static function. (make_time): Reimplemented as call to make_time_impl. (timegm_hack): New conditionally-defined static function. (make_time_utc): New function. * lib.h (make_time_utc): Declared. * txr.1: make-time-utc documented. --- configure | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 8 deletions(-) (limited to 'configure') diff --git a/configure b/configure index e318ef17..51e067a9 100755 --- a/configure +++ b/configure @@ -84,6 +84,7 @@ opt_flags=-O2 lang_flags='-ansi -D_XOPEN_SOURCE=2' diag_flags='-Wall -Wmissing-prototypes -Wstrict-prototypes' debug_flags=-g +config_flags=' -Werror' # special: used only during configure inline= platform_flags= remove_flags= @@ -98,6 +99,9 @@ mpi_version=1.8.6 have_quilt= have_patch= have_unistd= +have_timegm= +need_svid_source= +need_bsd_source= # # Parse configuration variables @@ -583,7 +587,7 @@ NM := $nm OPT_FLAGS := $opt_flags LANG_FLAGS := $lang_flags -DIAG_FLAGS := $diag_flags +DIAG_FLAGS := $diag_flags$config_flags DBG_FLAGS := $debug_flags PLATFORM_FLAGS := $platform_flags REMOVE_FLAGS := $remove_flags @@ -1152,14 +1156,10 @@ printf "Checking whether we have ... " cat > conftest.c < -int main(void) -{ - struct stat s; - return 0; -} +struct stat s; ! rm -f conftest -if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then +if ! $make conftest.o > conftest.err 2>&1; then printf "no\n" else printf "yes\n" @@ -1250,7 +1250,7 @@ fi # Check for fields inside struct tm # -printf "Printf detecting timezone fields in struct tm ..." +printf "Printf detecting timezone fields in struct tm ... " tm_gmtoff= tm_tmzone= @@ -1283,6 +1283,69 @@ done printf "done\n" +printf "Checking for timegm function ... " + +cat > conftest.c < + +int main(void) +{ + struct tm tms = { 0 }; + timegm(&tms); + return 0; +} +! +rm -f conftest +if ! $make EXTRA_FLAGS='-D_SVID_SOURCE' conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then + printf "no\n" +else + printf "yes\n" + printf "#define HAVE_TIMEGM 1\n" >> config.h + have_timegm=y + need_svid_source=y +fi + +if [ -z "$have_timegm" ] ; then + printf "Checking for setenv and unsetenv functions ... " + + cat > conftest.c < + +int main(void) +{ + setenv("TERM", "foo", 1); + unsetenv("TERM"); + return 0; +} +! + rm -f conftest + if ! $make EXTRA_FLAGS='-D_BSD_SOURCE' conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then + printf "no\n" + else + printf "yes\n" + printf "#define HAVE_SETENV 1\n" >> config.h + need_bsd_source=y + fi +fi +printf "Checking for tzset function ... " + +cat > conftest.c < + +int main(void) +{ + tzset(); + return 0; +} +! +rm -f conftest +if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then + printf "no\n" +else + printf "yes\n" + printf "#define HAVE_TZSET 1\n" >> config.h +fi + printf "Checking for POSIX sleep function ... " cat > conftest.c <