Mail Archives: cygwin-apps/2001/03/14/09:17:06
This is a multi-part message in MIME format.
------=_NextPart_000_0351_01C0ACED.6DEBA400
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
I've put together a autoconf macro to configure CC to include the Win32
API, if it is available. I've only put in the methods _I know of and can
test_, more fallback tests are welcome.
Sample code to use it in configure.in, when the program _needs_ the
win32 API:
AC_CANONICAL_HOST
case "${host}" in
*-*-cygwin*)
AC_PROG_CC_WIN32
test "$ac_cc_win32" = "no" && { echo "configure: error: Win32
API needed and no ac
ceptable cc could be found" 1>&2; exit 1; }
;;
esac
It sets ac_cc_win32 to yes or no as appropriate, so test writers in
configure.in can do an AC_SUBST or AC_DEFINE and switch off bits of
their code, or do as above, and fail the configure script.
It's my first foray into m4 beyond being a bare bones configure.in
tweaker, so if I'm breaking coding rules etc just let me know and I'll
go fix it up.
This test should allow existing programs that build under the Cygwin net
release gcc-2.95.2-6 or before (current release) or under the new
gcc-2.95.2-9 which no longer has the Win32 API by default.
If this looks ok I'll submit it to the autoconf macro archive..
Rob
------=_NextPart_000_0351_01C0ACED.6DEBA400
Content-Type: application/octet-stream;
name="acinclude.m4"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="acinclude.m4"
AC_DEFUN(AC_PROG_CC_WIN32, [=0A=
dnl figure out how to run CC with access to the win32 api if present=0A=
dnl configure that as the CC program, and set ac_cc_win32 to yes if found=0A=
dnl or no if not found. We don't simply abort because=0A=
dnl some folk may just want to test their environment and fallback with =
#defines=0A=
dnl in their code.=0A=
dnl WIN32 may be present with WINE, under cygwin, or under mingw,=0A=
dnl or cross compilers targeting those same three targets.=0A=
dnl as it happens, I can only test cygwin, so extra input here will be =
appreciated=0A=
dnl send bug reports to Robert Collins <rbtcollins AT hotmail DOT com>=0A=
=0A=
dnl logic: is CC already configured? if not, call AC_PROG_CC.=0A=
dnl if so - try it. If that doesn't work ,try -mwin32. If that doesn't =
work, fail=0A=
AC_REQUIRE([AC_PROG_CC])=0A=
echo $ECHO_N "checking how to access the Win32 API..." >&6=0A=
AC_TRY_CPP([#include <windows.h>], [=0A=
dnl found windows.h with the current config.=0A=
echo "${ECHO_T}Win32 API found by default" >&6=0A=
ac_cc_win32=3Dyes=0A=
], [=0A=
dnl try -mwin32=0A=
save_cpp=3D"$ac_cpp"=0A=
ac_cpp=3D"$ac_cpp -mwin32"=0A=
AC_TRY_CPP([#include <windows.h>], [=0A=
dnl found windows.h using -mwin32=0A=
echo "${ECHO_T}Win32 API found via -mwin32" >&6=0A=
ac_cc_win32=3Dyes=0A=
ac_compile=3D"$ac_compile -mwin32"=0A=
ac_link=3D"$ac_link -mwin32"=0A=
CC=3D"$CC -mwin32"=0A=
], [=0A=
ac_cc_win32=3Dno=0A=
ac_cpp=3D"$save_cpp"=0A=
echo "${ECHO_T}Win32 API Not found" >&6=0A=
])=0A=
])=0A=
=0A=
AC_PROVIDE([$0])=0A=
])=0A=
------=_NextPart_000_0351_01C0ACED.6DEBA400--
- Raw text -