MESSAGE ("-- Creating config.h")

INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckCXXSymbolExists.cmake)

CHECK_INCLUDE_FILE("sys/statfs.h" HAVE_SYS_STATFS_H)
CHECK_INCLUDE_FILE("sys/statvfs.h" HAVE_SYS_STATVFS_H)
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILE("sys/swap.h" HAVE_SYS_SWAP_H)
CHECK_INCLUDE_FILE("sys/sysctl.h" HAVE_SYS_SYSCTL_H)
CHECK_INCLUDE_FILE("sys/systeminfo.h" HAVE_SYS_SYSTEMINFO_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/un.h" HAVE_SYS_UN_H)
CHECK_INCLUDE_FILE("sys/utsname.h" HAVE_SYS_UTSNAME_H)
CHECK_INCLUDE_FILE("sys/wait.h" HAVE_SYS_WAIT_H)
CHECK_INCLUDE_FILE("dirent.h" HAVE_DIRENT_H)
CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H)
CHECK_INCLUDE_FILE("fcntl.h" HAVE_FCNTL_H)
CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
CHECK_INCLUDE_FILE("ndir.h" HAVE_NDIR_H)
CHECK_INCLUDE_FILE("netdb.h" HAVE_NETDB_H)
CHECK_INCLUDE_FILE("netinet/ether.h" HAVE_NETINET_ETHER_H)
CHECK_INCLUDE_FILE("netinet/if_ether.h" HAVE_NETINET_IF_ETHER_H)
CHECK_INCLUDE_FILE("netinet/in.h" HAVE_NETINET_IN_H)
CHECK_INCLUDE_FILE("netinet/tcp.h" HAVE_NETINET_TCP_H)
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
CHECK_INCLUDE_FILE("utmp.h" HAVE_UTMP_H)
CHECK_INCLUDE_FILE("setjmp.h" HAVE_SETJMP_H)
CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
CHECK_INCLUDE_FILE("windows.h" HAVE_WINDOWS_H)
CHECK_INCLUDE_FILE("winsock2.h" HAVE_WINSOCK2_H)
CHECK_INCLUDE_FILE("winsock.h" HAVE_WINSOCK_H)
CHECK_INCLUDE_FILE("glaux.h" HAVE_GLAUX_H)
CHECK_INCLUDE_FILE("GLUT/glut.h" HAVE_GLUT_GLUT_H)
CHECK_INCLUDE_FILE("glut.h" HAVE_GLUT_H)
CHECK_INCLUDE_FILE("glu.h" HAVE_GLU_H)
CHECK_INCLUDE_FILE("GL/glaux.h" HAVE_GL_GLAUX_H)
CHECK_INCLUDE_FILE("GL/glut.h" HAVE_GL_GLUT_H)
CHECK_INCLUDE_FILE("GL/glu.h" HAVE_GL_GLU_H)
CHECK_INCLUDE_FILE("GL/gl.h" HAVE_GL_GL_H)
CHECK_INCLUDE_FILE("gl.h" HAVE_GL_H)
CHECK_INCLUDE_FILE("grp.h" HAVE_GRP_H)
CHECK_INCLUDE_FILE("gtk/gtk.h" HAVE_GTK_GTK_H)
CHECK_INCLUDE_FILE("ieeefp.h" HAVE_IEEEFP_H)
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE("MesaGL/glaux.h" HAVE_MESAGL_GLAUX_H)
CHECK_INCLUDE_FILE("MesaGL/glut.h" HAVE_MESAGL_GLUT_H)
CHECK_INCLUDE_FILE("MesaGL/glu.h" HAVE_MESAGL_GLU_H)
CHECK_INCLUDE_FILE("MesaGL/gl.h" HAVE_MESAGL_GL_H)
CHECK_INCLUDE_FILE("OpenGL/glaux.h" HAVE_OPENGL_GLAUX_H)
CHECK_INCLUDE_FILE("OpenGL/glut.h" HAVE_OPENGL_GLUT_H)
CHECK_INCLUDE_FILE("OpenGL/glu.h" HAVE_OPENGL_GLU_H)
CHECK_INCLUDE_FILE("OpenGL/gl.h" HAVE_OPENGL_GL_H)
CHECK_INCLUDE_FILE("procfs.h" HAVE_PROCFS_H)
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
CHECK_INCLUDE_FILE("sys/auxv.h" HAVE_SYS_AUXV_H)
CHECK_INCLUDE_FILE("sys/fcntl.h" HAVE_SYS_FCNTL_H)
CHECK_INCLUDE_FILE("sys/file.h" HAVE_SYS_FILE_H)
CHECK_INCLUDE_FILE("sys/ioctl.h" HAVE_SYS_IOCTL_H)
CHECK_INCLUDE_FILE("sys/ipc.h" HAVE_SYS_IPC_H)
CHECK_INCLUDE_FILE("sys/mount.h" HAVE_SYS_MOUNT_H)
CHECK_INCLUDE_FILE("sys/msg.h" HAVE_SYS_MSG_H)
CHECK_INCLUDE_FILE("sys/param.h" HAVE_SYS_PARAM_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/sensors.h" HAVE_SYS_SENSORS_H)
CHECK_INCLUDE_FILE("sys/shm.h" HAVE_SYS_SHM_H)
CHECK_INCLUDE_FILE("sys/socket.h" HAVE_SYS_SOCKET_H)
CHECK_INCLUDE_FILE("sys/sockio.h" HAVE_SYS_SOCKIO_H)
CHECK_INCLUDE_FILE("libnotify/notify.h" HAVE_LIBNOTIFY_NOTIFY_H)
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
CHECK_INCLUDE_FILE("xlocale.h" HAVE_XLOCALE_H)
CHECK_INCLUDE_FILE("arpa/inet.h" HAVE_ARPA_INET_H)
CHECK_INCLUDE_FILE("ntapi.h" HAVE_NTAPI_H)
CHECK_INCLUDE_FILE("ddk/ntapi.h" HAVE_DDK_NTAPI_H)
CHECK_INCLUDE_FILE("ntdef.h" HAVE_NTDEF_H)

CHECK_FUNCTION_EXISTS("unsetenv" HAVE_UNSETENV)
CHECK_FUNCTION_EXISTS("strcasecmp" HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS("strcasestr" HAVE_STRCASESTR)
CHECK_FUNCTION_EXISTS("strdup" HAVE_STRDUP)
CHECK_FUNCTION_EXISTS("strdupa" HAVE_STRDUPA)
CHECK_FUNCTION_EXISTS("putenv" HAVE_PUTENV)
CHECK_FUNCTION_EXISTS("res_init" HAVE_RES_INIT)
CHECK_FUNCTION_EXISTS("sched_setscheduler" HAVE_SCHED_SETSCHEDULER)
CHECK_FUNCTION_EXISTS("setenv" HAVE_SETENV)
CHECK_FUNCTION_EXISTS("setpriority" HAVE_SETPRIORITY)
CHECK_FUNCTION_EXISTS("setutent" HAVE_SETUTENT)
CHECK_FUNCTION_EXISTS("sigaction" HAVE_SIGACTION)
CHECK_FUNCTION_EXISTS("strlcat" HAVE_STRLCAT)
CHECK_FUNCTION_EXISTS("strlcpy" HAVE_STRLCPY)
CHECK_FUNCTION_EXISTS("strtoull" HAVE_STRTOULL)
CHECK_FUNCTION_EXISTS("ether_ntoa" HAVE_ETHER_NTOA)
CHECK_FUNCTION_EXISTS("getisax" HAVE_GETISAX)
CHECK_FUNCTION_EXISTS("getutent" HAVE_GETUTENT)
CHECK_FUNCTION_EXISTS("sqlite3_open" HAVE_SQLITE3_OPEN)
CHECK_FUNCTION_EXISTS("stat64" HAVE_STAT64)
CHECK_FUNCTION_EXISTS("vprintf" HAVE_VPRINTF)
CHECK_FUNCTION_EXISTS("daemon" HAVE_DAEMON)

if(${HAVE_NTAPI_H})
  CHECK_TYPE_SIZE_EX("CLIENT_ID" "ntapi.h" CLIENT_ID) #struct
  CHECK_TYPE_SIZE_EX("VM_COUNTERS" "ntapi.h" VM_COUNTERS) #struct
  CHECK_TYPE_SIZE_EX("SYSTEM_THREADS" "ntapi.h" SYSTEM_THREADS) #struct
  CHECK_TYPE_SIZE_EX("SYSTEM_PROCESSES" "ntapi.h" SYSTEM_PROCESSES) #struct
  CHECK_TYPE_SIZE_EX("THREAD_STATE" "ntapi.h" THREAD_STATE) #enum
  CHECK_TYPE_SIZE_EX("THREAD_WAIT_REASON" "ntapi.h" THREAD_WAIT_REASON) #enum
elseif(${HAVE_DDK_NTAPI_H})
  CHECK_TYPE_SIZE_EX("CLIENT_ID" "ddk/ntapi.h" CLIENT_ID) #struct
  CHECK_TYPE_SIZE_EX("VM_COUNTERS" "ddk/ntapi.h" VM_COUNTERS) #struct
  CHECK_TYPE_SIZE_EX("SYSTEM_THREADS" "ddk/ntapi.h" SYSTEM_THREADS) #struct
  CHECK_TYPE_SIZE_EX("SYSTEM_PROCESSES" "ddk/ntapi.h" SYSTEM_PROCESSES) #struct
  CHECK_TYPE_SIZE_EX("THREAD_STATE" "ddk/ntapi.h" THREAD_STATE) #enum
  CHECK_TYPE_SIZE_EX("THREAD_WAIT_REASON" "ddk/ntapi.h" THREAD_WAIT_REASON) #enum
else()
  set(HAVE_CLIENT_ID 0)
  set(HAVE_VM_COUNTERS 0)
  set(HAVE_SYSTEM_THREADS 0)
  set(HAVE_SYSTEM_PROCESSES 0)
  set(HAVE_THREAD_STATE 0)
  set(HAVE_THREAD_WAIT_REASON 0)
endif()

configure_file("${PROJECT_SOURCE_DIR}/modules/config.h.in"
               "${PROJECT_SOURCE_DIR}/src/config.h" )
list(APPEND ADDITIONAL_MAKE_CLEAN_FILES_LIST "${PROJECT_SOURCE_DIR}/src/config.h")
               
include_directories(${PROJECT_SOURCE_DIR}/src)