summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-bin-mirb/mrbgem.rake
blob: a4ae6840ac9a778bd8188763bd4ebdd0ef9d65fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
MRuby::Gem::Specification.new('mruby-bin-mirb') do |spec|
  spec.license = 'MIT'
  spec.author  = 'mruby developers'
  spec.summary = 'mirb command'

  if spec.build.cc.search_header_path 'readline/readline.h'
    spec.cc.defines << "ENABLE_READLINE"
    if spec.build.cc.search_header_path 'termcap.h'
      if MRUBY_BUILD_HOST_IS_CYGWIN || MRUBY_BUILD_HOST_IS_OPENBSD
        if spec.build.cc.search_header_path 'termcap.h'
          if MRUBY_BUILD_HOST_IS_CYGWIN then
            spec.linker.libraries << 'ncurses'
          else
            spec.linker.libraries << 'termcap'
          end
        end
      end
    end
    if RUBY_PLATFORM.include?('netbsd')
      spec.linker.libraries << 'edit'
    else
      spec.linker.libraries << 'readline'
      if RUBY_PLATFORM.include?('darwin')
        # Workaround to build with Homebrew's readline on Mac (#4537)
        lib_path = spec.build.cc.header_search_paths.find do |include_path|
          lib_path = File.expand_path("#{include_path}/../lib")
          break lib_path if File.exist?("#{lib_path}/libreadline.dylib") ||
                            File.exist?("#{lib_path}/libreadline.a")
        end
        spec.linker.library_paths << lib_path if lib_path
      end
      if spec.build.cc.search_header_path 'curses.h'
        spec.linker.libraries << 'ncurses'
      end
    end
  elsif spec.build.cc.search_header_path 'linenoise.h'
    spec.cc.defines << "ENABLE_LINENOISE"
  end

  spec.bins = %w(mirb)
  spec.add_dependency('mruby-compiler', :core => 'mruby-compiler')
end