issue5545: Switch to Autoconf for multiprocessing; special thanks to Martin Lowis for help
diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c
index 48049c7..9008f31 100644
--- a/Modules/_multiprocessing/multiprocessing.c
+++ b/Modules/_multiprocessing/multiprocessing.c
@@ -8,6 +8,12 @@
 
 #include "multiprocessing.h"
 
+#ifdef SCM_RIGHTS
+	#define HAVE_FD_TRANSFER 1
+#else
+	#define HAVE_FD_TRANSFER 0
+#endif
+
 PyObject *create_win32_namespace(void);
 
 PyObject *pickle_dumps, *pickle_loads, *pickle_protocol;
@@ -244,7 +250,7 @@
 	Py_INCREF(&ConnectionType);	
 	PyModule_AddObject(module, "Connection", (PyObject*)&ConnectionType);
 
-#if defined(MS_WINDOWS) || HAVE_SEM_OPEN
+#if defined(MS_WINDOWS) || defined(HAVE_SEM_OPEN)
 	/* Add SemLock type to module */
 	if (PyType_Ready(&SemLockType) < 0)
 		return;
diff --git a/Modules/_multiprocessing/multiprocessing.h b/Modules/_multiprocessing/multiprocessing.h
index 4f4f9d7..f6ab994 100644
--- a/Modules/_multiprocessing/multiprocessing.h
+++ b/Modules/_multiprocessing/multiprocessing.h
@@ -27,7 +27,7 @@
 #  include <sys/socket.h>
 #  include <sys/uio.h>
 #  include <arpa/inet.h>             /* htonl() and ntohl() */
-#  if HAVE_SEM_OPEN
+#  ifdef HAVE_SEM_OPEN
 #    include <semaphore.h>
      typedef sem_t *SEM_HANDLE;
 #  endif
diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c
index 2c2fb10f..d282b77 100644
--- a/Modules/_multiprocessing/semaphore.c
+++ b/Modules/_multiprocessing/semaphore.c
@@ -197,11 +197,11 @@
 #define SEM_GETVALUE(sem, pval) sem_getvalue(sem, pval)
 #define SEM_UNLINK(name) sem_unlink(name)
 
-#if HAVE_BROKEN_SEM_UNLINK
+#ifndef HAVE_SEM_UNLINK
 #  define sem_unlink(name) 0
 #endif
 
-#if !HAVE_SEM_TIMEDWAIT
+#ifndef HAVE_SEM_TIMEDWAIT
 #  define sem_timedwait(sem,deadline) sem_timedwait_save(sem,deadline,_save)
 
 int
@@ -348,7 +348,7 @@
 		}
 		assert(self->count == 1);
 	} else {
-#if HAVE_BROKEN_SEM_GETVALUE
+#ifdef HAVE_BROKEN_SEM_GETVALUE
 		/* We will only check properly the maxvalue == 1 case */
 		if (self->maxvalue == 1) {
 			/* make sure that already locked */
@@ -494,7 +494,7 @@
 static PyObject *
 semlock_getvalue(SemLockObject *self)
 {
-#if HAVE_BROKEN_SEM_GETVALUE
+#ifdef HAVE_BROKEN_SEM_GETVALUE
 	PyErr_SetNone(PyExc_NotImplementedError);
 	return NULL;
 #else
@@ -512,7 +512,7 @@
 static PyObject *
 semlock_iszero(SemLockObject *self)
 {
-#if HAVE_BROKEN_SEM_GETVALUE
+#ifdef HAVE_BROKEN_SEM_GETVALUE
 	if (sem_trywait(self->handle) < 0) {
 		if (errno == EAGAIN)
 			Py_RETURN_TRUE;