summaryrefslogtreecommitdiff
path: root/ext/psych/extconf.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/psych/extconf.rb')
-rw-r--r--ext/psych/extconf.rb38
1 files changed, 27 insertions, 11 deletions
diff --git a/ext/psych/extconf.rb b/ext/psych/extconf.rb
index fe7795f..65e83a3 100644
--- a/ext/psych/extconf.rb
+++ b/ext/psych/extconf.rb
@@ -1,21 +1,37 @@
+# -*- coding: us-ascii -*-
require 'mkmf'
+require 'fileutils'
# :stopdoc:
-RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
+dir_config 'libyaml'
-INCLUDEDIR = Config::CONFIG['includedir']
-LIBDIR = Config::CONFIG['libdir']
-LIB_DIRS = ['/opt/local/lib', '/usr/local/lib', LIBDIR, '/usr/lib']
-libyaml = dir_config 'libyaml', '/opt/local/include', '/opt/local/lib'
+if enable_config("bundled-libyaml", false) || !(find_header('yaml.h') && find_library('yaml', 'yaml_get_version'))
+ # Embed libyaml since we could not find it.
-def asplode missing
- abort "#{missing} is missing. Try 'port install libyaml +universal' " +
- "or 'yum install libyaml-devel'"
-end
+ $VPATH << "$(srcdir)/yaml"
+ $INCFLAGS << " -I$(srcdir)/yaml"
+
+ $srcs = Dir.glob("#{$srcdir}/{,yaml/}*.c").map {|n| File.basename(n)}
+
+ if have_macro("_WIN32")
+ $CPPFLAGS << " -DYAML_DECLARE_STATIC -DHAVE_CONFIG_H"
+ end
-asplode('yaml.h') unless find_header 'yaml.h'
-asplode('libyaml') unless find_library 'yaml', 'yaml_get_version'
+ have_header 'dlfcn.h'
+ have_header 'inttypes.h'
+ have_header 'memory.h'
+ have_header 'stdint.h'
+ have_header 'stdlib.h'
+ have_header 'strings.h'
+ have_header 'string.h'
+ have_header 'sys/stat.h'
+ have_header 'sys/types.h'
+ have_header 'unistd.h'
+
+ find_header 'yaml.h'
+ have_header 'config.h'
+end
create_makefile 'psych'