summaryrefslogtreecommitdiff
path: root/ext/extmk.rb.in
diff options
context:
space:
mode:
Diffstat (limited to 'ext/extmk.rb.in')
-rw-r--r--ext/extmk.rb.in30
1 files changed, 16 insertions, 14 deletions
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index c97f86a687..272a508e0f 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -218,29 +218,31 @@ SRC
return true
end
-def have_func(func)
+def have_func(func, header=nil)
libs = $libs
-
- if /mswin32|mingw/ =~ RUBY_PLATFORM
- r = try_link(<<"SRC", libs)
+ src =
+ if /mswin32|mingw/ =~ RUBY_PLATFORM
+ r = <<"SRC"
#include <windows.h>
#include <winsock.h>
+SRC
+ else
+ ""
+ end
+ unless header.nil?
+ src << <<"SRC"
+#include <#{header}>
+SRC
+ end
+ r = try_link(src + <<"SRC", libs)
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
- unless r
- r = try_link(<<"SRC", libs)
-#include <windows.h>
-#include <winsock.h>
+ unless r
+ r = try_link(src + <<"SRC", libs)
int main() { return 0; }
int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; }
SRC
- end
- else
- r = try_link(<<"SRC", libs)
-int main() { return 0; }
-int t() { #{func}(); return 0; }
-SRC
end
unless r
return false