summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-22 10:09:31 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-22 10:09:31 +0000
commit9fc31792ce55306e977f65d9a44f3da3e015a4cf (patch)
tree07aab9e589f78bb9678c440f98183f141d92ff14 /ext
parent1a6b0bab94a1594d892afd498b08830a29089422 (diff)
* ext/curses/extconf.rb: refactored.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/curses/extconf.rb51
1 files changed, 31 insertions, 20 deletions
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index a23a64014e..cd8f685c8a 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -11,34 +11,45 @@ def transact
result
end
+def check_header_library(hdr, libs)
+ if !have_header(hdr)
+ return nil
+ end
+ libs.each {|lib|
+ if have_library(lib, "initscr")
+ return [hdr, lib]
+ end
+ }
+ nil
+end
+
dir_config('curses')
dir_config('ncurses')
dir_config('termcap')
-make=false
-headers = []
-
have_library("mytinfo", "tgetent") if /bow/ =~ RUBY_PLATFORM
have_library("tinfo", "tgetent") or have_library("termcap", "tgetent")
-curses = nil
-if transact { have_header(*curses=%w"ncurses.h") and
- (have_library("ncursesw", "initscr") or
- have_library("ncurses", "initscr")) }
- make=true
-elsif transact { have_header(*curses=%w"ncurses/curses.h") and
- have_library("ncurses", "initscr") }
- make=true
-elsif transact { have_header(*curses=%w"curses_colr/curses.h") and
- have_library("cur_colr", "initscr") }
- curses.unshift("varargs.h")
- make=true
-elsif transact { have_header(*curses=%w"curses.h") and
- have_library("curses", "initscr") }
- make=true
-end
+header_library = nil
+[
+ ["ncurses.h", ["ncursesw", "ncurses"]],
+ ["ncurses/curses.h", ["ncurses"]],
+ ["curses_colr/curses.h", ["cur_colr"]],
+ ["curses.h", ["curses"]],
+].each {|hdr, libs|
+ header_library = transact { check_header_library(hdr, libs) }
+ if header_library
+ break;
+ end
+}
+
+if header_library
+ header, _ = header_library
+ curses = [header]
+ if header == 'curses_colr/curses.h'
+ curses.unshift("varargs.h")
+ end
-if make
for f in %w(beep bkgd bkgdset curs_set deleteln doupdate flash
getbkgd getnstr init isendwin keyname keypad resizeterm
scrl set setscrreg ungetch