diff --git a/block/raw-posix.c b/block/raw-posix.c
index 6b72470..1f61a7f 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -29,7 +29,7 @@
 #include "module.h"
 #include "block/raw-posix-aio.h"

-#ifdef CONFIG_COCOA
+#if defined(__APPLE__) && (__MACH__)
 #include <paths.h>
 #include <sys/param.h>
 #include <IOKit/IOKitLib.h>
@@ -235,7 +235,7 @@ static int raw_open(BlockDriverState *bs, const
char *filename, int flags)
                 bufsize = sectorsize;
         }
 #endif
-#ifdef CONFIG_COCOA
+#if defined(__APPLE__) && defined(__MACH__)
         uint32_t blockSize = 512;
         if ( !ioctl( fd, DKIOCGETBLOCKSIZE, &blockSize ) && blockSize
> bufsize) {
             bufsize = blockSize;
@@ -680,7 +680,7 @@ again:
         }
         if (size == 0)
 #endif
-#ifdef CONFIG_COCOA
+#if defined(__APPLE__) && defined(__MACH__)
         size = LONG_LONG_MAX;
 #else
         size = lseek(fd, 0LL, SEEK_END);
@@ -820,7 +820,7 @@ static BlockDriver bdrv_file = {
 /***********************************************/
 /* host device */

-#ifdef CONFIG_COCOA
+#if defined(__APPLE__) && defined(__MACH__)
 static kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator );
 static kern_return_t GetBSDPath( io_iterator_t mediaIterator, char
*bsdPath, CFIndex maxPathSize );

@@ -898,7 +898,7 @@ static int hdev_open(BlockDriverState *bs, const
char *filename, int flags)
 {
     BDRVRawState *s = bs->opaque;

-#ifdef CONFIG_COCOA
+#if defined(__APPLE__) && defined(__MACH__)
     if (strstart(filename, "/dev/cdrom", NULL)) {
         kern_return_t kernResult;
         io_iterator_t mediaIterator;
diff --git a/configure b/configure
index d7dba5d..6a5864f 100755
--- a/configure
+++ b/configure
@@ -635,6 +635,8 @@ for opt do
   ;;
   --enable-profiler) profiler="yes"
   ;;
+  --disable-cocoa) cocoa="no"
+  ;;
   --enable-cocoa)
       cocoa="yes" ;
       sdl="no" ;
@@ -932,6 +934,7 @@ echo "  --disable-sdl            disable SDL"
 echo "  --enable-sdl             enable SDL"
 echo "  --disable-vnc            disable VNC"
 echo "  --enable-vnc             enable VNC"
+echo "  --disable-cocoa          disable COCOA"
 echo "  --enable-cocoa           enable COCOA (Mac OS X only)"
 echo "  --audio-drv-list=LIST    set audio drivers list:"
 echo "                           Available drivers: $audio_possible_drivers"
