Skip to content

Instantly share code, notes, and snippets.

@kjunichi
Last active October 14, 2015 02:18
Show Gist options
  • Save kjunichi/81d876fe0c7307ba3978 to your computer and use it in GitHub Desktop.
Save kjunichi/81d876fe0c7307ba3978 to your computer and use it in GitHub Desktop.
building mruby-onig-regexp on cygwin

m4/libtool.m4

5194c5194,5202
<       _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
---
>       #_LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
>   case $build_os in
>     cygwin*)
>       _LT_TAGVAR(old_archive_cmds, $1)='ar rcs $oldlib $oldobjs $old_deplibs'
>       ;;
>   *)
>       _LT_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
>       ;;
>   esac

mrbgem.rake

--- a/deps/mruby-onig-regexp/mrbgem.rake
+++ b/deps/mruby-onig-regexp/mrbgem.rake
@@ -14,7 +14,7 @@ MRuby::Gem::Specification.new('mruby-onig-regexp') do |spec|
     version = '5.15.0'
     oniguruma_dir = "#{build_dir}/Onigmo-Onigmo-#{version}"
     oniguruma_lib = libfile "#{oniguruma_dir}/.libs/libonig"
-    unless ENV['OS'] == 'Windows_NT'
+    unless ENV['OS'] == 'Windows_N_'
       oniguruma_lib = libfile "#{oniguruma_dir}/.libs/libonig"
     else
       oniguruma_lib = libfile "#{oniguruma_dir}/onig_s"
@@ -30,8 +30,9 @@ MRuby::Gem::Specification.new('mruby-onig-regexp') do |spec|
       Dir.chdir(build_dir) do
         _pp 'extracting', "Onigmo-#{version}"
         `gzip -dc "#{dir}/Onigmo-#{version}.tar.gz" | tar xf -`
+        `cp #{dir}/libtool.m4 #{oniguruma_dir}/m4/libtool.m4`
       end
-      unless ENV['OS'] == 'Windows_NT'
+      unless ENV['OS'] == 'Windows_N_'
         Dir.chdir(oniguruma_dir) do
           `patch -p0 < #{dir}/Onigmo-bsd-compat.patch`
         end
@@ -56,11 +57,12 @@ MRuby::Gem::Specification.new('mruby-onig-regexp') do |spec|
           'CXX' => "#{build.cxx.command} #{build.cxx.flags.join(' ')}",
           'LD' => "#{build.linker.command} #{build.linker.flags.join(' ')}",
           'AR' => build.archiver.command }
-        unless ENV['OS'] == 'Windows_NT'
+        unless ENV['OS'] == 'Windows_N_'
           _pp 'autotools', oniguruma_dir
           run_command e, './autogen.sh' if File.exists? 'autogen.sh'
-          run_command e, './configure --disable-shared --enable-static'
+          run_command e, './configure --disable-shared --enable-static --with-gnu-ld'
           run_command e, 'make'
+          run_command e, 'cp .libs/libonig.lib .libs/libonig.a'
         else
           run_command e, 'cmd /c "copy /Y win32 > NUL"'
           run_command e, 'make -f Makefile.mingw'
@@ -69,6 +71,8 @@ MRuby::Gem::Specification.new('mruby-onig-regexp') do |spec|

       FileUtils.mkdir_p libonig_objs_dir
       Dir.chdir(libonig_objs_dir) { `ar x #{oniguruma_lib}` }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment