File: extconf.rb

package info (click to toggle)
ruby-sdl 2.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,344 kB
  • ctags: 4,200
  • sloc: cpp: 7,598; ansic: 4,475; ruby: 2,258; sh: 102; makefile: 97
file content (114 lines) | stat: -rw-r--r-- 3,002 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
109
110
111
112
113
114
require 'mkmf'

$srcs = Dir.glob(File.join($srcdir, "*.c"))
if /mswin32/ =~ CONFIG["arch"]
  have_library("SDL")
else
  sdl_config = with_config('sdl-config', 'sdl-config')
  $CPPFLAGS += " " + `#{sdl_config} --cflags`.chomp
  $LOCAL_LIBS += ' ' + `#{sdl_config} --libs`.chomp
  
  if /-Dmain=SDL_main/ =~ $CPPFLAGS then
    def try_func(func, libs, headers = nil, &b)
      headers = cpp_include(headers)
      try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b)
#{headers}
/*top*/
int main(int argc,char** argv) { return 0; }
int t() { #{func}(); return 0; }
SRC
#{COMMON_HEADERS}
#{headers}
/*top*/
int main(int argc,char** argv) { return 0; }
int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; }
SRC
    end
  end
end

if enable_config("static-libs",false) then
  have_library("stdc++")
  have_library("z")
  have_library("png")
  have_library("tiff")
  have_library("jpeg")
  have_library("freetype")
  have_library("iconv")
  have_library("ogg")
  have_library("vorbis")
  have_library("vorbisfile")
  have_library("vorbisenc")
  have_library("winmm")
  have_library("SDL")
end

if have_library("smpeg","SMPEG_new") then
  $CPPFLAGS+= " -D HAVE_SMPEG "
  smpeg_config = with_config('smpeg-config', 'smpeg-config')
  if system(smpeg_config, "--version")
    $CPPFLAGS += ' ' + `#{smpeg_config} --cflags`.chomp
    $LOCAL_LIBS += ' ' + `#{smpeg_config} --libs`.chomp
  end
end
if have_library("SDL_mixer","Mix_OpenAudio") then
  $CPPFLAGS+= " -D HAVE_SDL_MIXER "
end
if have_library("SDL_image","IMG_Load") then
  $CPPFLAGS+= " -D HAVE_SDL_IMAGE "
end
if have_library("SDL_ttf","TTF_Init") then
  $CPPFLAGS+= " -D HAVE_SDL_TTF "
end
use_imported_sge = enable_config("imported-sge", false)
if use_imported_sge
  $CPPFLAGS+= " -Isge -D HAVE_SGE "
else
  if have_library("SGE","sge_Line") then
    $CPPFLAGS+= " -D HAVE_SGE "
  end
end

have_func("TTF_OpenFontIndex")
have_func("TTF_FontFaces")
have_func("TTF_FontFaceIsFixedWidth")
have_func("TTF_FontFaceFamilyName")
have_func("TTF_FontFaceStyleName")
have_func("Mix_LoadMUS_RW")
have_func("rb_thread_blocking_region")
if have_header("ruby/thread.h")
  have_func("rb_thread_call_without_gvl")
end

if enable_config("m17n", true)
  if have_func("rb_enc_str_new") && have_func("rb_str_export_to_enc")
    $CPPFLAGS += " -D ENABLE_M17N "
    if enable_config("m17n-filesystem", false)
      $CPPFLAGS += " -D ENABLE_M17N_FILESYSTEM "
    end
  end
end

if have_library("SDLSKK","SDLSKK_Context_new") then
  $CPPFLAGS+= " -D HAVE_SDLSKK "
end
if enable_config("opengl",true) then
  dir_config('x11','/usr/X11R6')
  
  $CPPFLAGS+= " -D ENABLE_OPENGL "

  if /linux/ =~ CONFIG["arch"] then
    have_library("GL","glVertex3d")
  elsif /mingw32/ =~ CONFIG["arch"] then
    have_library("opengl32","glVertex3d")
    have_library("glu32","gluGetString")
  end
end

if use_imported_sge
  $srcs += Dir.glob(File.join($srcdir, "sge/*.cpp"))
  $objs = $srcs.map{|fname| fname.sub(/\.(c|cpp)\Z/, ".o") }
end

create_makefile("sdl_ext")