Mailing-List: contact cygwin-apps-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-apps-owner AT sourceware DOT cygnus DOT com List-Subscribe: List-Archive: List-Post: List-Help: , Delivered-To: mailing list cygwin-apps AT sources DOT redhat DOT com Message-ID: <030101c0b40c$a792b1f0$0200a8c0@lifelesswks> From: "Robert Collins" To: Cc: Subject: AC_API_WIN32 and AC_API_NOWIN32 Date: Sat, 24 Mar 2001 13:46:23 +1100 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_02FC_01C0B468.D0DBD440" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-OriginalArrivalTime: 24 Mar 2001 02:41:02.0250 (UTC) FILETIME=[DDA398A0:01C0B40B] This is a multi-part message in MIME format. ------=_NextPart_000_02FC_01C0B468.D0DBD440 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit The two attached files are macros for configuring a compiler respectively, enable WIN32 support or disable WIN32 support. They both have a high level interface that sets CFLAGS/CXXFLAGS and CPPFLAGS and a low level interface that sets [NO]WIN32FLAGS for use in projects that override CFLAGS/CPPFLAGS. The second macro was introduced so that projects that don't port well if the win32 api is in the include path can be updated easily. (windows.h is not unique to win32, and if it gets included, WIN32 gets defined...) Rob ------=_NextPart_000_02FC_01C0B468.D0DBD440 Content-Type: application/octet-stream; name="win32.m4" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="win32.m4" dnl COMPILER WIN32 support = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= # figure out how to run CC with access to the win32 api if present=0A= # configure that as the CC program, =0A= # WIN32 may be present with WINE, under cygwin, or under mingw,=0A= # or cross compilers targeting those same three targets.=0A= # as it happens, I can only test cygwin, so extra input here will be = appreciated=0A= # send bug reports to Robert Collins =0A= #=0A= # logic: is CC already configured? if not, call AC_PROG_CC.=0A= # if so - try it. If that doesn't work ,try -mwin32. If that doesn't = work, fail=0A= #=0A= # 2001-03-15 - Changed from yes/no to true/false -suggested by Lars J = Aas=0A= # * Change true to : - suggest by Alexandre Oliva = =0A= # * changed layout on the basis of autoconf mailing list:=0A= # there are now two interfaces, a language specific one which sets=0A= # or clears WIN32 && WIN32FLAGS as appropriate=0A= # * m4 Syntax fixup: Akim Demaille =0A= #=0A= # All faults& bugs are mine - Robert=0A= =0A= AC_DEFUN([AC_PROG_CC_WIN32], [=0A= AC_REQUIRE([AC_PROG_CC])dnl=0A= AC_MSG_CHECKING([how to access the Win32 API])=0A= WIN32FLAGS=3D=0A= AC_TRY_COMPILE(,[=0A= #ifndef WIN32=0A= # ifndef _WIN32=0A= # error WIN32 or _WIN32 not defined=0A= # endif=0A= #endif], [=0A= dnl found windows.h with the current config.=0A= AC_MSG_RESULT([present by default])=0A= ], [=0A= dnl try -mwin32=0A= ac_compile_save=3D"$ac_compile"=0A= dnl we change CC so config.log looks correct=0A= save_CC=3D"$CC"=0A= ac_compile=3D"$ac_compile -mwin32"=0A= CC=3D"$CC -mwin32"=0A= AC_TRY_COMPILE(,[=0A= #ifndef WIN32=0A= # ifndef _WIN32=0A= # error WIN32 or _WIN32 not defined=0A= # endif=0A= #endif], [=0A= dnl found windows.h using -mwin32=0A= AC_MSG_RESULT([found via -mwin32])=0A= ac_compile=3D"$ac_compile_save"=0A= CC=3D"$save_CC"=0A= WIN32FLAGS=3D"-mwin32"=0A= ], [=0A= ac_compile=3D"$ac_compile_save"=0A= CC=3D"$save_CC"=0A= AC_MSG_RESULT([not found])=0A= ])=0A= ])=0A= =0A= ])=0A= =0A= =0A= # figure out how to run CXX with access to the win32 api if present=0A= # configure that as the CXX program,=0A= # WIN32 may be present with WINE, under cygwin, or under mingw,=0A= # or cross compilers targeting those same three targets.=0A= # as it happens, I can only test cygwin, so extra input here will be = appreciated=0A= # send bug reports to Robert Collins =0A= =0A= AC_DEFUN([AC_PROG_CXX_WIN32], [=0A= AC_REQUIRE([AC_PROG_CXX])dnl=0A= AC_MSG_CHECKING([how to access the Win32 API])=0A= WIN32FLAGS=3D=0A= AC_TRY_COMPILE(,[=0A= #ifndef WIN32=0A= # ifndef _WIN32=0A= # error WIN32 or _WIN32 not defined=0A= # endif=0A= #endif], [=0A= dnl found windows.h with the current config.=0A= AC_MSG_RESULT([present by default])=0A= ], [=0A= dnl try -mwin32=0A= ac_compile_save=3D"$ac_compile"=0A= dnl we change CC so config.log looks correct=0A= save_CXX=3D"$CXX"=0A= ac_compile=3D"$ac_compile -mwin32"=0A= CXX=3D"$CXX -mwin32"=0A= AC_TRY_COMPILE(,[=0A= #ifndef WIN32=0A= # ifndef _WIN32=0A= # error WIN32 or _WIN32 not defined=0A= # endif=0A= #endif], [=0A= dnl found windows.h using -mwin32=0A= AC_MSG_RESULT([found via -mwin32])=0A= ac_compile=3D"$ac_compile_save"=0A= CXX=3D"$save_CXX"=0A= WIN32FLAGS=3D"-mwin32"=0A= ], [=0A= ac_compile=3D"$ac_compile_save"=0A= CXX=3D"$save_CXX"=0A= AC_MSG_RESULT([not found])=0A= ])=0A= ])=0A= =0A= ])=0A= =0A= =0A= # high level interface for finding out compiler support for win32.=0A= AC_DEFUN([AC_API_WIN32], [=0A= =0A= AC_LANG_CASE(=0A= [C], [AC_PROG_CC_WIN32=0A= CFLAGS=3D"$WIN32FLAGS $CFLAGS"=0A= CPPFLAGS=3D"$WIN32FLAGS $CPPFLAGS"],=0A= [C++], [AC_PROG_CXX_WIN32=0A= CXXFLAGS=3D"$WIN32FLAGS $CXXFLAGS"=0A= CPPFLAGS=3D"$WIN32FLAGS $CPPFLAGS"],=0A= [AC_FATAL([No macro support for WIN32 with ] _AC_LANG) ])=0A= ])=0A= =0A= dnl end compiler WIN32 support = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= ------=_NextPart_000_02FC_01C0B468.D0DBD440 Content-Type: application/octet-stream; name="nowin32.m4" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="nowin32.m4" dnl COMPILER NO WIN32 support = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= # figure out how to run CC without access to the win32 api (if it=0A= # was present).=0A= # configure that as the CC program, =0A= # WIN32 may be present with WINE, under cygwin, or under mingw,=0A= # or cross compilers targeting those same three targets.=0A= # as it happens, I can only test cygwin, so extra input here will=0A= # be appreciated=0A= # send bug reports to Robert Collins =0A= #=0A= # logic: is CC already configured? if not, call AC_PROG_CC.=0A= # if so - try it. If that doesn't work ,try -mno-win32. If that =0A= # doesn't work, fail=0A= #=0A= # 2001-03-24 - NoWIN32 derived from WIN32 Macro. Entries beforethis = refer to=0A= # * the Win32 Macro. It now sets NOWIN32FLAGS for avoiding win32.=0A= # 2001-03-15 - Changed from yes/no to true/false -suggested by Lars J = Aas=0A= # * Change true to : - suggest by Alexandre Oliva = =0A= # * changed layout on the basis of autoconf mailing list:=0A= # there are now two interfaces, a language specific one which sets=0A= # or clears WIN32 && WIN32FLAGS as appropriate=0A= # * m4 Syntax fixup: Akim Demaille =0A= #=0A= # All faults& bugs are mine - Robert=0A= # 1. do we have windows.h? =0A= # yes - does it define WIN32?=0A= # yes - try -mno-win32=0A= # no - nowin32 api.=0A= # no - nowin32 api.=0A= =0A= AC_DEFUN([AC_PROG_CC_NOWIN32], [=0A= AC_REQUIRE([AC_PROG_CC])dnl=0A= AC_MSG_CHECKING([how to avoid the Win32 API])=0A= NOWIN32FLAGS=3D=0A= dnl do we have windows.h ?=0A= AC_TRY_COMPILE([#include ],[], [=0A= dnl does it define WIN32 ?=0A= =0A= AC_TRY_COMPILE([#include ],[=0A= #ifdef WIN32=0A= # error WIN32 defined=0A= #endif=0A= #ifdef _WIN32=0A= # error _WIN32 defined=0A= #endif=0A= ], [=0A= dnl no win32 defined, we're ok=0A= AC_MSG_RESULT([absent by default])=0A= ], [=0A= dnl try -mno-win32 - if the flag is accepted we're ok, even if a = different windows.h is =0A= dnl found.=0A= ac_compile_save=3D"$ac_compile"=0A= dnl we change CC so config.log looks correct=0A= save_CC=3D"$CC"=0A= ac_compile=3D"$ac_compile -mno-win32"=0A= CC=3D"$CC -mno-win32"=0A= AC_TRY_COMPILE(,[=0A= #ifdef WIN32=0A= # error WIN32 defined=0A= #endif=0A= #ifdef _WIN32=0A= # error _WIN32 defined=0A= #endif],[=0A= ac_compile=3D"$ac_compile_save"=0A= CC=3D"$save_CC"=0A= NOWIN32FLAGS=3D"-mno-win32"=0A= AC_MSG_RESULT([avoided via -mno-win32])],[=0A= ac_compile=3D"$ac_compile_save"=0A= CC=3D"$save_CC"=0A= AC_MSG_RESULT([Couldn't turn off the WIN32 API. A new test case is = needed or your compiler always includes the win32 API])] )=0A= ])=0A= ],[=0A= dnl no win32 with the current config.=0A= AC_MSG_RESULT([absent by default])=0A= ])=0A= ])=0A= =0A= # figure out how to run CXX without access to the win32 api if present=0A= # configure that as the CXX program,=0A= # WIN32 may be present with WINE, under cygwin, or under mingw,=0A= # or cross compilers targeting those same three targets.=0A= # as it happens, I can only test cygwin, so extra input here will be = appreciated=0A= # send bug reports to Robert Collins =0A= =0A= AC_DEFUN([AC_PROG_CXX_NOWIN32], [=0A= AC_REQUIRE([AC_PROG_CXX])dnl=0A= AC_MSG_CHECKING([how to avoid the Win32 API])=0A= NOWIN32FLAGS=3D=0A= AC_TRY_COMPILE(,[=0A= #include =0A= #ifdef WIN32=0A= # error WIN32 defined=0A= #endif=0A= #ifdef _WIN32=0A= # error _WIN32 defined=0A= #endif], [=0A= dnl found windows.h with the current config.=0A= AC_MSG_RESULT([abesnt by default])=0A= ], [=0A= dnl try -mno-win32=0A= ac_compile_save=3D"$ac_compile"=0A= dnl we change CC so config.log looks correct=0A= save_CXX=3D"$CXX"=0A= ac_compile=3D"$ac_compile -mno-win32"=0A= CXX=3D"$CXX -mno-win32"=0A= AC_TRY_COMPILE(,[=0A= #include =0A= #ifdef WIN32=0A= # error WIN32 defined=0A= #endif=0A= #ifdef _WIN32=0A= # error _WIN32 not defined=0A= #endif], [=0A= dnl avoided WIN32 using -mno-win32=0A= AC_MSG_RESULT([avoided via -mno-win32])=0A= ac_compile=3D"$ac_compile_save"=0A= CXX=3D"$save_CXX"=0A= NOWIN32FLAGS=3D"-mno-win32"=0A= ], [=0A= ac_compile=3D"$ac_compile_save"=0A= CXX=3D"$save_CXX"=0A= AC_MSG_RESULT([tests failed - inconclusive])=0A= ])=0A= ])=0A= =0A= ])=0A= =0A= =0A= AC_DEFUN([AC_PROG_CXX_NOWIN32], [=0A= AC_REQUIRE([AC_PROG_CXX])dnl=0A= AC_MSG_CHECKING([how to avoid the Win32 API])=0A= NOWIN32FLAGS=3D=0A= dnl do we have windows.h ?=0A= AC_TRY_COMPILE([#include ],[], [=0A= dnl does it define WIN32 ?=0A= =0A= AC_TRY_COMPILE([#include ],[=0A= #ifdef WIN32=0A= # error WIN32 defined=0A= #endif=0A= #ifdef _WIN32=0A= # error _WIN32 defined=0A= #endif=0A= ], [=0A= dnl no win32 defined, we're ok=0A= AC_MSG_RESULT([absent by default])=0A= ], [=0A= dnl try -mno-win32 - if the flag is accepted we're ok, even if a = different windows.h is =0A= dnl found.=0A= ac_compile_save=3D"$ac_compile"=0A= dnl we change CXX so config.log looks correct=0A= save_CXX=3D"$CXX"=0A= ac_compile=3D"$ac_compile -mno-win32"=0A= CXX=3D"$CXX -mno-win32"=0A= AC_TRY_COMPILE(,[=0A= #ifdef WIN32=0A= # error WIN32 defined=0A= #endif=0A= #ifdef _WIN32=0A= # error _WIN32 defined=0A= #endif],[=0A= ac_compile=3D"$ac_compile_save"=0A= CXX=3D"$save_CXX"=0A= NOWIN32FLAGS=3D"-mno-win32"=0A= AC_MSG_RESULT([avoided via -mno-win32])],[=0A= ac_compile=3D"$ac_compile_save"=0A= CXX=3D"$save_CXX"=0A= AC_MSG_RESULT([Couldn't turn off the WIN32 API. A new test case is = needed or your compiler always includes the win32 API])] )=0A= ])=0A= ],[=0A= dnl no win32 with the current config.=0A= AC_MSG_RESULT([absent by default])=0A= ])=0A= ])=0A= =0A= =0A= =0A= # high level interface for avoiding compiler support for win32.=0A= AC_DEFUN([AC_API_NOWIN32], [=0A= =0A= AC_LANG_CASE(=0A= [C], [AC_PROG_CC_NOWIN32=0A= CFLAGS=3D"$NOWIN32FLAGS $CFLAGS"=0A= CPPFLAGS=3D"$NOWIN32FLAGS $CPPFLAGS"],=0A= [C++], [AC_PROG_CXX_NOWIN32=0A= CXXFLAGS=3D"$NOWIN32FLAGS $CXXFLAGS"=0A= CPPFLAGS=3D"$NOWIN32FLAGS $CPPFLAGS"],=0A= [AC_FATAL([No macro support for NOWIN32 with ] _AC_LANG) ])=0A= ])=0A= =0A= dnl end compiler NOWIN32 support = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= ------=_NextPart_000_02FC_01C0B468.D0DBD440--