--- a/main/trunk/CMakeLists.txt
+++ b/main/trunk/CMakeLists.txt
@@ -44,6 +44,7 @@
 include(CheckIncludeFile)
 include(CheckLibraryExists)
 include(CheckFunctionExists)
+include(CheckSymbolExists)
 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/bin)
 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/bin)
 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/bin)
@@ -120,65 +121,90 @@
             -DOOREXX_COPY_YEAR="${ORX_COPY_YEAR}"
             -DORX_SYS_STR="${CMAKE_SYSTEM_NAME}"
             -DORX_CATDIR="${catdir}"
-            -DORX_SHARED_LIBRARY_EXT="${CMAKE_SHARED_LIBRARY_SUFFIX}")
-endif ()
-
-# Check for libraries and functions
-if (WIN32)
-   # TODO: add Windows checks here
-else ()
-   find_library(ORX_SYSLIB_DL dl)
-   find_library(ORX_SYSLIB_PTHREAD pthread)
-   if (${ORX_SYSLIB_PTHREAD})
-      check_function_exists(pthread_mutexattr_settype HAVE_PTHREAD_MUTEXATTR_SETTYPE)
-   endif ()
-   find_library(ORX_SYSLIB_RT rt)
-   if (${ORX_SYSLIB_RT})
-      check_function_exists(nanosleep HAVE_NANOSLEEP)
-   endif ()
-endif ()
-
-# Check header files
-# Std C headers
-check_include_file(stdlib.h HAVE_STDLIB_H)
-check_include_file(stdarg.h HAVE_STDARG_H)
-check_include_file(stddef.h HAVE_STDDEF_H)
-check_include_file(stdio.h HAVE_STDIO_H)
-check_include_file(string.h HAVE_STRING_H)
-check_include_file(float.h HAVE_FLOAT_H)
+            -DORX_SHARED_LIBRARY_EXT="${CMAKE_SHARED_LIBRARY_SUFFIX}"
+            -DLINUX)
+endif ()
+
+
+# Check header files and functions. These are all defined to the config.h file.
+check_include_file(attr/xattr.h HAVE_ATTR_XATTR_H)
+check_function_exists(catopen HAVE_CATOPEN)
 check_include_file(ctype.h HAVE_CTYPE_H)
-check_include_file(locale.h HAVE_LOCAL_H)
-check_include_file(signal.h HAVE_SIGNAL_H)
-check_include_file(time.h HAVE_TIME_H)
-check_include_file(limits.h HAVE_LIMITS_H)
-# Other header files
+check_include_file(dlfcn.h HAVE_DLFCN_H)
 check_include_file(fcntl.h HAVE_FCNTL_H)
 check_include_file(features.h HAVE_FEATURES_H)
 check_include_file(filehdr.h HAVE_FILEHDR_H)
+check_function_exists(fstat HAVE_FSTAT)
+check_function_exists(gcvt HAVE_GCVT)
+check_function_exists(geteuid HAVE_GETEUID)
+check_function_exists(getpgrp HAVE_GETPGRP)
+check_function_exists(getpwuid HAVE_GETPUID)
+check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
+check_function_exists(getuserattr HAVE_GETUSERATTR)
+check_function_exists(IDtouser HAVE_IDTOUSER)
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+check_include_file(float.h HAVE_FLOAT_H)
+find_library(HAVE_LIBPTHREAD pthread)
+find_library(HAVE_LIBRT rt)
+check_include_file(limits.h HAVE_LIMITS_H)
+check_include_file(locale.h HAVE_LOCALE_H)
+check_include_file(malloc.h HAVE_MALLOC_H)
+check_include_file(memory.h HAVE_MEMORY_H)
+check_include_file(memset HAVE_MEMSET)
 check_include_file(mesg.h HAVE_MESG_H)
-check_include_file(malloc.h HAVE_MALLOC_H)
-check_include_file(netinet/in.h HAVE_IN_H)
+check_function_exists(nanosleep HAVE_NANOSLEEP)
+check_include_file(netinet/in.h HAVE_NETINET_IN_H)
 check_include_file(nl_types.h HAVE_NL_TYPES_H)
