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
|
#!/usr/bin/env ruby
# encoding: UTF-8
=begin
Copyright 2010-2011 Vincent Carmona
vinc4mai@gmail.com
This file is part of rghk.
rghk is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
rghk is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with rghk; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=end
require 'mkmf'
def add_distclean(file)
$distcleanfiles ||= []
$distcleanfiles << file
end
find_header('ruby.h') or exit 1
gtk_cflags=`pkg-config --cflags gtk+-2.0`.chomp!
$CFLAGS+=gtk_cflags
find_library('X11', 'XKeysymToKeycode') or exit 1
find_library('gobject-2.0', 'g_type_init') or exit 1
find_library('gdk-x11-2.0', '') or exit 1
find_header('string.h') or exit 1
find_header('X11/X.h') or exit 1
find_header('X11/Xlib.h') or exit 1
find_header('gdk/gdkwindow.h') or exit 1
find_header('gdk/gdkevents.h') or exit 1
find_header('gdk/gdkx.h') or exit 1
gdkkeysyms_file=nil
gtk_cflags.scan(/-I.+?\ /).map{|pp| File.join(pp[2..-2], "gdk/gdkkeysyms.h")}.each{|file|
if File.exist?(file)
gdkkeysyms_file=file
break
end
}
f=File.open(gdkkeysyms_file, 'r')
keysyms_file=File.join(File.dirname(__FILE__), "keysyms.h")
File.open(keysyms_file, 'w'){|file|
f.each_line{|line|
if line =~ /^#define\s+(GDK_\w+)\s+\d+/
gdk_name=$1
name= gdk_name =~/GDK_KEY_/ ? gdk_name[4..-1] : "KEY_"+gdk_name[4..-1]
file.puts "rb_define_const(mKeyVal, \"#{name}\", INT2FIX(#{gdk_name}));"
end
}
}
f.close
add_distclean(keysyms_file)
create_makefile("globalhotkeys_ext")
|