From 439bd03e10053c088eac26da28c0a85be0c325a4 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 9 Jan 2014 21:08:11 -0800 Subject: Long overdue MinGW port maintenance. * Makefile: Use new EXE variable from config.mk. * configure (exe, have_windows_h): New variables. Handle situations with .exe suffix; on MiGW, the rm command doesn't work on executables if the .exe suffix is not given. New tests for localtime_r and gmtime_r. * lib.c: Supply declarations which are missing on MinGW because we use gcc -ansi, because MinGW doesn't follow established conventions like -D_POSIX_SOURCE. Supply definitions for gmtime_r, localtime_r, setenv and unsetenv. * parser.l: Supply declarations which are missing on MinGW. * signal.h (async_sig_enabled): Declare differently based on HAVE_POSIX_SIGS. Misspelled typedef fixed in the code for !HAVE_POSIX_SIGS that has hitherto not been compiled. (sig_mask): Wrap declaration in #ifdef HAVE_POSIX_SIGS because it relies on sigset_t. * stream.c: Supply declarations which are missing on MinGW. Include if we have it. (sleep): Define for Windows. (statf): Handle missing st_blksize and st_blocks members in struct stat. (stream_init): Handle numerous missing S_* macros. * utf8.c: Supply declarations which are missing on MinGW. --- configure | 79 +++++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 17 deletions(-) (limited to 'configure') diff --git a/configure b/configure index a08d9ab4..791f6c6e 100755 --- a/configure +++ b/configure @@ -72,6 +72,7 @@ compiler_prefix= ccname=gcc cc='$(cross)$(compiler_prefix)$(ccname)' intptr= +exe= tool_prefix= lex='$(cross)$(tool_prefix)flex' lexlib=-lfl @@ -100,6 +101,7 @@ have_patch= have_unistd= have_timegm= have_syslog= +have_windows_h= have_posix_sigs= need_svid_source= need_bsd_source= @@ -586,6 +588,9 @@ debug_support := $debug_support # MPI version mpi_version := $mpi_version +# EXE suffix +exe := $exe + CC := $cc LEX := $lex LEXLIB := $lexlib @@ -639,7 +644,7 @@ int main(void) } ! -rm -f conftest +rm -f conftest conftest.exe if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "failed\n\n" printf "Errors from compilation: \n\n" @@ -647,9 +652,19 @@ if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then exit 1 fi -rm -f conftest printf "okay\n" +printf "Checking whether executables have that idiotic .exe suffix ... " + +if ls conftest.exe > /dev/null ; then + echo "yes" + exe=.exe +else + echo "no" +fi + +rm -f conftest$exe + # # Check for annoying clashes from non-conforming BSD-derived systems that don't # honor Unix/POSIX feature selection macros! @@ -684,7 +699,7 @@ int $ident(void); int main(void) { return 0; } ! - rm -f conftest + rm -f conftest$exe if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "#define %s txr_%s\n" $ident $ident >> config.h have_unistd=y @@ -1048,7 +1063,7 @@ $inline int func(void) return 0; } ! - rm -f conftest2 + rm -f conftest2$exe if ! $make conftest2 > conftest.err 2>&1 || ! [ -x conftest2 ] ; then continue fi @@ -1146,7 +1161,7 @@ int main(void) return 0; } ! -rm -f conftest +rm -f conftest$exe if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else @@ -1170,7 +1185,7 @@ int main(void) return 0; } ! -rm -f conftest +rm -f conftest$exe if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else @@ -1195,7 +1210,7 @@ int main(void) return 0; } ! -rm -f conftest +rm -f conftest$exe if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else @@ -1218,12 +1233,13 @@ int main(void) return 0; } ! -rm -f conftest +rm -f conftest$exe if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else printf "yes\n" printf "#define HAVE_GETENVIRONMENTSTRINGS 1\n" >> config.h + have_windows_h=y fi # @@ -1250,7 +1266,7 @@ int main(int argc, char **argv) return 0; } ! -rm -f conftest +rm -f conftest$exe if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else @@ -1308,7 +1324,7 @@ int main(void) return 0; } ! -rm -f conftest +rm -f conftest$exe if ! $make EXTRA_FLAGS='-D_SVID_SOURCE' conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else @@ -1331,7 +1347,7 @@ int main(void) return 0; } ! - rm -f conftest + rm -f conftest$exe if ! $make EXTRA_FLAGS='-D_BSD_SOURCE' conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else @@ -1351,7 +1367,7 @@ int main(void) return 0; } ! -rm -f conftest +rm -f conftest$exe if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else @@ -1359,6 +1375,31 @@ else printf "#define HAVE_TZSET 1\n" >> config.h fi +printf "Checking for localtime_r and gmtime_r functions ... " + +cat > conftest.c < + +int main(int argc, char **argv) +{ + struct tm stm; + time_t t; + + localtime_r(&t, &stm); + gmtime_r(&t, &stm); + return 0; +} +! +rm -f conftest$exe +if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then + printf "no\n" +else + printf "yes\n" + printf "#define HAVE_GMTIME_R 1\n" >> config.h + have_unistd=y +fi + + printf "Checking for POSIX sleep function ... " cat > conftest.c < conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else @@ -1389,7 +1430,7 @@ int main(int argc, char **argv) return daemon(0, 0); } ! -rm -f conftest +rm -f conftest$exe if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else @@ -1409,7 +1450,7 @@ int main(void) return 0; } ! -rm -f conftest +rm -f conftest$exe if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else @@ -1432,7 +1473,7 @@ int main(void) return 0; } ! -rm -f conftest +rm -f conftest$exe if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else @@ -1459,7 +1500,7 @@ int main(void) return 0; } ! -rm -f conftest +rm -f conftest$exe if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then printf "no\n" else @@ -1476,6 +1517,10 @@ if [ -n "$have_unistd" ] ; then printf "#define HAVE_UNISTD_H 1\n" >> config.h fi +if [ -n "$have_windows_h" ] ; then + printf "#define HAVE_WINDOWS_H 1\n" >> config.h +fi + # # Extra debugging. # -- cgit v1.2.3