+check_function_exists(nsleep HAVE_NSLEEP)
 check_include_file(pthread.h HAVE_PTHREAD_H)
+check_function_exists(pthread_mutexattr_settype HAVE_PTHREAD_MUTEXATTR_SETTYPE)
+check_symbol_exists(PTHREAD_MUTEX_ERRORCHECK "pthread.h" HAVEPTHREAD_MUTEX_ERRORCHECK)
+check_symbol_exists(PTHREAD_MUTEX_RECURSIVE "pthread.h" HAVEPTHREAD_MUTEX_RECURSIVE)
+check_symbol_exists(PTHREAD_MUTEX_RECURSIVE_NP "pthread.h" HAVEPTHREAD_MUTEX_RECURSIVE_NP)
 check_include_file(pwd.h HAVE_PWD_H)
 check_include_file(sched.h HAVE_SCHED_H)
+check_function_exists(setlocale HAVE_SETLOCALE)
+check_function_exists(sighold HAVE_SIGHOLD)
+check_include_file(signal.h HAVE_SIGNAL_H)
+check_include_file(stdarg.h HAVE_STDARG_H)
+check_include_file(stddef.h HAVE_STDDEF_H)
+check_include_file(stdint.h HAVE_STDINT_H)
+check_include_file(stdio.h HAVE_STDIO_H)
+check_include_file(stdlib.h HAVE_STDLIB_H)
+check_function_exists(strdup HAVE_STRDUP)
+check_include_file(strings.h HAVE_STRINGS_H)
+check_include_file(string.h HAVE_STRING_H)
 check_include_file(stropts.h HAVE_STROPTS_H)
-check_include_file(sys/filio.h HAVE_FILIO_H)
+check_include_file(sys/filio.h HAVE_SYS_FILIO_H)
 check_include_file(sys/ldr.h HAVE_SYS_LDR_H)
-check_include_file(sys/resource.h HAVE_RESOURCE_H)
-check_include_file(sys/select.h HAVE_SELECT_H)
-check_include_file(sys/sem.h HAVE_SEM_H)
+check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
+check_include_file(sys/select.h HAVE_SYS_SELECT_H)
+check_include_file(sys/sem.h HAVE_SYS_SEM_H)
 check_include_file(sys/signal.h HAVE_SYS_SIGNAL_H)
 check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
+check_include_file(sys/stat.h HAVE_SYS_STAT_H)
+check_include_file(sys/syscall.h HAVE_SYS_SYSCALL_H)
 check_include_file(sys/time.h HAVE_SYS_TIME_H)
+check_include_file(sys/types.h HAVE_SYS_TYPES_H)
 check_include_file(sys/utsname.h HAVE_SYS_UTSNAME_H)
 check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
-check_include_file(sys/syscall.h HAVE_SYS_SYSCALL_H)
+check_include_file(time.h HAVE_TIME_H)
+check_symbol_exists(semun "sys/sem.h" HAVE_UNION_SEMUN)
 check_include_file(unistd.h HAVE_UNISTD_H)
 check_include_file(usersec.h HAVE_USERSEC_H)
-check_include_file(attr/xattr.h HAVE_ATTR_XATTR_H)
+check_function_exists(vprintf HAVE_VPRINTF)
+set (PACKAGE ${PROJECT_NAME})
+set (PACKAGE_BUGREPORT "http://sourceforge.net/projects/oorexx/")
+set (PACKAGE_NAME ${PROJECT_NAME})
+set (PACKAGE_STRING ${PROJECT_NAME})
+set (PACKAGE_TARNAME "ooRexx.tar")
+set (PACKAGE_URL "http://www.oorexx.org/")
+set (PACKAGE_VERSION ${ORX_VER_STR})
+set (STDC_HEADERS 1)
+
 
 # Configure files
+configure_file(config.h.in.cmake config.h)
 # TODO: revisit this section later
 #if (NOT WIN32)
 #   configure_file(platform/unix/oorexx.spec.in platform/unix/oorexx.spec)