>>> "gd" == Guido Draheim <[EMAIL PROTECTED]> writes:
gd> Hi everyone,
gd> in the last days I did hit a problem that I thought was good to
gd> do with an autoconf-macro - may be someone has already done
gd> such a beast. It goes about the number of arguments to mkdir(2).
gd> While every unix (posix?) system takes two arguments (the
gd> filename and the modebits), quite a few platforms only want
gd> one argument, in my case it was not only win'ish mingw32
gd> but also vxworks. As a side note: cygwin uses two args,
gd> mingw32 one arg. I guess quite a few embedded RTOS do also
gd> define mkdir with just one arg.
gd> The question is: how to reliably detect the number of
gd> arguments without TRY_RUN since it must be detectable
gd> for crosscompiling targets. Anyone to give me a hint on
gd> how to implement such an m4-macro? Or already on disk somewhere?
I have been using the following macro for a few weeks,
it might not be really perfect but at least it works for the
hosts I need (this include crosscompiling to mingw32).
dnl AC_FUNC_MKDIR
dnl Check for mkdir.
dnl Can define HAVE_MKDIR, HAVE__MKDIR and MKDIR_TAKES_ONE_ARG.
dnl
dnl #if HAVE_MKDIR
dnl # if MKDIR_TAKES_ONE_ARG
dnl /* Mingw32 */
dnl # define mkdir(a,b) mkdir(a)
dnl # endif
dnl #else
dnl # if HAVE__MKDIR
dnl /* plain Win32 */
dnl # define mkdir(a,b) _mkdir(a)
dnl # else
dnl # error "Don't know how to create a directory on this system."
dnl # endif
dnl #endif
dnl
dnl Written by Alexandre Duret-Lutz <[EMAIL PROTECTED]>.
AC_DEFUN([AC_FUNC_MKDIR],
[AC_CHECK_FUNCS([mkdir _mkdir])
AC_CACHE_CHECK([whether mkdir takes one argument],
[ac_cv_mkdir_takes_one_arg],
[AC_TRY_COMPILE([
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
],[mkdir (".");],
[ac_cv_mkdir_takes_one_arg=yes],[ac_cv_mkdir_takes_one_arg=no])])
if test x"$ac_cv_mkdir_takes_one_arg" = xyes; then
AC_DEFINE([MKDIR_TAKES_ONE_ARG],1,
[Define if mkdir takes only one argument.])
fi
])
--
Alexandre Duret-Lutz