blob: a54c7c37ad189b6fdaeb0ab71e33422db5f6c292 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/usr/bin/env ruby
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']
cflags ||= ""
ldflags ||= ""
# then ultimately default back to gcc
cc ||= "gcc"
# 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" ])
else
# always install libyajl2 on Jruby
# FIXME: get the conditional mkmf stuff to work on Jruby
libyajl2_ok = false
end
prefix=File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
unless libyajl2_ok
ENV['CFLAGS'] = cflags
ENV['LDFLAGS'] = ldflags
ENV['CC'] = cc
puts "CFLAGS = #{ENV['CFLAGS']}"
puts "LDFLAGS = #{ENV['LDFLAGS']}"
puts "CC = #{ENV['CC']}"
system "wget -O yajl-2.0.1.tar.gz http://github.com/lloyd/yajl/tarball/2.0.1" or raise "wget failed"
system "tar xvf yajl-2.0.1.tar.gz" or raise "tar xvf failed"
Dir.chdir "lloyd-yajl-f4b2b1a" or raise "chdir failed"
system "./configure --prefix=#{prefix} > /tmp/libyajl.out" or raise "configure failed"
system "make install >> /tmp/libyajl.out" or raise "make install failed"
Dir.chdir ".."
end
dir_config 'libyajl2'
File.open("Makefile", "w") do |mf|
mf.puts "# Dummy makefile for non-mri rubies"
mf.puts "all install::\n"
end
|