- Fixed editing of a Makefile with 8-bit characters.  Fixes #181
Update history for #181 backport
ext_conf_builder.rb: build in separate dir

* lib/rubygems/ext/ext_conf_builder.rb (Gem::Ext::ExtConfBuilder.build):
  build in a separate temporary directory, and not mess up the source
  directory.  [Bug #7698]
builder.rb: command line macros

* lib/rubygems/ext/builder.rb (Gem::Ext::Builder.make): pass dest_path
  by command line macros, not editing generated Makefile.  [Bug #7698]
Import r39558, r39559, r39560, r39572 from ruby

These commits fix extension building in RubyGems to match the new
mkmf.rb output.

Also, 1.8.7 compatibility was restored.
Import r39579 from trunk by nobu

Fix for unusal cases again.  install to a temporary directory once and
move instaled files to the destination directory, if it is same as the
current directory.  [Bug #7698]
Import r39592 from trunk

clear DESTDIR so RUBYARCHDIR and RUBYLIBDIR are not be overrdden.
Move DESTDIR changes alongside RUBYOPT
Import r39590 from ruby trunk

It is impossible to predict which file will be installed to where, by
the arguments, so use intermediate destination directory always.

Patch by nobu
Pass DESTDIR via command line to override what's in MAKEFLAGS.

This fixes an installation problem under a package building
environment where DESTDIR is specified in the (parent) command line.

Related bug reports:
- https://bugzilla.redhat.com/show_bug.cgi?id=921650
- https://github.com/ruby/ruby/pull/327
Remove siteconf temp file once unused

Clean up the sitearch temp file before running any make commands to prevent
the temp file being copied into the gem installation.
Reset RUBYOPT when unlinking siteconf

The rice gem uses an unconventional extconf.rb during its build.
Instead of using mkmf it gathers configuration information from RbConfig
and runs a configure script which creates a Makefile.  The Makefile
invokes ruby during the build process.

When running the Makefile the RUBYOPT environment variable required the
siteconf file which had been removed.  This would cause ruby to raise an
exception.

Now RUBYOPT is reset when the siteconf file is removed which fixes this
bug.

Fixes #582
Use Tempfile.create to unlink siteconf on Windows

Import of r41893 from ruby trunk by naruse
On ruby 1.8.7 a Tempfile can be unlinked only once
Fixed installing gems with extensions under -V

Commit f815636f changed the return value of ExtConfBuilder#build to nil
from the input result array.  When running with -V RubyGems prints the
results of compilation by joining the returned Array.  nil does not have
this so a NoMethodError was raised.

Fixes #601
Fix extension building on Ruby 1.9.3 and mingw

Supplying DESTDIR on mingw causes link errors due to reasons I don't
understand (see the related bug).  Now, on 1.9.3, DESTDIR is not
supplied to the make command which prevents the bug.  Ruby 2.0.0 behaves
as before.

Fixes #594, see also duplicate bug #599
Prevent extensions from building in parallel

Building an extension requires changing the path so commands executed
via a subprocess will work correctly.  In order to prevent parallel
extension builds from changing each other's directory a mutex is
required.

Fixes #607
Fix CVE-2013-4287, remove regexp backtracking

The Gem::Version regexp used backtracking to validate gem versions.
This could cause excessive CPU usage when creating Gem::Version objects
including when packaging gems. See CVE-2013-4287.txt (in this commit)
for details.

Fixes #626
Update version for release
Require 'thread' for builder mutex

This was missed when 05e9e55 was cherry-picked