From: bangerth Date: Wed, 8 Dec 2010 02:55:59 +0000 (+0000) Subject: OK, this was one of the weirder bugs I've found recently: when we do X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30976fce2065ed3fc2b63356a32d730819aa6af7;p=dealii-svn.git OK, this was one of the weirder bugs I've found recently: when we do #include we expect that either (i) make_dependencies ignores this dependence because it can't find the file anywhere, e.g. because it doesn't know the path to system header files, or (ii) enter the proper dependency to the file if it does know where to find the file. But what happened in the tests/serialization directory is that it found a *subdirectory* named 'vector' and added it to the list of dependencies. And 'make' then tries to re-build this directory by compiling (using an implicit rule built into 'make') the executable 'vector' from 'vector.cc', which fails because the implicit rule of course doesn't know anything about where deal.II include files reside, etc. Completely strange. So the solution is to ignore directories, if we happen to find them. In the process, I also replaced the use of std::istream to test-open a file (which weirdly succeeds for directories, although you can't read from it) by uses of stat(), which should be faster as well. git-svn-id: https://svn.dealii.org/trunk@22940 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/common/scripts/make_dependencies.cc b/deal.II/common/scripts/make_dependencies.cc index 5262961d7d..07f9515f13 100644 --- a/deal.II/common/scripts/make_dependencies.cc +++ b/deal.II/common/scripts/make_dependencies.cc @@ -46,6 +46,7 @@ #include #include #include +#include // base path for object files, // including trailing slash if @@ -177,18 +178,33 @@ void determine_direct_includes (const std::string &file) for (std::vector::const_iterator include_dir=include_directories.begin(); include_dir!=include_directories.end(); ++include_dir) - if (std::ifstream((*include_dir+included_file).c_str())) - { - included_file = *include_dir+included_file; - break; - } + { + struct stat buf; + int error = stat ((*include_dir+included_file).c_str(), &buf); + + if ((error == 0) && + S_ISREG(buf.st_mode)) + { + included_file = *include_dir+included_file; + break; + } + } } - // make sure the file - // exists, otherwise just - // ignore the line - if (!std::ifstream(included_file.c_str())) - continue; + // make sure the file exists + // and that we can read from + // it, otherwise just ignore + // the line + { + struct stat buf; + int error = stat (included_file.c_str(), &buf); + + if ((error != 0) || + !S_ISREG(buf.st_mode)) + continue; + } + + // ok, so we did find an // appropriate file. add it to