summary refs log tree commit diff stats
path: root/tools
diff options
context:
space:
mode:
authorAndreas Rumpf <ar@kimeta.de>2014-04-10 01:47:20 +0200
committerAndreas Rumpf <ar@kimeta.de>2014-04-10 01:47:20 +0200
commitdcfc7a8896166563f6fd80fbab81bc50e0b5a217 (patch)
tree4a247ec2d64bafec53e5ab24b0fda89642908a07 /tools
parenta86c774932afd8b6782df1925837df9df04ef381 (diff)
parent8b82004359b8d852fa0107d79cc78b21eb35c028 (diff)
downloadNim-dcfc7a8896166563f6fd80fbab81bc50e0b5a217.tar.gz
resolved conflict
Diffstat (limited to 'tools')
-rw-r--r--tools/cmerge.nim4
-rw-r--r--tools/detect/detect.nim23
-rw-r--r--tools/detect/linux_amd64_consts.nim631
-rw-r--r--tools/detect/macosx_consts.nim629
-rw-r--r--tools/detect/windows_amd64_consts.nim152
-rw-r--r--tools/detect/windows_i386_consts.nim96
-rw-r--r--tools/nimgrep.nim8
-rw-r--r--tools/niminst/buildbat.tmpl2
-rw-r--r--tools/niminst/buildsh.tmpl2
-rw-r--r--tools/niminst/debcreation.nim2
-rw-r--r--tools/niminst/deinstall.tmpl2
-rw-r--r--tools/niminst/inno.tmpl2
-rw-r--r--tools/niminst/install.tmpl2
-rw-r--r--tools/niminst/niminst.nim24
-rw-r--r--tools/nimweb.nim69
-rw-r--r--tools/website.tmpl12
16 files changed, 1607 insertions, 53 deletions
diff --git a/tools/cmerge.nim b/tools/cmerge.nim
index ca221014f..003b0e555 100644
--- a/tools/cmerge.nim
+++ b/tools/cmerge.nim
@@ -34,7 +34,7 @@ proc main(dir, outfile: string) =
   else:
     quit("Cannot open for writing: " & outfile)
 
-if ParamCount() != 2:
+if paramCount() != 2:
   quit "Usage: cmerge directory outfile"
 else:
-  main(ParamStr(1), addFileExt(ParamStr(2), "c"))
+  main(paramStr(1), addFileExt(paramStr(2), "c"))
diff --git a/tools/detect/detect.nim b/tools/detect/detect.nim
index cf61c2823..87b682ad5 100644
--- a/tools/detect/detect.nim
+++ b/tools/detect/detect.nim
@@ -10,7 +10,7 @@
 import os, strutils
 
 const
