File: extconf.rb

package info (click to toggle)
libzlib-ruby 0.6.0-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 348 kB
  • ctags: 658
  • sloc: ansic: 2,555; ruby: 170; makefile: 129
file content (108 lines) | stat: -rw-r--r-- 2,528 bytes parent folder | download
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#
# extconf.rb
#
# $Id: extconf.rb,v 1.12 2003/06/18 15:00:38 katsu Exp $
#

require 'mkmf'
require 'rbconfig'

unless respond_to? :try_compile then
  class << self
    alias try_compile try_link
  end
end

unless respond_to? :message then
  def message(s)
    printf s
    $stdout.flush
  end
end

def have_ruby_func(s)
  oldlibs = $libs
  oldlibpath = $LIBPATH
  $libs += " " + Config::CONFIG['LIBRUBYARG']
  $LIBPATH = [$libdir, $archdir || Config::CONFIG["compile_dir"]] | $LIBPATH
  begin
    have_func s, 'ruby.h'
  rescue ArgumentError   # for ruby-1.4
    have_func s
  ensure
    $libs = oldlibs
    $LIBPATH = oldlibpath
  end
end


dir_config 'zlib'


if %w'z libz zlib'.find {|z| have_library(z, 'deflateReset')} and
    have_header('zlib.h') then

  defines = []

  have_ruby_func 'rb_block_given_p'       # for ruby-1.4
  have_ruby_func 'rb_str_buf_new'         # for ruby-1.6
  have_ruby_func 'rb_io_print'            # for ruby-1.6
  have_ruby_func 'rb_io_printf'           # for ruby-1.6
  have_ruby_func 'rb_io_puts'             # for ruby-1.6
  have_ruby_func 'rb_io_addstr'           # for ruby-1.6
  have_ruby_func 'rb_define_alloc_func'   # for ruby-1.6
  have_ruby_func 'rb_undef_alloc_func'    # for ruby-1.6

  message 'checking for kind of operating system... '
  os_code = with_config('os-code') ||
    case RUBY_PLATFORM.split('-',2)[1]
    when 'amigaos' then
      os_code = 'AMIGA'
    when /\Aos2[\-_]emx\z/ then
      os_code = 'OS2'
    when 'mswin32', 'mingw32', 'bccwin32' then
      # NOTE: cygwin should be regarded as Unix.
      os_code = 'WIN32'
    else
      os_code = 'UNIX'
    end
  os_code = 'OS_' + os_code.upcase

  OS_NAMES = {
    'OS_MSDOS'   => 'MS-DOS',
    'OS_AMIGA'   => 'Amiga',
    'OS_VMS'     => 'VMS',
    'OS_UNIX'    => 'Unix',
    'OS_ATARI'   => 'Atari',
    'OS_OS2'     => 'OS/2',
    'OS_MACOS'   => 'MacOS',
    'OS_TOPS20'  => 'TOPS20',
    'OS_WIN32'   => 'Win32',
    'OS_VMCMS'   => 'VM/CMS',
    'OS_ZSYSTEM' => 'Z-System',
    'OS_CPM'     => 'CP/M',
    'OS_QDOS'    => 'QDOS',
    'OS_RISCOS'  => 'RISCOS',
    'OS_UNKNOWN' => 'Unknown',
  }
  unless OS_NAMES.key? os_code then
    puts "invalid OS_CODE `#{os_code}'"
    exit
  end
  message "#{OS_NAMES[os_code]}\n"
  defines << "OS_CODE=#{os_code}"

  unless enable_config('transitional', true) then
    defines << 'TRANSITIONAL=0'
  end

  defines = defines.collect{|d|' -D'+d}.join
  if $CPPFLAGS then
    $CPPFLAGS += defines
  else
    $CFLAGS += defines
  end

  create_makefile('zlib')

end