Skip to content

Commit

Permalink
Import rsdl-0.1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
knu committed Apr 29, 2009
0 parents commit 62ad982
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Makefile.in
@@ -0,0 +1,28 @@

CC = <%= config['CC'] %>

arch = <%= config['arch'] %>
CFLAGS = <%= config['CFLAGS'] %>
LIBS = <%= config['LIBS'] %>
LDFLAGS = <%= config['LDFLAGS'] %>
LIBRUBYARG = <%= config['LIBRUBYARG'] %>
EXEEXT = <%= config['EXEEXT'] %>

PROGRAM = <%= config['RSDL'] %>$(EXEEXT)

OBJS = rsdl.o

.c.o:
$(CC) $(CFLAGS) -c $<

all: $(PROGRAM)

clean:
<%= config['RMALL'] %> $(PROGRAM) $(OBJS)

install:
<%= config['INSTALL'] %> $(PROGRAM) <%= config['bindir'] %>

$(PROGRAM): $(OBJS)
$(CC) $(OBJS) $(LDFLAGS) $(LIBRUBYARG) $(LIBS) -o $@

21 changes: 21 additions & 0 deletions README
@@ -0,0 +1,21 @@
rsdl - SDL initialized ruby

REQUIREMENTS:
- ruby 1.8 or later
- libsdl

INSTALL:
$ruby configure.rb
$make
$sudo make install

USAGE:
Run your script with rsdl instead of ruby.
$rsdl myscript.rb

LICENSE:
ruby's.

Copyright 2009 Ryuichi Sakamoto.
mail: kumaryu __at__ kumaryu.net

41 changes: 41 additions & 0 deletions configure.rb
@@ -0,0 +1,41 @@
#!/usr/bin/env ruby
# vim:encoding=utf-8

require 'mkmf'
require 'erb'

dir_config('sdl') #--with-sdl-dir, --with-sdl-include, or --with-sdl-lib
sdlconfig = with_config('sdl-config', 'sdl-config')

config = {}
config['arch'] = Config::CONFIG['arch']
config['INSTALL'] = Config::CONFIG['INSTALL']
config['RMALL'] = Config::CONFIG['RMALL']
config['CC'] = Config::CONFIG['CC']
config['CFLAGS'] = Config::CONFIG['CFLAGS']
config['CFLAGS'] += " -I\"#{$hdrdir}\"" if $hdrdir
config['CFLAGS'] += " -I\"#{$arch_hdrdir}\"" if $arch_hdrdir
config['CFLAGS'] += ' ' + `"#{sdlconfig}" --cflags` if sdlconfig and not sdlconfig.empty?
config['LDFLAGS'] = Config::CONFIG['LDFLAGS']
config['LIBS'] = Config::CONFIG['LIBS']
config['LIBS'] += ' ' + `"#{sdlconfig}" --libs` if sdlconfig and not sdlconfig.empty?
config['LIBRUBYARG'] = Config::CONFIG['LIBRUBYARG']
config['EXEEXT'] = Config::CONFIG['EXEEXT']
config['bindir'] = Config::CONFIG['bindir']
config['RSDL'] = Config::CONFIG['RUBY_INSTALL_NAME'].sub(/ruby/, 'rsdl')

headers = []
headers << '#define HAVE_RUBY_SYSINIT 1' if have_func('ruby_sysinit')
headers << '#define HAVE_RUBY_RUN_NODE 1' if have_func('ruby_run_node')
config['COMMON_HEADERS'] = ([(COMMON_HEADERS || '')]+headers).join("\n")

makefile_in = ERB.new(File.read('Makefile.in'), nil, '%')
open('Makefile', 'w') do |f|
f.print makefile_in.result
end

rsdl_c_in = ERB.new(File.read('rsdl.c.in'), nil, '%')
open('rsdl.c', 'w') do |f|
f.print rsdl_c_in.result
end

37 changes: 37 additions & 0 deletions rsdl.c.in
@@ -0,0 +1,37 @@

#include <ruby.h>
<%= config['COMMON_HEADERS'] %>
#include <SDL.h>
#include "SDL_main.h"
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif

#ifdef RUBY_GLOBAL_SETUP
RUBY_GLOBAL_SETUP
#endif

int main(int argc, char **argv)
{
#ifdef HAVE_LOCALE_H
setlocale(LC_CTYPE, "");
#endif

#ifdef HAVE_RUBY_SYSINIT
ruby_sysinit(&argc, &argv);
#endif
{
#ifdef RUBY_INIT_STACK
RUBY_INIT_STACK;
#endif
ruby_init();
#ifdef HAVE_RUBY_RUN_NODE
return ruby_run_node(ruby_options(argc, argv));
#else
ruby_options(argc, argv);
ruby_run(); //no return
return 0;
#endif
}
}

0 comments on commit 62ad982

Please sign in to comment.