Created
June 16, 2010 00:42
-
-
Save anagrius/439951 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'formula' | |
class Ffmpeg <Formula | |
head 'svn://svn.ffmpeg.org/ffmpeg/trunk', | |
:revisions => { :trunk => 22916, 'libswscale' => 31045 } | |
homepage 'http://ffmpeg.org/' | |
feature :x264_support, :depends_on => 'x264', :default => true | |
feature :faac_support, :depends_on => 'faac', :default => true | |
feature :faad2_support, :depends_on => 'faad2', :default => true | |
feature :lame_support, :depends_on => 'lame', :default => true | |
# :default => true could also be implied if the opposite is not specified | |
# That might be a bit more concise. | |
# The current depends_on method would describe a common dependency needed for all features. | |
depends_on :xlib | |
# Further examples: | |
# | |
# EX1: Some features could require specific features enabled on their dependencies: | |
# | |
feature :feature_a, :depends_on => ['libx(y_support,z_support)'] | |
# Homebrew would in such a situation select the installed 'libx' with y_support and z_support | |
# features installed. | |
# EX2: Some features might require other features or prohibit them: | |
# | |
feature :feature_a, ... | |
feature :feature_b, ..., :requires => [:feature_a], :prohibits => [:feature_c] | |
# | |
# CONFLICT: | |
feature :feature_c, ..., :requires => [:feature_b], :prohibits => [:feature_a] | |
# This sort of conflict would have to be handled when validating a formula. | |
# EX3: For a variant of 'libx' having eg. feature_a and feature_b enabled and version at 2.3 | |
# its keg path could look like this: | |
# | |
# Cellar/xlib/2.3(a,b)/ | |
# | |
# Others could be: | |
# | |
# Cellar/xlib/2.3(b)/ | |
# Cellar/xlib/2.3(a,b,c)/ | |
# | |
# Listing features alphabetically would enable homebrew to quickly figure out if a feature is enabled | |
# without the need for meta files. The current path structure could be used in the way it is now. | |
# | |
# If eg. a feature depends on a library 'xlib' with features 'a' and 'b' enabled, that is xlib(a,b), | |
# and several versions are already installed. Homebrew should (I think) select the the version with the | |
# least features satisfying the requirement. In the 3 versions listed above that would be | |
# Cellar/xlib/2.3(a,b)/ even though Cellar/xlib/2.3(a,b,c)/ also has all the features. | |
# This could potentially lower build size. | |
# These ideas are of course just off the top of my head and there are alot of details I | |
def install | |
configure_flags = [ | |
"--prefix=#{prefix}", | |
"--disable-debug", | |
"--enable-shared", | |
"--enable-pthreads", | |
"--enable-nonfree", | |
"--enable-gpl" | |
] | |
# You can then query for enabled features. | |
configure_flags << "--enable-libx264" if features.include?('x264') | |
configure_flags << "--enable-libfaac" if features.include?('faac') | |
configure_flags << "--enable-libfaad" if features.include?('faad2') | |
configure_flags << "--enable-libmp3lame" if features.include?('lame') | |
# For 32-bit compilation under gcc 4.2, see: | |
# http://trac.macports.org/ticket/20938#comment:22 | |
if MACOS_VERSION >= 10.6 and not Hardware.is_64_bit? | |
ENV.append_to_cflags "-mdynamic-no-pic" | |
end | |
system "./configure", *configure_flags | |
inreplace 'config.mak' do |s| | |
if MACOS_VERSION >= 10.6 and Hardware.is_64_bit? | |
shflags = s.get_make_var 'SHFLAGS' | |
s.change_make_var! 'SHFLAGS', shflags.gsub!(' -Wl,-read_only_relocs,suppress', '') | |
end | |
end | |
system "make install" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment