dnl COMPILER NO WIN32 support ==================================== # figure out how to run CC without access to the win32 api (if it # was present). # configure that as the CC program, # WIN32 may be present with WINE, under cygwin, or under mingw, # or cross compilers targeting those same three targets. # as it happens, I can only test cygwin, so extra input here will # be appreciated # send bug reports to Robert Collins # # logic: is CC already configured? if not, call AC_PROG_CC. # if so - try it. If that doesn't work ,try -mno-win32. If that # doesn't work, fail # # 2001-03-24 - NoWIN32 derived from WIN32 Macro. Entries beforethis refer to # * the Win32 Macro. It now sets NOWIN32FLAGS for avoiding win32. # 2001-03-15 - Changed from yes/no to true/false -suggested by Lars J Aas # * Change true to : - suggest by Alexandre Oliva # * changed layout on the basis of autoconf mailing list: # there are now two interfaces, a language specific one which sets # or clears WIN32 && WIN32FLAGS as appropriate # * m4 Syntax fixup: Akim Demaille # # All faults& bugs are mine - Robert # 1. do we have windows.h? # yes - does it define WIN32? # yes - try -mno-win32 # no - nowin32 api. # no - nowin32 api. AC_DEFUN([AC_PROG_CC_NOWIN32], [ AC_REQUIRE([AC_PROG_CC])dnl AC_MSG_CHECKING([how to avoid the Win32 API]) NOWIN32FLAGS= dnl do we have windows.h ? AC_TRY_COMPILE([#include ],[], [ dnl does it define WIN32 ? AC_TRY_COMPILE([#include ],[ #ifdef WIN32 # error WIN32 defined #endif #ifdef _WIN32 # error _WIN32 defined #endif ], [ dnl no win32 defined, we're ok AC_MSG_RESULT([absent by default]) ], [ dnl try -mno-win32 - if the flag is accepted we're ok, even if a different windows.h is dnl found. ac_compile_save="$ac_compile" dnl we change CC so config.log looks correct save_CC="$CC" ac_compile="$ac_compile -mno-win32" CC="$CC -mno-win32" AC_TRY_COMPILE(,[ #ifdef WIN32 # error WIN32 defined #endif #ifdef _WIN32 # error _WIN32 defined #endif],[ ac_compile="$ac_compile_save" CC="$save_CC" NOWIN32FLAGS="-mno-win32" AC_MSG_RESULT([avoided via -mno-win32])],[ ac_compile="$ac_compile_save" CC="$save_CC" AC_MSG_RESULT([Couldn't turn off the WIN32 API. A new test case is needed or your compiler always includes the win32 API])] ) ]) ],[ dnl no win32 with the current config. AC_MSG_RESULT([absent by default]) ]) ]) # figure out how to run CXX without access to the win32 api if present # configure that as the CXX program, # WIN32 may be present with WINE, under cygwin, or under mingw, # or cross compilers targeting those same three targets. # as it happens, I can only test cygwin, so extra input here will be appreciated # send bug reports to Robert Collins AC_DEFUN([AC_PROG_CXX_NOWIN32], [ AC_REQUIRE([AC_PROG_CXX])dnl AC_MSG_CHECKING([how to avoid the Win32 API]) NOWIN32FLAGS= AC_TRY_COMPILE(,[ #include #ifdef WIN32 # error WIN32 defined #endif #ifdef _WIN32 # error _WIN32 defined #endif], [ dnl found windows.h with the current config. AC_MSG_RESULT([abesnt by default]) ], [ dnl try -mno-win32 ac_compile_save="$ac_compile" dnl we change CC so config.log looks correct save_CXX="$CXX" ac_compile="$ac_compile -mno-win32" CXX="$CXX -mno-win32" AC_TRY_COMPILE(,[ #include #ifdef WIN32 # error WIN32 defined #endif #ifdef _WIN32 # error _WIN32 not defined #endif], [ dnl avoided WIN32 using -mno-win32 AC_MSG_RESULT([avoided via -mno-win32]) ac_compile="$ac_compile_save" CXX="$save_CXX" NOWIN32FLAGS="-mno-win32" ], [ ac_compile="$ac_compile_save" CXX="$save_CXX" AC_MSG_RESULT([tests failed - inconclusive]) ]) ]) ]) AC_DEFUN([AC_PROG_CXX_NOWIN32], [ AC_REQUIRE([AC_PROG_CXX])dnl AC_MSG_CHECKING([how to avoid the Win32 API]) NOWIN32FLAGS= dnl do we have windows.h ? AC_TRY_COMPILE([#include ],[], [ dnl does it define WIN32 ? AC_TRY_COMPILE([#include ],[ #ifdef WIN32 # error WIN32 defined #endif #ifdef _WIN32 # error _WIN32 defined #endif ], [ dnl no win32 defined, we're ok AC_MSG_RESULT([absent by default]) ], [ dnl try -mno-win32 - if the flag is accepted we're ok, even if a different windows.h is dnl found. ac_compile_save="$ac_compile" dnl we change CXX so config.log looks correct save_CXX="$CXX" ac_compile="$ac_compile -mno-win32" CXX="$CXX -mno-win32" AC_TRY_COMPILE(,[ #ifdef WIN32 # error WIN32 defined #endif #ifdef _WIN32 # error _WIN32 defined #endif],[ ac_compile="$ac_compile_save" CXX="$save_CXX" NOWIN32FLAGS="-mno-win32" AC_MSG_RESULT([avoided via -mno-win32])],[ ac_compile="$ac_compile_save" CXX="$save_CXX" AC_MSG_RESULT([Couldn't turn off the WIN32 API. A new test case is needed or your compiler always includes the win32 API])] ) ]) ],[ dnl no win32 with the current config. AC_MSG_RESULT([absent by default]) ]) ]) # high level interface for avoiding compiler support for win32. AC_DEFUN([AC_API_NOWIN32], [ AC_LANG_CASE( [C], [AC_PROG_CC_NOWIN32 CFLAGS="$NOWIN32FLAGS $CFLAGS" CPPFLAGS="$NOWIN32FLAGS $CPPFLAGS"], [C++], [AC_PROG_CXX_NOWIN32 CXXFLAGS="$NOWIN32FLAGS $CXXFLAGS" CPPFLAGS="$NOWIN32FLAGS $CPPFLAGS"], [AC_FATAL([No macro support for NOWIN32 with ] _AC_LANG) ]) ]) dnl end compiler NOWIN32 support ===========================================