1 | # |
---|
2 | # build.rb |
---|
3 | # Configure and build Rappture extension |
---|
4 | |
---|
5 | ############################################################################## |
---|
6 | # The configure script should set these local configuration options. |
---|
7 | # These are options which Ruby would not know (e.g. Rappture, C++). |
---|
8 | |
---|
9 | rappture_dir = "@prefix@" |
---|
10 | cxx = "@CXX@" |
---|
11 | cxxflags = "@CXXFLAGS@" |
---|
12 | srcdir = "@srcdir@" |
---|
13 | install = "@INSTALL@" |
---|
14 | shlib_cflags = "@SHLIB_CFLAGS@" |
---|
15 | shlib_ldflags = "@SHLIB_LDFLAGS@" |
---|
16 | |
---|
17 | ############################################################################## |
---|
18 | # Get the remaining configuration options from the Config module, created |
---|
19 | # during the Ruby installation process. |
---|
20 | |
---|
21 | require 'rbconfig' |
---|
22 | |
---|
23 | objext = Config::CONFIG["OBJEXT"] |
---|
24 | dlext = Config::CONFIG["DLEXT"] |
---|
25 | rubydir = Config::CONFIG["prefix"] |
---|
26 | rb_archdir = Config::CONFIG["archdir"] |
---|
27 | sitedir = Config::CONFIG["sitedir"] |
---|
28 | ldshared = Config::CONFIG["LDSHARED"] |
---|
29 | ldflags = Config::CONFIG["LDFLAGS"] |
---|
30 | libs = Config::CONFIG["LIBS"] |
---|
31 | cxx_dlflags = Config::CONFIG["CCDLFLAGS"] # XXX This is for CC, not CXX |
---|
32 | |
---|
33 | ############################################################################## |
---|
34 | # Values needed in Makefile |
---|
35 | |
---|
36 | source = "Ruby_Rappture" |
---|
37 | target = "Rappture" |
---|
38 | exceptions = "-DRAISE_EXCEPTIONS" |
---|
39 | |
---|
40 | ############################################################################## |
---|
41 | # Create Makefile |
---|
42 | |
---|
43 | f = File.new("Makefile.ruby", "w") |
---|
44 | f.printf("\n") |
---|
45 | f.printf("srcdir = #{srcdir}\n") |
---|
46 | f.printf("incdir = $(RAPPTURE_DIR)/include\n") |
---|
47 | f.printf("archdir = #{rb_archdir}\n") |
---|
48 | f.printf("SOURCE = #{source}\n") |
---|
49 | f.printf("TARGET = #{target}\n\n") |
---|
50 | f.printf("OBJEXT = #{objext}\n") |
---|
51 | f.printf("DLEXT = #{dlext}\n\n") |
---|
52 | f.printf("RAPPTURE_DIR = #{rappture_dir}\n") |
---|
53 | f.printf("RUBY_DIR = #{rubydir}\n") |
---|
54 | f.printf("SITE_DIR = #{sitedir}\n\n") |
---|
55 | f.printf("SITE_DIR = $(RAPPTURE_DIR)/lib/ruby/ruby_site\n\n") |
---|
56 | f.printf("CXX = #{cxx}\n") |
---|
57 | f.printf("CFLAGS = #{cxxflags}\n") |
---|
58 | f.printf("CXX_DLFLAGS = #{cxx_dlflags}\n") |
---|
59 | f.printf("INCLUDES = -I$(incdir) -I#{srcdir}/../../src/core -I$(archdir)/\n") |
---|
60 | f.printf("INSTALL = #{install}\n") |
---|
61 | f.printf("SHLIB_FLAGS = $(CFLAGS) $(CXX_DLFLAGS) $(LDFLAGS) $(INCLUDES)\n\n") |
---|
62 | f.printf("EXCEPTIONS = #{exceptions}\n\n") |
---|
63 | f.printf("SHLIB_LD = #{ldshared}\n") |
---|
64 | f.printf("LDFLAGS = #{ldflags}\n") |
---|
65 | f.printf("LIBS = -L../../src/core -lrappture #{libs}\n\n") |
---|
66 | f.printf("package = $(TARGET).$(DLEXT)\n\n") |
---|
67 | f.printf("all: extension\n\n") |
---|
68 | f.printf("extension: $(package)\n") |
---|
69 | f.printf("$(package): $(srcdir)/$(SOURCE).cc\n") |
---|
70 | f.printf(" $(SHLIB_LD) $(SHLIB_FLAGS) $(EXCEPTIONS) $< -o $@ $(LIBS)\n\n") |
---|
71 | f.printf("install: $(package)\n") |
---|
72 | f.printf(" $(INSTALL) -m 0755 $(package) $(SITE_DIR)\n\n") |
---|
73 | f.close |
---|
74 | |
---|
75 | ############################################################################## |
---|
76 | # Build the extension |
---|
77 | |
---|
78 | #`make extension` |
---|
79 | #`make install` |
---|
80 | |
---|