Top Level Namespace

Defined Under Namespace

Modules: Swat Classes: KeyBinder

Constant Summary collapse

PACKAGE_NAME =

extconf.rb for Ruby/GTK extention library

"gtk2"
PKG_CONFIG_ID =
"gtk+-2.0"

Instance Method Summary collapse

Instance Method Details

#add_depend_package(target_name, target_srcdir, top_srcdir) ⇒ Object

add_depend_package(“glib2”, “glib/src”, “/.…./ruby-gnome2”)



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'ext/mkmf-gnome2.rb', line 115

def add_depend_package(target_name, target_srcdir, top_srcdir)
  [top_srcdir, $configure_args['--topdir']].each do |topdir|
    topdir = File.expand_path(topdir)
    if RUBY_VERSION < "1.8.5"
      $CFLAGS = "-I#{File.join(topdir, target_srcdir)} #{$CFLAGS}"
    else
      $INCFLAGS = "-I#{File.join(topdir, target_srcdir)} #{$INCFLAGS}"
    end

    if /cygwin|mingw/ =~ RUBY_PLATFORM
      $libs << " -lruby-#{target_name}"
      $LDFLAGS << " -L#{topdir}/#{target_srcdir}"
    elsif /mswin32/ =~ RUBY_PLATFORM
      $DLDFLAGS << " /libpath:#{topdir}/#{target_srcdir}"
      $libs << " libruby-#{target_name}.lib"
    end
  end
end

#add_distcleanfile(file) ⇒ Object



134
135
136
137
# File 'ext/mkmf-gnome2.rb', line 134

def add_distcleanfile(file)
  $distcleanfiles ||= []
  $distcleanfiles << file
end

#add_obj(name) ⇒ Object



271
272
273
# File 'ext/mkmf-gnome2.rb', line 271

def add_obj(name)
  $objs << name unless $objs.index(name)
end

#check_ruby_funcObject



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'ext/mkmf-gnome2.rb', line 242

def check_ruby_func
  $CPPFLAGS << " -I$(sitearchdir) "

  #Other options
  have_func("rb_define_alloc_func") # for ruby-1.8
  have_func("rb_block_proc") # for ruby-1.8

  STDOUT.print("checking for new allocation framework... ") # for ruby-1.7
  if Object.respond_to? :allocate
    STDOUT.print "yes\n"
    $defs << "-DHAVE_OBJECT_ALLOCATE"
  else
    STDOUT.print "no\n"
  end

  STDOUT.print("checking for attribute assignment... ") # for ruby-1.7
  STDOUT.flush
  if defined? try_compile and try_compile <<SRC
#include "ruby.h"
#include "node.h"
int node_attrasgn = (int)NODE_ATTRASGN;
SRC
    STDOUT.print "yes\n"
    $defs << "-DHAVE_NODE_ATTRASGN"
  else
    STDOUT.print "no\n"
  end
end

#check_win32Object



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
# File 'ext/mkmf-gnome2.rb', line 45

def check_win32()
  $G_PLATFORM_WIN32 = false
  $G_OS_WIN32       = false
  $G_WITH_CYGWIN    = false

  STDOUT.print("checking for G_PLATFORM_WIN32... ")
  STDOUT.flush
  if macro_defined?('G_PLATFORM_WIN32', "#include <glibconfig.h>\n")
    STDOUT.print "yes\n"
    $G_PLATFORM_WIN32 = true
  else
    STDOUT.print "no\n"
  end

  if $G_PLATFORM_WIN32
    STDOUT.print("checking for G_OS_WIN32... ")
    STDOUT.flush
    if macro_defined?('G_OS_WIN32', "#include <glibconfig.h>\n")
      STDOUT.print "yes\n"
      $G_OS_WIN32 = true
      if $cc_is_gcc
	if /^2\./ =~ `#{Config::CONFIG['CC']} -dumpversion`.chomp
	  $CFLAGS += ' -fnative-struct'
	else
	  $CFLAGS += ' -mms-bitfields'
	end
      end
    else
      STDOUT.print "no\n"
    end

#    STDOUT.print("checking for G_WITH_CYGWIN... ")
#    STDOUT.flush
#    if macro_defined?('G_WITH_CYGWIN', "#include <glibconfig.h>\n")
#      STDOUT.print "yes\n"
#      $G_WITH_CYGWIN = true
#    else
#      STDOUT.print "no\n"
#    end
  end

  nil
end

#create_makefile_at_srcdir(pkg_name, srcdir, defs = nil) ⇒ Object



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'ext/mkmf-gnome2.rb', line 139

def create_makefile_at_srcdir(pkg_name, srcdir, defs = nil)
  base_dir = File.basename(Dir.pwd)
  builddir = srcdir[(srcdir.rindex(base_dir) + base_dir.size + 1)..-1]
  builddir ||= "."
  FileUtils.mkdir_p(builddir)

  Dir.chdir(builddir) do
    yield if block_given?

    $defs << defs if defs

    pattern = "*.{#{SRC_EXT.join(',')}}"
    srcs = Dir[File.join(srcdir, pattern)]
    srcs |= Dir[File.join(".", pattern)]
    $objs = srcs.collect do |src|
      File.basename(src, ".*") + ".o"
    end.flatten.uniq

    create_makefile(pkg_name, srcdir)
  end
end

#create_top_makefile(sub_dirs = ["src"]) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'ext/mkmf-gnome2.rb', line 161

