Feature #3330

mkmf (find|have)_cxx_header

Added by Makoto Kishimoto almost 4 years ago. Updated over 1 year ago.

[ruby-dev:41386]
Status:Rejected
Priority:Low
Assignee:Nobuyoshi Nakada
Category:-
Target version:-

Description

=begin
うっかりruby-listに投げてしまったきしもとです

で振ってみた話題に関係して、なのですが(ツリーになりませんでしたが)、
mkmf に C++ のヘッダをチェックする機能を追加するパッチです。

Index: configure.in
===================================================================
--- configure.in (revision 27940)
+++ configure.in (working copy)
@@ -243,6 +243,7 @@
fi
ACPROGCC
ACPROGCXX
+ACPROGCXXCPP
ACPROGGCCTRADITIONAL
AC
SUBST(GCC)
if test "$GCC" = yes; then
Index: lib/mkmf.rb
===================================================================
--- lib/mkmf.rb (revision 27940)
+++ lib/mkmf.rb (working copy)
@@ -408,6 +408,14 @@
conf)
end

+def cxxcppcommand(outfile, opt="")
+ conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote,
+ 'arch
hdrdir' => "#$archhdrdir",
+ 'top
srcdir' => $topsrcdir.quote)
+ RbConfig::expand("$(CXXCPP) #$INCFLAGS #$CPPFLAGS #$CXXFLAGS #{opt} #{CONFTEST
C} #{outfile}",
+ conf)
+end
+
def libpathflag(libpath=$DEFLIBPATH|$LIBPATH)
libpath.map{|x|
case x
@@ -454,8 +462,15 @@
rm_f "conftest*"
end

+def trycxxcpp(src, opt="", &b)
+ try
do(src, cxxcppcommand(CPPOUTFILE, opt), &b)
+ensure
+ rm
f "conftest*"
+end
+
class Object
aliasmethod :tryheader, (configstring('tryheader') || :trycpp)
+ alias
method :trycxxheader, (configstring('trycxxheader') || :trycxxcpp)
end

def cpp_include(header)
@@ -840,6 +855,24 @@
end
end

+# Returns whether or not the given C plus plus +header+ file can be found on
+# your system. If found, a macro is passed as a preprocessor constant to the
+# compiler using the header file name, in uppercase, prepended with 'HAVE'.
+#
+# For example, if have
header('foo.h') returned true, then the HAVEFOOH
+# preprocessor macro would be passed to the compiler.
+#
+def havecxxheader(header, preheaders = nil, &b)
+ checkingfor header do
+ if try
cxxheader(cppinclude(preheaders)+cppinclude(header), &b)
+ $defs.push(format("-DHAVE
%s", header.tr_cpp))
+ 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.
#
@@ -867,6 +900,33 @@
end
end

+# Instructs mkmf to search for the given C plus plus +header+ in any of the
+# +paths+ provided, and returns whether or not it was found in those paths.
+#
+# If the header is found then the path it was found on is added to the list
+# of included directories that are sent to the compiler (via the -I switch).
+#
+def findcxxheader(header, *paths)
+ message = checkingmessage(header, paths)
+ header = cpp
include(header)
+ checkingfor message do
+ if try
cxxheader(header)
+ true
+ else
+ found = false
+ paths.each do |dir|
+ opt = "-I#{dir}".quote
+ if try
cxx_header(header, opt)
+ $INCFLAGS << " " << opt
+ found = true
+ break
+ end
+ end
+ found
+ end
+ end
+end
+
# Returns whether or not the struct of type +type+ contains +member+. If
# it does not, or the struct type can't be found, then false is returned. You
# may optionally specify additional +headers+ in which to look for the struct
=end


Related issues

Related to ruby-trunk - Feature #4924: mkmf have_header fails with C++ headers Assigned 06/24/2011

History

#1 Updated by Yusuke Endoh about 2 years ago

  • Description updated (diff)
  • Status changed from Open to Assigned
  • Assignee set to Nobuyoshi Nakada

#2 Updated by Yusuke Endoh over 1 year ago

  • Status changed from Assigned to Rejected

#3333 と重複らしいのでこっちは閉じますね。(せっかくなのでキリ番を残す)

Yusuke Endoh mame@tsg.ne.jp

Also available in: Atom PDF