Fix MacOSX build improving configure checks and using right linker flag

By comparing the "pyconfig.h" configured by CMake and the one generated
building python using Autoconf. It turns out that the hardcoded value
that were working for my Ubuntu 10.04 (gcc 4.4.3) were not sufficient
and more check were required.

The following checks are now performed so that "pyconfig.h.in" can
be configured adequately:

* Check for additional header files and set the following variables:
   HAVE_LINUX_TIPC_H
   HAVE_SYS_EPOLL_H
   HAVE_SYS_EVENT_H
   HAVE_UTIL_H

* Check for presence of "crypt" and "nsl" library and set the following
variables accordingly:
   HAVE_LIBCRYPT
   HAVE_LIBNSL

* Extend list "CFG_HEADERS" to check for presence of the following
symbols:
   epoll
   getresgid
   getresuid
   kqueue
   lchmod

* Check for availability of "struct tm" and set TM_IN_SYS_TIME

* Add compile and run test to set the following variables:
 POSIX_SEMAPHORES_NOT_ENABLED
 HAVE_BROKEN_SEM_GETVALUE

* Add compile test to set the variable: HAVE_OSX105_SDK

* HAVE_LARGEFILE_SUPPORT is now set conditionally using value of
SIZEOF_OFF_T, SIZEOF_LONG and SIZEOF_LONG_LONG.


Also review how _BSD_SOURCE, _XOPEN_SOURCE, _XOPEN_SOURCE_EXTENDED
and _POSIX_C_SOURCE were set. On MacOSX, these variable have to be set
conditionally.

Note that it is by comparing both "pyconfig.h" file (CMake generated
and Autoconf generated) and looking at "configure.in" file that these
changes were implemented.


Since extension are compiled before the python library itself, the linker
flag "-undefined,dynamic_lookup" has been associated with each extension
target.

TODO: Build of ctype has been simply disabled on MacOSX. Some work is needed
to figure out which files need to be compiled together.

HACK: Added "-undefined,dynamic_lookup" when building python library
because of undefined symbols "_setresgid" and "_setresuid". Comparing
both pyconfig.h, macro HAVE_SETRESGID and HAVE_SETRESUID are set differently.
This will have to be investigated.
Shut up compile warnings related deprecated/unused
Move python_platform macros and add support for REQUIRED vars.

Add CMake code allowing to consider the variables:
  CMAKE_REQUIRED_LIBRARIES
  CMAKE_REQUIRED_INCLUDES
  CMAKE_REQUIRED_DEFINITIONS
  CMAKE_REQUIRED_FLAGS

The corresponding code has been copied from existing
macros CHECK_C_SOURCE_COMPILES/RUNS provided by CMake itself.

By ensuring our macros consider these variables, more "configure test"
will be passing when expected.
Add configure test for HAVE_BROKEN_UNSETENV
Tweak test associated with HAVE_LIBIEEE and find library only if needed
Tweak HAVE_LIBRESOLV test and find the library only if needed
Fix style of HAVE_BROKEN_{POSIX_SEMAPHORES/PTHREAD_SIGMASK} cmakedefine
Fix test associated with HAVE_EPOLL by checking for the correct function.
Fix POSIX_SEMAPHORES_NOT_ENABLED and HAVE_BROKEN_SEM_GETVALUE test

The double quote were not escaped and the check state was poped to early
which was preventing the threading library from being associated
with the test.
Tweak test associated with thread and set _REENTRANT when appropriate.