# # build.rb # Configure and build Rappture extension ############################################################################## # The configure script should set these local configuration options. # These are options which Ruby would not know (e.g. Rappture, C++). rappture_dir = "@prefix@" cxx = "@CXX@" cxxflags = "@CXXFLAGS@" srcdir = "@srcdir@" install = "@INSTALL@" shlib_cflags = "@SHLIB_CFLAGS@" shlib_ldflags = "@SHLIB_LDFLAGS@" ############################################################################## # Get the remaining configuration options from the Config module, created # during the Ruby installation process. require 'rbconfig' objext = Config::CONFIG["OBJEXT"] dlext = Config::CONFIG["DLEXT"] rubydir = Config::CONFIG["prefix"] rb_archdir = Config::CONFIG["archdir"] sitedir = Config::CONFIG["sitedir"] ldshared = Config::CONFIG["LDSHARED"] ldflags = Config::CONFIG["LDFLAGS"] libs = Config::CONFIG["LIBS"] cxx_dlflags = Config::CONFIG["CCDLFLAGS"] # XXX This is for CC, not CXX ############################################################################## # Values needed in Makefile source = "Ruby_Rappture" target = "Rappture" exceptions = "-DRAISE_EXCEPTIONS" ############################################################################## # Create Makefile f = File.new("Makefile.ruby", "w") f.printf("\n") f.printf("srcdir = #{srcdir}\n") f.printf("incdir = $(RAPPTURE_DIR)/include\n") f.printf("archdir = #{rb_archdir}\n") f.printf("SOURCE = #{source}\n") f.printf("TARGET = #{target}\n\n") f.printf("OBJEXT = #{objext}\n") f.printf("DLEXT = #{dlext}\n\n") f.printf("RAPPTURE_DIR = #{rappture_dir}\n") f.printf("RUBY_DIR = #{rubydir}\n") f.printf("SITE_DIR = #{sitedir}\n\n") f.printf("SITE_DIR = $(RAPPTURE_DIR)/lib/ruby/ruby_site\n\n") f.printf("CXX = #{cxx}\n") f.printf("CFLAGS = #{cxxflags}\n") f.printf("CXX_DLFLAGS = #{cxx_dlflags}\n") f.printf("INCLUDES = -I$(incdir) -I#{srcdir}/../../src/core -I$(archdir)/\n") f.printf("INSTALL = #{install}\n") f.printf("SHLIB_FLAGS = $(CFLAGS) $(CXX_DLFLAGS) $(LDFLAGS) $(INCLUDES)\n\n") f.printf("EXCEPTIONS = #{exceptions}\n\n") f.printf("SHLIB_LD = #{ldshared}\n") f.printf("LDFLAGS = #{ldflags}\n") f.printf("LIBS = -L../../src/core -lrappture #{libs}\n\n") f.printf("package = $(TARGET).$(DLEXT)\n\n") f.printf("all: extension\n\n") f.printf("extension: $(package)\n") f.printf("$(package): $(srcdir)/$(SOURCE).cc\n") f.printf(" $(SHLIB_LD) $(SHLIB_FLAGS) $(EXCEPTIONS) $< -o $@ $(LIBS)\n\n") f.printf("install: $(package)\n") f.printf(" $(INSTALL) -m 0755 $(package) $(SITE_DIR)\n\n") f.close ############################################################################## # Build the extension #`make extension` #`make install`