libvips/acinclude.m4

567 lines
14 KiB
Plaintext
Raw Normal View History

2007-08-29 18:23:50 +02:00
dnl From FIND_MOTIF and ACX_PTHREAD, without much understanding
dnl
dnl FIND_ZIP[ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]
dnl ------------------------------------------------
dnl
dnl Find ZIP libraries and headers
dnl
dnl Put includes stuff in ZIP_INCLUDES
dnl Put link stuff in ZIP_LIBS
2008-06-24 12:37:54 +02:00
dnl Define HAVE_ZIP if found
2007-08-29 18:23:50 +02:00
dnl
AC_DEFUN([FIND_ZIP], [
AC_REQUIRE([AC_PATH_XTRA])
ZIP_INCLUDES=""
ZIP_LIBS=""
AC_ARG_WITH(zip,
2008-10-11 23:29:16 +02:00
AS_HELP_STRING([--without-zip], [build without libx (default: test)]))
2007-08-29 18:23:50 +02:00
# Treat --without-zip like --without-zip-includes --without-zip-libraries.
if test "$with_zip" = "no"; then
2008-06-24 12:37:54 +02:00
ZIP_INCLUDES=no
ZIP_LIBS=no
2007-08-29 18:23:50 +02:00
fi
AC_ARG_WITH(zip-includes,
2008-10-11 23:29:16 +02:00
AS_HELP_STRING([--with-zip-includes=DIR], [libz includes are in DIR]),
ZIP_INCLUDES="-I$withval")
2007-08-29 18:23:50 +02:00
AC_ARG_WITH(zip-libraries,
2008-10-11 23:29:16 +02:00
AS_HELP_STRING([--with-zip-libraries=DIR], [libz libraries are in DIR]),
ZIP_LIBS="-L$withval -lz")
2007-08-29 18:23:50 +02:00
AC_MSG_CHECKING(for ZIP)
# Look for zlib.h
if test "$ZIP_INCLUDES" = ""; then
2008-06-24 12:37:54 +02:00
# Check the standard search path
AC_TRY_COMPILE([#include <zlib.h>],[int a;],[
ZIP_INCLUDES=""
], [
# zlib.h is not in the standard search path, try
# $prefix
zip_save_INCLUDES="$INCLUDES"
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
INCLUDES="-I${prefix}/include $INCLUDES"
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
AC_TRY_COMPILE([#include <zlib.h>],[int a;],[
ZIP_INCLUDES="-I${prefix}/include"
], [
ZIP_INCLUDES="no"
])
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
INCLUDES=$zip_save_INCLUDES
])
2007-08-29 18:23:50 +02:00
fi
# Now for the libraries
if test "$ZIP_LIBS" = ""; then
2008-06-24 12:37:54 +02:00
zip_save_LIBS="$LIBS"
zip_save_INCLUDES="$INCLUDES"
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
LIBS="-lz $LIBS"
INCLUDES="$ZIP_INCLUDES $INCLUDES"
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
# Try the standard search path first
AC_TRY_LINK([#include <zlib.h>],[zlibVersion()], [
ZIP_LIBS="-lz"
], [
# libz is not in the standard search path, try $prefix
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
LIBS="-L${prefix}/lib $LIBS"
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
AC_TRY_LINK([#include <zlib.h>],[zlibVersion()], [
ZIP_LIBS="-L${prefix}/lib -lz"
], [
ZIP_LIBS=no
])
])
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
LIBS="$zip_save_LIBS"
INCLUDES="$zip_save_INCLUDES"
2007-08-29 18:23:50 +02:00
fi
AC_SUBST(ZIP_LIBS)
AC_SUBST(ZIP_INCLUDES)
# Print a helpful message
zip_libraries_result="$ZIP_LIBS"
zip_includes_result="$ZIP_INCLUDES"
if test x"$zip_libraries_result" = x""; then
2008-06-24 12:37:54 +02:00
zip_libraries_result="in default path"
2007-08-29 18:23:50 +02:00
fi
if test x"$zip_includes_result" = x""; then
2008-06-24 12:37:54 +02:00
zip_includes_result="in default path"
2007-08-29 18:23:50 +02:00
fi
if test "$zip_libraries_result" = "no"; then
2008-06-24 12:37:54 +02:00
zip_libraries_result="(none)"
2007-08-29 18:23:50 +02:00
fi
if test "$zip_includes_result" = "no"; then
2008-06-24 12:37:54 +02:00
zip_includes_result="(none)"
2007-08-29 18:23:50 +02:00
fi
2008-06-24 12:37:54 +02:00
AC_MSG_RESULT([libraries $zip_libraries_result, headers $zip_includes_result])
2007-08-29 18:23:50 +02:00
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test "$ZIP_INCLUDES" != "no" && test "$ZIP_LIBS" != "no"; then
2008-06-24 12:37:54 +02:00
AC_DEFINE(HAVE_ZIP,1,[Define if you have libz libraries and header files.])
$1
2007-08-29 18:23:50 +02:00
else
2008-06-24 12:37:54 +02:00
ZIP_LIBS=""
ZIP_INCLUDES=""
$2
2007-08-29 18:23:50 +02:00
fi
])dnl
dnl From FIND_MOTIF and ACX_PTHREAD, without much understanding
dnl
dnl FIND_TIFF[ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]
dnl ------------------------------------------------
dnl
dnl Find TIFF libraries and headers
dnl
dnl Put compile stuff in TIFF_INCLUDES
dnl Put link stuff in TIFF_LIBS
2008-06-24 12:37:54 +02:00
dnl Define HAVE_TIFF if found
2007-08-29 18:23:50 +02:00
dnl
AC_DEFUN([FIND_TIFF], [
AC_REQUIRE([AC_PATH_XTRA])
TIFF_INCLUDES=""
TIFF_LIBS=""
AC_ARG_WITH(tiff,
2008-10-11 23:29:16 +02:00
AS_HELP_STRING([--without-tiff], [build without libtiff (default: test)]))
2007-08-29 18:23:50 +02:00
# Treat --without-tiff like --without-tiff-includes --without-tiff-libraries.
if test "$with_tiff" = "no"; then
2008-06-24 12:37:54 +02:00
TIFF_INCLUDES=no
TIFF_LIBS=no
2007-08-29 18:23:50 +02:00
fi
AC_ARG_WITH(tiff-includes,
2008-10-11 23:29:16 +02:00
AS_HELP_STRING([--with-tiff-includes=DIR], [libtiff includes are in DIR]),
TIFF_INCLUDES="-I$withval")
2007-08-29 18:23:50 +02:00
AC_ARG_WITH(tiff-libraries,
2008-10-11 23:29:16 +02:00
AS_HELP_STRING([--with-tiff-libraries=DIR], [libtiff libraries are in DIR]),
TIFF_LIBS="-L$withval -ltiff")
2007-08-29 18:23:50 +02:00
AC_MSG_CHECKING(for TIFF)
# Look for tiff.h
if test "$TIFF_INCLUDES" = ""; then
2008-06-24 12:37:54 +02:00
# Check the standard search path
AC_TRY_COMPILE([#include <tiff.h>],[int a;],[
TIFF_INCLUDES=""
], [
# tiff.h is not in the standard search path, try
# $prefix
tiff_save_INCLUDES="$INCLUDES"
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
INCLUDES="-I${prefix}/include $INCLUDES"
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
AC_TRY_COMPILE([#include <tiff.h>],[int a;],[
TIFF_INCLUDES="-I${prefix}/include"
], [
TIFF_INCLUDES="no"
])
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
INCLUDES=$tiff_save_INCLUDES
])
2007-08-29 18:23:50 +02:00
fi
# Now for the libraries
if test "$TIFF_LIBS" = ""; then
2008-06-24 12:37:54 +02:00
tiff_save_LIBS="$LIBS"
tiff_save_INCLUDES="$INCLUDES"
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
LIBS="-ltiff -lm $LIBS"
INCLUDES="$TIFF_INCLUDES $INCLUDES"
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
# Try the standard search path first
AC_TRY_LINK([#include <tiff.h>],[TIFFGetVersion()], [
TIFF_LIBS="-ltiff"
], [
# libtiff is not in the standard search path, try $prefix
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
LIBS="-L${prefix}/lib $LIBS"
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
AC_TRY_LINK([#include <tiff.h>],[TIFFGetVersion()], [
TIFF_LIBS="-L${prefix}/lib -ltiff"
], [
TIFF_LIBS=no
])
])
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
LIBS="$tiff_save_LIBS"
INCLUDES="$tiff_save_INCLUDES"
2007-08-29 18:23:50 +02:00
fi
AC_SUBST(TIFF_LIBS)
AC_SUBST(TIFF_INCLUDES)
# Print a helpful message
tiff_libraries_result="$TIFF_LIBS"
tiff_includes_result="$TIFF_INCLUDES"
if test x"$tiff_libraries_result" = x""; then
2008-06-24 12:37:54 +02:00
tiff_libraries_result="in default path"
2007-08-29 18:23:50 +02:00
fi
if test x"$tiff_includes_result" = x""; then
2008-06-24 12:37:54 +02:00
tiff_includes_result="in default path"
2007-08-29 18:23:50 +02:00
fi
if test "$tiff_libraries_result" = "no"; then
2008-06-24 12:37:54 +02:00
tiff_libraries_result="(none)"
2007-08-29 18:23:50 +02:00
fi
if test "$tiff_includes_result" = "no"; then
2008-06-24 12:37:54 +02:00
tiff_includes_result="(none)"
2007-08-29 18:23:50 +02:00
fi
2008-06-24 12:37:54 +02:00
AC_MSG_RESULT([libraries $tiff_libraries_result, headers $tiff_includes_result])
2007-08-29 18:23:50 +02:00
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test "$TIFF_INCLUDES" != "no" && test "$TIFF_LIBS" != "no"; then
2008-06-24 12:37:54 +02:00
AC_DEFINE(HAVE_TIFF,1,[Define if you have tiff libraries and header files.])
$1
2007-08-29 18:23:50 +02:00
else
2008-06-24 12:37:54 +02:00
TIFF_INCLUDES=""
TIFF_LIBS=""
$2
2007-08-29 18:23:50 +02:00
fi
])dnl
dnl From FIND_MOTIF and ACX_PTHREAD, without much understanding
dnl
dnl FIND_JPEG[ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]
dnl ------------------------------------------------
dnl
dnl Find JPEG libraries and headers
dnl
dnl Put compile stuff in JPEG_INCLUDES
dnl Put link stuff in JPEG_LIBS
2008-06-24 12:37:54 +02:00
dnl Define HAVE_JPEG if found
2007-08-29 18:23:50 +02:00
dnl
AC_DEFUN([FIND_JPEG], [
AC_REQUIRE([AC_PATH_XTRA])
JPEG_INCLUDES=""
JPEG_LIBS=""
AC_ARG_WITH(jpeg,
2008-10-11 23:29:16 +02:00
AS_HELP_STRING([--without-jpeg], [build without libjpeg (default: test)]))
2007-08-29 18:23:50 +02:00
# Treat --without-jpeg like --without-jpeg-includes --without-jpeg-libraries.
if test "$with_jpeg" = "no"; then
2008-06-24 12:37:54 +02:00
JPEG_INCLUDES=no
JPEG_LIBS=no
2007-08-29 18:23:50 +02:00
fi
AC_ARG_WITH(jpeg-includes,
2008-10-11 23:29:16 +02:00
AS_HELP_STRING([--with-jpeg-includes=DIR], [libjpeg includes are in DIR]),
JPEG_INCLUDES="-I$withval")
2007-08-29 18:23:50 +02:00
AC_ARG_WITH(jpeg-libraries,
2008-10-11 23:29:16 +02:00
AS_HELP_STRING([--with-jpeg-libraries=DIR], [libjpeg libraries are in DIR]),
JPEG_LIBS="-L$withval -ljpeg")
2007-08-29 18:23:50 +02:00
AC_MSG_CHECKING(for JPEG)
2008-06-19 18:38:31 +02:00
# Look for jpeglib.h
2007-08-29 18:23:50 +02:00
if test "$JPEG_INCLUDES" = ""; then
2008-06-24 12:37:54 +02:00
# Check the standard search path
AC_TRY_COMPILE([#include <stdio.h>
#include <jpeglib.h>],[int a;],[
JPEG_INCLUDES=""
], [
# jpeglib.h is not in the standard search path, try
# $prefix
jpeg_save_INCLUDES="$INCLUDES"
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
INCLUDES="-I${prefix}/include $INCLUDES"
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
AC_TRY_COMPILE([#include <stdio.h>
#include <jpeglib.h>],[int a;],[
JPEG_INCLUDES="-I${prefix}/include"
], [
JPEG_INCLUDES="no"
])
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
INCLUDES=$jpeg_save_INCLUDES
])
2007-08-29 18:23:50 +02:00
fi
# Now for the libraries
if test "$JPEG_LIBS" = ""; then
2008-06-24 12:37:54 +02:00
jpeg_save_LIBS="$LIBS"
jpeg_save_INCLUDES="$INCLUDES"
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
LIBS="-ljpeg $LIBS"
INCLUDES="$JPEG_INCLUDES $INCLUDES"
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
# Try the standard search path first
AC_TRY_LINK([#include <stdio.h>
#include <jpeglib.h>
],[jpeg_abort((void*)0)], [
JPEG_LIBS="-ljpeg"
], [
# libjpeg is not in the standard search path, try $prefix
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
LIBS="-L${prefix}/lib $LIBS"
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
AC_TRY_LINK([#include <stdio.h>
#include <jpeg.h>
],[jpeg_abort((void*)0)], [
JPEG_LIBS="-L${prefix}/lib -ljpeg"
], [
JPEG_LIBS=no
])
])
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
LIBS="$jpeg_save_LIBS"
INCLUDES="$jpeg_save_INCLUDES"
2007-08-29 18:23:50 +02:00
fi
AC_SUBST(JPEG_LIBS)
AC_SUBST(JPEG_INCLUDES)
# Print a helpful message
jpeg_libraries_result="$JPEG_LIBS"
jpeg_includes_result="$JPEG_INCLUDES"
if test x"$jpeg_libraries_result" = x""; then
2008-06-24 12:37:54 +02:00
jpeg_libraries_result="in default path"
2007-08-29 18:23:50 +02:00
fi
if test x"$jpeg_includes_result" = x""; then
2008-06-24 12:37:54 +02:00
jpeg_includes_result="in default path"
2007-08-29 18:23:50 +02:00
fi
if test "$jpeg_libraries_result" = "no"; then
2008-06-24 12:37:54 +02:00
jpeg_libraries_result="(none)"
2007-08-29 18:23:50 +02:00
fi
if test "$jpeg_includes_result" = "no"; then
2008-06-24 12:37:54 +02:00
jpeg_includes_result="(none)"
2007-08-29 18:23:50 +02:00
fi
2008-06-24 12:37:54 +02:00
AC_MSG_RESULT([libraries $jpeg_libraries_result, headers $jpeg_includes_result])
2007-08-29 18:23:50 +02:00
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test "$JPEG_INCLUDES" != "no" && test "$JPEG_LIBS" != "no"; then
2008-06-24 12:37:54 +02:00
AC_DEFINE(HAVE_JPEG,1,[Define if you have jpeg libraries and header files.])
$1
2007-08-29 18:23:50 +02:00
else
2008-06-24 12:37:54 +02:00
JPEG_INCLUDES=""
JPEG_LIBS=""
$2
2007-08-29 18:23:50 +02:00
fi
])dnl
dnl From FIND_MOTIF and ACX_PTHREAD, without much understanding
dnl
dnl FIND_PNG[ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]
dnl ------------------------------------------------
dnl
dnl Find PNG libraries and headers
dnl
dnl Put compile stuff in PNG_INCLUDES
dnl Put link stuff in PNG_LIBS
2008-06-24 12:37:54 +02:00
dnl Define HAVE_PNG if found.
2007-08-29 18:23:50 +02:00
dnl
AC_DEFUN([FIND_PNG], [
AC_REQUIRE([AC_PATH_XTRA])
PNG_INCLUDES=""
PNG_LIBS=""
AC_ARG_WITH(png,
2008-10-11 23:29:16 +02:00
AS_HELP_STRING([--without-png], [build without libpng (default: test)]))
2007-08-29 18:23:50 +02:00
# Treat --without-png like --without-png-includes --without-png-libraries.
if test "$with_png" = "no"; then
2008-06-24 12:37:54 +02:00
PNG_INCLUDES=no
PNG_LIBS=no
2007-08-29 18:23:50 +02:00
fi
AC_ARG_WITH(png-includes,
2008-10-11 23:29:16 +02:00
AS_HELP_STRING([--with-png-includes=DIR], [libpng includes are in DIR]),
PNG_INCLUDES="-I$withval")
2007-08-29 18:23:50 +02:00
AC_ARG_WITH(png-libraries,
2008-10-11 23:29:16 +02:00
AS_HELP_STRING([--with-png-libraries=DIR], [libpng libraries are in DIR]),
PNG_LIBS="-L$withval -lpng")
2007-08-29 18:23:50 +02:00
2008-10-11 23:29:16 +02:00
AC_MSG_CHECKING(for libpng)
2007-08-29 18:23:50 +02:00
# Look for png.h
if test "$PNG_INCLUDES" = ""; then
2008-06-24 12:37:54 +02:00
# Check the standard search path
AC_TRY_COMPILE([#include <png.h>],[int a;],[
PNG_INCLUDES=""
], [
# png.h is not in the standard search path, try
# $prefix
png_save_INCLUDES="$INCLUDES"
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
INCLUDES="-I${prefix}/include $INCLUDES"
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
AC_TRY_COMPILE([#include <png.h>],[int a;],[
PNG_INCLUDES="-I${prefix}/include"
], [
PNG_INCLUDES="no"
])
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
INCLUDES=$png_save_INCLUDES
])
2007-08-29 18:23:50 +02:00
fi
# Now for the libraries
if test "$PNG_LIBS" = ""; then
2008-06-24 12:37:54 +02:00
png_save_LIBS="$LIBS"
png_save_INCLUDES="$INCLUDES"
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
LIBS="-lpng $LIBS"
INCLUDES="$PNG_INCLUDES $INCLUDES"
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
# Try the standard search path first
AC_TRY_LINK([#include <png.h>],[png_access_version_number()], [
PNG_LIBS="-lpng"
], [
# libpng is not in the standard search path, try $prefix
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
LIBS="-L${prefix}/lib $LIBS"
2008-06-19 18:38:31 +02:00
2008-06-24 12:37:54 +02:00
AC_TRY_LINK([#include <png.h>],[png_access_version_number()], [
PNG_LIBS="-L${prefix}/lib -lpng"
], [
PNG_LIBS=no
])
])
2007-08-29 18:23:50 +02:00
2008-06-24 12:37:54 +02:00
LIBS="$png_save_LIBS"
INCLUDES="$png_save_INCLUDES"
2007-08-29 18:23:50 +02:00
fi
AC_SUBST(PNG_LIBS)
AC_SUBST(PNG_INCLUDES)
# Print a helpful message
png_libraries_result="$PNG_LIBS"
png_includes_result="$PNG_INCLUDES"
if test x"$png_libraries_result" = x""; then
2008-06-24 12:37:54 +02:00
png_libraries_result="in default path"
2007-08-29 18:23:50 +02:00
fi
if test x"$png_includes_result" = x""; then
2008-06-24 12:37:54 +02:00
png_includes_result="in default path"
2007-08-29 18:23:50 +02:00
fi
if test "$png_libraries_result" = "no"; then
2008-06-24 12:37:54 +02:00
png_libraries_result="(none)"
2007-08-29 18:23:50 +02:00
fi
if test "$png_includes_result" = "no"; then
2008-06-24 12:37:54 +02:00
png_includes_result="(none)"
2007-08-29 18:23:50 +02:00
fi
2008-06-24 12:37:54 +02:00
AC_MSG_RESULT([libraries $png_libraries_result, headers $png_includes_result])
2007-08-29 18:23:50 +02:00
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test "$PNG_INCLUDES" != "no" && test "$PNG_LIBS" != "no"; then
2008-06-24 12:37:54 +02:00
AC_DEFINE(HAVE_PNG,1,[Define if you have png libraries and header files.])
$1
2007-08-29 18:23:50 +02:00
else
2008-06-24 12:37:54 +02:00
PNG_INCLUDES=""
PNG_LIBS=""
$2
2007-08-29 18:23:50 +02:00
fi
])dnl
dnl a macro to check for ability to create python extensions
dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
dnl function also defines PYTHON_INCLUDES
AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
[AC_REQUIRE([AM_PATH_PYTHON])
AC_MSG_CHECKING(for headers required to compile python extensions)
dnl deduce PYTHON_INCLUDES
py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
if test "$py_prefix" != "$py_exec_prefix"; then
PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
fi
AC_SUBST(PYTHON_INCLUDES)
dnl check if the headers exist:
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
AC_TRY_CPP([#include <Python.h>],dnl
[AC_MSG_RESULT(found)
$1],dnl
[AC_MSG_RESULT(not found)
$2])
CPPFLAGS="$save_CPPFLAGS"
])
2012-03-26 23:08:59 +02:00
dnl @synopsis AC_FUNC_MKDIR
dnl
dnl Check whether mkdir() is mkdir or _mkdir, and whether it takes one
dnl or two arguments.
dnl
dnl This macro can define HAVE_MKDIR, HAVE__MKDIR, and
dnl MKDIR_TAKES_ONE_ARG, which are expected to be used as follows:
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 Windows 32 */
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 @category C
dnl @author Alexandre Duret-Lutz <adl@gnu.org>
dnl @version 2003-12-28
dnl @license GPLWithACException
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>
#if 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
])
dnl Note:
dnl =====
dnl I have not implemented the following suggestion because I don't have
dnl access to such a broken environment to test the macro. So I'm just
dnl appending the comments here in case you have, and want to fix
dnl AC_FUNC_MKDIR that way.
dnl
dnl |Thomas E. Dickey (dickey@herndon4.his.com) said:
dnl | it doesn't cover the problem areas (compilers that mistreat mkdir
dnl | may prototype it in dir.h and dirent.h, for instance).
dnl |
dnl |Alexandre:
dnl | Would it be sufficient to check for these headers and #include
dnl | them in the AC_TRY_COMPILE block? (and is AC_HEADER_DIRENT
dnl | suitable for this?)
dnl |
dnl |Thomas:
dnl | I think that might be a good starting point (with the set of recommended
dnl | ifdef's and includes for AC_HEADER_DIRENT, of course).