@@ -27,6 +27,8 @@ if (APPLE) 
   endif (CMAKE_BUILD_TYPE STREQUAL "Release")
 
   set(OS_EXTRA_SOURCES os_macosx.c os_mac_conv.c)
+  set(PYTHON_INTERP 1)
+  set(RUBY_INTERP 1)
 else (NOT APPLE)
   set(PROGNAME vim)
 endif (APPLE)
@@ -37,20 +39,27 @@ if (CMAKE_COMPILER_IS_GNUCC) 
 endif (CMAKE_COMPILER_IS_GNUCC)
 
 find_path(PYTHON_INCLUDE_DIR Python.h)
-find_path(COCOA_INCLUDE_DIR Cocoa/Cocoa.h)
+find_path(RUBY_INCLUDE_DIR   ruby.h HINTS "/System/Library/Frameworks")
+find_path(COCOA_INCLUDE_DIR  Cocoa/Cocoa.h)
 find_path(PSMTBC_INCLUDE_DIR PSMTabBarControl/PSMTabBarControl.h ${VIM_SOURCE_DIR}/mac/build/Release)
 
-include_directories(${VIM_SOURCE_DIR} ${VIM_SOURCE_DIR}/proto 
-                    ${PYTHON_INCLUDE_DIR} ${COCOA_INCLUDE_DIR} ${PSMTBC_INCLUDE_DIR})
+include_directories(${CMAKE_CURRENT_BINARY_DIR}
+                    ${VIM_SOURCE_DIR} ${VIM_SOURCE_DIR}/proto 
+                    ${PYTHON_INCLUDE_DIR} ${RUBY_INCLUDE_DIR}
+                    ${COCOA_INCLUDE_DIR} ${PSMTBC_INCLUDE_DIR})
 
 # -DHAVE_CONFIG_H -DFEAT_GUI_MAC -DFEAT_GUI_COCOA
 add_definitions(-DHAVE_CONFIG_H -DFEAT_GUI_MAC -DFEAT_GUI_COCOA -DMACOS_X_UNIX 
                 -D_FORTIFY_SOURCE=1)
 
 set(PYTHON_INTERP_SOURCES   if_python.c)
+set(RUBY_INTERP_SOURCES     if_ruby.c)
 if (PYTHON_INTERP)
     set(INTERP_SOURCES ${INTERP_SOURCES} ${PYTHON_INTERP_SOURCES})
 endif (PYTHON_INTERP)
+if (RUBY_INTERP)
+    set(INTERP_SOURCES ${INTERP_SOURCES} ${RUBY_INTERP_SOURCES})
+endif (RUBY_INTERP)
 
 set(COCOA_GUI_SOURCES       pty.c gui.c gui_mac.m)
 
@@ -60,6 +69,7 @@ endif(GUI STREQUAL "Cocoa") 
 
 set(VIM_DIR_PATH                ".app/Contents/Resources/vim")
 set(PATHDEF_SOURCE              "${CMAKE_CURRENT_BINARY_DIR}/pathdef.c")