def create_top_makefile(sub_dirs = ["src"])
  mfile = File.open("Makefile", "w")
  if /mswin32/ =~ RUBY_PLATFORM
    mfile.print <<MSWIN32_END

all:
#{sub_dirs.map{|d| "	@cd #{d}\n	@nmake -nologo all\n	@cd ..\n"}.join('')}
install:
#{sub_dirs.map{|d| "	@cd #{d}\n	@nmake -nologo install DESTDIR=$(DESTDIR)\n	@cd ..\n"}.join('')}
site-install:
#{sub_dirs.map{|d| "	@cd #{d}\n	@nmake -nologo site-install DESTDIR=$(DESTDIR)\n	@cd ..\n"}.join('')}
clean:
#{sub_dirs.map{|d| "	@cd #{d}\n	@nmake -nologo clean\n	@cd ..\n"}.join('')}	@if exist extconf.h del extconf.h
	@if exist conftest.* del conftest.*
	@if exist *.lib del *.lib
	@if exist *~ del *~
	@if exist mkmf.log del mkmf.log
MSWIN32_END
  else
    mfile.print <<END
all:
#{sub_dirs.map{|d| "	@cd #{d}; make all\n"}.join('')}

install:
#{sub_dirs.map{|d| "	@cd #{d}; make install\n"}.join('')}
site-install:
#{sub_dirs.map{|d| "	@cd #{d}; make site-install\n"}.join('')}
clean:
#{sub_dirs.map{|d| "	@cd #{d}; make clean\n"}.join('')}
distclean:	clean
#{sub_dirs.map{|d| "	@cd #{d}; make distclean\n"}.join('')}
	@rm -f Makefile extconf.h conftest.*
	@rm -f core *~ mkmf.log
END
  end
  mfile.close
end

#glib_mkenums(prefix, files, g_type_prefix, include_files) ⇒ Object



275
276
277
278
279
# File 'ext/mkmf-gnome2.rb', line 275

def glib_mkenums(prefix, files, g_type_prefix, include_files)
  add_distcleanfile(prefix + ".h")
  add_distcleanfile(prefix + ".c")
  GLib::MkEnums.create(prefix, files, g_type_prefix, include_files)
end

#macro_defined?(macro, src, opt = "") ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
# File 'ext/mkmf-gnome2.rb', line 17

def macro_defined?(macro, src, opt="")
  try_cpp(src + <<EOP, opt)
#ifndef #{macro}
# error
#endif
EOP
end

#make_version_header(app_name, pkgname, dir = "src") ⇒ Object

This is used for the library which doesn’t support version info.



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'ext/mkmf-gnome2.rb', line 200

def make_version_header(app_name, pkgname, dir = "src")
  version = PKGConfig.modversion(pkgname).split(/\./)
  (0..2).each do |v|
    version[v] = "0" unless version[v]
  end
  filename = "rb#{app_name.downcase}version.h"

  puts "creating #{filename}"

  add_distcleanfile(filename)

  FileUtils.mkdir_p(dir)
  out = File.open(File.join(dir, filename), "w")

  out.print %Q[/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/************************************************

  #{filename} -

  This file was generated by mkmf-gnome2.rb.

************************************************/

#ifndef __RB#{app_name}_VERSION_H__
#define __RB#{app_name}_VERSION_H__

#define #{app_name}_MAJOR_VERSION (#{version[0]})
#define #{app_name}_MINOR_VERSION (#{version[1]})
#define #{app_name}_MICRO_VERSION (#{version[2]})

#define #{app_name}_CHECK_VERSION(major,minor,micro)    \\
    (#{app_name}_MAJOR_VERSION > (major) || \\
     (#{app_name}_MAJOR_VERSION == (major) && #{app_name}_MINOR_VERSION > (minor)) || \\
     (#{app_name}_MAJOR_VERSION == (major) && #{app_name}_MINOR_VERSION == (minor) && \\
      #{app_name}_MICRO_VERSION >= (micro)))


#endif /* __RB#{app_name}_VERSION_H__ */
]
      out.close
end

#set_output_lib(target_name) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'ext/mkmf-gnome2.rb', line 89

def set_output_lib(target_name)
  if /cygwin|mingw/ =~ RUBY_PLATFORM
    filename = "libruby-#{target_name}.a"
    if RUBY_VERSION > "1.8.0"
      $DLDFLAGS << ",--out-implib=#{filename}" if filename
    elsif RUBY_VERSION > "1.8"
      $DLDFLAGS.gsub!(/ -Wl,--out-implib=[^ ]+/, '')
      $DLDFLAGS << " -Wl,--out-implib=#{filename}" if filename
    else
      $DLDFLAGS.gsub!(/ --output-lib\s+[^ ]+/, '')
      $DLDFLAGS << " --output-lib #{filename}" if filename
    end
  elsif /mswin32/ =~ RUBY_PLATFORM
      filename = "libruby-#{target_name}.lib"
      $DLDFLAGS.gsub!(/ --output-lib\s+[^ ]+/, '')
      $DLDFLAGS.gsub!(/ \/IMPLIB:[^ ]+/, '')
      $DLDFLAGS << " /IMPLIB:#{filename}" if filename   
  end
end

#setup_win32(target_name) ⇒ Object



109
110
111
112
# File 'ext/mkmf-gnome2.rb', line 109

def setup_win32(target_name)
  check_win32
  set_output_lib(target_name)
end