head 1.24; access; symbols RELEASE_1_8_1:1.24 RELEASE_1_8_0:1.23 RELEASE_1_7_0:1.23 RELEASE_1_6_3:1.22 RELEASE_1_6_2:1.22 RELEASE_1_6_1:1.19 RELEASE_1_6_0:1.19 RELEASE_1_5_1:1.6 RELEASE_1_5_0:1.3 RELEASE_1_4_1:1.1 RELEASE_1_4_0:1.1; locks; strict; comment @# @; 1.24 date 2008.11.01.14.23.13; author kou; state Exp; branches; next 1.23; commitid 7IjE9csm76fPQUot; 1.23 date 2008.08.02.01.29.07; author kou; state Exp; branches; next 1.22; commitid C8sMNpEBXuAru9dt; 1.22 date 2008.06.12.14.28.35; author kou; state Exp; branches; next 1.21; commitid 2hgLSmRnH5eCrF6t; 1.21 date 2008.04.30.04.57.50; author kou; state Exp; branches; next 1.20; commitid 714mCxLisQRrF51t; 1.20 date 2008.04.24.13.22.55; author kou; state Exp; branches; next 1.19; commitid 2Tb6f72EUVJLEm0t; 1.19 date 2008.04.04.14.04.26; author kou; state Exp; branches; next 1.18; commitid 6a5hYXK3gq4OwNXs; 1.18 date 2008.04.04.13.55.57; author kou; state Exp; branches; next 1.17; commitid aoonrDAS9btUtNXs; 1.17 date 2008.04.04.05.56.43; author kou; state Exp; branches; next 1.16; commitid l9xqZgOujLcyPKXs; 1.16 date 2008.04.04.05.40.58; author kou; state Exp; branches; next 1.15; commitid AUlgjcBwFx57KKXs; 1.15 date 2008.04.04.04.43.38; author kou; state Exp; branches; next 1.14; commitid Iw5VBosGTIOsqKXs; 1.14 date 2008.04.04.04.37.03; author kou; state Exp; branches; next 1.13; commitid 09ypfr4damadoKXs; 1.13 date 2008.04.04.04.34.06; author kou; state Exp; branches; next 1.12; commitid Y23BiBuwOlxbnKXs; 1.12 date 2008.04.04.04.32.11; author kou; state Exp; branches; next 1.11; commitid HZolpp4vYgywmKXs; 1.11 date 2008.04.04.04.17.26; author kou; state Exp; branches; next 1.10; commitid AwjTKT73ahquhKXs; 1.10 date 2008.04.04.03.59.04; author kou; state Exp; branches; next 1.9; commitid a92LrJRPtXGbbKXs; 1.9 date 2008.04.04.03.44.27; author kou; state Exp; branches; next 1.8; commitid LfIwa9Y6DCLa6KXs; 1.8 date 2008.02.24.07.26.52; author kou; state Exp; branches; next 1.7; commitid RN6VYjYXiOe8CCSs; 1.7 date 2008.01.18.04.00.16; author kou; state Exp; branches; next 1.6; commitid hOWOtVKfRCl3FQNs; 1.6 date 2008.01.11.08.14.34; author kou; state Exp; branches; next 1.5; commitid OEKp3EMv092diYMs; 1.5 date 2007.06.14.12.23.45; author kou; state Exp; branches; next 1.4; 1.4 date 2007.06.14.12.02.59; author kou; state Exp; branches; next 1.3; 1.3 date 2007.04.13.12.35.13; author kou; state Exp; branches; next 1.2; 1.2 date 2007.04.08.06.04.01; author kou; state Exp; branches; next 1.1; 1.1 date 2007.03.06.12.17.33; author kou; state Exp; branches; next ; desc @@ 1.24 log @* extconf.rb, src/rb_cairo_surface.c: check ruby/io.h availability. @ text @#!/usr/bin/env ruby # vim: filetype=ruby:expandtab:shiftwidth=2:tabstop=8:softtabstop=2 : $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'English' require 'mkmf' require 'pkg-config' require 'fileutils' # from mkmf-gnome2.rb STDOUT.print("checking for GCC... ") STDOUT.flush if macro_defined?("__GNUC__", "") STDOUT.print "yes\n" $CFLAGS += ' -Wall' $cc_is_gcc = true else STDOUT.print "no\n" $cc_is_gcc = false end def check_win32 checking_for("Win32 OS") do win32_os = /cygwin|mingw|mswin32/ =~ RUBY_PLATFORM if win32_os $defs << "-DRUBY_CAIRO_PLATFORM_WIN32" if $cc_is_gcc if /^2\./ =~ `#{Config::CONFIG['CC']} -dumpversion`.chomp $CFLAGS += ' -fnative-struct' else $CFLAGS += ' -mms-bitfields' end end end win32_os end end def set_output_lib(target_name, directory=nil) case RUBY_PLATFORM when /cygwin|mingw/ filename = File.join(*([directory, "libruby-#{target_name}.a"].compact)) if RUBY_VERSION > "1.8.0" $DLDFLAGS << ",--out-implib=#{filename}" elsif RUBY_VERSION > "1.8" $DLDFLAGS.gsub!(/ -Wl,--out-implib=[^ ]+/, '') $DLDFLAGS << " -Wl,--out-implib=#{filename}" else $DLDFLAGS.gsub!(/ --output-lib\s+[^ ]+/, '') $DLDFLAGS << " --output-lib #{filename}" end $cleanfiles << filename when /mswin32/ $DLDFLAGS.gsub!(/ --output-lib\s+[^ ]+/, '') $DLDFLAGS.gsub!(/ \/IMPLIB:[^ ]+/, '') $DLDFLAGS << " /IMPLIB:$(IMPLIB)" when /darwin/ if have_macro("CAIRO_HAS_QUARTZ_SURFACE", ["cairo.h"]) checking_for("RubyCocoa") do begin require 'osx/cocoa' $defs << "-DHAVE_RUBY_COCOA" $DLDFLAGS << " -Wl,-framework,RubyCocoa" true rescue LoadError false end end end end end pkg = "cairo" modname = "cairo" ext_dir_name = "src" srcdir = File.join(File.expand_path(File.dirname(__FILE__)), ext_dir_name) major, minor, micro = 1, 2, 0 PKGConfig.have_package(pkg, major, minor, micro) or exit 1 have_header("ruby/st.h") unless have_macro("HAVE_RUBY_ST_H", "ruby.h") have_header("ruby/io.h") unless have_macro("HAVE_RUBY_IO_H", "ruby.h") have_func("rb_errinfo", "ruby.h") have_type("enum ruby_value_type", "ruby.h") check_win32 target_name = File.basename(modname) set_output_lib(target_name, ext_dir_name) $defs << "-DRB_CAIRO_COMPILATION" create_makefile(modname, srcdir) wine = with_config("wine", false) makefile = File.read("Makefile") File.open("Makefile", "w") do |f| objs = [] co = nil makefile.each_line do |line| if wine line.gsub!(/\s+gcc\b/, " i586-mingw32msvc-gcc") line.gsub!(/C:/, "$(HOME)/.wine/drive_c") line.gsub!(/Z:/, "") end case line when /^DLLIB\s*=\s*/ dllib = $POSTMATCH f.puts("DLLIB = #{ext_dir_name}/#{dllib}") f.puts("IMPLIB = #{ext_dir_name}/libruby-#{dllib.gsub(/\..+?$/, '.lib')}") when /^(SRCS)\s*=\s*/ name = $1 vars = $POSTMATCH.split.collect {|var| "$(srcdir)/#{var}"}.join(" ") f.puts("#{name} = #{vars}") when /^(OBJS|CLEANLIBS|CLEANOBJS)\s*=\s*/ name = $1 vars = $POSTMATCH.split.collect {|var| "#{ext_dir_name}/#{var}"} objs = vars if name == "OBJS" vars = vars.join(" ") f.puts("#{name} = #{vars}") when /^LDSHARED\s*=/ def_file = "#{ext_dir_name}/#{target_name}.def" line.gsub!(/\b-shared\b/, "-shared #{def_file}") if wine f.puts(line) when /^\t\$\(CC\)/ if PKGConfig.msvc? output_option = "-Fo" else output_option = "-o" end unless /#{Regexp.escape(output_option)}/ =~ line line = "#{line.chomp} #{output_option}$@@" end co = line f.puts(line) else f.puts(line) end end if co and !objs.empty? f.puts if PKGConfig.msvc? f.puts "{$(srcdir)}.c{#{ext_dir_name}}.obj:" f.puts co else objs.each do |obj| f.puts "#{obj}: $(srcdir)/#{File.basename(obj).sub(/\..+?$/, '.c')}" f.puts co end end end end FileUtils.mkdir_p(ext_dir_name) @ 1.23 log @* README: update Paul van Tilburg's entry. * extconf.rb: check ruby/st.h availability. Suggested by Paul van Tilburg. * src/rb_cairo_surface.c: use HAVE_RUBY_ST_H. @ text @d84 1 @ 1.22 log @* extconf.rb: include . @ text @d83 1 @ 1.21 log @* src/rb_cairo.h: move environment dependent headers to ... * src/rb_cairo_surface.c: ... here. guard T_DATA macro for old Mac OS X environment. * extconf.rb: check enum ruby_value_type availability that is defined in Ruby 1.9 with RUBY_T_DATA. @ text @d83 1 a83 1 have_func("rb_errinfo") @ 1.20 log @* extconf.rb: don't substitute prefixed gcc. @ text @d84 1 @ 1.19 log @* extconf.rb: cleanup libruby-cairo.a. @ text @d99 1 a99 1 line.gsub!(/\bgcc\b/, "i586-mingw32msvc-gcc") @ 1.18 log @* extconf.rb: support building with Wine + MinGW on my Linux environment. @ text @d40 1 a40 1 def set_output_lib(target_name) d43 1 a43 1 filename = "libruby-#{target_name}.a" d53 1 d87 1 a87 1 set_output_lib(target_name) @ 1.17 log @* extconf.rb: use search path for nmake. @ text @d45 1 a45 1 $DLDFLAGS << ",--out-implib=#{filename}" if filename d48 1 a48 1 $DLDFLAGS << " -Wl,--out-implib=#{filename}" if filename d51 1 a51 1 $DLDFLAGS << " --output-lib #{filename}" if filename d85 2 a86 1 set_output_lib(File.basename(modname)) d90 2 d97 6 d106 2 a107 2 f.print("DLLIB = #{ext_dir_name}/#{dllib}") f.print("IMPLIB = #{ext_dir_name}/libruby-#{dllib.gsub(/\..+?$/, '.lib')}") d118 4 d134 1 a134 1 f.print(line) d141 1 a141 1 f.puts "{$(srcdir)}.c{src}.obj:" @ 1.16 log @* extconf.rb: add the same directory of extconf.rb to load path. @ text @d127 2 a128 2 objs.each do |obj| f.puts "#{obj}: $(srcdir)/#{File.basename(obj).sub(/\..+?$/, '.c')}" d130 5 @ 1.15 log @* extconf.rb: use - not /. @ text @d4 1 a4 1 $LOAD_PATH.unshift(".") @ 1.14 log @* extconf.rb: support output option for MSVC. @ text @d111 1 a111 1 output_option = "/Fo" @ 1.13 log @* extconf.rb: fix object file extension substitution. @ text @d110 8 a117 1 line = "#{line.chomp} -o $@@" if /-o/ !~ line @ 1.12 log @* extconf.rb: fix IMPLIB path. @ text @d121 1 a121 1 f.puts "#{obj}: $(srcdir)/#{File.basename(obj).sub(/.o$/, '.c')}" @ 1.11 log @* extconf.rb: substitute DLLIB not TARGET. @ text @a53 1 filename = "libruby-#{target_name}.lib" d56 1 a56 1 $DLDFLAGS << " /IMPLIB:#{filename}" if filename d96 3 a98 1 f.print("DLLIB = #{ext_dir_name}/#{$POSTMATCH}") @ 1.10 log @* extconf.rb: support output option for MSVC. @ text @d96 2 a97 2 when /^TARGET\s*=\s*/ f.print("TARGET = #{ext_dir_name}/#{$POSTMATCH}") d109 1 a109 8 if PKGConfig.msvc? output_option = "/Fo" else output_option = "-o" end unless /#{Regexp.escape(output_option)}/ =~ line line = "#{line.chomp} #{output_option}$@@" end d120 1 a120 1 f.puts "#{obj}: $(srcdir)/#{File.basename(obj).sub(/\..+?$/, '.c')}" @ 1.9 log @* extconf.rb: fix object file extension substitution. @ text @d109 8 a116 1 line = "#{line.chomp} -o $@@" if /-o/ !~ line @ 1.8 log @* src/rb_cairo_context.c: fixed declaration position. * extconf.rb: RUBY_ -> RB_. * pkg-config.rb: implemented pkg-config for cross compiling with Wine. @ text @d120 1 a120 1 f.puts "#{obj}: $(srcdir)/#{File.basename(obj).sub(/.o$/, '.c')}" @ 1.7 log @* extconf.rb: detected RubyCocoa. @ text @d87 1 a87 1 $defs << "-DRUBY_CAIRO_COMPILATION" @ 1.6 log @* extconf.rb: added Quartz backend check for -framework RubyCocoa. @ text @d60 10 a69 1 $DLDFLAGS << " -Wl,-framework,RubyCocoa" @ 1.5 log @* extconf.rb, src/rb_cairo_surface.c, src/rb_cairo_private.h: used rb_errinfo() and RSTRING_LEN() if available for supporting ruby 1.9. Thanks to Paul van Tilburg!!! @ text @d23 11 a33 11 def check_win32() STDOUT.print("checking for Win32 OS... ") STDOUT.flush if /cygwin|mingw|mswin32/ =~ RUBY_PLATFORM $defs << "-DRUBY_CAIRO_PLATFORM_WIN32" STDOUT.print "yes\n" if $cc_is_gcc if /^2\./ =~ `#{Config::CONFIG['CC']} -dumpversion`.chomp $CFLAGS += ' -fnative-struct' else $CFLAGS += ' -mms-bitfields' d36 1 a36 2 else STDOUT.print "no\n" d41 2 a42 1 if /cygwin|mingw/ =~ RUBY_PLATFORM d53 9 a61 5 elsif /mswin32/ =~ RUBY_PLATFORM filename = "libruby-#{target_name}.lib" $DLDFLAGS.gsub!(/ --output-lib\s+[^ ]+/, '') $DLDFLAGS.gsub!(/ \/IMPLIB:[^ ]+/, '') $DLDFLAGS << " /IMPLIB:#{filename}" if filename a64 5 def setup_win32(target_name) check_win32 set_output_lib(target_name) end d76 2 a77 1 setup_win32(File.basename(modname)) @ 1.4 log @* extconf.rb: used String#each_line instead of String#each for supporting ruby 1.9. Thanks to Paul van Tilburg!!! @ text @d75 2 @ 1.3 log @* extconf.rb, Rakefile: supported RubyGems. @ text @d83 1 a83 1 makefile.each do |line| @ 1.2 log @* src/rb_cairo_surface.c (ensure_finish_proc): supported Cairo::Surface.new with block. If block is exited, a surface is finished automatically. * sample/*.rb: followed the above change. @ text @d5 2 a65 52 def create_makefile_at_srcdir(pkg_name, srcdir, defs=nil) begin Dir.mkdir(srcdir) unless File.exist?(srcdir) Dir.chdir(srcdir) yield if block_given? $defs << defs if defs create_makefile(pkg_name, srcdir) ensure Dir.chdir('..') end end def create_top_makefile(sub_dirs=["src"]) File.open("Makefile", "w") do |mfile| if /mswin32/ =~ RUBY_PLATFORM mfile.print <