<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,3 +2,4 @@
 *.swo
 *.swp
 pkg/
+coverage/</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 #
 # The recipe for integrating amalgalite into the ruby build
 #
-Crate::GemIntegration.new(&quot;amalgalite&quot;, &quot;0.4.0&quot;) do |t|
-  t.upstream_source  = &quot;http://www.copiousfreetime.org/gems/gems/amalgalite-0.4.0.gem&quot;
-  t.upstream_sha1    = &quot;410ddb2e96c74ff12d8542079fcb5d7951b267e4&quot;
+Crate::GemIntegration.new(&quot;amalgalite&quot;, &quot;0.4.3&quot;) do |t|
+  t.upstream_source  = &quot;http://www.copiousfreetime.org/gems/gems/amalgalite-0.4.3.gem&quot;
+  t.upstream_sha1    = &quot;569c497f56bfe95d6a7abe4834f5372394857b5a&quot;
 end</diff>
      <filename>data/recipes/amalgalite/amalgalite.rake</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,14 @@
 #
 # Crate recipe for ruby version 1.2.3
 #
-Crate::Ruby.new( &quot;ruby&quot;, &quot;1.8.6-p114&quot;) do |t|
+Crate::Ruby.new( &quot;ruby&quot;, &quot;1.8.6-p287&quot;) do |t|
   t.depends_on( &quot;openssl&quot; )
   t.depends_on( &quot;zlib&quot; )
 
   t.integrates( &quot;amalgalite&quot; )
 
-  t.upstream_source  = &quot;ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p114.tar.gz&quot;
-  t.upstream_md5     = &quot;500a9f11613d6c8ab6dcf12bec1b3ed3&quot;
+  t.upstream_source  = &quot;ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p287.tar.gz&quot;
+  t.upstream_md5     = &quot;f6cd51001534ced5375339707a757556&quot;
 
   ENV[&quot;CPPFLAGS&quot;]= &quot;-I#{File.join( t.install_dir, 'usr', 'include')}&quot;
   ENV[&quot;LDFLAGS&quot;] = &quot;-L#{File.join( t.install_dir, 'usr', 'lib' )}&quot;</diff>
      <filename>data/recipes/ruby/ruby.rake</filename>
    </modified>
    <modified>
      <diff>@@ -66,7 +66,7 @@ module Crate
     end
 
     #
-    # each of the key value pairs indicates an matching path (the key)  from the
+    # each of the key value pairs indicates a matching path (the key)  from the
     # gemspec that should be installed into the designated destiation path (the
     # value)
     #</diff>
      <filename>lib/crate/gem_integration.rb</filename>
    </modified>
    <modified>
      <diff>@@ -149,11 +149,11 @@ module Crate
     end
 
     #
-    # Iterate over all the feils in the Crate project template directory and
+    # Iterate over all the files in the Crate project template directory and
     # store them in a hash
     #
     def project_files
-      keep       = %r/.rake$|Rakefile$|.patch$/
+      keep       = %r/.rake$|Rakefile$|.patch$|.c$/
       strip_path = %r/\A#{data}?/o
       paths      = Hash.new { |h,k| h[k] = [] }
       Find.find( data ) do |path|</diff>
      <filename>lib/crate/main.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,7 @@
 require 'rake'
 require 'rake/tasklib'
+require 'amalgalite'
+require 'amalgalite/requires'
 
 module Crate
   #
@@ -25,6 +27,9 @@ module Crate
     # default 'fakeroot'
     attr_accessor :install_dir
 
+    # the directory where the final products are stored
+    attr_accessor :dist_dir
+
     # The list of extensions to compile
     attr_reader :extensions
 
@@ -35,6 +40,7 @@ module Crate
       @recipe_dir   = File.join( @project_root, 'recipes' )
       @build_dir    = File.join( @project_root, 'build' )
       @install_dir  = File.join( @project_root, 'fakeroot' )
+      @dist_dir     = File.join( @project_root, 'dist' )
       yield self if block_given?
       ::Crate.project = self
       define
@@ -52,6 +58,10 @@ module Crate
       @install_dir = File.join( project_root, id )
     end
 
