comparison ruby/rbdc/extconf.rb @ 0:0cfcc391201f

initial from svn dyncall-1745
author Daniel Adler
date Thu, 19 Mar 2015 22:26:28 +0100
parents
children 5e159be89d73
comparison
equal deleted inserted replaced
-1:000000000000 0:0cfcc391201f
1 #//////////////////////////////////////////////////////////////////////
2 #
3 # extconf.rb
4 # Copyright (c) 2007-2014 Daniel Adler <dadler@uni-goettingen.de>,
5 # Tassilo Philipp <tphilipp@potion-studios.com>
6 #
7 # Permission to use, copy, modify, and distribute this software for any
8 # purpose with or without fee is hereby granted, provided that the above
9 # copyright notice and this permission notice appear in all copies.
10 #
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #
19 # Configuration file for dyncall/ruby extension. This script creates
20 # a makefile that can be used to compile the C-extension. It is
21 # configured such that every .c file in this directory will be used
22 # for compilation.
23 #
24 #///////////////////////////////////////////////////////////////////////
25
26 require 'mkmf'
27
28 dir_config 'rbdc'
29 base_dir = '../../../dyncall/'
30
31 $CFLAGS << ' -I../../../dyncall/dyncall '
32
33 # Build dyncall libs.
34 puts 'Building dyncall libraries:'
35 Dir.chdir(base_dir) do
36 cmd = case
37 when RUBY_PLATFORM =~ /mswin/ then 'configure.bat && nmake /f Nmakefile'
38 else './configure && env CFLAGS="-fPIC" make'
39 end
40 puts cmd
41 raise "'#{cmd}' failed" unless system(cmd)
42 end
43
44 # Search for dyncall libs.
45 puts 'Using the following dyncall libraries to build native ruby extension:'
46 Dir[base_dir+'**/*'].each { |d|
47 if d =~ /(lib)?dyn(call(back)?|load)_s\./
48 $LOCAL_LIBS << '"'+d+'" '
49 puts d
50 end
51 }
52
53 if($LOCAL_LIBS.size > 0) then
54 # Write out a makefile for our dyncall extension.
55 create_makefile 'rbdc'
56 else
57 puts "Couldn't find dyncall and dynload libraries - dyncall build seems to have failed!"
58 end
59