 +
 +rule link
 +  description = LINK $out
-+  command = g++ $ldflags -o $out -Wl,-rpath=@lib \\
++  command = g++ $ldflags -o $out -Wl,-rpath=$b/lib \\
 +    -Wl,--start-group $in -Wl,--end-group $libs
 +
 +rule stamp

+}
+
+NINJA_BASE = """\
+builddir = $root/ninja
+
+cc = ccache gcc
+cxx = ccache g++

+    # libraries go into shared library dir, and everything else
+    # goes into the normal place.
+    if spec['type'] in ('executable', 'loadable_module'):
+      return os.path.join('$b/', filename)
+    elif spec['type'] == 'shared_library':
+      return os.path.join('$b/lib', filename)
+    else:
+      return self.OutputPath(filename)
+
