Skip to content

Instantly share code, notes, and snippets.

@turboladen
Forked from jamiehodge/libav.rb
Last active December 17, 2015 08:28
Show Gist options
  • Save turboladen/5579818 to your computer and use it in GitHub Desktop.
Save turboladen/5579818 to your computer and use it in GitHub Desktop.
require 'formula'
class Libav < Formula
homepage 'http://libav.org/'
url 'http://libav.org/releases/libav-9.6.tar.xz'
sha1 '7c66e9776e83b13910eae960d63b7b86ad229dfe'
head 'git://git.libav.org/libav.git'
option "without-x264", "Disable H264 encoder"
option "without-faac", "Disable AAC encoder"
option "without-lame", "Disable MP3 encoder"
option "without-xvid", "Disable Xvid MPEG-4 video format"
option 'without-avplay', 'Disable AVPlay media player'
option "with-freetype", "Enable FreeType"
option "with-theora", "Enable Theora video format"
option "with-libvorbis", "Enable Vorbis audio format"
option "with-libvpx", "Enable VP8 video format"
option "with-rtmpdump", "Enable RTMP protocol"
option "with-opencore-amr", "Enable AMR audio format"
option "with-libvo-aacenc", "Enable VisualOn AAC encoder"
option "with-libass", "Enable ASS/SSA subtitle format"
option "with-openjpeg", 'Enable JPEG 2000 image format'
option 'with-schroedinger', 'Enable Dirac video format'
option 'with-tools', 'Enable additional FFmpeg tools'
depends_on 'pkg-config' => :build
depends_on 'xz' => :build
# manpages won't be built without texi2html
depends_on 'texi2html' => :build if MacOS.version >= :mountain_lion
depends_on 'yasm' => :build
depends_on 'gnutls' => :build
depends_on 'x264' unless build.include? 'without-x264'
depends_on 'faac' unless build.include? 'without-faac'
depends_on 'lame' unless build.include? 'without-lame'
depends_on 'xvid' unless build.include? 'without-xvid'
depends_on 'sdl' unless build.include? 'without-avplay'
depends_on :freetype if build.include? 'with-freetype'
depends_on 'theora' if build.include? 'with-theora'
depends_on 'libvorbis' if build.include? 'with-libvorbis'
depends_on 'libvpx' if build.include? 'with-libvpx'
depends_on 'rtmpdump' if build.include? 'with-rtmpdump'
depends_on 'opencore-amr' if build.include? 'with-opencore-amr'
depends_on 'libvo-aacenc' if build.include? 'with-libvo-aacenc'
depends_on 'libass' if build.include? 'with-libass'
depends_on 'openjpeg' if build.include? 'with-openjpeg'
depends_on 'speex' if build.include? 'with-speex'
depends_on 'schroedinger' if build.include? 'with-schroedinger'
conflicts_with 'ffmpeg',
:because => 'libav and ffmpeg install the same libraries'
def install
args = ["--prefix=#{prefix}",
"--enable-shared",
"--enable-pthreads",
"--enable-gpl",
"--enable-version3",
"--enable-nonfree",
"--enable-hardcoded-tables",
"--enable-avresample",
"--enable-vda",
'--enable-gnutls',
'--enable-runtime-cpudetect',
'--disable-indev=jack',
"--cc=#{ENV.cc}",
"--host-cflags=#{ENV.cflags}",
"--host-ldflags=#{ENV.ldflags}"
]
args << "--enable-libx264" if build.with? 'x264'
args << "--enable-libfaac" if build.with? 'faac'
args << "--enable-libmp3lame" if build.with? 'lame'
args << "--enable-libxvid" if build.with? 'xvid'
args << "--enable-avplay" unless build.include? 'without-avplay'
args << "--enable-libfreetype" if build.with? 'freetype'
args << "--enable-libtheora" if build.with? 'theora'
args << "--enable-libvorbis" if build.with? 'libvorbis'
args << "--enable-libvpx" if build.with? 'libvpx'
args << "--enable-librtmp" if build.with? 'rtmpdump'
args << "--enable-libopencore-amrnb" << "--enable-libopencore-amrwb" if build.with? 'opencore-amr'
args << "--enable-libvo-aacenc" if build.with? 'libvo-aacenc'
args << "--enable-libass" if build.with? 'libass'
args << "--enable-ffplay" if build.include? 'with-ffplay'
args << "--enable-libspeex" if build.with? 'speex'
args << '--enable-libschroedinger' if build.with? 'schroedinger'
args << "--enable-libfdk-aac" if build.with? 'fdk-aac'
args << "--enable-openssl" if build.with? 'openssl'
args << "--enable-libopus" if build.with? 'opus'
args << "--enable-frei0r" if build.with? 'frei0r'
args << "--enable-libcaca" if build.with? 'libcaca'
if build.with? 'openjpeg'
args << '--enable-libopenjpeg'
args << '--extra-cflags=' + %x[pkg-config --cflags libopenjpeg].chomp
end
# For 32-bit compilation under gcc 4.2, see:
# http://trac.macports.org/ticket/20938#comment:22
ENV.append_to_cflags "-mdynamic-no-pic" if Hardware.is_32_bit? && Hardware.cpu_type == :intel && ENV.compiler == :clang
system "./configure", *args
if MacOS.prefer_64_bit?
inreplace 'config.mak' do |s|
shflags = s.get_make_var 'SHFLAGS'
if shflags.gsub!(' -Wl,-read_only_relocs,suppress', '')
s.change_make_var! 'SHFLAGS', shflags
end
end
end
system "make install"
if build.include? 'with-tools'
system "make alltools"
bin.install Dir['tools/*'].select {|f| File.executable? f}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment