2014-05-16 10:41:47 +00:00
|
|
|
require "formula"
|
2009-06-05 11:57:50 +00:00
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Flac < Formula
|
2014-05-16 10:41:47 +00:00
|
|
|
homepage "http://xiph.org/flac/"
|
|
|
|
url "http://downloads.xiph.org/releases/flac/flac-1.3.0.tar.xz"
|
|
|
|
sha1 "a136e5748f8fb1e6c524c75000a765fc63bb7b1b"
|
|
|
|
|
|
|
|
head do
|
|
|
|
url "git://git.xiph.org/flac.git"
|
|
|
|
depends_on "autoconf" => :build
|
|
|
|
depends_on "automake" => :build
|
|
|
|
depends_on "libtool" => :build
|
|
|
|
end
|
2010-07-20 01:11:29 +00:00
|
|
|
|
2014-02-22 19:14:36 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any
|
2014-05-16 14:30:53 +00:00
|
|
|
revision 2
|
|
|
|
sha1 "727da2e469235bc5e62a2daf6083a12672833762" => :mountain_lion
|
|
|
|
sha1 "085ed13b395fff327ee104ed7771ab1afdc33960" => :lion
|
2014-02-22 19:14:36 +00:00
|
|
|
end
|
|
|
|
|
2013-05-11 15:58:41 +00:00
|
|
|
option :universal
|
|
|
|
|
2014-05-16 10:41:47 +00:00
|
|
|
depends_on "pkg-config" => :build
|
|
|
|
depends_on "lame"
|
|
|
|
depends_on "libogg" => :optional
|
2013-10-25 05:57:09 +00:00
|
|
|
|
2012-03-18 20:33:24 +00:00
|
|
|
fails_with :llvm do
|
|
|
|
build 2326
|
|
|
|
cause "Undefined symbols when linking"
|
|
|
|
end
|
2011-02-14 18:57:55 +00:00
|
|
|
|
2011-03-21 21:24:22 +00:00
|
|
|
def install
|
2013-05-11 15:58:41 +00:00
|
|
|
ENV.universal_binary if build.universal?
|
|
|
|
|
2014-05-16 10:41:47 +00:00
|
|
|
ENV.append "CFLAGS", "-std=gnu89"
|
|
|
|
|
|
|
|
system "./autogen.sh" if build.head?
|
2013-10-25 05:57:09 +00:00
|
|
|
|
2014-03-10 00:46:21 +00:00
|
|
|
args = %W[
|
|
|
|
--disable-dependency-tracking
|
|
|
|
--disable-debug
|
|
|
|
--prefix=#{prefix}
|
|
|
|
--mandir=#{man}
|
|
|
|
--enable-sse
|
|
|
|
--enable-static
|
|
|
|
]
|
|
|
|
|
|
|
|
args << "--without-ogg" if build.without? "libogg"
|
|
|
|
|
|
|
|
system "./configure", *args
|
|
|
|
|
2014-05-16 10:41:47 +00:00
|
|
|
ENV["OBJ_FORMAT"]="macho"
|
2013-05-11 15:58:41 +00:00
|
|
|
|
|
|
|
# adds universal flags to the generated libtool script
|
|
|
|
inreplace "libtool" do |s|
|
2013-08-02 03:40:42 +00:00
|
|
|
s.gsub! ":$verstring\"", ":$verstring -arch #{Hardware::CPU.arch_32_bit} -arch #{Hardware::CPU.arch_64_bit}\""
|
2013-05-11 15:58:41 +00:00
|
|
|
end
|
|
|
|
|
2009-07-31 13:04:49 +00:00
|
|
|
system "make install"
|
2014-05-16 10:41:47 +00:00
|
|
|
(bin/"flac2mp3").write DATA.read
|
2009-06-05 11:57:50 +00:00
|
|
|
end
|
2011-02-14 18:57:55 +00:00
|
|
|
end
|
2013-06-13 18:34:52 +00:00
|
|
|
|
|
|
|
__END__
|
|
|
|
#!/usr/bin/env ruby
|
2014-05-16 10:41:47 +00:00
|
|
|
# https://github.com/rmndk/flac2mp3
|
2013-06-13 18:34:52 +00:00
|
|
|
|
|
|
|
filename, quality = ARGV[0], ARGV[1]
|
|
|
|
abort "Usage: flac2mp3 FLACFILE [V2|V1|V0|320]\nDefault (and recommended) quality is V0." if filename.nil?
|
|
|
|
|
|
|
|
qualarg = case quality
|
|
|
|
when "V0","V1","V2" then quality
|
|
|
|
when "320" then "b 320"
|
|
|
|
else "V0"
|
|
|
|
end
|
|
|
|
|
|
|
|
map = {"TITLE" => "--tt", "ARTIST" => "--ta", "ALBUM" => "--tl", "TRACKNUMBER" => "--tn", "GENRE" => "--tg", "DATE" => "--ty"}
|
|
|
|
args = ""
|
|
|
|
|
|
|
|
`metaflac --export-tags-to=- "#{filename}"`.each_line do |line|
|
|
|
|
key, value = line.strip.split('=', 2)
|
|
|
|
key.upcase!
|
|
|
|
args << %Q{#{map[key]} "#{value.gsub('"', '\"')}" } if map[key]
|
|
|
|
end
|
|
|
|
|
|
|
|
basename = File.basename(filename, File.extname(filename))
|
|
|
|
|
|
|
|
puts "Encoding #{basename}.mp3"
|
|
|
|
exec %Q[flac -sdc "#{filename}" | lame -#{qualarg} #{args} - "#{basename}.mp3"]
|