+    def dist_dir=( dd )
+      @dist_dir = File.join( project_root, dd )
+    end
+
     def extensions=( list )
       @extensions = list.select { |l| l.index(&quot;#&quot;).nil? }
     end
@@ -76,16 +86,84 @@ module Crate
     end
 
     #
+    # Load upthe compile params we may need to compile the project.  This method
+    # is usless until after the :ruby task has been completed
+    #
+    def compile_params 
+      unless @compile_params
+        @compile_params = {}
+        Dir.chdir( ::Crate.ruby.pkg_dir ) do
+          %w[ CC CFLAGS XCFLAGS LDFLAGS CPPFLAGS LIBS ].each do |p|
+            @compile_params[p] = %x( ./miniruby -I. -rrbconfig -e 'puts Config::CONFIG[&quot;#{p}&quot;]' ).strip
+          end
+        end
+      end
+      return @compile_params
+    end
+
+    # 
+    # Compile the crate_boot stub to an object file
+    #
+    def compile_crate_boot
+      compile_options = %w[ CFLAGS XCFLAGS CPPFLAGS ].collect { |c| compile_params[c] }.join(' ')
+      cmd = &quot;#{compile_params['CC']} #{compile_options} -I#{Crate.ruby.pkg_dir} -o crate_boot.o -c crate_boot.c&quot;
+      logger.debug cmd
+      sh cmd
+      ::CLEAN &lt;&lt; &quot;crate_boot.o&quot;
+    end
+
+    #
+    # Run the link command to create the final executable
+    #
+    def link_project
+      link_options = %w[ CFLAGS XCFLAGS LDFLAGS ].collect { |c| compile_params[c] }.join(' ')
+      Dir.chdir( ::Crate.ruby.pkg_dir ) do
+        dot_a = FileList[ &quot;**/*.a&quot; ]
+        dot_o = [ &quot;ext/extinit.o&quot;, File.join( project_root, &quot;crate_boot.o&quot; )]
+        libs = compile_params['LIBS']
+        cmd = &quot;#{compile_params['CC']} #{link_options} #{dot_o.join(' ')} #{dot_a.join(' ')} -o #{File.join( dist_dir, name) }&quot;
+        logger.debug cmd
+        sh cmd
+      end
+    end
+
+    #
     # define the project task
     #
     def define
+      lib_db = File.join( dist_dir, &quot;lib.db&quot; )
+      directory dist_dir
+
+      task :pack_ruby =&gt; dist_dir do
+        logger.info &quot;Storing rubylib in #{lib_db}&quot;
+        ::Amalgalite::Requires.store_dir_in_db( File.join( ::Crate.ruby.pkg_dir, &quot;lib&quot; ), :dbfile =&gt; lib_db )
+      end
+
+      task :pack_amalgalite =&gt; dist_dir do
+        cmd = &quot;~/Projects/amalgalite/bin/amalgalite-pack-into-db --force #{lib_db}&quot;
+        logger.info cmd
+        sh &quot;#{cmd} &gt; /dev/null&quot;
+      end
+
+      file &quot;crate_boot.o&quot; =&gt; &quot;crate_boot.c&quot; do
+        compile_crate_boot
+      end
+
+      app_path = File.join( dist_dir, name )
+      file app_path =&gt; [ &quot;crate_boot.o&quot;, dist_dir ] do
+        link_project
+      end
+
       desc &quot;Build #{name}&quot;
-      task :default =&gt; [ :ruby, main_c ] do 
+      #task :default =&gt; [ :ruby ] do 
+      task :default =&gt; [ app_path, :pack_amalgalite, :pack_ruby ] do
         logger.info &quot;Build #{name}&quot;
-        #logger.info ::Crate.ruby.inspect 
+        compile_crate_boot
+        link_project
       end
       ::CLEAN &lt;&lt; self.install_dir
       ::CLEAN &lt;&lt; &quot;project.log&quot;
+      ::CLEAN &lt;&lt; self.dist_dir
       load_rakefiles
     end
 </diff>
      <filename>lib/crate/project.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ require 'crate/gem_integration'
 module Crate
   class Ruby &lt; Dependency
     #
-    # Create a Crate Ruby  with the given name and version
+    # Create a Crate Ruby with the given name and version
     #
     def initialize( name = nil, version = nil )
       @name = name</diff>
      <filename>lib/crate/ruby.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,4 +2,4 @@ require 'rubygems'
 require 'spec'
 
 $: &lt;&lt; File.expand_path(File.join(File.dirname(__FILE__),&quot;..&quot;,&quot;lib&quot;))
-require 'assimilate'
+require 'crate'</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3ddfbdb6f52a87264f0ad9af3c796158cb1aa613</id>
    </parent>
  </parents>
  <author>
    <name>Jeremy Hinegardner</name>
    <email>jeremy@hinegardner.org</email>
  </author>
  <url>http://github.com/copiousfreetime/crate/commit/7b2907c80b65371cd4fd2a0c27bf97272a99b3ca</url>
  <id>7b2907c80b65371cd4fd2a0c27bf97272a99b3ca</id>
  <committed-date>2008-10-22T23:57:27-07:00</committed-date>
  <authored-date>2008-10-22T23:57:27-07:00</authored-date>
  <message>savepoint</message>
  <tree>4429b28d1ec5b0d30573879485e5a565ce201e74</tree>
  <committer>
    <name>Jeremy Hinegardner</name>
    <email>jeremy@hinegardner.org</email>
  </committer>
</commit>
