class Dnsmasq < Formula desc "Lightweight DNS forwarder and DHCP server" homepage "http://www.thekelleys.org.uk/dnsmasq/doc.html" url "http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.80.tar.gz" sha256 "9e4a58f816ce0033ce383c549b7d4058ad9b823968d352d2b76614f83ea39adc" bottle do rebuild 1 sha256 "870a8cbfdfb7d74be6524ccb8432e3c8795234c7b1e0be4eb852aae1d9a0618a" => :catalina sha256 "4d150c19c5c856435f9d38307c4b9fb153f942ea3f19ebf0f80e33f976f4790e" => :mojave sha256 "10122336f50fd20aeb36488b5d4652557eac4da7b921ecf158910b23ad3ec8fb" => :high_sierra sha256 "eac459e515128a405939939da7dd15f4b3f6ad4bede132b18d6d40f84330ae5e" => :sierra end depends_on "pkg-config" => :build def install ENV.deparallelize # Fix etc location inreplace %w[dnsmasq.conf.example src/config.h man/dnsmasq.8 man/es/dnsmasq.8 man/fr/dnsmasq.8].each do |s| s.gsub! "/var/lib/misc/dnsmasq.leases", var/"lib/misc/dnsmasq/dnsmasq.leases", false s.gsub! "/etc/dnsmasq.conf", etc/"dnsmasq.conf", false s.gsub! "/var/run/dnsmasq.pid", var/"run/dnsmasq/dnsmasq.pid", false s.gsub! "/etc/dnsmasq.d", etc/"dnsmasq.d", false s.gsub! "/etc/ppp/resolv.conf", etc/"dnsmasq.d/ppp/resolv.conf", false s.gsub! "/etc/dhcpc/resolv.conf", etc/"dnsmasq.d/dhcpc/resolv.conf", false s.gsub! "/usr/sbin/dnsmasq", HOMEBREW_PREFIX/"sbin/dnsmasq", false end # Fix compilation on newer macOS versions. ENV.append_to_cflags "-D__APPLE_USE_RFC_3542" inreplace "Makefile" do |s| s.change_make_var! "CFLAGS", ENV.cflags s.change_make_var! "LDFLAGS", ENV.ldflags end system "make", "install", "PREFIX=#{prefix}" etc.install "dnsmasq.conf.example" => "dnsmasq.conf" end def post_install (var/"lib/misc/dnsmasq").mkpath (var/"run/dnsmasq").mkpath (etc/"dnsmasq.d/ppp").mkpath (etc/"dnsmasq.d/dhcpc").mkpath end plist_options :startup => true def plist; <<~EOS Label #{plist_name} ProgramArguments #{opt_sbin}/dnsmasq --keep-in-foreground -C #{etc}/dnsmasq.conf RunAtLoad KeepAlive EOS end test do system "#{sbin}/dnsmasq", "--test" end end