- use clang
- don't hardcode -O3 and respect ${CFLAGS}
- don't hardcode /usr/local and /usr/X11R6
- remove /usr/pkg tentacles

Index: config/nim.cfg
--- config/nim.cfg.orig
+++ config/nim.cfg
@@ -8,7 +8,7 @@
 # Environment variables can be accessed like so:
 #  gcc.path %= "$CC_PATH"
 
-cc = gcc
+cc = clang
 
 # additional options always passed to the compiler:
 --parallel_build: "0" # 0 to auto-detect number of processors
@@ -111,7 +111,7 @@ nimblepath="$home/.nimble/pkgs/"
 @if unix:
   @if bsd:
     # BSD got posix_spawn only recently, so we deactivate it for osproc:
-    define:useFork
+    # define:useFork
   @elif haiku:
     gcc.options.linker = "-Wl,--as-needed -lnetwork"
     gcc.cpp.options.linker = "-Wl,--as-needed -lnetwork"
@@ -201,21 +201,27 @@ clang.objc.options.linker = "-lobjc -lgnustep-base"
 
 # Options for FreeBSD, OpenBSD, NetBSD linker to add locations for searching
 # shared libraries.
-@if freebsd or openbsd or netbsd:
+@if openbsd:
+  gcc.options.linker = "-Wl,-rpath=.:${LOCALBASE}/lib:${X11BASE}/lib"
+  gcc.cpp.options.linker = "-Wl,-rpath=.:${LOCALBASE}/lib:${X11BASE}/lib"
+  llvm_gcc.options.linker = "-Wl,-rpath=.:${LOCALBASE}/lib:${X11BASE}/lib"
+  llvm_gcc.cpp.options.linker = "-Wl,-rpath=.:${LOCALBASE}/lib:${X11BASE}/lib"
+  clang.options.linker = "-Wl,-rpath=.:${LOCALBASE}/lib:${X11BASE}/lib"
+  clang.cpp.options.linker = "-Wl,-rpath=.:${LOCALBASE}/lib:${X11BASE}/lib"
+@end
+
+@if freebsd or netbsd:
   gcc.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
   gcc.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
   llvm_gcc.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
   llvm_gcc.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
   clang.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
   clang.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib"
-
-  cincludes: "/usr/local/include"
-  clibdir: "/usr/local/lib"
 @end
 
 @if freebsd or openbsd:
-  cincludes: "/usr/local/include"
-  clibdir: "/usr/local/lib"
+  cincludes: "${LOCALBASE}/include"
+  clibdir: "${LOCALBASE}/lib"
 @elif netbsd:
   cincludes: "/usr/pkg/include"
   clibdir: "/usr/pkg/lib"
@@ -235,15 +241,15 @@ clang.objc.options.linker = "-lobjc -lgnustep-base"
   gcc.options.linker %= "-L $WIND_BASE/target/lib/usr/lib/ppc/PPC32/common -mrtp -fno-strict-aliasing -D_C99 -D_HAS_C9X -std=c99 -fasm -Wall -Wno-write-strings"
 @end
 
-gcc.options.speed = "-O3 -fno-strict-aliasing -fno-ident"
-gcc.options.size = "-Os -fno-ident"
+gcc.options.speed = "${CFLAGS} -fno-strict-aliasing -fno-ident"
+gcc.options.size = "${CFLAGS} -Os -fno-ident"
 @if windows:
   gcc.options.debug = "-g3 -Og -gdwarf-3"
 @else:
   gcc.options.debug = "-g3 -Og"
 @end
-gcc.cpp.options.speed = "-O3 -fno-strict-aliasing -fno-ident"
-gcc.cpp.options.size = "-Os -fno-ident"
+gcc.cpp.options.speed = "${CFLAGS} -fno-strict-aliasing -fno-ident"
+gcc.cpp.options.size = "${CFLAGS} -Os -fno-ident"
 gcc.cpp.options.debug = "-g3 -Og"
 #passl = "-pg"
 
@@ -257,8 +263,8 @@ llvm_gcc.options.size = "-Os"
 clang.options.debug = "-g"
 clang.cpp.options.debug = "-g"
 clang.options.always = "-w -ferror-limit=3"
-clang.options.speed = "-O3"
-clang.options.size = "-Os"
+clang.options.speed = "${CFLAGS}"
+clang.options.size = "${CFLAGS} -Os"
 
 @if windows:
   clang_cl.cpp.options.always %= "${clang_cl.options.always} /EHsc"
