@@ -1,140 +1,7 @@
1-# Environment Variable Configuration:
2-#
3-# MRUBY_MIRB_READLINE - Control which readline library mirb uses:
4-# auto (default) - Auto-detect: try readline, then edit, then linenoise
5-# readline, gnu - Force GNU readline only
6-# edit, libedit - Force libedit only
7-# linenoise - Force linenoise only
8-# none, off, false, disabled - Use plain input mode (no readline)
9-#
10-# Example:
11-# MRUBY_MIRB_READLINE=none rake
12-# MRUBY_MIRB_READLINE=linenoise rake
13-141MRuby::Gem::Specification.new('mruby-bin-mirb') do |spec|
152spec.license = 'MIT'
163spec.author = 'mruby developers'
174spec.summary = 'mirb command'
18-19-# Allow user to override readline detection via environment variable
20-readline_mode = (ENV['MRUBY_MIRB_READLINE'] || 'auto').downcase
21-22-case readline_mode
23-when 'auto'
24-# Auto-detect: try readline, then edit, then linenoise (default behavior)
25-if spec.build.cc.search_header_path 'readline/readline.h'
26-spec.cc.defines << "MRB_USE_READLINE"
27-spec.cc.defines << "MRB_READLINE_HEADER='<readline/readline.h>'"
28-spec.cc.defines << "MRB_READLINE_HISTORY='<readline/history.h>'"
29-if spec.build.cc.search_header_path 'termcap.h'
30-if MRUBY_BUILD_HOST_IS_CYGWIN || MRUBY_BUILD_HOST_IS_OPENBSD
31-if spec.build.cc.search_header_path 'termcap.h'
32-if MRUBY_BUILD_HOST_IS_CYGWIN then
33-spec.linker.libraries << 'ncurses'
34-else
35-spec.linker.libraries << 'termcap'
36-end
37-end
38-end
39-end
40-if RUBY_PLATFORM.include?('netbsd')
41-spec.linker.libraries << 'edit'
42-else
43-spec.linker.libraries << 'readline'
44-if RUBY_PLATFORM.include?('darwin')
45-# Workaround to build with Homebrew's readline on Mac (#4537)
46-lib_path = spec.build.cc.header_search_paths.find do |include_path|
47-lib_path = File.expand_path("#{include_path}/../lib")
48-break lib_path if File.exist?("#{lib_path}/libreadline.dylib") ||
49-File.exist?("#{lib_path}/libreadline.a")
50-end
51-spec.linker.library_paths << lib_path if lib_path
52-elsif spec.build.cc.search_header_path 'curses.h'
53-spec.linker.libraries << 'ncurses'
54-if spec.build.cc.search_header_path 'term.h'
55-spec.linker.libraries << 'tinfo'
56-end
57-elsif spec.build.cc.search_header_path 'ncursesw/curses.h'
58-spec.linker.libraries << 'ncursesw'
59-if spec.build.cc.search_header_path 'ncursesw/term.h'
60-spec.linker.libraries << 'tinfow'
61-end
62-end
63-end
64-elsif spec.build.cc.search_header_path 'edit/readline/readline.h'
65-spec.cc.defines << "MRB_USE_READLINE"
66-spec.cc.defines << "MRB_READLINE_HEADER='<edit/readline/readline.h>'"
67-spec.cc.defines << "MRB_READLINE_HISTORY='<edit/readline/history.h>'"
68-spec.linker.libraries << "edit"
69-elsif spec.build.cc.search_header_path 'linenoise.h'
70-spec.cc.defines << "MRB_USE_LINENOISE"
71-end
72-73-when 'readline', 'gnu'
74-# Force GNU readline only
75-if spec.build.cc.search_header_path 'readline/readline.h'
76-spec.cc.defines << "MRB_USE_READLINE"
77-spec.cc.defines << "MRB_READLINE_HEADER='<readline/readline.h>'"
78-spec.cc.defines << "MRB_READLINE_HISTORY='<readline/history.h>'"
79-if spec.build.cc.search_header_path 'termcap.h'
80-if MRUBY_BUILD_HOST_IS_CYGWIN || MRUBY_BUILD_HOST_IS_OPENBSD
81-if spec.build.cc.search_header_path 'termcap.h'
82-if MRUBY_BUILD_HOST_IS_CYGWIN then
83-spec.linker.libraries << 'ncurses'
84-else
85-spec.linker.libraries << 'termcap'
86-end
87-end
88-end
89-end
90-if RUBY_PLATFORM.include?('netbsd')
91-spec.linker.libraries << 'edit'
92-else
93-spec.linker.libraries << 'readline'
94-if RUBY_PLATFORM.include?('darwin')
95-lib_path = spec.build.cc.header_search_paths.find do |include_path|
96-lib_path = File.expand_path("#{include_path}/../lib")
97-break lib_path if File.exist?("#{lib_path}/libreadline.dylib") ||
98-File.exist?("#{lib_path}/libreadline.a")
99-end
100-spec.linker.library_paths << lib_path if lib_path
101-elsif spec.build.cc.search_header_path 'curses.h'
102-spec.linker.libraries << 'ncurses'
103-if spec.build.cc.search_header_path 'term.h'
104-spec.linker.libraries << 'tinfo'
105-end
106-elsif spec.build.cc.search_header_path 'ncursesw/curses.h'
107-spec.linker.libraries << 'ncursesw'
108-if spec.build.cc.search_header_path 'ncursesw/term.h'
109-spec.linker.libraries << 'tinfow'
110-end
111-end
112-end
113-end
114-115-when 'edit', 'libedit'
116-# Force libedit only
117-if spec.build.cc.search_header_path 'edit/readline/readline.h'
118-spec.cc.defines << "MRB_USE_READLINE"
119-spec.cc.defines << "MRB_READLINE_HEADER='<edit/readline/readline.h>'"
120-spec.cc.defines << "MRB_READLINE_HISTORY='<edit/readline/history.h>'"
121-spec.linker.libraries << "edit"
122-end
123-124-when 'linenoise'
125-# Force linenoise only
126-if spec.build.cc.search_header_path 'linenoise.h'
127-spec.cc.defines << "MRB_USE_LINENOISE"
128-end
129-130-when 'none', 'off', 'false', 'disabled'
131-# Disable readline - use plain input mode
132-133-else
134-fail "Invalid MRUBY_MIRB_READLINE='#{readline_mode}'. " \
135-"Valid values: auto, readline, gnu, edit, libedit, linenoise, none, off, false, disabled"
136-end
137-1385spec.bins = %w(mirb)
1396spec.add_dependency('mruby-compiler', :core => 'mruby-compiler')
1407end