require 'formula'

class Geoip < Formula
  homepage 'http://www.maxmind.com/app/c'
  url 'http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.8.tar.gz'
  sha1 '7bafb9918e3c35a6ccc71bb14945245d45c4b796'

  # These are needed for the autoreconf it always tries to run.
  depends_on :automake
  depends_on :libtool

  def options
    [["--universal", "Build a universal binary."]]
  end

  def install
    # Fix issue with sed barfing on unicode characters on Mountain Lion.
    ENV.delete('LANG')
    ENV.universal_binary if ARGV.build_universal?

    # Fixes a build error on Lion when configure does a variant of autoreconf
    # that results in a botched Makefile, causing this error:
    # No rule to make target '../libGeoIP/libGeoIP.la', needed by 'geoiplookup'
    # This works on Snow Leopard also when it tries but fails to run autoreconf.
    system "autoreconf", "-ivf"

    system "./configure", "--prefix=#{prefix}", "--disable-dependency-tracking"
    system "make install"
  end
end

require 'formula'

class Geoip < Formula
  homepage 'http://www.maxmind.com/app/c'
  url 'http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.8.tar.gz'
  sha1 '7bafb9918e3c35a6ccc71bb14945245d45c4b796'

  # These are needed for the autoreconf it always tries to run.
  depends_on :automake
  depends_on :libtool

  def options
    [["--universal", "Build a universal binary."]]
  end

  def install
    ENV.universal_binary if ARGV.build_universal?

    # Fixes a build error on Lion when configure does a variant of autoreconf
    # that results in a botched Makefile, causing this error:
    # No rule to make target '../libGeoIP/libGeoIP.la', needed by 'geoiplookup'
    # This works on Snow Leopard also when it tries but fails to run autoreconf.
    system "autoreconf", "-ivf"

    system "./configure", "--prefix=#{prefix}", "--disable-dependency-tracking"
    system "make install"
  end
end

Fix Mountain Lion sed by setting LANG.
Fix Mountain Lion sed by setting LANG.

It's also necessary to delete LC_ALL or it overrides the new LANG.
LC_COLLATE is the problem variable but is affected by LANG and LC_ALL
so just use them instead. Extends the fix made to geoip in dc955c.

Fix Homebrew/homebrew#11728, fix Homebrew/homebrew#12890, fix Homebrew/homebrew#13653, fix Homebrew/homebrew#13734, fix Homebrew/homebrew#13787, fix Homebrew/homebrew#13818.
