diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-25 14:17:33 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-25 14:17:33 +0000 |
commit | 5e9dc52be520c976bcba1c5932a2ef9e567972eb (patch) | |
tree | ceaa2a5613209d50e451bc25fb00213dfcbdb9e9 | |
parent | a0fa43b0948f1811f3965d0965afc9b5b3bbb9f0 (diff) | |
download | ruby-5e9dc52be520c976bcba1c5932a2ef9e567972eb.tar.gz |
* ext/curses/extconf.rb: Implement
--with-curses-version={function,variable} configure option for
cross-compiling.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ext/curses/extconf.rb | 78 |
2 files changed, 54 insertions, 30 deletions
@@ -1,3 +1,9 @@ +Thu Apr 25 23:16:28 2013 Tanaka Akira <akr@fsij.org> + + * ext/curses/extconf.rb: Implement + --with-curses-version={function,variable} configure option for + cross-compiling. + Thu Apr 25 18:15:46 2013 Tanaka Akira <akr@fsij.org> * ext/socket/extconf.rb: Don't use WIDE getaddrinfo by default. diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb index f63de1cd6c..467494e190 100644 --- a/ext/curses/extconf.rb +++ b/ext/curses/extconf.rb @@ -77,39 +77,57 @@ if header_library # SVR4 curses has a (undocumented) variable char *curses_version. # ncurses and PDcurses has a function char *curses_version(). # Note that the original BSD curses doesn't provide version information. + # + # configure option: + # --with-curses-version=function for SVR4 + # --with-curses-version=variable for ncurses and PDcurses + # (not given) automatically determined - prolog = cpp_include(curses) - if checking_for(checking_message('function curses_version', curses)) { - try_run(<<-"End") - #{prolog} - int main(int argc, char *argv[]) - { - curses_version(); - return EXIT_SUCCESS; - } - End - } + case with_curses_version = with_config("curses-version") + when "function" $defs << '-DHAVE_FUNC_CURSES_VERSION' - end - - if checking_for(checking_message('variable curses_version', curses)) { - try_run(<<-"End") - #{prolog} - extern char *curses_version; - int main(int argc, char *argv[]) - { - int i = 0; - for (i = 0; i < 100; i++) { - if (curses_version[i] == 0) - return 0 < i ? EXIT_SUCCESS : EXIT_FAILURE; - if (curses_version[i] & 0x80) - return EXIT_FAILURE; - } - return EXIT_FAILURE; - } - End - } + when "variable" $defs << '-DHAVE_VAR_CURSES_VERSION' + when nil + function_p = nil + variable_p = nil + if [header, library].any? {|v| /ncurses|pdcurses|xcurses/i =~ v } + function_p = true + end + if !CROSS_COMPILING + prolog = cpp_include(curses) + function_p = checking_for(checking_message('function curses_version', curses)) { + try_run(<<-"End") + #{prolog} + int main(int argc, char *argv[]) + { + curses_version(); + return EXIT_SUCCESS; + } + End + } + variable_p = checking_for(checking_message('variable curses_version', curses)) { + try_run(<<-"End") + #{prolog} + extern char *curses_version; + int main(int argc, char *argv[]) + { + int i = 0; + for (i = 0; i < 100; i++) { + if (curses_version[i] == 0) + return 0 < i ? EXIT_SUCCESS : EXIT_FAILURE; + if (curses_version[i] & 0x80) + return EXIT_FAILURE; + } + return EXIT_FAILURE; + } + End + } + end + $defs << '-DHAVE_FUNC_CURSES_VERSION' if function_p + $defs << '-DHAVE_VAR_CURSES_VERSION' if variable_p + else + warn "unexpeted value for --with-curses-version: #{with_curses_version}" end create_makefile("curses") |