aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/avidemux.rb
blob: d4966935aa54d48c982d2bda7b7f71a6ebfb8c07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
require 'formula'

# Help! Wanted: someone who can get Avidemux working with SDL.

class Avidemux < Formula
  homepage 'http://avidemux.sourceforge.net/'
  url 'http://downloads.sourceforge.net/avidemux/avidemux_2.6.4.tar.gz'
  sha1 '7ed55fd5cfb6cfa73ebb9058af72fa2e3c9717c3'
  head 'git://gitorious.org/avidemux2-6/avidemux2-6.git'

  option 'with-debug', 'Enable debug build.'

  depends_on 'pkg-config' => :build
  depends_on 'cmake' => :build
  depends_on 'yasm' => :build
  depends_on :fontconfig
  depends_on 'gettext'
  depends_on 'x264' => :recommended
  depends_on 'faac' => :recommended
  depends_on 'faad2' => :recommended
  depends_on 'lame' => :recommended
  depends_on 'xvid' => :recommended
  depends_on :freetype => :recommended
  depends_on 'theora' => :recommended
  depends_on 'libvorbis' => :recommended
  depends_on 'libvpx' => :recommended
  depends_on 'rtmpdump' => :recommended
  depends_on 'opencore-amr' => :recommended
  depends_on 'libvo-aacenc' => :recommended
  depends_on 'libass' => :recommended
  depends_on 'openjpeg' => :recommended
  depends_on 'speex' => :recommended
  depends_on 'schroedinger' => :recommended
  depends_on 'fdk-aac' => :recommended
  depends_on 'opus' => :recommended
  depends_on 'frei0r' => :recommended
  depends_on 'libcaca' => :recommended
  depends_on 'qt' => :recommended


  def install
    ENV['REV'] = version.to_s

    # For 32-bit compilation under gcc 4.2, see:
    # http://trac.macports.org/ticket/20938#comment:22
    if MacOS.version <= :leopard or Hardware.is_32_bit? && Hardware::CPU.intel? && ENV.compiler == :clang
      inreplace 'cmake/admFFmpegBuild.cmake',
        '${CMAKE_INSTALL_PREFIX})',
        '${CMAKE_INSTALL_PREFIX} --extra-cflags=-mdynamic-no-pic)'
    end

    # Build the core
    mkdir 'buildCore' do
      args = std_cmake_args
      args << "-DAVIDEMUX_SOURCE_DIR=#{buildpath}"
      args << "-DGETTEXT_INCLUDE_DIR=#{Formula.factory('gettext').opt_prefix}/include"
      # Todo: We could depend on SDL and then remove the `-DSDL=OFF` arguments
      # but I got build errors about NSview.
      args << "-DSDL=OFF"

      if build.with? 'debug'
        ENV.O2
        ENV.enable_warnings
        args << '-DCMAKE_BUILD_TYPE=Debug'
        args << '-DCMAKE_VERBOSE_MAKEFILE=true'
        unless ENV.compiler == :clang
          args << '-DCMAKE_C_FLAGS_DEBUG=-ggdb3'
          args << '-DCMAKE_CXX_FLAGS_DEBUG=-ggdb3'
        end
      end

      args << '../avidemux_core'
      system "cmake", *args
      # Parallel build sometimes fails with: "ld: library not found for -lADM6avcodec"
      ENV.deparallelize
      system "make"
      system "make", "install"
      # There is no ENV.parallelize, so:
      ENV['MAKEFLAGS'] = "-j#{ENV.make_jobs}"
    end

    # UIs: Build Qt4 and cli
    interfaces = ['cli']
    interfaces << 'qt4' if build.with? 'qt'
    interfaces.each do |interface|
      mkdir "build#{interface}" do
        args = std_cmake_args
        args << "-DAVIDEMUX_SOURCE_DIR=#{buildpath}"
        args << "-DAVIDEMUX_LIB_DIR=#{lib}"
        # If you get SDL to work with avidemux, you might still need to add -I like so:
        # args << "-DCMAKE_CXX_FLAGS=-I#{Formula.factory('sdl').opt_prefix}/include/SDL"
        args << "-DSDL=OFF"
        args << "../avidemux/#{interface}"
        system "cmake", *args
        system "make"
        system "make", "install"
      end
    end

    # Plugins
    plugins = ['COMMON', 'CLI']
    plugins << 'QT4' if build.with? 'qt'
    plugins.each do |plugin|
      mkdir "buildplugin#{plugin}" do
        args = std_cmake_args + %W[
          -DPLUGIN_UI=#{plugin}
          -DAVIDEMUX_LIB_DIR=#{lib}
          -DAVIDEMUX_SOURCE_DIR=#{buildpath}
        ]

        if build.with? 'debug'
          args << '-DCMAKE_BUILD_TYPE=Debug'
          args << '-DCMAKE_VERBOSE_MAKEFILE=true'
          unless ENV.compiler == :clang
            args << '-DCMAKE_C_FLAGS_DEBUG=-ggdb3'
            args << '-DCMAKE_CXX_FLAGS_DEBUG=-ggdb3'
          end
        end

        args << "../avidemux_plugins"
        system "cmake", *args
        system "make"
        system "make install"
      end
    end

    # Steps from the bootStrapOsx.bash:
    app = prefix/"Avidemux2.6.app/Contents"
    mkdir_p app/"Resources"
    mkdir_p app/"MacOS"
    cp_r "./cmake/osx/Avidemux2.6", app/"MacOS/Avidemux2.6.app"
    chmod 0755, app/"MacOS/Avidemux2.6.app"
    cp_r Formula.factory('qt').opt_prefix/"lib/QtGui.framework/Resources/qt_menu.nib", app/"MacOS/" if build.with? 'qt'
    cp "./cmake/osx/Info.plist", app
    ln_s lib, app/"Resources/"
    ln_s bin, app/"Resources/"
    cp Dir["./cmake/osx/*.icns"], app/"Resources/"
  end

  def caveats
    if build.with? 'qt' then <<-EOS.undent
      You may want to `brew linkapps` to link the Qt GUI app
      #{opt_prefix}/Avidemux2.6.app it to `~/Applications`.

      To enable sound: In preferences, set the audio to CoreAudio instead of Dummy.
      EOS
    end
  end
end