summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-27 09:59:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-27 09:59:29 +0000
commit444b943e354725bf623a050c88a4a8bd3f926c74 (patch)
tree282c9126cabed3d85b2d2fc57ee0ec520760ee63 /lib
parent58f1d31a1ddd071f092600d155601592f3930163 (diff)
* lib/mkmf.rb (have_framework): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/mkmf.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 696609a6a4..c1cd3dfefb 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -839,6 +839,26 @@ def have_header(header, preheaders = nil, &b)
end
end
+# Returns whether or not the given +framework+ can be found on your system.
+# If found, a macro is passed as a preprocessor constant to the compiler using
+# the framework name, in uppercase, prepended with 'HAVE_FRAMEWORK_'.
+#
+# For example, if have_framework('Ruby') returned true, then the HAVE_FRAMEWORK_RUBY
+# preprocessor macro would be passed to the compiler.
+#
+def have_framework(fw, &b)
+ checking_for fw do
+ src = cpp_include("#{fw}/#{fw}.h") << "\n" "int main(void){return 0;}"
+ if try_link(src, opt = "-framework #{fw}", &b)
+ $defs.push(format("-DHAVE_FRAMEWORK_%s", fw.tr_cpp))
+ $LDFLAGS << " " << opt
+ true
+ else
+ false
+ end
+ end
+end
+
# Instructs mkmf to search for the given +header+ in any of the +paths+
# provided, and returns whether or not it was found in those paths.
#
@@ -1875,6 +1895,12 @@ site-install-rb: install-rb
mfile.printf("\n\t%s\n\n", COMPILE_C)
end
end
+ %w[m].each do |e|
+ COMPILE_RULES.each do |rule|
+ mfile.printf(rule, e, $OBJEXT)
+ mfile.printf("\n\t%s\n\n", COMPILE_OBJC)
+ end
+ end
mfile.print "$(RUBYARCHDIR)/" if $extout
mfile.print "$(DLLIB): "
@@ -2037,6 +2063,7 @@ COMPILE_RULES = config_string('COMPILE_RULES', &split) || %w[.%s.%s:]
RULE_SUBST = config_string('RULE_SUBST')
COMPILE_C = config_string('COMPILE_C') || '$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<'
COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<'
+COMPILE_OBJC = config_string('COMPILE_OBJC') || COMPILE_C
TRY_LINK = config_string('TRY_LINK') ||
"$(CC) #{OUTFLAG}conftest $(INCFLAGS) $(CPPFLAGS) " \
"$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"