+set(CONFIG_H                    "${CMAKE_CURRENT_BINARY_DIR}/auto/config.h")
 
 set(VIM_SOURCES version.c buffer.c charset.c diff.c digraph.c edit.c eval.c
                 ex_cmds.c ex_cmds2.c ex_docmd.c ex_eval.c ex_getln.c fileio.c
@@ -73,8 +83,6 @@ set(VIM_SOURCES version.c buffer.c charset.c diff.c digraph.c edit.c eval.c 
                 ${INTERP_SOURCES}
                 ${GUI_SOURCES})
 
-message("${VIM_SOURCES}")
-
 # Simply treat it as C source should be fine, otherwise cmake will choose
 # a C++ compiler to build it
 set_source_files_properties(gui_mac.m PROPERTIES LANGUAGE C)
@@ -83,14 +91,15 @@ find_library(m m) 
 find_library(ncurses ncurses)
 find_library(iconv iconv)
 
-find_library(COCOA_FRAMEWORK Cocoa)
+find_library(COCOA_FRAMEWORK  Cocoa)
 find_library(PYTHON_FRAMEWORK Python)
+find_library(RUBY_FRAMEWORK   Ruby)
 
 set(PSMTBC_PATH ${VIM_SOURCE_DIR}/mac/build/Release)
 find_library(PSMTBC_FRAMEWORK PSMTabBarControl ${PSMTBC_PATH})
 
 set(VIM_LIBRARIES ${m} ${ncurses} ${iconv}
-    ${COCOA_FRAMEWORK} ${PSMTBC_FRAMEWORK} ${PYTHON_FRAMEWORK})
+    ${COCOA_FRAMEWORK} ${PSMTBC_FRAMEWORK} ${PYTHON_FRAMEWORK} ${RUBY_FRAMEWORK})
 
 file(GLOB ICON_FILES os_mac_rsrc/*.icns)
 set_source_files_properties(${ICON_FILES} PROPERTIES
@@ -118,6 +127,9 @@ endif(NOT COMPILED_BY) 
 # Create pathdef.c, which describes the configuration of this build
 configure_file(pathdef.c.in ${PATHDEF_SOURCE} ESCAPE_QUOTES)
 
+# Create config.h like configure does
+configure_file(config.h.cmakein ${CONFIG_H} ESCAPE_QUOTES)
+
 # Variables for app bundle Info.plist generation
 set(MACOSX_BUNDLE_BUNDLE_VERSION ${VIM_VERSION})
 set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.vim.Vim-${VIM_VERSION}")
 
--- /dev/null
+/* auto/config.h.  Generated from config.h.in by configure.  */
+/*
+ * config.h.in.  Generated automatically from configure.in by autoheader, and
+ * manually changed after that.
+ */
+
+/* Define if we have EBCDIC code */
+#cmakedefine EBCDIC
+
+/* Define unless no X support found */
+#cmakedefine HAVE_X11
+
+/* Define when terminfo support found */
+#define TERMINFO 1
+
+/* Define when termcap.h contains ospeed */
+#define HAVE_OSPEED 1
+
+/* Define when ospeed can be extern */
+/* #undef OSPEED_EXTERN */
+
+/* Define when termcap.h contains UP, BC and PC */
+#define HAVE_UP_BC_PC 1
+
+/* Define when UP, BC and PC can be extern */
+/* #undef UP_BC_PC_EXTERN */
+
+/* Define when termcap.h defines outfuntype */
+/* #undef HAVE_OUTFUNTYPE */
+
+/* Define when __DATE__ " " __TIME__ can be used */
+#define HAVE_DATE_TIME 1
+
+/* defined always when using configure */
+#cmakedefine UNIX
+
+/* Defined to the size of an int */
+#define SIZEOF_INT 4
+
+/*
+ * If we cannot trust one of the following from the libraries, we use our
+ * own safe but probably slower vim_memmove().
+ */
+/* #undef USEBCOPY */
+#define USEMEMMOVE 1
+/* #undef USEMEMCPY */
+
+/* Define when "man -s 2" is to be used */
+#define USEMAN_S 1
+
+/* Define to empty if the keyword does not work.  */
+/* #undef const */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef mode_t */
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+/* #undef off_t */
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+/* #undef pid_t */
+
+/* Define to `unsigned' if <sys/types.h> doesn't define.  */
+/* #undef size_t */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef uid_t */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef gid_t */
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+/* #undef ino_t */
+
+/* Define to `unsigned' if <sys/types.h> doesn't define.  */
+/* #undef dev_t */
+
+/* Define to `unsigned long' if <sys/types.h> doesn't define.  */
+/* #undef rlim_t */
+
+/* Define to `struct sigaltstack' if <signal.h> doesn't define.  */
+/* #undef stack_t */
+
+/* Define if stack_t has the ss_base field. */
+/* #undef HAVE_SS_BASE */
+
+/* Define if you can safely include both <sys/time.h> and <time.h>.  */
+#define TIME_WITH_SYS_TIME 1
+
+/* Define if you can safely include both <sys/time.h> and <sys/select.h>.  */
+#define SYS_SELECT_WITH_SYS_TIME 1
+
+/* Define if you have /dev/ptc */
+/* #undef HAVE_DEV_PTC */
+
+/* Define if you have Sys4 ptys */
+#define HAVE_SVR4_PTYS 1
+
+/* Define to range of pty names to try */
+#define PTYRANGE0 "pqrstuvw"
+#define PTYRANGE1 "0123456789abcdef"
+
+/* Define mode for pty */
+/* #undef PTYMODE */
+
+/* Define group for pty */
+/* #undef PTYGROUP */
+
+/* Define as the return type of signal handlers (int or void).  */
+#define RETSIGTYPE void
+
+/* Define as the command at the end of signal handlers ("" or "return 0;").  */
+#define SIGRETURN return
+
+/* Define if struct sigcontext is present */
+#define HAVE_SIGCONTEXT 1
+
+/* Define if touuper/tolower only work on lower/upercase characters */
+/* #undef BROKEN_TOUPPER */
+
+/* Define if stat() ignores a trailing slash */
+/* #undef STAT_IGNORES_SLASH */
+
+/* Define if tgetstr() has a second argument that is (char *) */
+/* #undef TGETSTR_CHAR_P */
+
+/* Define if tgetent() returns zero for an error */
+/* #undef TGETENT_ZERO_ERR */
+
+/* Define if the getcwd() function should not be used.  */
+/* #undef BAD_GETCWD */
+
+/* Define if you the function: */
+#define HAVE_BCMP 1
+#define HAVE_FCHDIR 1
+#define HAVE_FCHOWN 1
+#define HAVE_FSEEKO 1
+#define HAVE_FSYNC 1
+#define HAVE_FTELLO 1
+#define HAVE_GETCWD 1
+/* #undef HAVE_GETPSEUDOTTY */
+#define HAVE_GETPWNAM 1
+#define HAVE_GETPWUID 1
+#define HAVE_GETRLIMIT 1
+#define HAVE_GETTIMEOFDAY 1
+#define HAVE_GETWD 1
+#define HAVE_ICONV 1
+#define HAVE_NL_LANGINFO_CODESET 1
+#define HAVE_LSTAT 1
+#define HAVE_MEMCMP 1
+#define HAVE_MEMSET 1
+#define HAVE_NANOSLEEP 1
+#define HAVE_OPENDIR 1
+#define HAVE_FLOAT_FUNCS 1
+#define HAVE_PUTENV 1
+#define HAVE_QSORT 1
+#define HAVE_READLINK 1
+#define HAVE_RENAME 1
+#define HAVE_SELECT 1
+/* #undef HAVE_SELINUX */
+#define HAVE_SETENV 1
+#define HAVE_SETPGID 1
+#define HAVE_SETSID 1
+#define HAVE_SIGACTION 1
+#define HAVE_SIGALTSTACK 1
+#define HAVE_SIGSET 1
+#define HAVE_SIGSETJMP 1
+/* #undef HAVE_SIGSTACK */
+#define HAVE_SIGVEC 1
+#define HAVE_STRCASECMP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRFTIME 1
+/* #undef HAVE_STRICMP */
+#define HAVE_STRNCASECMP 1
+/* #undef HAVE_STRNICMP */
+#define HAVE_STRPBRK 1
+#define HAVE_STRTOL 1
+#define HAVE_ST_BLKSIZE 1
+/* #undef HAVE_SYSCONF */
+#define HAVE_SYSCTL 1
+/* #undef HAVE_SYSINFO */
+/* #undef HAVE_SYSINFO_MEM_UNIT */
+#define HAVE_TGETENT 1
+#define HAVE_TOWLOWER 1
+#define HAVE_TOWUPPER 1
+#define HAVE_ISWUPPER 1
+#define HAVE_USLEEP 1
+#define HAVE_UTIME 1
+/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */
+
+/* Define if you do not have utime(), but do have the utimes() function. */
+#define HAVE_UTIMES 1
+
+/* Define if you have the header file: */
+#define HAVE_DIRENT_H 1
+#define HAVE_ERRNO_H 1
+#define HAVE_FCNTL_H 1
+/* #undef HAVE_FRAME_H */
+#define HAVE_ICONV_H 1
+#define HAVE_LANGINFO_H 1
+#define HAVE_LIBC_H 1
+#define HAVE_LIBGEN_H 1
+/* #undef HAVE_LIBINTL_H */
+#define HAVE_LOCALE_H 1
+#define HAVE_MATH_H 1
+/* #undef HAVE_NDIR_H */
+#define HAVE_POLL_H 1
+/* #undef HAVE_PTHREAD_NP_H */
+#define HAVE_PWD_H 1
+#define HAVE_SETJMP_H 1
+#define HAVE_SGTTY_H 1
+#define HAVE_STRINGS_H 1
+/* #undef HAVE_STROPTS_H */
+/* #undef HAVE_SYS_ACCESS_H */
+#define HAVE_SYS_ACL_H 1
+/* #undef HAVE_SYS_DIR_H */
+#define HAVE_SYS_IOCTL_H 1
+/* #undef HAVE_SYS_NDIR_H */
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_SYS_POLL_H 1
+/* #undef HAVE_SYS_PTEM_H */
+#define HAVE_SYS_RESOURCE_H 1
+#define HAVE_SYS_SELECT_H 1
+/* #undef HAVE_SYS_STATFS_H */
+/* #undef HAVE_SYS_STREAM_H */
+#define HAVE_SYS_SYSCTL_H 1
+/* #undef HAVE_SYS_SYSINFO_H */
+/* #undef HAVE_SYS_SYSTEMINFO_H */
+#define HAVE_SYS_TIME_H 1
+#define HAVE_SYS_UTSNAME_H 1
+#define HAVE_WCHAR_H 1
+#define HAVE_WCTYPE_H 1
+#define HAVE_TERMCAP_H 1
+#define HAVE_TERMIOS_H 1
+/* #undef HAVE_TERMIO_H */
+#define HAVE_UNISTD_H 1
+/* #undef HAVE_UTIL_DEBUG_H */
+/* #undef HAVE_UTIL_MSGI18N_H */
+#define HAVE_UTIME_H 1
+/* #undef HAVE_X11_SUNKEYSYM_H */
+/* #undef HAVE_XM_XM_H */
+/* #undef HAVE_XM_XPMP_H */
+/* #undef HAVE_XM_TRAITP_H */
+/* #undef HAVE_XM_MANAGER_H */
+/* #undef HAVE_XM_UNHIGHLIGHTT_H */
+/* #undef HAVE_XM_JOINSIDET_H */
+/* #undef HAVE_XM_NOTEBOOK_H */
+/* #undef HAVE_X11_XPM_H */
+/* #undef HAVE_X11_XMU_EDITRES_H */
+#define HAVE_X11_SM_SMLIB_H 1
+
+/* Define to the type of the XpmAttributes type. */
+/* #undef XPMATTRIBUTES_TYPE */
+
+/* Define if you have <sys/wait.h> that is POSIX.1 compatible.  */
+#define HAVE_SYS_WAIT_H 1
+
+/* Define if you have a <sys/wait.h> that is not POSIX.1 compatible. */
+/* #undef HAVE_UNION_WAIT */
+
+/* This is currently unused in vim: */
+/* Define if you have the ANSI C header files. */
+/* #undef STDC_HEADERS */
+
+/* instead, we check a few STDC things ourselves */
+#define HAVE_STDARG_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+
+/* Define if strings.h cannot be included when strings.h already is */
+#define NO_STRINGS_WITH_STRING_H 1
+
+/* Define if you want tiny features. */
+/* #undef FEAT_TINY */
+
+/* Define if you want small features. */
+/* #undef FEAT_SMALL */
+
+/* Define if you want normal features. */
+#define FEAT_NORMAL 1
+
+/* Define if you want big features. */
+/* #undef FEAT_BIG */
+
+/* Define if you want huge features. */
+/* #undef FEAT_HUGE */
+
+/* Define if you want to include the MzScheme interpreter. */
+/* #undef FEAT_MZSCHEME */
+
+/* Define if you want to include the Perl interpreter. */
+/* #undef FEAT_PERL */
+
+/* Define if you want to include the Python interpreter. */
+#define FEAT_PYTHON 1
+
+/* Define if you want to include the Ruby interpreter. */
+#define FEAT_RUBY 1
+
+/* Define if you want to include the Tcl interpreter. */
+/* #undef FEAT_TCL */
+
+/* Define if you want to include the Sniff interface. */
+/* #undef FEAT_SNIFF */
+
+/* Define if you want to add support for ACL */
+#define HAVE_POSIX_ACL 1
+/* #undef HAVE_SOLARIS_ACL */
+/* #undef HAVE_AIX_ACL */
+
+/* Define if you want to add support of GPM (Linux console mouse daemon) */
+/* #undef HAVE_GPM */
+
+/* Define if you want to add support of sysmouse (*BSD console mouse) */
+/* #undef HAVE_SYSMOUSE */
+
+/* Define if you want to include the Cscope interface. */
+/* #undef FEAT_CSCOPE */
+
+/* Define if you want to include multibyte support. */
+#define FEAT_MBYTE 1
+
+/* Define if you want to include fontset support. */
+/* #undef FEAT_XFONTSET */
+
+/* Define if you want to include XIM support. */
+/* #undef FEAT_XIM */
+
+/* Define if you want to include Hangul input support. */
+/* #undef FEAT_HANGULIN */
+
+/* Define if you use GTK and want GNOME support. */
+/* #undef FEAT_GUI_GNOME */
+
+/* Define if you use KDE and want KDE Toolbar support. */
+/* #undef FEAT_KDETOOLBAR */
+
+/* Define if GTK+ 2 is available. */
+/* #undef HAVE_GTK2 */
+
+/* Define if GTK+ multihead support is available (requires GTK+ >= 2.1.1). */
+/* #undef HAVE_GTK_MULTIHEAD */
+
+/* Define if your X has own locale library */
+/* #undef X_LOCALE */
+
+/* Define if we have dlfcn.h. */
+#define HAVE_DLFCN_H 1
+
+/* Define if there is a working gettext(). */
+/* #undef HAVE_GETTEXT */
+
+/* Define if _nl_msg_cat_cntr is present. */
+/* #undef HAVE_NL_MSG_CAT_CNTR */
+
+/* Define if we have dlopen() */
+#define HAVE_DLOPEN 1
+
+/* Define if we have dlsym() */
+#define HAVE_DLSYM 1
+
+/* Define if we have dl.h. */
+/* #undef HAVE_DL_H */
+
+/* Define if we have shl_load() */
+/* #undef HAVE_SHL_LOAD */
+
+/* Define if you want to include Sun Visual Workshop support. */
+/* #undef FEAT_SUN_WORKSHOP */
+
+/* Define if you want to include NetBeans integration. */
+#define FEAT_NETBEANS_INTG 1
+
+/* Define default global runtime path */
+/* #undef RUNTIME_GLOBAL */
+
+/* Define name of who modified a released Vim */
+/* #undef MODIFIED_BY */
+
+/* Define if you want XSMP interaction as well as vanilla swapfile safety */
+#define USE_XSMP_INTERACT 1