Reworked the build system.
[ruby-esmart.git] / library.rb
1 # $Id: library.rb 326 2005-04-27 14:25:18Z tilman $
2
3 require "rbconfig"
4
5 class Library
6         def initialize(name, prefix, dir, lib = name)
7                 @name = name
8                 @prefix = prefix
9                 @dir = dir
10                 @lib = lib
11         end
12
13         def ldflags
14                 s = "#{ENV["LDFLAGS"]} -L #{@prefix}/lib -L " +
15                     Config::CONFIG["libdir"] + " " +
16                     Config::CONFIG["LIBRUBYARG_SHARED"] +
17                         " -shared -Wl"
18                 s << " -l#{@lib}" unless @lib.nil?
19                 s
20         end
21
22         def cflags
23                 "#{ENV["CFLAGS"]} -I #{@prefix}/include " +
24                 "-I #{Config::CONFIG['archdir']} " +
25                 "-I #{Config::CONFIG['sitearchdir']} -fPIC"
26         end
27
28         def so
29                 "#{@dir}/#{@name}.so"
30         end
31
32         def objects
33                 Dir["#{@dir}/*.c"].map { |f| f.sub(/\.[^.]+$/, ".o") }
34         end
35 end