summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2013-12-22 13:28:13 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2013-12-22 13:28:13 -0800
commiteb79b6b7254d0a828d34db756cd6ee371ffe35f8 (patch)
tree3cd705c3a2e3c9e2cd7dab47df220044c8f85e3b /ext
parent65889e7a8f664f38bc6577ec2c9d9f3e72ee970b (diff)
downloadffi-yajl-eb79b6b7254d0a828d34db756cd6ee371ffe35f8.tar.gz
stop extracting ruby's cflags and ldflags
too hard to get this right in a portable fashion.
Diffstat (limited to 'ext')
-rw-r--r--ext/libyajl2/extconf.rb38
1 files changed, 21 insertions, 17 deletions
diff --git a/ext/libyajl2/extconf.rb b/ext/libyajl2/extconf.rb
index 8df1541..db3c094 100644
--- a/ext/libyajl2/extconf.rb
+++ b/ext/libyajl2/extconf.rb
@@ -1,21 +1,25 @@
#!/usr/bin/env ruby
-if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
- require 'mkmf'
- require 'rbconfig'
+require 'rbconfig'
+
+cflags = ENV['CFLAGS']
+ldflags = ENV['LDFLAGS']
+cc = ENV['CC']
+
+# use the CC that ruby was compiled with by default
+cc ||= RbConfig::MAKEFILE_CONFIG['CC']
- # the customer is always right, ruby is always compiled to be stupid
- $CFLAGS = ENV['CFLAGS'] if ENV['CFLAGS']
- $LDFLAGS = ENV['LDFLAGS'] if ENV['LDFLAGS']
- RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
+# then ultimately default back to gcc
+cc ||= "gcc"
- # except if you're doing an unoptimized gcc install we're going to help you out a bit
- if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc|clang/
- $CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
- # how many people realize that -Wall is a compiler-specific flag???
- # apparently not many based on reading lots of shitty extconf.rb's out there
- $CFLAGS << " -Wall"
- end
+# FIXME: add more compilers with default options
+if cc =~ /gcc|clang/
+ cflags << " -O3" unless cflags[/-O\d/]
+ cflags << " -Wall"
+end
+
+if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
+ require 'mkmf'
# yajl_complete_parse is only in >= 2.0
libyajl2_ok = have_library("yajl", "yajl_complete_parse", [ "yajl/yajl_parse.h" ])
@@ -28,9 +32,9 @@ end
prefix=File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
unless libyajl2_ok
- ENV['CFLAGS'] = RbConfig::expand "$(CFLAGS)"
- ENV['LDFLAGS'] = RbConfig::expand "$(LDFLAGS)"
- ENV['CC'] = RbConfig::MAKEFILE_CONFIG['CC']
+ ENV['CFLAGS'] = cflags
+ ENV['LDFLAGS'] = ldflags
+ ENV['CC'] = cc
puts "CFLAGS = #{ENV['CFLAGS']}"
puts "LDFLAGS = #{ENV['LDFLAGS']}"
puts "CC = #{ENV['CC']}"