CVS m4 is using the mkstemp module, which includes tempname.c. But there are a couple of compatibility problems preventing a clean compile on mingw32.
First is the fact that on Windows, mkdir only takes one argument (as noted in doc/functions.texi). Mingw declares mkdir (and _mkdir) in <io.h> rather than <sys/stat.h>, but <fcntl.h> includes <io.h>, leading to other problems if I redefine mkdir inside my config.h. Would it be worth augmenting the mkdir module to add lib/mkdir.h which neutralizes mingw mkdir, then making all modules which use mkdir (mkdir-p, openat, mkdtemp, mkstemp) depend on the mkdir module and include "mkdir.h" so that they can work on mingw? For that matter, why are mkstemp and mkdtemp not sharing tempname.c? In the case of mkstemp, maybe it would be easier to strip the (unused) mkdir out of tempname.c, since only mkdtemp really needs to call mkdir. And mkdtemp already contains mingw mkdir neutralization code. I'm thinking something like this for a new lib/mkdir.h: #ifndef _gl_MKDIR_H #define _gl_MKDIR_H /* Get mkdir from compliant headers. */ #include <sys/stat.h> /* On mingw32, mkdir is declared in <io.h> with only one argument. */ #if HAVE_IO_H # include <io.h> #endif #if MKDIR_TAKES_ONE_ARG # define mkdir(file, mode) mkdir(file) #endif #endif /* _gl_MKDIR_H */ Second is the fact that since mingw does not support symlinks, it does not have lstat. This portability pitfall is not mentioned in doc/functions.texi yet. The workaround is as simple as: #if !HAVE_FUNC_LSTAT # define lstat stat #endif Would it be worth augmenting the lstat module to check for this case, then make all modules that use lstat (canonicalize, error, fts, fts-lgpl, getcwd, glob, lchown, mkdir-p, mkstemp, mountlist, openat, readlink, utimecmp) also depend on the lstat module? -- Eric Blake
