* [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES @ 2008-03-04 14:14 Michal Rokos 2008-03-04 14:59 ` Johannes Schindelin 2008-03-04 15:32 ` Mike Ralphson 0 siblings, 2 replies; 6+ messages in thread From: Michal Rokos @ 2008-03-04 14:14 UTC (permalink / raw) To: GIT Add test for FREAD_READS_DIRECTORIES to configure script. When "." could be opened and fread reads more than 0 items, FREAD_READS_DIRECTORIES will be set. Signed-off-by: Michal Rokos <michal.rokos@nextsoft.cz> diff --git a/config.mak.in b/config.mak.in index ee6c33d..516c468 100644 --- a/config.mak.in +++ b/config.mak.in @@ -46,3 +46,4 @@ NO_MKDTEMP=@NO_MKDTEMP@ NO_ICONV=@NO_ICONV@ OLD_ICONV=@OLD_ICONV@ NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@ +FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@ diff --git a/configure.ac b/configure.ac index 85d7ef5..8f748a9 100644 --- a/configure.ac +++ b/configure.ac @@ -326,6 +326,27 @@ else NO_C99_FORMAT= fi AC_SUBST(NO_C99_FORMAT) +# +# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds +# when attempting to read from an fopen'ed directory. +AC_CACHE_CHECK([whether system succeeds to read fopen'ed directory], + [ac_cv_fread_reads_directories], +[ +AC_RUN_IFELSE( + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], + [[char c; + FILE *f = fopen(".", "r"); + if (! f) return 0; + if (f && fread(&c, 1, 1, f) > 0) return 1]])], + [ac_cv_fread_reads_directories=no], + [ac_cv_fread_reads_directories=yes]) +]) +if test $ac_cv_fread_reads_directories = yes; then + FREAD_READS_DIRECTORIES=UnfortunatelyYes +else + FREAD_READS_DIRECTORIES= +fi +AC_SUBST(FREAD_READS_DIRECTORIES) ## Checks for library functions. ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES 2008-03-04 14:14 [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES Michal Rokos @ 2008-03-04 14:59 ` Johannes Schindelin 2008-03-04 15:30 ` Michal Rokos 2008-03-04 15:32 ` Mike Ralphson 1 sibling, 1 reply; 6+ messages in thread From: Johannes Schindelin @ 2008-03-04 14:59 UTC (permalink / raw) To: Michal Rokos; +Cc: GIT Hi, On Tue, 4 Mar 2008, Michal Rokos wrote: > +AC_RUN_IFELSE( > + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], > + [[char c; > + FILE *f = fopen(".", "r"); > + if (! f) return 0; > + if (f && fread(&c, 1, 1, f) > 0) return 1]])], > + [ac_cv_fread_reads_directories=no], > + [ac_cv_fread_reads_directories=yes]) I do not see the issue addressed that I saw on msysGit. Ciao, Dscho ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES 2008-03-04 14:59 ` Johannes Schindelin @ 2008-03-04 15:30 ` Michal Rokos 2008-03-04 16:01 ` Johannes Schindelin 0 siblings, 1 reply; 6+ messages in thread From: Michal Rokos @ 2008-03-04 15:30 UTC (permalink / raw) To: Johannes Schindelin; +Cc: GIT Hello, On Tuesday 04 March 2008 15:59:02 Johannes Schindelin wrote: > On Tue, 4 Mar 2008, Michal Rokos wrote: > > +AC_RUN_IFELSE( > > + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], > > + [[char c; > > + FILE *f = fopen(".", "r"); > > + if (! f) return 0; > > + if (f && fread(&c, 1, 1, f) > 0) return 1]])], > > + [ac_cv_fread_reads_directories=no], > > + [ac_cv_fread_reads_directories=yes]) > > I do not see the issue addressed that I saw on msysGit. ahh, sorry I've included some old one. Now it's +AC_RUN_IFELSE( + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], + [[char c; + FILE *f = fopen(".", "r"); + return f && fread(&c, 1, 1, f)]])], + [ac_cv_fread_reads_directories=no], + [ac_cv_fread_reads_directories=yes]) I've tried to reproduce, but I failed to do so. When I put "return 0;" it detect that "no"; when I return something else, "yes" is detected - as it should. The C snippet in configure script looks like: $ac_includes_default int main () { char c; FILE *f = fopen(".", "r"); return f && fread(&c, 1, 1, f) ; return 0; } Does your autoconf create the same thing? Michal ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES 2008-03-04 15:30 ` Michal Rokos @ 2008-03-04 16:01 ` Johannes Schindelin 0 siblings, 0 replies; 6+ messages in thread From: Johannes Schindelin @ 2008-03-04 16:01 UTC (permalink / raw) To: Michal Rokos; +Cc: GIT Hi, On Tue, 4 Mar 2008, Michal Rokos wrote: > On Tuesday 04 March 2008 15:59:02 Johannes Schindelin wrote: > > On Tue, 4 Mar 2008, Michal Rokos wrote: > > > +AC_RUN_IFELSE( > > > + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], > > > + [[char c; > > > + FILE *f = fopen(".", "r"); > > > + if (! f) return 0; > > > + if (f && fread(&c, 1, 1, f) > 0) return 1]])], > > > + [ac_cv_fread_reads_directories=no], > > > + [ac_cv_fread_reads_directories=yes]) > > > > I do not see the issue addressed that I saw on msysGit. > > ahh, sorry I've included some old one. Now it's > +AC_RUN_IFELSE( > + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], > + [[char c; > + FILE *f = fopen(".", "r"); > + return f && fread(&c, 1, 1, f)]])], > + [ac_cv_fread_reads_directories=no], > + [ac_cv_fread_reads_directories=yes]) > > I've tried to reproduce, but I failed to do so. When I put "return 0;" it > detect that "no"; when I return something else, "yes" is detected - as it > should. I finally figured out what is going wrong. But first let me say what a PITA it is to debug configure. It is utterly, completely painful! When you insert random "exit"s, like you usually do with scripts that are too garbled and complex and ugly to understand (the worst Perl code I ever saw was not as ugly), it does not exit _at all_! Turns out that the compilation fails: ...\ld.exe: cannot find -lsocket 1 exit status Nice. FWIW it tries to link with cc -o conftest.exe -g -O2 conftest.c -liconv -lsocket >&5 Hth, Dscho ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES 2008-03-04 14:14 [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES Michal Rokos 2008-03-04 14:59 ` Johannes Schindelin @ 2008-03-04 15:32 ` Mike Ralphson 2008-03-04 16:22 ` Fwd: " Mike Ralphson 1 sibling, 1 reply; 6+ messages in thread From: Mike Ralphson @ 2008-03-04 15:32 UTC (permalink / raw) To: Michal Rokos; +Cc: GIT On 04/03/2008, Michal Rokos <michal.rokos@nextsoft.cz> wrote: > Add test for FREAD_READS_DIRECTORIES to configure script. > > When "." could be opened and fread reads more than 0 items, > FREAD_READS_DIRECTORIES will be set. On AIX 5.3 this appears to work correctly, i.e. it defines FREAD_READS_DIRECTORIES I've negatively tested it just by swapping the return values. It is susceptible to failing for other reasons than those expected (i.e. the configure script gets the libsocket test wrong on my platform if I forget to amend CFLAGS because libg is not available, and then various tests including this one fail because libsocket is erroneously linked in and the test programs fail to compile at all), but that is I think a wider issue with autoconf tests in general. So, with those caveats: Tested-by: Mike Ralphson <mike@abacus.co.uk> Patch to set this option by default on AIX for the non-autoconf Makefile to follow. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Fwd: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES 2008-03-04 15:32 ` Mike Ralphson @ 2008-03-04 16:22 ` Mike Ralphson 0 siblings, 0 replies; 6+ messages in thread From: Mike Ralphson @ 2008-03-04 16:22 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Git Mailing List, Michal Rokos On 04/03/2008, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote: > On Tue, 4 Mar 2008, Michal Rokos wrote: > > > On Tuesday 04 March 2008 15:59:02 Johannes Schindelin wrote: > > > On Tue, 4 Mar 2008, Michal Rokos wrote: > > > > +AC_RUN_IFELSE( > > > > + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], > > > > + [[char c; > > > > + FILE *f = fopen(".", "r"); > > > > + if (! f) return 0; > > > > + if (f && fread(&c, 1, 1, f) > 0) return 1]])], > > > > + [ac_cv_fread_reads_directories=no], > > > > + [ac_cv_fread_reads_directories=yes]) > > > > > > I do not see the issue addressed that I saw on msysGit. > > > > ahh, sorry I've included some old one. Now it's > > +AC_RUN_IFELSE( > > + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], > > + [[char c; > > + FILE *f = fopen(".", "r"); > > + return f && fread(&c, 1, 1, f)]])], > > + [ac_cv_fread_reads_directories=no], > > + [ac_cv_fread_reads_directories=yes]) > > > > I've tried to reproduce, but I failed to do so. When I put "return 0;" it > > detect that "no"; when I return something else, "yes" is detected - as it > > should. > > > I finally figured out what is going wrong. > > But first let me say what a PITA it is to debug configure. It is utterly, > completely painful! When you insert random "exit"s, like you usually do > with scripts that are too garbled and complex and ugly to understand (the > worst Perl code I ever saw was not as ugly), it does not exit _at all_! > > Turns out that the compilation fails: > > ...\ld.exe: cannot find -lsocket 1 exit status > > Nice. > > FWIW it tries to link with > > cc -o conftest.exe -g -O2 conftest.c -liconv -lsocket >&5 > Should probably have copied you on the mail below. Seems like you hit a similar problem. With configure you have to always go back to the initial failure (which may have been reported as a success!) as all subsequent test results could be invalid. Either the test to see whether gcc accepts -g is flawed (it doesn't check whether it actually works, only that the gcc wrapper accepts it; or -g only works if libg is available, and it fails to test for that... ---------- Forwarded message ---------- From: Mike Ralphson <mike.ralphson@gmail.com> Date: 4 Mar 2008 15:32 Subject: Re: [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES To: Michal Rokos <michal.rokos@nextsoft.cz> Cc: GIT <git@vger.kernel.org> On 04/03/2008, Michal Rokos <michal.rokos@nextsoft.cz> wrote: > Add test for FREAD_READS_DIRECTORIES to configure script. > > When "." could be opened and fread reads more than 0 items, > FREAD_READS_DIRECTORIES will be set. On AIX 5.3 this appears to work correctly, i.e. it defines FREAD_READS_DIRECTORIES I've negatively tested it just by swapping the return values. It is susceptible to failing for other reasons than those expected (i.e. the configure script gets the libsocket test wrong on my platform if I forget to amend CFLAGS because libg is not available, and then various tests including this one fail because libsocket is erroneously linked in and the test programs fail to compile at all), but that is I think a wider issue with autoconf tests in general. So, with those caveats: Tested-by: Mike Ralphson <mike@abacus.co.uk> Patch to set this option by default on AIX for the non-autoconf Makefile to follow. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-03-04 16:23 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-03-04 14:14 [PATCH v3] autoconf: Test FREAD_READS_DIRECTORIES Michal Rokos 2008-03-04 14:59 ` Johannes Schindelin 2008-03-04 15:30 ` Michal Rokos 2008-03-04 16:01 ` Johannes Schindelin 2008-03-04 15:32 ` Mike Ralphson 2008-03-04 16:22 ` Fwd: " Mike Ralphson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).