class ShadowsocksLibev < Formula desc "Libev port of shadowsocks" homepage "https://github.com/shadowsocks/shadowsocks-libev" url "https://github.com/shadowsocks/shadowsocks-libev/archive/v2.2.2.tar.gz" sha256 "9919d041a6ee4f7b7de2ea7209533b0b9d5fd5732eaa430a6f4055f6e7f1c23f" bottle do cellar :any sha256 "04218b8b59658022859e9f0cbad23a3239bc220af33ce129a80b710217c3b827" => :yosemite sha256 "e957a1465f01c7e87b84043921c46ca7017fb092e6df3b054897b9d88f4db47f" => :mavericks sha256 "e6e49efa0d30888891cb79513a0873953df24c899f5461f7369cb31ed81f666b" => :mountain_lion end head "https://github.com/shadowsocks/shadowsocks-libev.git" option "with-polarssl", "Use PolarSSL instead of OpenSSL" depends_on "polarssl" => :optional depends_on "openssl" if build.without? "polarssl" def install args = ["--prefix=#{prefix}"] if build.with? "polarssl" polarssl = Formula["polarssl"] args << "--with-crypto-library=polarssl" args << "--with-polarssl=#{polarssl.opt_prefix}" end system "./configure", *args system "make" bin.install "src/ss-local" bin.install "src/ss-tunnel" (buildpath/"shadowsocks-libev.json").write <<-EOS.undent { "server":"localhost", "server_port":8388, "local_port":1080, "password":"barfoo!", "timeout":600, "method":null } EOS etc.install "shadowsocks-libev.json" inreplace "shadowsocks-libev.8", "/etc/shadowsocks-libev/config.json", "#{etc}/shadowsocks-libev.json" man8.install "shadowsocks-libev.8" end plist_options :manual => "#{HOMEBREW_PREFIX}/opt/shadowsocks-libev/bin/ss-local -c #{HOMEBREW_PREFIX}/etc/shadowsocks-libev.json" def plist; <<-EOS.undent Label #{plist_name} ProgramArguments #{opt_bin}/ss-local -c #{etc}/shadowsocks-libev.json RunAtLoad KeepAlive SuccessfulExit EOS end end