-  cc = "gcc -o $1 $1.c"
+  cc = "gcc -o $# $#.c"
 
   cfile = """
 /* Generated by detect.nim */
@@ -37,6 +37,7 @@ var
   tl = ""
 
 proc myExec(cmd: string): bool = 
+  echo "CMD ", cmd
   return execShellCmd(cmd) == 0
 
 proc header(s: string): bool = 
@@ -46,7 +47,7 @@ proc header(s: string): bool =
     f.write("#include $1\n" % s)
     f.write("int main() { return 0; }\n")
     close(f)
-    result = myExec(cc % testh)
+    result = myExec(cc % [testh.addFileExt(ExeExt), testh])
     removeFile(addFileExt(testh, "c"))
   if result:
     addf(hd, "#include $1\n", s)
@@ -60,13 +61,16 @@ proc main =
   if open(f, addFileExt(gen, "c"), fmWrite): 
     f.write(cfile % [hd, tl, system.hostOS, system.hostCPU])
     close(f)
-  if not myExec(cc % gen): quit(1)
-  if not myExec("./" & gen): quit(1)
-  removeFile(addFileExt(gen, "c"))
+  if not myExec(cc % [gen.addFileExt(ExeExt), gen]): quit(1)
+  when defined(windows):
+    if not myExec(gen.addFileExt(ExeExt)): quit(1)
+  else:
+    if not myExec("./" & gen): quit(1)
+  #removeFile(addFileExt(gen, "c"))
   echo("Success")
 
 proc v(name: string, typ: TTypeKind=cint) = 
-  var n = if name[0] == '_': copy(name, 1) else: name
+  var n = if name[0] == '_': substr(name, 1) else: name
   var t = $typ
   case typ
   of pointer: 
@@ -369,7 +373,7 @@ if header("<pthread.h>"):
   #v("PTHREAD_MUTEX_INITIALIZER") 
   v("PTHREAD_MUTEX_NORMAL") 
   v("PTHREAD_MUTEX_RECURSIVE") #{.importc, header: "<pthread.h>".}: cint
-  v("PTHREAD_ONCE_INIT") #{.importc, header: "<pthread.h>".}: cint
+  #v("PTHREAD_ONCE_INIT") #{.importc, header: "<pthread.h>".}: cint
   v("PTHREAD_PRIO_INHERIT") #{.importc, header: "<pthread.h>".}: cint
   v("PTHREAD_PRIO_NONE") #{.importc, header: "<pthread.h>".}: cint
   v("PTHREAD_PRIO_PROTECT") #{.importc, header: "<pthread.h>".}: cint
@@ -820,5 +824,8 @@ if header("<spawn.h>"):
   v("POSIX_SPAWN_SETSIGDEF")
   v("POSIX_SPAWN_SETSIGMASK")
 
-main()
+if header("<stdio.h>"):
+  v "_IOFBF"
+  v "_IONBF"
 
+main()
diff --git a/tools/detect/linux_amd64_consts.nim b/tools/detect/linux_amd64_consts.nim
new file mode 100644
index 000000000..eb85da045
--- /dev/null
+++ b/tools/detect/linux_amd64_consts.nim
@@ -0,0 +1,631 @@
+# Generated by detect.nim
+const
+  AIO_ALLDONE* = cint(2)
+  AIO_CANCELED* = cint(0)
+  AIO_NOTCANCELED* = cint(1)
+  LIO_NOP* = cint(2)
+  LIO_NOWAIT* = cint(1)
+  LIO_READ* = cint(0)
+  LIO_WAIT* = cint(0)
+  LIO_WRITE* = cint(1)
+  RTLD_LAZY* = cint(1)
+  RTLD_NOW* = cint(2)
+  RTLD_GLOBAL* = cint(256)
+  RTLD_LOCAL* = cint(0)
+  E2BIG* = cint(7)
+  EACCES* = cint(13)
+  EADDRINUSE* = cint(98)
+  EADDRNOTAVAIL* = cint(99)
+  EAFNOSUPPORT* = cint(97)
+  EAGAIN* = cint(11)
+  EALREADY* = cint(114)
+  EBADF* = cint(9)
+  EBADMSG* = cint(74)
+  EBUSY* = cint(16)
+  ECANCELED* = cint(125)
+  ECHILD* = cint(10)
+  ECONNABORTED* = cint(103)
+  ECONNREFUSED* = cint(111)
+  ECONNRESET* = cint(104)
+  EDEADLK* = cint(35)
+  EDESTADDRREQ* = cint(89)
+  EDOM* = cint(33)
+  EDQUOT* = cint(122)
+  EEXIST* = cint(17)
+  EFAULT* = cint(14)
+  EFBIG* = cint(27)
+  EHOSTUNREACH* = cint(113)
+  EIDRM* = cint(43)
+  EILSEQ* = cint(84)
+  EINPROGRESS* = cint(115)
+  EINTR* = cint(4)
+  EINVAL* = cint(22)
+  EIO* = cint(5)
+  EISCONN* = cint(106)
+  EISDIR* = cint(21)
+  ELOOP* = cint(40)
+  EMFILE* = cint(24)
+  EMLINK* = cint(31)
+  EMSGSIZE* = cint(90)
+  EMULTIHOP* = cint(72)
+  ENAMETOOLONG* = cint(36)
+  ENETDOWN* = cint(100)
+  ENETRESET* = cint(102)
+  ENETUNREACH* = cint(101)
+  ENFILE* = cint(23)
+  ENOBUFS* = cint(105)
+  ENODATA* = cint(61)
+  ENODEV* = cint(19)
+  ENOENT* = cint(2)
+  ENOEXEC* = cint(8)
+  ENOLCK* = cint(37)
+  ENOLINK* = cint(67)
+  ENOMEM* = cint(12)
+  ENOMSG* = cint(42)
+  ENOPROTOOPT* = cint(92)
+  ENOSPC* = cint(28)
+  ENOSR* = cint(63)
+  ENOSTR* = cint(60)
+  ENOSYS* = cint(38)
+  ENOTCONN* = cint(107)
+  ENOTDIR* = cint(20)
+  ENOTEMPTY* = cint(39)
+  ENOTSOCK* = cint(88)
+  ENOTSUP* = cint(95)
+  ENOTTY* = cint(25)
+  ENXIO* = cint(6)
+  EOPNOTSUPP* = cint(95)
+  EOVERFLOW* = cint(75)
+  EPERM* = cint(1)
+  EPIPE* = cint(32)
+  EPROTO* = cint(71)
+  EPROTONOSUPPORT* = cint(93)
+  EPROTOTYPE* = cint(91)
+  ERANGE* = cint(34)
+  EROFS* = cint(30)
+  ESPIPE* = cint(29)
+  ESRCH* = cint(3)
+  ESTALE* = cint(116)
+  ETIME* = cint(62)
+  ETIMEDOUT* = cint(110)
+  ETXTBSY* = cint(26)
+  EWOULDBLOCK* = cint(11)
+  EXDEV* = cint(18)
+  F_DUPFD* = cint(0)
+  F_GETFD* = cint(1)
+  F_SETFD* = cint(2)
+  F_GETFL* = cint(3)
+  F_SETFL* = cint(4)
+  F_GETLK* = cint(5)
+  F_SETLK* = cint(6)
+  F_SETLKW* = cint(7)
+  F_GETOWN* = cint(9)
+  F_SETOWN* = cint(8)
+  FD_CLOEXEC* = cint(1)
+  F_RDLCK* = cint(0)
+  F_UNLCK* = cint(2)
+  F_WRLCK* = cint(1)
+  O_CREAT* = cint(64)
+  O_EXCL* = cint(128)
+  O_NOCTTY* = cint(256)
+  O_TRUNC* = cint(512)
+  O_APPEND* = cint(1024)
+  O_DSYNC* = cint(4096)
+  O_NONBLOCK* = cint(2048)
+  O_RSYNC* = cint(1052672)
+  O_SYNC* = cint(1052672)
+  O_ACCMODE* = cint(3)
+  O_RDONLY* = cint(0)
+  O_RDWR* = cint(2)
+  O_WRONLY* = cint(1)
+  POSIX_FADV_NORMAL* = cint(0)
+  POSIX_FADV_SEQUENTIAL* = cint(2)
+  POSIX_FADV_RANDOM* = cint(1)
+  POSIX_FADV_WILLNEED* = cint(3)
+  POSIX_FADV_DONTNEED* = cint(4)
+  POSIX_FADV_NOREUSE* = cint(5)
+  FE_DIVBYZERO* = cint(4)
+  FE_INEXACT* = cint(32)
+  FE_INVALID* = cint(1)
+  FE_OVERFLOW* = cint(8)
+  FE_UNDERFLOW* = cint(16)
+  FE_ALL_EXCEPT* = cint(61)
+  FE_DOWNWARD* = cint(1024)
+  FE_TONEAREST* = cint(0)
+  FE_TOWARDZERO* = cint(3072)
+  FE_UPWARD* = cint(2048)
+  FE_DFL_ENV* = cast[pointer](0xffffffffffffffff)
+  MM_HARD* = cint(1)
+  MM_SOFT* = cint(2)
+  MM_FIRM* = cint(4)
+  MM_APPL* = cint(8)
+  MM_UTIL* = cint(16)
+  MM_OPSYS* = cint(32)
+  MM_RECOVER* = cint(64)
+  MM_NRECOV* = cint(128)
+  MM_HALT* = cint(1)
+  MM_ERROR* = cint(2)
+  MM_WARNING* = cint(3)
+  MM_INFO* = cint(4)
+  MM_NOSEV* = cint(0)
+  MM_PRINT* = cint(256)
+  MM_CONSOLE* = cint(512)
+  MM_OK* = cint(0)
+  MM_NOTOK* = cint(-1)
+  MM_NOMSG* = cint(1)
+  MM_NOCON* = cint(4)
+  FNM_NOMATCH* = cint(1)
+  FNM_PATHNAME* = cint(1)
+  FNM_PERIOD* = cint(4)
+  FNM_NOESCAPE* = cint(2)
+  FTW_F* = cint(0)
+  FTW_D* = cint(1)
+  FTW_DNR* = cint(2)
+  FTW_NS* = cint(3)
+  FTW_SL* = cint(4)
+  GLOB_APPEND* = cint(32)
+  GLOB_DOOFFS* = cint(8)
+  GLOB_ERR* = cint(1)
+  GLOB_MARK* = cint(2)
+  GLOB_NOCHECK* = cint(16)
+  GLOB_NOESCAPE* = cint(64)
+  GLOB_NOSORT* = cint(4)
+  GLOB_ABORTED* = cint(2)
+  GLOB_NOMATCH* = cint(3)
+  GLOB_NOSPACE* = cint(1)
+  GLOB_NOSYS* = cint(4)
+  CODESET* = cint(14)
+  D_T_FMT* = cint(131112)
+  D_FMT* = cint(131113)
+  T_FMT* = cint(131114)
+  T_FMT_AMPM* = cint(131115)
+  AM_STR* = cint(131110)
+  PM_STR* = cint(131111)
+  DAY_1* = cint(131079)
+  DAY_2* = cint(131080)
+  DAY_3* = cint(131081)
+  DAY_4* = cint(131082)
+  DAY_5* = cint(131083)
+  DAY_6* = cint(131084)
+  DAY_7* = cint(131085)
+  ABDAY_1* = cint(131072)
+  ABDAY_2* = cint(131073)
+  ABDAY_3* = cint(131074)
+  ABDAY_4* = cint(131075)
+  ABDAY_5* = cint(131076)
+  ABDAY_6* = cint(131077)
+  ABDAY_7* = cint(131078)
+  MON_1* = cint(131098)
+  MON_2* = cint(131099)
+  MON_3* = cint(131100)
+  MON_4* = cint(131101)
+  MON_5* = cint(131102)
+  MON_6* = cint(131103)
+  MON_7* = cint(131104)
+  MON_8* = cint(131105)
+  MON_9* = cint(131106)
+  MON_10* = cint(131107)
+  MON_11* = cint(131108)
+  MON_12* = cint(131109)
+  ABMON_1* = cint(131086)
+  ABMON_2* = cint(131087)
+  ABMON_3* = cint(131088)
+  ABMON_4* = cint(131089)
+  ABMON_5* = cint(131090)
+  ABMON_6* = cint(131091)
+  ABMON_7* = cint(131092)
+  ABMON_8* = cint(131093)
+  ABMON_9* = cint(131094)
+  ABMON_10* = cint(131095)
+  ABMON_11* = cint(131096)
+  ABMON_12* = cint(131097)
+  ERA* = cint(131116)
+  ERA_D_FMT* = cint(131118)
+  ERA_D_T_FMT* = cint(131120)
+  ERA_T_FMT* = cint(131121)
+  ALT_DIGITS* = cint(131119)
+  RADIXCHAR* = cint(65536)
+  THOUSEP* = cint(65537)
+  YESEXPR* = cint(327680)
+  NOEXPR* = cint(327681)
+  CRNCYSTR* = cint(262159)
+  LC_ALL* = cint(6)
+  LC_COLLATE* = cint(3)
+  LC_CTYPE* = cint(0)
+  LC_MESSAGES* = cint(5)
+  LC_MONETARY* = cint(4)
+  LC_NUMERIC* = cint(1)
+  LC_TIME* = cint(2)
+  PTHREAD_BARRIER_SERIAL_THREAD* = cint(-1)
+  PTHREAD_CANCEL_ASYNCHRONOUS* = cint(1)
+  PTHREAD_CANCEL_ENABLE* = cint(0)
+  PTHREAD_CANCEL_DEFERRED* = cint(0)
+  PTHREAD_CANCEL_DISABLE* = cint(1)
+  PTHREAD_CREATE_DETACHED* = cint(1)
+  PTHREAD_CREATE_JOINABLE* = cint(0)
+  PTHREAD_EXPLICIT_SCHED* = cint(1)
+  PTHREAD_INHERIT_SCHED* = cint(0)
+  PTHREAD_PROCESS_SHARED* = cint(1)
+  PTHREAD_PROCESS_PRIVATE* = cint(0)
+  PTHREAD_SCOPE_PROCESS* = cint(1)
+  PTHREAD_SCOPE_SYSTEM* = cint(0)
+  POSIX_ASYNC_IO* = cint(1)
+  F_OK* = cint(0)
+  R_OK* = cint(4)
+  W_OK* = cint(2)
+  X_OK* = cint(1)
+  CS_PATH* = cint(0)
+  CS_POSIX_V6_ILP32_OFF32_CFLAGS* = cint(1116)
+  CS_POSIX_V6_ILP32_OFF32_LDFLAGS* = cint(1117)
+  CS_POSIX_V6_ILP32_OFF32_LIBS* = cint(1118)
+  CS_POSIX_V6_ILP32_OFFBIG_CFLAGS* = cint(1120)
+  CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS* = cint(1121)
+  CS_POSIX_V6_ILP32_OFFBIG_LIBS* = cint(1122)
+  CS_POSIX_V6_LP64_OFF64_CFLAGS* = cint(1124)
+  CS_POSIX_V6_LP64_OFF64_LDFLAGS* = cint(1125)
+  CS_POSIX_V6_LP64_OFF64_LIBS* = cint(1126)
+  CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS* = cint(1128)
+  CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS* = cint(1129)
+  CS_POSIX_V6_LPBIG_OFFBIG_LIBS* = cint(1130)
+  CS_POSIX_V6_WIDTH_RESTRICTED_ENVS* = cint(1)
+  F_LOCK* = cint(1)
+  F_TEST* = cint(3)
+  F_TLOCK* = cint(2)
+  F_ULOCK* = cint(0)
+  PC_2_SYMLINKS* = cint(20)
+  PC_ALLOC_SIZE_MIN* = cint(18)
+  PC_ASYNC_IO* = cint(10)
+  PC_CHOWN_RESTRICTED* = cint(6)
+  PC_FILESIZEBITS* = cint(13)
+  PC_LINK_MAX* = cint(0)
+  PC_MAX_CANON* = cint(1)
+  PC_MAX_INPUT* = cint(2)
+  PC_NAME_MAX* = cint(3)
+  PC_NO_TRUNC* = cint(7)
+  PC_PATH_MAX* = cint(4)
+  PC_PIPE_BUF* = cint(5)
+  PC_PRIO_IO* = cint(11)
+  PC_REC_INCR_XFER_SIZE* = cint(14)
+  PC_REC_MIN_XFER_SIZE* = cint(16)
+  PC_REC_XFER_ALIGN* = cint(17)
+  PC_SYMLINK_MAX* = cint(19)
+  PC_SYNC_IO* = cint(9)
+  PC_VDISABLE* = cint(8)
+  SC_2_C_BIND* = cint(47)
+  SC_2_C_DEV* = cint(48)
+  SC_2_CHAR_TERM* = cint(95)
+  SC_2_FORT_DEV* = cint(49)
+  SC_2_FORT_RUN* = cint(50)
+  SC_2_LOCALEDEF* = cint(52)
+  SC_2_PBS* = cint(168)
+  SC_2_PBS_ACCOUNTING* = cint(169)
+  SC_2_PBS_CHECKPOINT* = cint(175)
+  SC_2_PBS_LOCATE* = cint(170)
+  SC_2_PBS_MESSAGE* = cint(171)
+  SC_2_PBS_TRACK* = cint(172)
+  SC_2_SW_DEV* = cint(51)
+  SC_2_UPE* = cint(97)
+  SC_2_VERSION* = cint(46)
+  SC_ADVISORY_INFO* = cint(132)
+  SC_AIO_LISTIO_MAX* = cint(23)
+  SC_AIO_MAX* = cint(24)
+  SC_AIO_PRIO_DELTA_MAX* = cint(25)
+  SC_ARG_MAX* = cint(0)
+  SC_ASYNCHRONOUS_IO* = cint(12)
+  SC_ATEXIT_MAX* = cint(87)
+  SC_BARRIERS* = cint(133)
+  SC_BC_BASE_MAX* = cint(36)
+  SC_BC_DIM_MAX* = cint(37)
+  SC_BC_SCALE_MAX* = cint(38)
+  SC_BC_STRING_MAX* = cint(39)
+  SC_CHILD_MAX* = cint(1)
+  SC_CLK_TCK* = cint(2)
+  SC_CLOCK_SELECTION* = cint(137)
+  SC_COLL_WEIGHTS_MAX* = cint(40)
+  SC_CPUTIME* = cint(138)
+  SC_DELAYTIMER_MAX* = cint(26)
+  SC_EXPR_NEST_MAX* = cint(42)
+  SC_FSYNC* = cint(15)
+  SC_GETGR_R_SIZE_MAX* = cint(69)
+  SC_GETPW_R_SIZE_MAX* = cint(70)
+  SC_HOST_NAME_MAX* = cint(180)
+  SC_IOV_MAX* = cint(60)
+  SC_IPV6* = cint(235)
+  SC_JOB_CONTROL* = cint(7)
+  SC_LINE_MAX* = cint(43)
+  SC_LOGIN_NAME_MAX* = cint(71)
+  SC_MAPPED_FILES* = cint(16)
+  SC_MEMLOCK* = cint(17)
+  SC_MEMLOCK_RANGE* = cint(18)
+  SC_MEMORY_PROTECTION* = cint(19)
+  SC_MESSAGE_PASSING* = cint(20)
+  SC_MONOTONIC_CLOCK* = cint(149)
+  SC_MQ_OPEN_MAX* = cint(27)
+  SC_MQ_PRIO_MAX* = cint(28)
+  SC_NGROUPS_MAX* = cint(3)
+  SC_OPEN_MAX* = cint(4)
+  SC_PAGE_SIZE* = cint(30)
+  SC_PRIORITIZED_IO* = cint(13)
+  SC_PRIORITY_SCHEDULING* = cint(10)
+  SC_RAW_SOCKETS* = cint(236)
+  SC_RE_DUP_MAX* = cint(44)
+  SC_READER_WRITER_LOCKS* = cint(153)
+  SC_REALTIME_SIGNALS* = cint(9)
+  SC_REGEXP* = cint(155)
+  SC_RTSIG_MAX* = cint(31)
+  SC_SAVED_IDS* = cint(8)
+  SC_SEM_NSEMS_MAX* = cint(32)
+  SC_SEM_VALUE_MAX* = cint(33)
+  SC_SEMAPHORES* = cint(21)
+  SC_SHARED_MEMORY_OBJECTS* = cint(22)
+  SC_SHELL* = cint(157)
+  SC_SIGQUEUE_MAX* = cint(34)
+  SC_SPAWN* = cint(159)
+  SC_SPIN_LOCKS* = cint(154)
+  SC_SPORADIC_SERVER* = cint(160)
+  SC_SS_REPL_MAX* = cint(241)
+  SC_STREAM_MAX* = cint(5)
+  SC_SYMLOOP_MAX* = cint(173)
+  SC_SYNCHRONIZED_IO* = cint(14)
+  SC_THREAD_ATTR_STACKADDR* = cint(77)
+  SC_THREAD_ATTR_STACKSIZE* = cint(78)
+  SC_THREAD_CPUTIME* = cint(139)
+  SC_THREAD_DESTRUCTOR_ITERATIONS* = cint(73)
+  SC_THREAD_KEYS_MAX* = cint(74)
+  SC_THREAD_PRIO_INHERIT* = cint(80)
+  SC_THREAD_PRIO_PROTECT* = cint(81)
+  SC_THREAD_PRIORITY_SCHEDULING* = cint(79)
+  SC_THREAD_PROCESS_SHARED* = cint(82)
+  SC_THREAD_SAFE_FUNCTIONS* = cint(68)
+  SC_THREAD_SPORADIC_SERVER* = cint(161)
+  SC_THREAD_STACK_MIN* = cint(75)
+  SC_THREAD_THREADS_MAX* = cint(76)
+  SC_THREADS* = cint(67)
+  SC_TIMEOUTS* = cint(164)
+  SC_TIMER_MAX* = cint(35)
+  SC_TIMERS* = cint(11)
+  SC_TRACE* = cint(181)
+  SC_TRACE_EVENT_FILTER* = cint(182)
+  SC_TRACE_EVENT_NAME_MAX* = cint(242)
+  SC_TRACE_INHERIT* = cint(183)
+  SC_TRACE_LOG* = cint(184)
+  SC_TRACE_NAME_MAX* = cint(243)
+  SC_TRACE_SYS_MAX* = cint(244)
+  SC_TRACE_USER_EVENT_MAX* = cint(245)
+  SC_TTY_NAME_MAX* = cint(72)
+  SC_TYPED_MEMORY_OBJECTS* = cint(165)
+  SC_TZNAME_MAX* = cint(6)
+  SC_V6_ILP32_OFF32* = cint(176)
+  SC_V6_ILP32_OFFBIG* = cint(177)
+  SC_V6_LP64_OFF64* = cint(178)
+  SC_V6_LPBIG_OFFBIG* = cint(179)
+  SC_VERSION* = cint(29)
+  SC_XBS5_ILP32_OFF32* = cint(125)
+  SC_XBS5_ILP32_OFFBIG* = cint(126)
+  SC_XBS5_LP64_OFF64* = cint(127)
+  SC_XBS5_LPBIG_OFFBIG* = cint(128)
+  SC_XOPEN_CRYPT* = cint(92)
+  SC_XOPEN_ENH_I18N* = cint(93)
+  SC_XOPEN_LEGACY* = cint(129)
+  SC_XOPEN_REALTIME* = cint(130)
+  SC_XOPEN_REALTIME_THREADS* = cint(131)
+  SC_XOPEN_SHM* = cint(94)
+  SC_XOPEN_STREAMS* = cint(246)
+  SC_XOPEN_UNIX* = cint(91)
+  SC_XOPEN_VERSION* = cint(89)
+  SEEK_SET* = cint(0)
+  SEEK_CUR* = cint(1)
+  SEEK_END* = cint(2)
+  SEM_FAILED* = cast[pointer]((nil))
+  IPC_CREAT* = cint(512)
+  IPC_EXCL* = cint(1024)
+  IPC_NOWAIT* = cint(2048)
+  IPC_PRIVATE* = cint(0)
+  IPC_RMID* = cint(0)
+  IPC_SET* = cint(1)
+  IPC_STAT* = cint(2)
+  S_IFMT* = cint(61440)
+  S_IFBLK* = cint(24576)
+  S_IFCHR* = cint(8192)
+  S_IFIFO* = cint(4096)
+  S_IFREG* = cint(32768)
+  S_IFDIR* = cint(16384)
+  S_IFLNK* = cint(40960)
+  S_IFSOCK* = cint(49152)
+  S_IRWXU* = cint(448)
+  S_IRUSR* = cint(256)
+  S_IWUSR* = cint(128)
+  S_IXUSR* = cint(64)
+  S_IRWXG* = cint(56)
+  S_IRGRP* = cint(32)
+  S_IWGRP* = cint(16)
+  S_IXGRP* = cint(8)
+  S_IRWXO* = cint(7)
+  S_IROTH* = cint(4)
+  S_IWOTH* = cint(2)
+  S_IXOTH* = cint(1)
+  S_ISUID* = cint(2048)
+  S_ISGID* = cint(1024)
+  S_ISVTX* = cint(512)
+  ST_RDONLY* = cint(1)
+  ST_NOSUID* = cint(2)
+  PROT_READ* = cint(1)
+  PROT_WRITE* = cint(2)
+  PROT_EXEC* = cint(4)
+  PROT_NONE* = cint(0)
+  MAP_SHARED* = cint(1)
+  MAP_PRIVATE* = cint(2)
+  MAP_FIXED* = cint(16)
+  MS_ASYNC* = cint(1)
+  MS_SYNC* = cint(4)
+  MS_INVALIDATE* = cint(2)
+  MCL_CURRENT* = cint(1)
+  MCL_FUTURE* = cint(2)
+  MAP_FAILED* = cast[pointer](0xffffffffffffffff)
+  POSIX_MADV_NORMAL* = cint(0)
+  POSIX_MADV_SEQUENTIAL* = cint(2)
+  POSIX_MADV_RANDOM* = cint(1)
+  POSIX_MADV_WILLNEED* = cint(3)
+  POSIX_MADV_DONTNEED* = cint(4)
+  CLOCKS_PER_SEC* = clong(1000000)
+  CLOCK_PROCESS_CPUTIME_ID* = cint(2)
+  CLOCK_THREAD_CPUTIME_ID* = cint(3)
+  CLOCK_REALTIME* = cint(0)
+  TIMER_ABSTIME* = cint(1)
+  CLOCK_MONOTONIC* = cint(1)
+  WNOHANG* = cint(1)
+  WUNTRACED* = cint(2)
+  WEXITED* = cint(4)
+  WSTOPPED* = cint(2)
+  WCONTINUED* = cint(8)
+  WNOWAIT* = cint(16777216)
+  SIGEV_NONE* = cint(1)
+  SIGEV_SIGNAL* = cint(0)
+  SIGEV_THREAD* = cint(2)
+  SIGABRT* = cint(6)
+  SIGALRM* = cint(14)
+  SIGBUS* = cint(7)
+  SIGCHLD* = cint(17)
+  SIGCONT* = cint(18)
+  SIGFPE* = cint(8)
+  SIGHUP* = cint(1)
+  SIGILL* = cint(4)
+  SIGINT* = cint(2)
+  SIGKILL* = cint(9)
+  SIGPIPE* = cint(13)
+  SIGQUIT* = cint(3)
+  SIGSEGV* = cint(11)
+  SIGSTOP* = cint(19)
+  SIGTERM* = cint(15)
+  SIGTSTP* = cint(20)
+  SIGTTIN* = cint(21)
+  SIGTTOU* = cint(22)
+  SIGUSR1* = cint(10)
+  SIGUSR2* = cint(12)
+  SIGPOLL* = cint(29)
+  SIGPROF* = cint(27)
+  SIGSYS* = cint(31)
+  SIGTRAP* = cint(5)
+  SIGURG* = cint(23)
+  SIGVTALRM* = cint(26)
+  SIGXCPU* = cint(24)
+  SIGXFSZ* = cint(25)
+  SA_NOCLDSTOP* = cint(1)
+  SIG_BLOCK* = cint(0)
+  SIG_UNBLOCK* = cint(1)
+  SIG_SETMASK* = cint(2)
+  SA_ONSTACK* = cint(134217728)
+  SA_RESETHAND* = cint(-2147483648)
+  SA_RESTART* = cint(268435456)
+  SA_SIGINFO* = cint(4)
+  SA_NOCLDWAIT* = cint(2)
+  SA_NODEFER* = cint(1073741824)
+  SS_ONSTACK* = cint(1)
+  SS_DISABLE* = cint(2)
+  MINSIGSTKSZ* = cint(2048)
+  SIGSTKSZ* = cint(8192)
+  NL_SETD* = cint(1)
+  NL_CAT_LOCALE* = cint(1)
+  SCHED_FIFO* = cint(1)
+  SCHED_RR* = cint(2)
+  SCHED_OTHER* = cint(0)
+  FD_SETSIZE* = cint(1024)
+  IF_NAMESIZE* = cint(16)
+  SCM_RIGHTS* = cint(1)
+  SOCK_DGRAM* = cint(2)
+  SOCK_RAW* = cint(3)
+  SOCK_SEQPACKET* = cint(5)
+  SOCK_STREAM* = cint(1)
+  SOL_SOCKET* = cint(1)
+  SO_ACCEPTCONN* = cint(30)
+  SO_BROADCAST* = cint(6)
+  SO_DEBUG* = cint(1)
+  SO_DONTROUTE* = cint(5)
+  SO_ERROR* = cint(4)
+  SO_KEEPALIVE* = cint(9)
+  SO_LINGER* = cint(13)
+  SO_OOBINLINE* = cint(10)
+  SO_RCVBUF* = cint(8)
+  SO_RCVLOWAT* = cint(18)
+  SO_RCVTIMEO* = cint(20)
+  SO_REUSEADDR* = cint(2)
+  SO_SNDBUF* = cint(7)
+  SO_SNDLOWAT* = cint(19)
+  SO_SNDTIMEO* = cint(21)
+  SO_TYPE* = cint(3)
+  SOMAXCONN* = cint(128)
+  MSG_CTRUNC* = cint(8)
+  MSG_DONTROUTE* = cint(4)
+  MSG_EOR* = cint(128)
+  MSG_OOB* = cint(1)
+  MSG_PEEK* = cint(2)
+  MSG_TRUNC* = cint(32)
+  MSG_WAITALL* = cint(256)
+  AF_INET* = cint(2)
+  AF_INET6* = cint(10)
+  AF_UNIX* = cint(1)
+  AF_UNSPEC* = cint(0)
+  SHUT_RD* = cint(0)
+  SHUT_RDWR* = cint(2)
+  SHUT_WR* = cint(1)
+  IPPROTO_IP* = cint(0)
+  IPPROTO_IPV6* = cint(41)
+  IPPROTO_ICMP* = cint(1)
+  IPPROTO_RAW* = cint(255)
+  IPPROTO_TCP* = cint(6)
+  IPPROTO_UDP* = cint(17)
+  INADDR_ANY* = cint(0)
+  INADDR_BROADCAST* = cint(-1)
+  INET_ADDRSTRLEN* = cint(16)
+  IPV6_JOIN_GROUP* = cint(20)
+  IPV6_LEAVE_GROUP* = cint(21)
+  IPV6_MULTICAST_HOPS* = cint(18)
+  IPV6_MULTICAST_IF* = cint(17)
+  IPV6_MULTICAST_LOOP* = cint(19)
+  IPV6_UNICAST_HOPS* = cint(16)
+  IPV6_V6ONLY* = cint(26)
+  IPPORT_RESERVED* = cint(1024)
+  HOST_NOT_FOUND* = cint(1)
+  NO_DATA* = cint(4)
+  NO_RECOVERY* = cint(3)
+  TRY_AGAIN* = cint(2)
+  AI_PASSIVE* = cint(1)
+  AI_CANONNAME* = cint(2)
+  AI_NUMERICHOST* = cint(4)
+  AI_NUMERICSERV* = cint(1024)
+  AI_V4MAPPED* = cint(8)
+  AI_ALL* = cint(16)
+  AI_ADDRCONFIG* = cint(32)
+  NI_NOFQDN* = cint(4)
+  NI_NUMERICHOST* = cint(1)
+  NI_NAMEREQD* = cint(8)
+  NI_NUMERICSERV* = cint(2)
+  NI_DGRAM* = cint(16)
+  EAI_AGAIN* = cint(-3)
+  EAI_BADFLAGS* = cint(-1)
+  EAI_FAIL* = cint(-4)
+  EAI_FAMILY* = cint(-6)
+  EAI_MEMORY* = cint(-10)
+  EAI_NONAME* = cint(-2)
+  EAI_SERVICE* = cint(-8)
+  EAI_SOCKTYPE* = cint(-7)
+  EAI_SYSTEM* = cint(-11)
+  EAI_OVERFLOW* = cint(-12)
+  POLLIN* = cshort(1)
+  POLLRDNORM* = cshort(64)
+  POLLRDBAND* = cshort(128)
+  POLLPRI* = cshort(2)
+  POLLOUT* = cshort(4)
+  POLLWRNORM* = cshort(256)
+  POLLWRBAND* = cshort(512)
+  POLLERR* = cshort(8)
+  POLLHUP* = cshort(16)
+  POLLNVAL* = cshort(32)
+  POSIX_SPAWN_RESETIDS* = cint(1)
+  POSIX_SPAWN_SETPGROUP* = cint(2)
+  POSIX_SPAWN_SETSCHEDPARAM* = cint(16)
+  POSIX_SPAWN_SETSCHEDULER* = cint(32)
+  POSIX_SPAWN_SETSIGDEF* = cint(4)
+  POSIX_SPAWN_SETSIGMASK* = cint(8)
+  IOFBF* = cint(0)
+  IONBF* = cint(2)
diff --git a/tools/detect/macosx_consts.nim b/tools/detect/macosx_consts.nim
new file mode 100644
index 000000000..e8be56e5f
--- /dev/null
+++ b/tools/detect/macosx_consts.nim
@@ -0,0 +1,629 @@
+# Generated by detect.nim
+const
+  AIO_ALLDONE* = cint(1)
+  AIO_CANCELED* = cint(2)
+  AIO_NOTCANCELED* = cint(4)
+  LIO_NOP* = cint(0)
+  LIO_NOWAIT* = cint(1)
+  LIO_READ* = cint(1)
+  LIO_WAIT* = cint(2)
+  LIO_WRITE* = cint(2)
+  RTLD_LAZY* = cint(1)
+  RTLD_NOW* = cint(2)
+  RTLD_GLOBAL* = cint(8)
+  RTLD_LOCAL* = cint(4)
+  E2BIG* = cint(7)
+  EACCES* = cint(13)
+  EADDRINUSE* = cint(48)
+  EADDRNOTAVAIL* = cint(49)
+  EAFNOSUPPORT* = cint(47)
+  EAGAIN* = cint(35)
+  EALREADY* = cint(37)
+  EBADF* = cint(9)
+  EBADMSG* = cint(94)
+  EBUSY* = cint(16)
+  ECANCELED* = cint(89)
+  ECHILD* = cint(10)
+  ECONNABORTED* = cint(53)
+  ECONNREFUSED* = cint(61)
+  ECONNRESET* = cint(54)
+  EDEADLK* = cint(11)
+  EDESTADDRREQ* = cint(39)
+  EDOM* = cint(33)
+  EDQUOT* = cint(69)
+  EEXIST* = cint(17)
+  EFAULT* = cint(14)
+  EFBIG* = cint(27)
+  EHOSTUNREACH* = cint(65)
+  EIDRM* = cint(90)
+  EILSEQ* = cint(92)
+  EINPROGRESS* = cint(36)
+  EINTR* = cint(4)
+  EINVAL* = cint(22)
+  EIO* = cint(5)
+  EISCONN* = cint(56)
+  EISDIR* = cint(21)
+  ELOOP* = cint(62)
+  EMFILE* = cint(24)
+  EMLINK* = cint(31)
+  EMSGSIZE* = cint(40)
+  EMULTIHOP* = cint(95)
+  ENAMETOOLONG* = cint(63)
+  ENETDOWN* = cint(50)
+  ENETRESET* = cint(52)
+  ENETUNREACH* = cint(51)
+  ENFILE* = cint(23)
+  ENOBUFS* = cint(55)
+  ENODATA* = cint(96)
+  ENODEV* = cint(19)
+  ENOENT* = cint(2)
+  ENOEXEC* = cint(8)
+  ENOLCK* = cint(77)
+  ENOLINK* = cint(97)
+  ENOMEM* = cint(12)
+  ENOMSG* = cint(91)
+  ENOPROTOOPT* = cint(42)
+  ENOSPC* = cint(28)
+  ENOSR* = cint(98)
+  ENOSTR* = cint(99)
+  ENOSYS* = cint(78)
+  ENOTCONN* = cint(57)
+  ENOTDIR* = cint(20)
+  ENOTEMPTY* = cint(66)
+  ENOTSOCK* = cint(38)
+  ENOTSUP* = cint(45)
+  ENOTTY* = cint(25)
+  ENXIO* = cint(6)
+  EOPNOTSUPP* = cint(102)
+  EOVERFLOW* = cint(84)
+  EPERM* = cint(1)
+  EPIPE* = cint(32)
+  EPROTO* = cint(100)
+  EPROTONOSUPPORT* = cint(43)
+  EPROTOTYPE* = cint(41)
+  ERANGE* = cint(34)
+  EROFS* = cint(30)
+  ESPIPE* = cint(29)
+  ESRCH* = cint(3)
+  ESTALE* = cint(70)
+  ETIME* = cint(101)
+  ETIMEDOUT* = cint(60)
+  ETXTBSY* = cint(26)
+  EWOULDBLOCK* = cint(35)
+  EXDEV* = cint(18)
+  F_DUPFD* = cint(0)
+  F_GETFD* = cint(1)
+  F_SETFD* = cint(2)
+  F_GETFL* = cint(3)
+  F_SETFL* = cint(4)
+  F_GETLK* = cint(7)
+  F_SETLK* = cint(8)
+  F_SETLKW* = cint(9)
+  F_GETOWN* = cint(5)
+  F_SETOWN* = cint(6)
+  FD_CLOEXEC* = cint(1)
+  F_RDLCK* = cint(1)
+  F_UNLCK* = cint(2)
+  F_WRLCK* = cint(3)
+  O_CREAT* = cint(512)
+  O_EXCL* = cint(2048)
+  O_NOCTTY* = cint(131072)
+  O_TRUNC* = cint(1024)
+  O_APPEND* = cint(8)
+  O_DSYNC* = cint(4194304)
+  O_NONBLOCK* = cint(4)
+  O_SYNC* = cint(128)
+  O_ACCMODE* = cint(3)
+  O_RDONLY* = cint(0)
+  O_RDWR* = cint(2)
+  O_WRONLY* = cint(1)
+  FE_DIVBYZERO* = cint(4)
+  FE_INEXACT* = cint(32)
+  FE_INVALID* = cint(1)
+  FE_OVERFLOW* = cint(8)
+  FE_UNDERFLOW* = cint(16)
+  FE_ALL_EXCEPT* = cint(63)
+  FE_DOWNWARD* = cint(1024)
+  FE_TONEAREST* = cint(0)
+  FE_TOWARDZERO* = cint(3072)
+  FE_UPWARD* = cint(2048)
+  FE_DFL_ENV* = when defined(amd64): cast[pointer](0x7fff9533b1b4)
+                else: cast[pointer](0x904797f4)
+  MM_HARD* = cint(1)
+  MM_SOFT* = cint(2)
+  MM_FIRM* = cint(4)
+  MM_APPL* = cint(16)
+  MM_UTIL* = cint(32)
+  MM_OPSYS* = cint(64)
+  MM_RECOVER* = cint(4096)
+  MM_NRECOV* = cint(8192)
+  MM_HALT* = cint(1)
+  MM_ERROR* = cint(2)
+  MM_WARNING* = cint(3)
+  MM_INFO* = cint(4)
+  MM_NOSEV* = cint(0)
+  MM_PRINT* = cint(256)
+  MM_CONSOLE* = cint(512)
+  MM_OK* = cint(0)
+  MM_NOTOK* = cint(3)
+  MM_NOMSG* = cint(1)
+  MM_NOCON* = cint(2)
+  FNM_NOMATCH* = cint(1)
+  FNM_PATHNAME* = cint(2)
+  FNM_PERIOD* = cint(4)
+  FNM_NOESCAPE* = cint(1)
+  FNM_NOSYS* = cint(-1)
+  FTW_F* = cint(0)
+  FTW_D* = cint(1)
+  FTW_DNR* = cint(2)
+  FTW_DP* = cint(3)
+  FTW_NS* = cint(4)
+  FTW_SL* = cint(5)
+  FTW_SLN* = cint(6)
+  FTW_PHYS* = cint(1)
+  FTW_MOUNT* = cint(2)
+  FTW_DEPTH* = cint(4)
+  FTW_CHDIR* = cint(8)
+  GLOB_APPEND* = cint(1)
+  GLOB_DOOFFS* = cint(2)
+  GLOB_ERR* = cint(4)
+  GLOB_MARK* = cint(8)
+  GLOB_NOCHECK* = cint(16)
+  GLOB_NOESCAPE* = cint(8192)
+  GLOB_NOSORT* = cint(32)
+  GLOB_ABORTED* = cint(-2)
+  GLOB_NOMATCH* = cint(-3)
+  GLOB_NOSPACE* = cint(-1)
+  GLOB_NOSYS* = cint(-4)
+  CODESET* = cint(0)
+  D_T_FMT* = cint(1)
+  D_FMT* = cint(2)
+  T_FMT* = cint(3)
+  T_FMT_AMPM* = cint(4)
+  AM_STR* = cint(5)
+  PM_STR* = cint(6)
+  DAY_1* = cint(7)
+  DAY_2* = cint(8)
+  DAY_3* = cint(9)
+  DAY_4* = cint(10)
+  DAY_5* = cint(11)
+  DAY_6* = cint(12)
+  DAY_7* = cint(13)
+  ABDAY_1* = cint(14)
+  ABDAY_2* = cint(15)
+  ABDAY_3* = cint(16)
+  ABDAY_4* = cint(17)
+  ABDAY_5* = cint(18)
+  ABDAY_6* = cint(19)
+  ABDAY_7* = cint(20)
+  MON_1* = cint(21)
+  MON_2* = cint(22)
+  MON_3* = cint(23)
+  MON_4* = cint(24)
+  MON_5* = cint(25)
+  MON_6* = cint(26)
+  MON_7* = cint(27)
+  MON_8* = cint(28)
+  MON_9* = cint(29)
+  MON_10* = cint(30)
+  MON_11* = cint(31)
+  MON_12* = cint(32)
+  ABMON_1* = cint(33)
+  ABMON_2* = cint(34)
+  ABMON_3* = cint(35)
+  ABMON_4* = cint(36)
+  ABMON_5* = cint(37)
+  ABMON_6* = cint(38)
+  ABMON_7* = cint(39)
+  ABMON_8* = cint(40)
+  ABMON_9* = cint(41)
+  ABMON_10* = cint(42)
+  ABMON_11* = cint(43)
+  ABMON_12* = cint(44)
+  ERA* = cint(45)
+  ERA_D_FMT* = cint(46)
+  ERA_D_T_FMT* = cint(47)
+  ERA_T_FMT* = cint(48)
+  ALT_DIGITS* = cint(49)
+  RADIXCHAR* = cint(50)
+  THOUSEP* = cint(51)
+  YESEXPR* = cint(52)
+  NOEXPR* = cint(53)
+  CRNCYSTR* = cint(56)
+  LC_ALL* = cint(0)
+  LC_COLLATE* = cint(1)
+  LC_CTYPE* = cint(2)
+  LC_MESSAGES* = cint(6)
+  LC_MONETARY* = cint(3)
+  LC_NUMERIC* = cint(4)
+  LC_TIME* = cint(5)
+  PTHREAD_CANCEL_ASYNCHRONOUS* = cint(0)
+  PTHREAD_CANCEL_ENABLE* = cint(1)
+  PTHREAD_CANCEL_DEFERRED* = cint(2)
+  PTHREAD_CANCEL_DISABLE* = cint(0)
+  PTHREAD_CREATE_DETACHED* = cint(2)
+  PTHREAD_CREATE_JOINABLE* = cint(1)
+  PTHREAD_EXPLICIT_SCHED* = cint(2)
+  PTHREAD_INHERIT_SCHED* = cint(1)
+  PTHREAD_MUTEX_DEFAULT* = cint(0)
+  PTHREAD_MUTEX_ERRORCHECK* = cint(1)
+  PTHREAD_MUTEX_NORMAL* = cint(0)
+  PTHREAD_MUTEX_RECURSIVE* = cint(2)
+  PTHREAD_PRIO_INHERIT* = cint(1)
+  PTHREAD_PRIO_NONE* = cint(0)
+  PTHREAD_PRIO_PROTECT* = cint(2)
+  PTHREAD_PROCESS_SHARED* = cint(1)
+  PTHREAD_PROCESS_PRIVATE* = cint(2)
+  PTHREAD_SCOPE_PROCESS* = cint(2)
+  PTHREAD_SCOPE_SYSTEM* = cint(1)
+  F_OK* = cint(0)
+  R_OK* = cint(4)
+  W_OK* = cint(2)
+  X_OK* = cint(1)
+  CS_PATH* = cint(1)
+  CS_POSIX_V6_ILP32_OFF32_CFLAGS* = cint(2)
+  CS_POSIX_V6_ILP32_OFF32_LDFLAGS* = cint(3)
+  CS_POSIX_V6_ILP32_OFF32_LIBS* = cint(4)
+  CS_POSIX_V6_ILP32_OFFBIG_CFLAGS* = cint(5)
+  CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS* = cint(6)
+  CS_POSIX_V6_ILP32_OFFBIG_LIBS* = cint(7)
+  CS_POSIX_V6_LP64_OFF64_CFLAGS* = cint(8)
+  CS_POSIX_V6_LP64_OFF64_LDFLAGS* = cint(9)
+  CS_POSIX_V6_LP64_OFF64_LIBS* = cint(10)
+  CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS* = cint(11)
+  CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS* = cint(12)
+  CS_POSIX_V6_LPBIG_OFFBIG_LIBS* = cint(13)
+  CS_POSIX_V6_WIDTH_RESTRICTED_ENVS* = cint(14)
+  F_LOCK* = cint(1)
+  F_TEST* = cint(3)
+  F_TLOCK* = cint(2)
+  F_ULOCK* = cint(0)
+  PC_2_SYMLINKS* = cint(15)
+  PC_ALLOC_SIZE_MIN* = cint(16)
+  PC_ASYNC_IO* = cint(17)
+  PC_CHOWN_RESTRICTED* = cint(7)
+  PC_FILESIZEBITS* = cint(18)
+  PC_LINK_MAX* = cint(1)
+  PC_MAX_CANON* = cint(2)
+  PC_MAX_INPUT* = cint(3)
+  PC_NAME_MAX* = cint(4)
+  PC_NO_TRUNC* = cint(8)
+  PC_PATH_MAX* = cint(5)
+  PC_PIPE_BUF* = cint(6)
+  PC_PRIO_IO* = cint(19)
+  PC_REC_INCR_XFER_SIZE* = cint(20)
+  PC_REC_MIN_XFER_SIZE* = cint(22)
+  PC_REC_XFER_ALIGN* = cint(23)
+  PC_SYMLINK_MAX* = cint(24)
+  PC_SYNC_IO* = cint(25)
+  PC_VDISABLE* = cint(9)
+  SC_2_C_BIND* = cint(18)
+  SC_2_C_DEV* = cint(19)
+  SC_2_CHAR_TERM* = cint(20)
+  SC_2_FORT_DEV* = cint(21)
+  SC_2_FORT_RUN* = cint(22)
+  SC_2_LOCALEDEF* = cint(23)
+  SC_2_PBS* = cint(59)
+  SC_2_PBS_ACCOUNTING* = cint(60)
+  SC_2_PBS_CHECKPOINT* = cint(61)
+  SC_2_PBS_LOCATE* = cint(62)
+  SC_2_PBS_MESSAGE* = cint(63)
+  SC_2_PBS_TRACK* = cint(64)
+  SC_2_SW_DEV* = cint(24)
+  SC_2_UPE* = cint(25)
+  SC_2_VERSION* = cint(17)
+  SC_ADVISORY_INFO* = cint(65)
+  SC_AIO_LISTIO_MAX* = cint(42)
+  SC_AIO_MAX* = cint(43)
+  SC_AIO_PRIO_DELTA_MAX* = cint(44)
+  SC_ARG_MAX* = cint(1)
+  SC_ASYNCHRONOUS_IO* = cint(28)
+  SC_ATEXIT_MAX* = cint(107)
+  SC_BARRIERS* = cint(66)
+  SC_BC_BASE_MAX* = cint(9)
+  SC_BC_DIM_MAX* = cint(10)
+  SC_BC_SCALE_MAX* = cint(11)
+  SC_BC_STRING_MAX* = cint(12)
+  SC_CHILD_MAX* = cint(2)
+  SC_CLK_TCK* = cint(3)
+  SC_CLOCK_SELECTION* = cint(67)
+  SC_COLL_WEIGHTS_MAX* = cint(13)
+  SC_CPUTIME* = cint(68)
+  SC_DELAYTIMER_MAX* = cint(45)
+  SC_EXPR_NEST_MAX* = cint(14)
+  SC_FSYNC* = cint(38)
+  SC_GETGR_R_SIZE_MAX* = cint(70)
+  SC_GETPW_R_SIZE_MAX* = cint(71)
+  SC_HOST_NAME_MAX* = cint(72)
+  SC_IOV_MAX* = cint(56)
+  SC_IPV6* = cint(118)
+  SC_JOB_CONTROL* = cint(6)
+  SC_LINE_MAX* = cint(15)
+  SC_LOGIN_NAME_MAX* = cint(73)
+  SC_MAPPED_FILES* = cint(47)
+  SC_MEMLOCK* = cint(30)
+  SC_MEMLOCK_RANGE* = cint(31)
+  SC_MEMORY_PROTECTION* = cint(32)
+  SC_MESSAGE_PASSING* = cint(33)
+  SC_MONOTONIC_CLOCK* = cint(74)
+  SC_MQ_OPEN_MAX* = cint(46)
+  SC_MQ_PRIO_MAX* = cint(75)
+  SC_NGROUPS_MAX* = cint(4)
+  SC_OPEN_MAX* = cint(5)
+  SC_PAGE_SIZE* = cint(29)
+  SC_PRIORITIZED_IO* = cint(34)
+  SC_PRIORITY_SCHEDULING* = cint(35)
+  SC_RAW_SOCKETS* = cint(119)
+  SC_RE_DUP_MAX* = cint(16)
+  SC_READER_WRITER_LOCKS* = cint(76)
+  SC_REALTIME_SIGNALS* = cint(36)
+  SC_REGEXP* = cint(77)
+  SC_RTSIG_MAX* = cint(48)
+  SC_SAVED_IDS* = cint(7)
+  SC_SEM_NSEMS_MAX* = cint(49)
+  SC_SEM_VALUE_MAX* = cint(50)
+  SC_SEMAPHORES* = cint(37)
+  SC_SHARED_MEMORY_OBJECTS* = cint(39)
+  SC_SHELL* = cint(78)
+  SC_SIGQUEUE_MAX* = cint(51)
+  SC_SPAWN* = cint(79)
+  SC_SPIN_LOCKS* = cint(80)
+  SC_SPORADIC_SERVER* = cint(81)
+  SC_SS_REPL_MAX* = cint(126)
+  SC_STREAM_MAX* = cint(26)
+  SC_SYMLOOP_MAX* = cint(120)
+  SC_SYNCHRONIZED_IO* = cint(40)
+  SC_THREAD_ATTR_STACKADDR* = cint(82)
+  SC_THREAD_ATTR_STACKSIZE* = cint(83)
+  SC_THREAD_CPUTIME* = cint(84)
+  SC_THREAD_DESTRUCTOR_ITERATIONS* = cint(85)
+  SC_THREAD_KEYS_MAX* = cint(86)
+  SC_THREAD_PRIO_INHERIT* = cint(87)
+  SC_THREAD_PRIO_PROTECT* = cint(88)
+  SC_THREAD_PRIORITY_SCHEDULING* = cint(89)
+  SC_THREAD_PROCESS_SHARED* = cint(90)
+  SC_THREAD_SAFE_FUNCTIONS* = cint(91)
+  SC_THREAD_SPORADIC_SERVER* = cint(92)
+  SC_THREAD_STACK_MIN* = cint(93)
+  SC_THREAD_THREADS_MAX* = cint(94)
+  SC_THREADS* = cint(96)
+  SC_TIMEOUTS* = cint(95)
+  SC_TIMER_MAX* = cint(52)
+  SC_TIMERS* = cint(41)
+  SC_TRACE* = cint(97)
+  SC_TRACE_EVENT_FILTER* = cint(98)
+  SC_TRACE_EVENT_NAME_MAX* = cint(127)
+  SC_TRACE_INHERIT* = cint(99)
+  SC_TRACE_LOG* = cint(100)
+  SC_TRACE_NAME_MAX* = cint(128)
+  SC_TRACE_SYS_MAX* = cint(129)
+  SC_TRACE_USER_EVENT_MAX* = cint(130)
+  SC_TTY_NAME_MAX* = cint(101)
+  SC_TYPED_MEMORY_OBJECTS* = cint(102)
+  SC_TZNAME_MAX* = cint(27)
+  SC_V6_ILP32_OFF32* = cint(103)
+  SC_V6_ILP32_OFFBIG* = cint(104)
+  SC_V6_LP64_OFF64* = cint(105)
+  SC_V6_LPBIG_OFFBIG* = cint(106)
+  SC_VERSION* = cint(8)
+  SC_XBS5_ILP32_OFF32* = cint(122)
+  SC_XBS5_ILP32_OFFBIG* = cint(123)
+  SC_XBS5_LP64_OFF64* = cint(124)
+  SC_XBS5_LPBIG_OFFBIG* = cint(125)
+  SC_XOPEN_CRYPT* = cint(108)
+  SC_XOPEN_ENH_I18N* = cint(109)
+  SC_XOPEN_LEGACY* = cint(110)
+  SC_XOPEN_REALTIME* = cint(111)
+  SC_XOPEN_REALTIME_THREADS* = cint(112)
+  SC_XOPEN_SHM* = cint(113)
+  SC_XOPEN_STREAMS* = cint(114)
+  SC_XOPEN_UNIX* = cint(115)
+  SC_XOPEN_VERSION* = cint(116)
+  SEEK_SET* = cint(0)
+  SEEK_CUR* = cint(1)
+  SEEK_END* = cint(2)
+  SEM_FAILED* = cast[pointer](-1)
+  IPC_CREAT* = cint(512)
+  IPC_EXCL* = cint(1024)
+  IPC_NOWAIT* = cint(2048)
+  IPC_PRIVATE* = cint(0)
+  IPC_RMID* = cint(0)
+  IPC_SET* = cint(1)
+  IPC_STAT* = cint(2)
+  S_IFMT* = cint(61440)
+  S_IFBLK* = cint(24576)
+  S_IFCHR* = cint(8192)
+  S_IFIFO* = cint(4096)
+  S_IFREG* = cint(32768)
+  S_IFDIR* = cint(16384)
+  S_IFLNK* = cint(40960)
+  S_IFSOCK* = cint(49152)
+  S_IRWXU* = cint(448)
+  S_IRUSR* = cint(256)
+  S_IWUSR* = cint(128)
+  S_IXUSR* = cint(64)
+  S_IRWXG* = cint(56)
+  S_IRGRP* = cint(32)
+  S_IWGRP* = cint(16)
+  S_IXGRP* = cint(8)
+  S_IRWXO* = cint(7)
+  S_IROTH* = cint(4)
+  S_IWOTH* = cint(2)
+  S_IXOTH* = cint(1)
+  S_ISUID* = cint(2048)
+  S_ISGID* = cint(1024)
+  S_ISVTX* = cint(512)
+  ST_RDONLY* = cint(1)
+  ST_NOSUID* = cint(2)
+  PROT_READ* = cint(1)
+  PROT_WRITE* = cint(2)
+  PROT_EXEC* = cint(4)
+  PROT_NONE* = cint(0)
+  MAP_SHARED* = cint(1)
+  MAP_PRIVATE* = cint(2)
+  MAP_FIXED* = cint(16)
+  MS_ASYNC* = cint(1)
+  MS_SYNC* = cint(16)
+  MS_INVALIDATE* = cint(2)
+  MCL_CURRENT* = cint(1)
+  MCL_FUTURE* = cint(2)
+  MAP_FAILED* = cast[pointer](-1)
+  POSIX_MADV_NORMAL* = cint(0)
+  POSIX_MADV_SEQUENTIAL* = cint(2)
+  POSIX_MADV_RANDOM* = cint(1)
+  POSIX_MADV_WILLNEED* = cint(3)
+  POSIX_MADV_DONTNEED* = cint(4)
+  CLOCKS_PER_SEC* = clong(1000000)
+  WNOHANG* = cint(1)
+  WUNTRACED* = cint(2)
+  WEXITED* = cint(4)
+  WSTOPPED* = cint(8)
+  WCONTINUED* = cint(16)
+  WNOWAIT* = cint(32)
+  SIGEV_NONE* = cint(0)
+  SIGEV_SIGNAL* = cint(1)
+  SIGEV_THREAD* = cint(3)
+  SIGABRT* = cint(6)
+  SIGALRM* = cint(14)
+  SIGBUS* = cint(10)
+  SIGCHLD* = cint(20)
+  SIGCONT* = cint(19)
+  SIGFPE* = cint(8)
+  SIGHUP* = cint(1)
+  SIGILL* = cint(4)
+  SIGINT* = cint(2)
+  SIGKILL* = cint(9)
+  SIGPIPE* = cint(13)
+  SIGQUIT* = cint(3)
+  SIGSEGV* = cint(11)
+  SIGSTOP* = cint(17)
+  SIGTERM* = cint(15)
+  SIGTSTP* = cint(18)
+  SIGTTIN* = cint(21)
+  SIGTTOU* = cint(22)
+  SIGUSR1* = cint(30)
+  SIGUSR2* = cint(31)
+  SIGPROF* = cint(27)
+  SIGSYS* = cint(12)
+  SIGTRAP* = cint(5)
+  SIGURG* = cint(16)
+  SIGVTALRM* = cint(26)
+  SIGXCPU* = cint(24)
+  SIGXFSZ* = cint(25)
+  SA_NOCLDSTOP* = cint(8)
+  SIG_BLOCK* = cint(1)
+  SIG_UNBLOCK* = cint(2)
+  SIG_SETMASK* = cint(3)
+  SA_ONSTACK* = cint(1)
+  SA_RESETHAND* = cint(4)
+  SA_RESTART* = cint(2)
+  SA_SIGINFO* = cint(64)
+  SA_NOCLDWAIT* = cint(32)
+  SA_NODEFER* = cint(16)
+  SS_ONSTACK* = cint(1)
+  SS_DISABLE* = cint(4)
+  MINSIGSTKSZ* = cint(32768)
+  SIGSTKSZ* = cint(131072)
+  NL_SETD* = cint(1)
+  NL_CAT_LOCALE* = cint(1)
+  SCHED_FIFO* = cint(4)
+  SCHED_RR* = cint(2)
+  SCHED_OTHER* = cint(1)
+  FD_SETSIZE* = cint(1024)
+  SCM_RIGHTS* = cint(1)
+  SOCK_DGRAM* = cint(2)
+  SOCK_RAW* = cint(3)
+  SOCK_SEQPACKET* = cint(5)
+  SOCK_STREAM* = cint(1)
+  SOL_SOCKET* = cint(65535)
+  SO_ACCEPTCONN* = cint(2)
+  SO_BROADCAST* = cint(32)
+  SO_DEBUG* = cint(1)
+  SO_DONTROUTE* = cint(16)
+  SO_ERROR* = cint(4103)
+  SO_KEEPALIVE* = cint(8)
+  SO_LINGER* = cint(128)
+  SO_OOBINLINE* = cint(256)
+  SO_RCVBUF* = cint(4098)
+  SO_RCVLOWAT* = cint(4100)
+  SO_RCVTIMEO* = cint(4102)
+  SO_REUSEADDR* = cint(4)
+  SO_SNDBUF* = cint(4097)
+  SO_SNDLOWAT* = cint(4099)
+  SO_SNDTIMEO* = cint(4101)
+  SO_TYPE* = cint(4104)
+  SOMAXCONN* = cint(128)
+  MSG_CTRUNC* = cint(32)
+  MSG_DONTROUTE* = cint(4)
+  MSG_EOR* = cint(8)
+  MSG_OOB* = cint(1)
+  MSG_PEEK* = cint(2)
+  MSG_TRUNC* = cint(16)
+  MSG_WAITALL* = cint(64)
+  AF_INET* = cint(2)
+  AF_INET6* = cint(30)
+  AF_UNIX* = cint(1)
+  AF_UNSPEC* = cint(0)
+  SHUT_RD* = cint(0)
+  SHUT_RDWR* = cint(2)
+  SHUT_WR* = cint(1)
+  IPPROTO_IP* = cint(0)
+  IPPROTO_IPV6* = cint(41)
+  IPPROTO_ICMP* = cint(1)
+  IPPROTO_RAW* = cint(255)
+  IPPROTO_TCP* = cint(6)
+  IPPROTO_UDP* = cint(17)
+  INADDR_ANY* = cint(0)
+  INADDR_BROADCAST* = cint(-1)
+  INET_ADDRSTRLEN* = cint(16)
+  IPV6_JOIN_GROUP* = cint(12)
+  IPV6_LEAVE_GROUP* = cint(13)
+  IPV6_MULTICAST_HOPS* = cint(10)
+  IPV6_MULTICAST_IF* = cint(9)
+  IPV6_MULTICAST_LOOP* = cint(11)
+  IPV6_UNICAST_HOPS* = cint(4)
+  IPV6_V6ONLY* = cint(27)
+  IPPORT_RESERVED* = cint(1024)
+  HOST_NOT_FOUND* = cint(1)
+  NO_DATA* = cint(4)
+  NO_RECOVERY* = cint(3)
+  TRY_AGAIN* = cint(2)
+  AI_PASSIVE* = cint(1)
+  AI_CANONNAME* = cint(2)
+  AI_NUMERICHOST* = cint(4)
+  AI_NUMERICSERV* = cint(4096)
+  AI_V4MAPPED* = cint(2048)
+  AI_ALL* = cint(256)
+  AI_ADDRCONFIG* = cint(1024)
+  NI_NOFQDN* = cint(1)
+  NI_NUMERICHOST* = cint(2)
+  NI_NAMEREQD* = cint(4)
+  NI_NUMERICSERV* = cint(8)
+  NI_DGRAM* = cint(16)
+  EAI_AGAIN* = cint(2)
+  EAI_BADFLAGS* = cint(3)
+  EAI_FAIL* = cint(4)
+  EAI_FAMILY* = cint(5)
+  EAI_MEMORY* = cint(6)
+  EAI_NONAME* = cint(8)
+  EAI_SERVICE* = cint(9)
+  EAI_SOCKTYPE* = cint(10)
+  EAI_SYSTEM* = cint(11)
+  EAI_OVERFLOW* = cint(14)
+  POLLIN* = cshort(1)
+  POLLRDNORM* = cshort(64)
+  POLLRDBAND* = cshort(128)
+  POLLPRI* = cshort(2)
+  POLLOUT* = cshort(4)
+  POLLWRNORM* = cshort(4)
+  POLLWRBAND* = cshort(256)
+  POLLERR* = cshort(8)
+  POLLHUP* = cshort(16)
+  POLLNVAL* = cshort(32)
+  POSIX_SPAWN_RESETIDS* = cint(1)
+  POSIX_SPAWN_SETPGROUP* = cint(2)
+  POSIX_SPAWN_SETSIGDEF* = cint(4)
+  POSIX_SPAWN_SETSIGMASK* = cint(8)
+  IOFBF* = cint(0)
+  IONBF* = cint(2)
+
diff --git a/tools/detect/windows_amd64_consts.nim b/tools/detect/windows_amd64_consts.nim
new file mode 100644
index 000000000..d72c9786d
--- /dev/null
+++ b/tools/detect/windows_amd64_consts.nim
@@ -0,0 +1,152 @@
+# Generated by detect.nim
+const
+  E2BIG* = cint(7)
+  EACCES* = cint(13)
+  EADDRINUSE* = cint(100)
+  EADDRNOTAVAIL* = cint(101)
+  EAFNOSUPPORT* = cint(102)
+  EAGAIN* = cint(11)
+  EALREADY* = cint(103)
+  EBADF* = cint(9)
+  EBUSY* = cint(16)
+  ECANCELED* = cint(105)
+  ECHILD* = cint(10)
+  ECONNABORTED* = cint(106)
+  ECONNREFUSED* = cint(107)
+  ECONNRESET* = cint(108)
+  EDEADLK* = cint(36)
+  EDESTADDRREQ* = cint(109)
+  EDOM* = cint(33)
+  EEXIST* = cint(17)
+  EFAULT* = cint(14)
+  EFBIG* = cint(27)
+  EHOSTUNREACH* = cint(110)
+  EILSEQ* = cint(42)
+  EINPROGRESS* = cint(112)
+  EINTR* = cint(4)
+  EINVAL* = cint(22)
+  EIO* = cint(5)
+  EISCONN* = cint(113)
+  EISDIR* = cint(21)
+  ELOOP* = cint(114)
+  EMFILE* = cint(24)
+  EMLINK* = cint(31)
+  EMSGSIZE* = cint(115)
+  ENAMETOOLONG* = cint(38)
+  ENETDOWN* = cint(116)
+  ENETRESET* = cint(117)
+  ENETUNREACH* = cint(118)
+  ENFILE* = cint(23)
+  ENOBUFS* = cint(119)
+  ENODEV* = cint(19)
+  ENOENT* = cint(2)
+  ENOEXEC* = cint(8)
+  ENOLCK* = cint(39)
+  ENOMEM* = cint(12)
+  ENOPROTOOPT* = cint(123)
+  ENOSPC* = cint(28)
+  ENOSYS* = cint(40)
+  ENOTCONN* = cint(126)
+  ENOTDIR* = cint(20)
+  ENOTEMPTY* = cint(41)
+  ENOTSOCK* = cint(128)
+  ENOTSUP* = cint(129)
+  ENOTTY* = cint(25)
+  ENXIO* = cint(6)
+  EOPNOTSUPP* = cint(130)
+  EOVERFLOW* = cint(132)
+  EPERM* = cint(1)
+  EPIPE* = cint(32)
+  EPROTO* = cint(134)
+  EPROTONOSUPPORT* = cint(135)
+  EPROTOTYPE* = cint(136)
+  ERANGE* = cint(34)
+  EROFS* = cint(30)
+  ESPIPE* = cint(29)
+  ESRCH* = cint(3)
+  ETIMEDOUT* = cint(138)
+  EWOULDBLOCK* = cint(140)
+  EXDEV* = cint(18)
+  O_CREAT* = cint(256)
+  O_EXCL* = cint(1024)
+  O_TRUNC* = cint(512)
+  O_APPEND* = cint(8)
+  O_ACCMODE* = cint(3)
+  O_RDONLY* = cint(0)
+  O_RDWR* = cint(2)
+  O_WRONLY* = cint(1)
+  FE_DIVBYZERO* = cint(4)
+  FE_INEXACT* = cint(32)
+  FE_INVALID* = cint(1)
+  FE_OVERFLOW* = cint(8)
+  FE_UNDERFLOW* = cint(16)
+  FE_ALL_EXCEPT* = cint(63)
+  FE_DOWNWARD* = cint(1024)
+  FE_TONEAREST* = cint(0)
+  FE_TOWARDZERO* = cint(3072)
+  FE_UPWARD* = cint(2048)
+  FE_DFL_ENV* = pointer(nil)
+  LC_ALL* = cint(0)
+  LC_COLLATE* = cint(1)
+  LC_CTYPE* = cint(2)
+  LC_MONETARY* = cint(3)
+  LC_NUMERIC* = cint(4)
+  LC_TIME* = cint(5)
+  PTHREAD_BARRIER_SERIAL_THREAD* = cint(1)
+  PTHREAD_CANCEL_ASYNCHRONOUS* = cint(2)
+  PTHREAD_CANCEL_ENABLE* = cint(1)
+  PTHREAD_CANCEL_DEFERRED* = cint(0)
+  PTHREAD_CANCEL_DISABLE* = cint(0)
+  PTHREAD_CREATE_DETACHED* = cint(4)
+  PTHREAD_CREATE_JOINABLE* = cint(0)
+  PTHREAD_EXPLICIT_SCHED* = cint(0)
+  PTHREAD_INHERIT_SCHED* = cint(8)
+  PTHREAD_MUTEX_DEFAULT* = cint(0)
+  PTHREAD_MUTEX_ERRORCHECK* = cint(1)
+  PTHREAD_MUTEX_NORMAL* = cint(0)
+  PTHREAD_MUTEX_RECURSIVE* = cint(2)
+  PTHREAD_PRIO_INHERIT* = cint(8)
+  PTHREAD_PRIO_NONE* = cint(0)
+  PTHREAD_PRIO_PROTECT* = cint(16)
+  PTHREAD_PROCESS_SHARED* = cint(1)
+  PTHREAD_PROCESS_PRIVATE* = cint(0)
+  PTHREAD_SCOPE_PROCESS* = cint(0)
+  PTHREAD_SCOPE_SYSTEM* = cint(16)
+  F_OK* = cint(0)
+  R_OK* = cint(4)
+  W_OK* = cint(2)
+  X_OK* = cint(1)
+  SEEK_SET* = cint(0)
+  SEEK_CUR* = cint(1)
+  SEEK_END* = cint(2)
+  SEM_FAILED* = pointer(nil)
+  S_IFMT* = cint(61440)
+  S_IFBLK* = cint(12288)
+  S_IFCHR* = cint(8192)
+  S_IFIFO* = cint(4096)
+  S_IFREG* = cint(32768)
+  S_IFDIR* = cint(16384)
+  S_IRWXU* = cint(448)
+  S_IRUSR* = cint(256)
+  S_IWUSR* = cint(128)
+  S_IXUSR* = cint(64)
+  CLOCKS_PER_SEC* = clong(1000)
+  CLOCK_PROCESS_CPUTIME_ID* = cint(2)
+  CLOCK_THREAD_CPUTIME_ID* = cint(3)
+  CLOCK_REALTIME* = cint(0)
+  TIMER_ABSTIME* = cint(1)
+  CLOCK_MONOTONIC* = cint(1)
+  SIGABRT* = cint(22)
+  SIGFPE* = cint(8)
+  SIGILL* = cint(4)
+  SIGINT* = cint(2)
+  SIGSEGV* = cint(11)
+  SIGTERM* = cint(15)
+  SIG_BLOCK* = cint(0)
+  SIG_UNBLOCK* = cint(1)
+  SIG_SETMASK* = cint(2)
+  SCHED_FIFO* = cint(1)
+  SCHED_RR* = cint(2)
+  SCHED_OTHER* = cint(0)
+  IOFBF* = cint(0)
+  IONBF* = cint(4)
diff --git a/tools/detect/windows_i386_consts.nim b/tools/detect/windows_i386_consts.nim
new file mode 100644
index 000000000..cd6c475f4
--- /dev/null
+++ b/tools/detect/windows_i386_consts.nim
@@ -0,0 +1,96 @@
+# Generated by detect.nim

+const

+  E2BIG* = cint(7)

+  EACCES* = cint(13)

+  EAGAIN* = cint(11)

+  EBADF* = cint(9)

+  EBUSY* = cint(16)

+  ECHILD* = cint(10)

+  EDEADLK* = cint(36)

+  EDOM* = cint(33)

+  EEXIST* = cint(17)

+  EFAULT* = cint(14)

+  EFBIG* = cint(27)

+  EILSEQ* = cint(42)

+  EINTR* = cint(4)

+  EINVAL* = cint(22)

+  EIO* = cint(5)

+  EISDIR* = cint(21)

+  EMFILE* = cint(24)

+  EMLINK* = cint(31)

+  ENAMETOOLONG* = cint(38)

+  ENFILE* = cint(23)

+  ENODEV* = cint(19)

+  ENOENT* = cint(2)

+  ENOEXEC* = cint(8)

+  ENOLCK* = cint(39)

+  ENOMEM* = cint(12)

+  ENOSPC* = cint(28)

+  ENOSYS* = cint(40)

+  ENOTDIR* = cint(20)

+  ENOTEMPTY* = cint(41)

+  ENOTSUP* = cint(48)

+  ENOTTY* = cint(25)

+  ENXIO* = cint(6)

+  EPERM* = cint(1)

+  EPIPE* = cint(32)

+  ERANGE* = cint(34)

+  EROFS* = cint(30)

+  ESPIPE* = cint(29)

+  ESRCH* = cint(3)

+  ETIMEDOUT* = cint(10060)

+  EXDEV* = cint(18)

+  O_CREAT* = cint(256)

+  O_EXCL* = cint(1024)

+  O_TRUNC* = cint(512)

+  O_APPEND* = cint(8)

+  O_ACCMODE* = cint(3)

+  O_RDONLY* = cint(0)

+  O_RDWR* = cint(2)

+  O_WRONLY* = cint(1)

+  FE_DIVBYZERO* = cint(4)

+  FE_INEXACT* = cint(32)

+  FE_INVALID* = cint(1)

+  FE_OVERFLOW* = cint(8)

+  FE_UNDERFLOW* = cint(16)

+  FE_ALL_EXCEPT* = cint(63)

+  FE_DOWNWARD* = cint(1024)

+  FE_TONEAREST* = cint(0)

+  FE_TOWARDZERO* = cint(3072)

+  FE_UPWARD* = cint(2048)

+  FE_DFL_ENV* = pointer(nil)

+  LC_ALL* = cint(0)

+  LC_COLLATE* = cint(1)

+  LC_CTYPE* = cint(2)

+  LC_MONETARY* = cint(3)

+  LC_NUMERIC* = cint(4)

+  LC_TIME* = cint(5)

+  F_OK* = cint(0)

+  R_OK* = cint(4)

+  W_OK* = cint(2)

+  X_OK* = cint(1)

+  SEEK_SET* = cint(0)

+  SEEK_CUR* = cint(1)

+  SEEK_END* = cint(2)

+  S_IFMT* = cint(61440)

+  S_IFBLK* = cint(12288)

+  S_IFCHR* = cint(8192)

+  S_IFIFO* = cint(4096)

+  S_IFREG* = cint(32768)

+  S_IFDIR* = cint(16384)

+  S_IRWXU* = cint(448)

+  S_IRUSR* = cint(256)

+  S_IWUSR* = cint(128)

+  S_IXUSR* = cint(64)

+  CLOCKS_PER_SEC* = clong(1000)

+  SIGABRT* = cint(22)

+  SIGFPE* = cint(8)

+  SIGILL* = cint(4)

+  SIGINT* = cint(2)

+  SIGSEGV* = cint(11)

+  SIGTERM* = cint(15)

+  SIG_BLOCK* = cint(0)

+  SIG_UNBLOCK* = cint(1)

+  SIG_SETMASK* = cint(2)

+  IOFBF* = cint(0)

+  IONBF* = cint(4)

diff --git a/tools/nimgrep.nim b/tools/nimgrep.nim
index c7893fe78..28d92402e 100644
--- a/tools/nimgrep.nim
+++ b/tools/nimgrep.nim
@@ -56,7 +56,7 @@ var
 
 proc ask(msg: string): string =
   stdout.write(msg)
-  result = stdin.readline()
+  result = stdin.readLine()
 
 proc Confirm: TConfirmEnum = 
   while true:
@@ -66,7 +66,7 @@ proc Confirm: TConfirmEnum =
     of "l", "all": return ceAll
     of "n", "no": return ceNo
     of "e", "none": return ceNone
-    else: nil
+    else: discard
 
 proc countLines(s: string, first, last: int): int = 
   var i = first
@@ -249,7 +249,7 @@ proc walker(dir: string) =
     of pcDir: 
       if optRecursive in options:
         walker(path)
-    else: nil
+    else: discard
   if existsFile(dir): processFile(dir)
 
 proc writeHelp() = 
@@ -308,7 +308,7 @@ checkOptions({optIgnoreCase, optIgnoreStyle}, "ignore_case", "ignore_style")
 
 if optStdin in options: 
   pattern = ask("pattern [ENTER to exit]: ")
-  if IsNil(pattern) or pattern.len == 0: quit(0)
+  if isNil(pattern) or pattern.len == 0: quit(0)
   if optReplace in options:
     replacement = ask("replacement [supports $1, $# notations]: ")
 
diff --git a/tools/niminst/buildbat.tmpl b/tools/niminst/buildbat.tmpl
index 712ebc794..9a19fc70b 100644
--- a/tools/niminst/buildbat.tmpl
+++ b/tools/niminst/buildbat.tmpl
@@ -1,5 +1,5 @@
 #! stdtmpl(subsChar='?') | standard
-#proc GenerateBuildBatchScript(c: TConfigData, winIndex, cpuIndex: int): string = 
+#proc generateBuildBatchScript(c: TConfigData, winIndex, cpuIndex: int): string = 
 #  result = "@echo off\nREM Generated by niminst\n"
 SET CC=gcc
 SET LINKER=gcc
diff --git a/tools/niminst/buildsh.tmpl b/tools/niminst/buildsh.tmpl
index 8fe5fea9f..4966af07a 100644
--- a/tools/niminst/buildsh.tmpl
+++ b/tools/niminst/buildsh.tmpl
@@ -1,5 +1,5 @@
 #! stdtmpl(subsChar='?') | standard
-#proc GenerateBuildShellScript(c: TConfigData): string = 
+#proc generateBuildShellScript(c: TConfigData): string = 
 #  result = "#! /bin/sh\n# Generated from niminst\n" &
 #           "# Template is in tools/buildsh.tmpl\n" &
 #           "# To regenerate run ``niminst csource`` or ``koch csource``\n"
diff --git a/tools/niminst/debcreation.nim b/tools/niminst/debcreation.nim
index 982bfaf3d..1f4a8630e 100644
--- a/tools/niminst/debcreation.nim
+++ b/tools/niminst/debcreation.nim
@@ -101,7 +101,7 @@ proc createChangelog(pkgName, version, maintainer: string): string =
   addN("  * Initial release.")
   addN("")
   addN(" -- " & maintainer & "  " &
-       formatDateTime(getGmTime(getTime()), "+0000"))
+       formatDateTime(getGMTime(getTime()), "+0000"))
 
 proc createRules(): string =
   ## Creates a nimrod application-agnostic rules file for building deb packages.
diff --git a/tools/niminst/deinstall.tmpl b/tools/niminst/deinstall.tmpl
index d9abf9228..15f912af6 100644
--- a/tools/niminst/deinstall.tmpl
+++ b/tools/niminst/deinstall.tmpl
@@ -1,5 +1,5 @@
 #! stdtmpl(subsChar='?') | standard
-#proc GenerateDeinstallScript(c: TConfigData): string = 
+#proc generateDeinstallScript(c: TConfigData): string = 
 #  result = "#! /bin/sh\n# Generated by niminst\n"
 #  var proj = c.name.toLower
 
diff --git a/tools/niminst/inno.tmpl b/tools/niminst/inno.tmpl
index 40edcc790..b9d04755e 100644
--- a/tools/niminst/inno.tmpl
+++ b/tools/niminst/inno.tmpl
@@ -1,5 +1,5 @@
 #! stdtmpl | standard
-#proc GenerateInnoSetup(c: TConfigData): string =
+#proc generateInnoSetup(c: TConfigData): string =
 #  result = ""
 ; Default Template for NimInst
 [Setup]
diff --git a/tools/niminst/install.tmpl b/tools/niminst/install.tmpl
index fa61eea5e..437e13dfb 100644
--- a/tools/niminst/install.tmpl
+++ b/tools/niminst/install.tmpl
@@ -1,5 +1,5 @@
 #! stdtmpl(subsChar = '?') | standard
-#proc GenerateInstallScript(c: TConfigData): string = 
+#proc generateInstallScript(c: TConfigData): string = 
 #  result = "#! /bin/sh\n# Generated by niminst\n"
 #  var proj = c.name.toLower
 
diff --git a/tools/niminst/niminst.nim b/tools/niminst/niminst.nim
index 96815ebe4..bf8a7a84f 100644
--- a/tools/niminst/niminst.nim
+++ b/tools/niminst/niminst.nim
@@ -111,7 +111,7 @@ proc skipRoot(f: string): string =
   # "abc/def/xyz" --> "def/xyz"
   var i = 0
   result = ""
-  for component in split(f, {dirsep, altsep}):
+  for component in split(f, {DirSep, AltSep}):
     if i > 0: result = result / component
     inc i
   if result.len == 0: result = f
@@ -126,7 +126,7 @@ include "deinstall.tmpl"
 
 const
   Version = "0.9"
-  Usage = "niminst - Nimrod Installation Generator Version " & version & """
+  Usage = "niminst - Nimrod Installation Generator Version " & Version & """
 
   (c) 2013 Andreas Rumpf
 Usage:
@@ -168,7 +168,7 @@ proc parseCmdLine(c: var TConfigData) =
         c.infile = addFileExt(key.string, "ini")
         c.nimrodArgs = cmdLineRest(p).string
         break
-    of cmdLongOption, cmdShortOption:
+    of cmdLongoption, cmdShortOption:
       case normalize(key.string)
       of "help", "h": 
         stdout.write(Usage)
@@ -188,7 +188,7 @@ proc parseCmdLine(c: var TConfigData) =
 proc walkDirRecursively(s: var seq[string], root: string) =
   for k, f in walkDir(root):
     case k
-    of pcFile, pcLinkToFile: add(s, UnixToNativePath(f))
+    of pcFile, pcLinkToFile: add(s, unixToNativePath(f))
     of pcDir: walkDirRecursively(s, f)
     of pcLinkToDir: nil
 
@@ -199,7 +199,7 @@ proc addFiles(s: var seq[string], patterns: seq[string]) =
     else:
       var i = 0
       for f in walkFiles(p):
-        add(s, UnixToNativePath(f))
+        add(s, unixToNativePath(f))
         inc(i)
       if i == 0: echo("[Warning] No file found that matches: " & p)
 
@@ -286,7 +286,7 @@ proc parseIniFile(c: var TConfigData) =
             of "console": c.app = appConsole
             of "gui": c.app = appGUI
             else: quit(errorStr(p, "expected: console or gui"))
-          of "license": c.license = UnixToNativePath(k.value)
+          of "license": c.license = unixToNativePath(k.value)
           else: quit(errorStr(p, "unknown variable: " & k.key))
         of "var": nil
         of "winbin": filesOnly(p, k.key, v, c.cat[fcWinBin])
@@ -312,7 +312,7 @@ proc parseIniFile(c: var TConfigData) =
           of "uninstallscript": c.uninstallScript = yesno(p, v)
           else: quit(errorStr(p, "unknown variable: " & k.key))
         of "unixbin": filesOnly(p, k.key, v, c.cat[fcUnixBin])
-        of "innosetup": pathFlags(p, k.key, v, c.innoSetup)
+        of "innosetup": pathFlags(p, k.key, v, c.innosetup)
         of "ccompiler": pathFlags(p, k.key, v, c.ccompiler)
         of "linker": pathFlags(p, k.key, v, c.linker)
         of "deb":
@@ -483,11 +483,11 @@ proc setupDist(c: var TConfigData) =
   var n = "build" / "install_$#_$#.iss" % [toLower(c.name), c.version]
   writeFile(n, scrpt, "\13\10")
   when defined(windows):
-    if c.innoSetup.path.len == 0:
-      c.innoSetup.path = "iscc.exe"
+    if c.innosetup.path.len == 0:
+      c.innosetup.path = "iscc.exe"
     var outcmd = if c.outdir.len == 0: "build" else: c.outdir
-    var cmd = "$# $# /O$# $#" % [quoteShell(c.innoSetup.path),
-                                 c.innoSetup.flags, outcmd, n]
+    var cmd = "$# $# /O$# $#" % [quoteShell(c.innosetup.path),
+                                 c.innosetup.flags, outcmd, n]
     echo(cmd)
     if execShellCmd(cmd) == 0:
       removeFile(n)
@@ -582,7 +582,7 @@ if actionScripts in c.actions:
   writeInstallScripts(c)
 if actionZip in c.actions:
   when haveZipLib:
-    zipdist(c)
+    zipDist(c)
   else:
     quit("libzip is not installed")
 if actionDeb in c.actions:
diff --git a/tools/nimweb.nim b/tools/nimweb.nim
index c5d510eac..5c78f3f45 100644
--- a/tools/nimweb.nim
+++ b/tools/nimweb.nim
@@ -9,7 +9,7 @@
 
 import
   os, strutils, times, parseopt, parsecfg, streams, strtabs, tables,
-  re, htmlgen, macros, md5
+  re, htmlgen, macros, md5, osproc
 
 type
   TKeyValPair = tuple[key, id, val: string]
@@ -19,6 +19,7 @@ type
     authors, projectName, projectTitle, logo, infile, outdir, ticker: string
     vars: PStringTable
     nimrodArgs: string
+    gitCommit: string
     quotations: TTable[string, tuple[quote, author: string]]
   TRssItem = object
     year, month, day, title: string
@@ -40,6 +41,11 @@ proc initConfigData(c: var TConfigData) =
   c.logo = ""
   c.ticker = ""
   c.vars = newStringTable(modeStyleInsensitive)
+  c.gitCommit = "master"
+  # Attempts to obtain the git current commit.
+  let (output, code) = execCmdEx("git log -n 1 --format=%H")
+  if code == 0 and output.strip.len == 40:
+    c.gitCommit = output.strip
   c.quotations = initTable[string, tuple[quote, author: string]]()
 
 include "website.tmpl"
@@ -130,7 +136,7 @@ proc walkDirRecursively(s: var seq[string], root, ext: string) =
       if cmpIgnoreCase(ext, splitFile(f).ext) == 0:
         add(s, f)
     of pcDir: walkDirRecursively(s, f, ext)
-    of pcLinkToDir: nil
+    of pcLinkToDir: discard
 
 proc addFiles(s: var seq[string], dir, ext: string, patterns: seq[string]) =
   for p in items(patterns):
@@ -153,7 +159,7 @@ proc parseIniFile(c: var TConfigData) =
       of cfgSectionStart:
         section = normalize(k.section)
         case section
-        of "project", "links", "tabs", "ticker", "documentation", "var": nil
+        of "project", "links", "tabs", "ticker", "documentation", "var": discard
         else: echo("[Warning] Skipping unknown section: " & section)
 
       of cfgKeyValuePair:
@@ -168,7 +174,7 @@ proc parseIniFile(c: var TConfigData) =
           of "logo": c.logo = v
           of "authors": c.authors = v
           else: quit(errorStr(p, "unknown variable: " & k.key))
-        of "var": nil
+        of "var": discard
         of "links":
           let valID = v.split(';')
           add(c.links, (k.key.replace('_', ' '), valID[1], valID[0]))
@@ -186,7 +192,7 @@ proc parseIniFile(c: var TConfigData) =
           let vSplit = v.split('-')
           doAssert vSplit.len == 2
           c.quotations[k.key.normalize] = (vSplit[0], vSplit[1])
-        else: nil
+        else: discard
 
       of cfgOption: quit(errorStr(p, "syntax error"))
       of cfgError: quit(errorStr(p, k.msg))
@@ -197,35 +203,55 @@ proc parseIniFile(c: var TConfigData) =
       c.outdir = splitFile(c.infile).dir
   else:
     quit("cannot open: " & c.infile)
+  # Ugly hack to override git command output when building private repo.
+  if c.vars.hasKey("githash"):
+    let githash = c.vars["githash"].strip
+    if githash.len > 0:
+      c.gitCommit = githash
 
 # ------------------- main ----------------------------------------------------
 
-proc Exec(cmd: string) =
+proc exec(cmd: string) =
   echo(cmd)
   if os.execShellCmd(cmd) != 0: quit("external program failed")
 
+proc buildDocSamples(c: var TConfigData, destPath: string) =
+  ## Special case documentation sample proc.
+  ##
+  ## The docgen sample needs to be generated twice with different commands, so
+  ## it didn't make much sense to integrate into the existing generic
+  ## documentation builders.
+  const src = "doc"/"docgen_sample.nim"
+  exec("nimrod doc $# -o:$# $#" %
+    [c.nimrodArgs, destPath / "docgen_sample.html", src])
+  exec("nimrod doc2 $# -o:$# $#" %
+    [c.nimrodArgs, destPath / "docgen_sample2.html", src])
+
 proc buildDoc(c: var TConfigData, destPath: string) =
   # call nim for the documentation:
   for d in items(c.doc):
-    Exec("nimrod rst2html $# -o:$# --index:on $#" %
-      [c.nimrodArgs, destPath / changeFileExt(splitFile(d).name, "html"), d])
+    exec("nimrod rst2html $# --docSeeSrcUrl:$# -o:$# --index:on $#" %
+      [c.nimrodArgs, c.gitCommit,
+      destPath / changeFileExt(splitFile(d).name, "html"), d])
   for d in items(c.srcdoc):
-    Exec("nimrod doc $# -o:$# --index:on $#" %
-      [c.nimrodArgs, destPath / changeFileExt(splitFile(d).name, "html"), d])
+    exec("nimrod doc $# --docSeeSrcUrl:$# -o:$# --index:on $#" %
+      [c.nimrodArgs, c.gitCommit,
+      destPath / changeFileExt(splitFile(d).name, "html"), d])
   for d in items(c.srcdoc2):
-    Exec("nimrod doc2 $# -o:$# --index:on $#" %
-      [c.nimrodArgs, destPath / changeFileExt(splitFile(d).name, "html"), d])
-  Exec("nimrod buildIndex -o:$1/theindex.html $1" % [destPath])
+    exec("nimrod doc2 $# --docSeeSrcUrl:$# -o:$# --index:on $#" %
+      [c.nimrodArgs, c.gitCommit,
+      destPath / changeFileExt(splitFile(d).name, "html"), d])
+  exec("nimrod buildIndex -o:$1/theindex.html $1" % [destPath])
 
 proc buildPdfDoc(c: var TConfigData, destPath: string) =
   if os.execShellCmd("pdflatex -version") != 0:
     echo "pdflatex not found; no PDF documentation generated"
   else:
     for d in items(c.pdf):
-      Exec("nimrod rst2tex $# $#" % [c.nimrodArgs, d])
+      exec("nimrod rst2tex $# $#" % [c.nimrodArgs, d])
       # call LaTeX twice to get cross references right:
-      Exec("pdflatex " & changeFileExt(d, "tex"))
-      Exec("pdflatex " & changeFileExt(d, "tex"))
+      exec("pdflatex " & changeFileExt(d, "tex"))
+      exec("pdflatex " & changeFileExt(d, "tex"))
       # delete all the crappy temporary files:
       var pdf = splitFile(d).name & ".pdf"
       moveFile(dest=destPath / pdf, source=pdf)
@@ -239,8 +265,9 @@ proc buildPdfDoc(c: var TConfigData, destPath: string) =
 proc buildAddDoc(c: var TConfigData, destPath: string) =
   # build additional documentation (without the index):
   for d in items(c.webdoc):
-    Exec("nimrod doc $# -o:$# $#" %
-      [c.nimrodArgs, destPath / changeFileExt(splitFile(d).name, "html"), d])
+    exec("nimrod doc $# --docSeeSrcUrl:$# -o:$# $#" %
+      [c.nimrodArgs, c.gitCommit,
+      destPath / changeFileExt(splitFile(d).name, "html"), d])
 
 proc parseNewsTitles(inputFilename: string): seq[TRssItem] =
   # parses the file for titles and returns them as TRssItem blocks.
@@ -253,7 +280,7 @@ proc parseNewsTitles(inputFilename: string): seq[TRssItem] =
   if not open(input, inputFilename):
     quit("Could not read $1 for rss generation" % [inputFilename])
   finally: input.close()
-  while input.readline(line):
+  while input.readLine(line):
     if line =~ reYearMonthDayTitle:
       result.add(TRssItem(year: matches[0], month: matches[1], day: matches[2],
         title: matches[3]))
@@ -332,7 +359,7 @@ proc main(c: var TConfigData) =
   for i in 0..c.tabs.len-1:
     var file = c.tabs[i].val
     let rss = if file in ["news", "index"]: extractFilename(rssUrl) else: ""
-    Exec(cmd % [c.nimrodArgs, file])
+    exec(cmd % [c.nimrodArgs, file])
     var temp = "web" / changeFileExt(file, "temp")
     var content: string
     try:
@@ -352,7 +379,9 @@ proc main(c: var TConfigData) =
   copyDir("web/assets", "web/upload/assets")
   buildNewsRss(c, "web/upload")
   buildAddDoc(c, "web/upload")
+  buildDocSamples(c, "web/upload")
   buildDoc(c, "web/upload")
+  buildDocSamples(c, "doc")
   buildDoc(c, "doc")
   buildPdfDoc(c, "doc")
 
diff --git a/tools/website.tmpl b/tools/website.tmpl
index 091079c1c..bd68bdb06 100644
--- a/tools/website.tmpl
+++ b/tools/website.tmpl
@@ -6,7 +6,7 @@
 
 <head>
   <title>$c.projectTitle</title>
-  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
+  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
   <link rel="stylesheet" type="text/css" href="assets/style.css" />
   #if len(rss) > 0:
   <link href="$rss" title="Recent changes" type="application/atom+xml" rel="alternate">
@@ -74,5 +74,15 @@
        <div id="legal">Copyright &copy; 2013 - Andreas Rumpf &amp; Contributors - All rights reserved - <a href="http://reign-studios.com/philipwitte/">Design by Philip Witte</a></div>
     </div>
   </div>
+  <script>
+    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+    ga('create', 'UA-48159761-1', 'nimrod-lang.org');
+    ga('send', 'pageview');
+
+  </script>
 </body>
 </html>