Backport #8593

MKMF have_framework check assumes the framework and header are identically named

Added by Karl Smeltzer about 2 years ago. Updated about 2 years ago.

[ruby-core:55745]
Status:Closed
Priority:Normal
Assignee:Tomoyuki Chikanaga

Description

I am working on a Ruby extension in which the C code links against SDL2.0 on OSX. This is distributed as an OSX framework (SDL2.framework directory) but the primary header file is simply SDL.h and not SDL2.h

When I add have_framework('SDL2') to my extconf.rb file, it fails the check because it only tests for SDL2/SDL2.h

If I create a symlink named SDL2.h in the same directory, then the check passes and everything builds correctly.

Associated revisions

Revision 41777
Added by Nobuyoshi Nakada about 2 years ago

mkmf.rb: header in framework

  • lib/mkmf.rb (have_framework): allow header file to check. [Bug #8593]

Revision 41779
Added by Nobuyoshi Nakada about 2 years ago

mkmf.rb: old syntax

  • lib/mkmf.rb (have_framework): get rid of newer syntax to run with ruby 1.8 for cross compiling. [Bug #8593]

Revision 42357
Added by Tomoyuki Chikanaga about 2 years ago

merge revision(s) 41777,41779: [Backport #8593]

* lib/mkmf.rb (have_framework): allow header file to check.
   [Bug #8593]

History

#1 Updated by Nobuyoshi Nakada about 2 years ago

  • Status changed from Open to Feedback

=begin
How about passing the header name by an optional argument?

have_framework("SDL2", header: "SDL.h")

diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 7f472f4..464cbbf 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -1081,9 +1081,9 @@ SRC
# the +HAVE_FRAMEWORK_RUBY+ preprocessor macro would be passed to the
# compiler.
#
- def have_framework(fw, &b)
+ def have_framework(fw, header: "#{fw}.h", &b)
checking_for fw do
- src = cpp_include("#{fw}/#{fw}.h") << "\n" "int main(void){return 0;}"
+ src = cpp_include("#{fw}/#{header}") << "\n" "int main(void){return 0;}"
opt = " -framework #{fw}"
if try_link(src, "-ObjC#{opt}", &b)
$defs.push(format("-DHAVE_FRAMEWORK_%s", fw.tr_cpp))
=end

#2 Updated by Nobuyoshi Nakada about 2 years ago

-framework option implies -l option, does the library name differ from its framework name?

#3 Updated by Nobuyoshi Nakada about 2 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r41777.
Karl, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


mkmf.rb: header in framework

  • lib/mkmf.rb (have_framework): allow header file to check. [Bug #8593]

#4 Updated by Tomoyuki Chikanaga about 2 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby trunk to Backport200
  • Status changed from Closed to Assigned
  • Assignee set to Tomoyuki Chikanaga

#5 Updated by Tomoyuki Chikanaga about 2 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r42357.
Karl, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 41777,41779: [Backport #8593]

* lib/mkmf.rb (have_framework): allow header file to check.
   [Bug #8593]

Also available in: Atom PDF