2010-07-25 19:41:08 +00:00
|
|
|
#!/usr/bin/env rake
|
|
|
|
# -*- mode: ruby; -*-
|
|
|
|
|
|
|
|
require "pp"
|
|
|
|
|
2010-07-25 20:43:57 +00:00
|
|
|
require "rake.d/extensions"
|
|
|
|
require "rake.d/config"
|
|
|
|
require "rake.d/helpers"
|
|
|
|
require "rake.d/target"
|
|
|
|
require "rake.d/application"
|
|
|
|
require "rake.d/library"
|
2010-07-25 19:41:08 +00:00
|
|
|
|
2010-07-26 10:29:18 +00:00
|
|
|
def setup_globals
|
|
|
|
$programs = %w{mkvmerge mkvinfo mkvextract mkvpropedit}
|
|
|
|
$programs << "mmg" if c?(:USE_WXWIDGETS)
|
2010-07-25 19:41:08 +00:00
|
|
|
|
2010-07-26 10:29:18 +00:00
|
|
|
$application_subdirs = { "mmg" => "mmg/" }
|
|
|
|
$applications = $programs.collect { |name| "src/#{$application_subdirs[name]}#{name}" + c(:EXEEXT) }
|
|
|
|
$manpages = $programs.collect { |name| "doc/man/#{name}.1" }
|
2010-07-25 19:41:08 +00:00
|
|
|
|
2010-07-26 10:29:18 +00:00
|
|
|
$system_includes = "-I. -Ilib -Ilib/avilib-0.6.10 -Ilib/utf8-cpp/source -Isrc"
|
|
|
|
$system_libdirs = "-Llib/avilib-0.6.10 -Llib/librmff -Lsrc/common -Lsrc/input -Lsrc/output -Lsrc/mpegparser"
|
2010-07-25 19:41:08 +00:00
|
|
|
|
2010-07-26 10:29:18 +00:00
|
|
|
$source_directories = %w{lib/avilib-0.6.10 lib/librmff src src/input src/output src/common src/common/chapters src/common/strings src/common/tags src/common/xml
|
2010-07-25 19:41:08 +00:00
|
|
|
src/mmg src/mmg/header_editor src/mmg/options src/mmg/tabs src/extract src/propedit src/merge src/info src/mpegparser}
|
2010-07-26 10:29:18 +00:00
|
|
|
$all_sources = $source_directories.collect { |dir| FileList[ "#{dir}/*.c", "#{dir}/*.cpp" ].to_a }.flatten
|
|
|
|
$all_headers = $source_directories.collect { |dir| FileList[ "#{dir}/*.h", ].to_a }.flatten
|
|
|
|
$all_objects = $all_sources.collect { |file| file.ext('o') }
|
|
|
|
|
|
|
|
$dependency_dir = "#{c(:top_srcdir)}/rake.d/dependecy.d"
|
2010-07-27 07:25:02 +00:00
|
|
|
|
|
|
|
$translations = c(:TRANSLATIONS).split /\s+/
|
|
|
|
$manpages_translations = c(:MANPAGES_TRANSLATIONS).split(/\s+/)
|
|
|
|
$guide_translations = c(:GUIDE_TRANSLATIONS).split(/\s+/)
|
2010-07-26 10:29:18 +00:00
|
|
|
end
|
|
|
|
|
2010-07-26 11:30:59 +00:00
|
|
|
def define_default_task
|
|
|
|
desc "Build everything"
|
2010-07-26 19:47:37 +00:00
|
|
|
|
|
|
|
# The applications themselves
|
2010-07-26 11:30:59 +00:00
|
|
|
targets = $applications.clone
|
2010-07-26 19:47:37 +00:00
|
|
|
|
|
|
|
# The tags file -- but only if it exists already
|
2010-07-26 11:30:59 +00:00
|
|
|
targets << "TAGS" if File.exist? "TAGS"
|
|
|
|
|
|
|
|
# Build man pages and translations?
|
|
|
|
if c?(:XSLTPROC_WORKS)
|
|
|
|
targets += $manpages
|
2010-07-27 07:25:02 +00:00
|
|
|
targets += $manpages_translations.collect { |language| $manpages.collect { |manpage| manpage.gsub(/man\//, "man/#{language}/") } }.flatten if c?(:PO4A_WORKS)
|
2010-07-26 11:30:59 +00:00
|
|
|
end
|
|
|
|
|
2010-07-26 19:31:57 +00:00
|
|
|
# Build translations for the programs
|
2010-07-27 07:25:02 +00:00
|
|
|
targets += $translations.collect { |language| "po/#{language}.mo" }
|
2010-07-26 19:31:57 +00:00
|
|
|
|
2010-07-26 19:47:37 +00:00
|
|
|
# The GUI help
|
2010-07-27 07:25:02 +00:00
|
|
|
targets += $guide_translations.collect { |language| "doc/guide/#{language}/mkvmerge-gui.hhk" }
|
2010-07-26 19:47:37 +00:00
|
|
|
|
|
|
|
task :default => targets
|
2010-07-26 11:30:59 +00:00
|
|
|
end
|
|
|
|
|
2010-07-26 10:29:18 +00:00
|
|
|
# main
|
|
|
|
read_config
|
|
|
|
adjust_config
|
|
|
|
setup_globals
|
|
|
|
import_dependencies
|
2010-07-25 19:41:08 +00:00
|
|
|
|
|
|
|
# Default task
|
2010-07-26 11:30:59 +00:00
|
|
|
define_default_task
|
2010-07-25 19:41:08 +00:00
|
|
|
|
2010-07-27 07:25:02 +00:00
|
|
|
desc "Build all applications"
|
|
|
|
task :apps => $applications
|
2010-07-25 19:41:08 +00:00
|
|
|
|
|
|
|
# Store compiler block for re-use
|
|
|
|
cxx_compiler = lambda do |t|
|
|
|
|
cxxflags = case
|
|
|
|
when !c?(:LIBMTXCOMMONDLL) then ''
|
|
|
|
when /src\/common/.match(t.name) then c(:CXXFLAGS_SRC_COMMON)
|
|
|
|
else c(:CXXFLAGS_NO_SRC_COMMON)
|
|
|
|
end
|
|
|
|
|
2010-07-26 10:42:14 +00:00
|
|
|
# t.sources is empty for a 'file' task (common_pch.h.o).
|
|
|
|
sources = t.sources.empty? ? [ t.prerequisites.first ] : t.sources
|
2010-07-26 10:29:18 +00:00
|
|
|
|
2010-07-26 10:42:14 +00:00
|
|
|
runq " CXX #{sources.first}", "#{c(:CXX)} #{c(:CXXFLAGS)} #{c(:INCLUDES)} #{$system_includes} #{cxxflags} -c -MMD -o #{t.name} #{sources.join(" ")}", :allow_failure => true
|
2010-07-26 10:29:18 +00:00
|
|
|
handle_deps t.name, last_exit_code
|
2010-07-25 19:41:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Precompiled headers
|
|
|
|
if c?(:USE_PRECOMPILED_HEADERS)
|
2010-07-26 10:42:14 +00:00
|
|
|
$all_objects.each { |name| file name => "src/common/common_pch.h.o" }
|
2010-07-25 19:41:08 +00:00
|
|
|
file "src/common/common_pch.h.o" => "src/common/common_pch.h", &cxx_compiler
|
|
|
|
end
|
|
|
|
|
|
|
|
# Pattern rules
|
|
|
|
rule '.o' => '.cpp', &cxx_compiler
|
|
|
|
|
|
|
|
rule '.o' => '.c' do |t|
|
2010-07-26 10:29:18 +00:00
|
|
|
runq " CC #{t.source}", "#{c(:CC)} #{c(:CFLAGS)} #{c(:INCLUDES)} #{$system_includes} -c -MMD -o #{t.name} #{t.sources.join(" ")}", :allow_failure => true
|
|
|
|
handle_deps t.name, last_exit_code
|
2010-07-25 19:41:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
rule '.o' => '.rc' do |t|
|
2010-07-26 10:29:18 +00:00
|
|
|
runq " WINDRES #{t.source}", "#{c(:WINDRES)} #{c(:WXWIDGETS_INCLUDES)} -Isrc/mmg -o #{t.name} #{t.sources.join(" ")}"
|
2010-07-25 19:41:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
rule '.mo' => '.po' do |t|
|
2010-07-26 10:29:18 +00:00
|
|
|
runq " MSGFMT #{t.source}", "msgfmt -o #{t.name} #{t.sources.join(" ")}"
|
2010-07-25 19:41:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# HTML help book stuff
|
|
|
|
rule '.hhk' => '.hhc' do |t|
|
2010-07-26 10:29:18 +00:00
|
|
|
runq " GREP #{t.source}", "#{c(:GREP)} -v 'name=\"ID\"' #{t.sources.join(" ")} > #{t.name}"
|
2010-07-25 19:41:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# man pages from DocBook XML
|
|
|
|
rule '.1' => '.xml' do |t|
|
2010-07-26 10:29:18 +00:00
|
|
|
runq "XSLTPROC #{t.source}", "#{c(:XSLTPROC)} #{c(:XSLTPROC_FLAGS)} -o #{t.name} #{c(:DOCBOOK_MANPAGES_STYLESHEET)} #{t.sources.join(" ")}"
|
2010-07-25 19:41:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Qt files
|
|
|
|
rule '.h' => '.ui' do |t|
|
2010-07-26 10:29:18 +00:00
|
|
|
runq " UIC #{t.source}", "#{c(:UIC)} #{t.sources.join(" ")} > #{t.name}"
|
2010-07-25 19:41:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
rule '.moc.cpp' => '.h' do |t|
|
2010-07-26 10:29:18 +00:00
|
|
|
runq " MOC #{t.source}", "#{c(:MOC)} #{c(:QT_CFLAGS)} #{t.sources.join(" ")} > #{t.name}"
|
2010-07-25 19:41:08 +00:00
|
|
|
end
|
|
|
|
|
2010-07-26 11:06:24 +00:00
|
|
|
# Tag files
|
|
|
|
desc "Create tags file for Emacs"
|
|
|
|
task :tags => "TAGS"
|
|
|
|
|
|
|
|
file "TAGS" => $all_sources do |t|
|
|
|
|
runq ' ETAGS', "#{c(:ETAGS)} -o #{t.name} #{t.prerequisites.join(" ")}"
|
|
|
|
end
|
|
|
|
|
2010-07-27 07:25:02 +00:00
|
|
|
# Translations for the programs
|
|
|
|
namespace :translations do
|
|
|
|
desc "Create a template for translating the programs"
|
|
|
|
task :pot => "po/mkvtoolnix.pot"
|
|
|
|
file "po/mkvtoolnix.pot" => $all_sources + $all_headers do |t|
|
|
|
|
runq 'XGETTEXT', <<-COMMAND
|
|
|
|
xgettext --keyword=YT --keyword=Y --keyword=Z --keyword=TIP --default-domain=mkvtoolnix --from-code=UTF-8 -s --omit-header -o #{t.name} #{t.prerequisites.join(" ")}
|
|
|
|
COMMAND
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Update the program translation files"
|
|
|
|
task "update" => [ "po/mkvtoolnix.pot", ] + $translations.collect { |language| "translations:update:#{language}".to_sym }
|
|
|
|
|
|
|
|
namespace "update" do
|
|
|
|
$translations.each do |language|
|
|
|
|
task language.to_sym => "po/mkvtoolnix.pot" do |t|
|
|
|
|
po = "po/#{language}.po"
|
|
|
|
new_po = "#{po}.new"
|
|
|
|
runq "MSGMERGE #{po}", "msgmerge -q -s --no-wrap #{po} po/mkvtoolnix.pot > #{new_po}", :allow_failure => true
|
|
|
|
|
|
|
|
exit_code = last_exit_code
|
|
|
|
if 0 != exit_code
|
|
|
|
File.unlink new_po
|
|
|
|
exit exit_code
|
|
|
|
end
|
|
|
|
|
|
|
|
File.open(po, "w") do |out|
|
|
|
|
lines = IO.readlines(new_po).collect { |line| line.chomp }
|
|
|
|
|
|
|
|
if %w{es nl ru uk zh_CN zh_TW}.include? language
|
|
|
|
no_nl = false
|
|
|
|
|
|
|
|
lines.each do |line|
|
|
|
|
if /^#:/.match(line)
|
|
|
|
out.puts line.gsub(/(\d) /, '\1' + "\n#: ")
|
|
|
|
elsif /^#~/.match(line)
|
|
|
|
no_nl = true
|
|
|
|
out.puts line
|
|
|
|
elsif !(no_nl && /^\s*$/.match(line))
|
|
|
|
out.puts line
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
out.puts
|
|
|
|
else
|
|
|
|
out.puts lines.join("\n")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
File.unlink new_po
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
[ :stats, :statistics ].each_with_index do |name, idx|
|
|
|
|
desc "Generate statistics about translation coverage" if 0 == idx
|
|
|
|
task name do
|
|
|
|
FileList["po/*.po", "doc/man/po4a/po/*.po"].each do |name|
|
|
|
|
command = "msgfmt --statistics -o /dev/null #{name} 2>&1"
|
|
|
|
if ENV["V"].to_bool
|
|
|
|
runq " MSGFMT #{name}", command, :allow_failure => true
|
|
|
|
else
|
|
|
|
puts "#{name} : " + `#{command}`.split(/\n/).first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Installation tasks
|
|
|
|
desc "Install all applications and support files"
|
|
|
|
task :install => [ "install:programs", c?(:USE_WXWIDGETS) ? "install:shared" : nil, "install:manpages", "install:translations:manpages", "install:translations:apps", "install:translations:guide" ].compact
|
|
|
|
|
2010-07-25 19:41:08 +00:00
|
|
|
# Cleaning tasks
|
2010-07-26 10:56:42 +00:00
|
|
|
desc "Remove all compiled files"
|
2010-07-25 19:41:08 +00:00
|
|
|
task :clean do
|
2010-07-26 10:29:18 +00:00
|
|
|
run <<-SHELL, :allow_failure => true
|
2010-07-25 19:41:08 +00:00
|
|
|
rm -f *.o */*.o */*/*.o */lib*.a */*/lib*.a po/*.mo #{$applications.join(" ")}
|
2010-07-26 19:47:37 +00:00
|
|
|
*/*.exe */*/*.exe */*/*.dll */*/*.dll.a doc/guide/*/*.hhk
|
2010-07-25 19:41:08 +00:00
|
|
|
src/info/ui/*.h src/info/*.moc.cpp src/common/*/*.o
|
2010-07-26 10:29:18 +00:00
|
|
|
src/mmg/*/*.o
|
2010-07-25 19:41:08 +00:00
|
|
|
SHELL
|
|
|
|
end
|
|
|
|
|
2010-07-27 07:25:02 +00:00
|
|
|
namespace :clean do
|
|
|
|
desc "Remove all compiled and generated files ('tarball' clean)"
|
|
|
|
task :dist => :clean do
|
2010-07-26 10:29:18 +00:00
|
|
|
run "rm -f config.h config.log config.cache build-config Makefile */Makefile */*/Makefile TAGS", :allow_failure => true
|
|
|
|
run "rm -rf #{$dependency_dir}", :allow_failure => true
|
2010-07-25 19:41:08 +00:00
|
|
|
end
|
|
|
|
|
2010-07-27 07:25:02 +00:00
|
|
|
desc "Remove all compiled and generated files ('git' clean)"
|
|
|
|
task :maintainer => "clean:dist" do
|
|
|
|
run "rm -f configure config.h.in", :allow_failure => true
|
|
|
|
end
|
2010-07-25 19:41:08 +00:00
|
|
|
|
2010-07-27 07:25:02 +00:00
|
|
|
desc "Remove all compiled libraries"
|
|
|
|
task :libs do
|
|
|
|
run "rm -f */lib*.a */*/lib*.a */*/*.dll */*/*.dll.a", :allow_failure => true
|
|
|
|
end
|
2010-07-25 19:41:08 +00:00
|
|
|
|
2010-07-27 07:25:02 +00:00
|
|
|
[:apps, :applications, :exe].each_with_index do |name, idx|
|
|
|
|
desc "Remove all compiled applications" if 0 == idx
|
|
|
|
task name do
|
|
|
|
run "rm -f #{$applications.join(" ")} */*.exe */*/*.exe", :allow_failure => true
|
|
|
|
end
|
2010-07-25 19:41:08 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# avilib-0.6.10
|
|
|
|
# librmff
|
|
|
|
# spyder's MPEG parser
|
|
|
|
# src/common
|
|
|
|
# src/input
|
|
|
|
# src/output
|
|
|
|
#
|
|
|
|
|
|
|
|
[ { :name => 'avi', :dir => 'lib/avilib-0.6.10' },
|
|
|
|
{ :name => 'rmff', :dir => 'lib/librmff' },
|
|
|
|
{ :name => 'mpegparser', :dir => 'src/mpegparser' },
|
|
|
|
{ :name => 'mtxcommon', :dir => [ 'src/common', 'src/common/chapters', 'src/common/strings', 'src/common/tags', 'src/common/xml' ] },
|
|
|
|
{ :name => 'mtxinput', :dir => 'src/input' },
|
|
|
|
{ :name => 'mtxoutput', :dir => 'src/output' },
|
|
|
|
].each do |lib|
|
|
|
|
Library.
|
|
|
|
new("#{[ lib[:dir] ].flatten.first}/lib#{lib[:name]}").
|
|
|
|
sources(*[ lib[:dir] ].flatten, :type => :dir).
|
|
|
|
build_dll(lib[:name] == 'mtxcommon').
|
|
|
|
libraries(:iconv, :z, :compression, :matroska, :ebml, :expat, :rpcrt4).
|
|
|
|
create
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# mkvmerge
|
|
|
|
#
|
|
|
|
|
|
|
|
Application.new("src/mkvmerge").
|
2010-07-26 10:56:42 +00:00
|
|
|
description("Build the mkvmerge executable").
|
2010-07-25 19:41:08 +00:00
|
|
|
aliases(:mkvmerge).
|
|
|
|
sources("src/merge", :type => :dir).
|
|
|
|
sources("src/merge/resources.o", :if => c?(:MINGW)).
|
|
|
|
libraries(:mtxinput, :mtxoutput, :mtxcommon, :magic, :matroska, :ebml, :avi, :rmff, :mpegparser, :flac, :vorbis, :ogg, :z, :compression, :expat, :iconv, :intl,
|
|
|
|
:boost_regex, :boost_filesystem, :boost_system).
|
|
|
|
libraries(:rpcrt4, :if => c?(:MINGW)).
|
|
|
|
create
|
|
|
|
|
|
|
|
#
|
|
|
|
# mkvinfo
|
|
|
|
#
|
|
|
|
|
|
|
|
$mkvinfo_ui_files = FileList["src/info/ui/*.ui"].to_a
|
|
|
|
file "src/info/qt_ui.o" => $mkvinfo_ui_files
|
|
|
|
|
|
|
|
Application.new("src/mkvinfo").
|
2010-07-26 10:56:42 +00:00
|
|
|
description("Build the mkvinfo executable").
|
2010-07-25 19:41:08 +00:00
|
|
|
aliases(:mkvinfo).
|
|
|
|
sources(FileList["src/info/*.cpp"].exclude("src/info/qt_ui.cpp", "src/info/wxwidgets_ui.cpp")).
|
|
|
|
sources("src/info/resources.o", :if => c?(:MINGW)).
|
|
|
|
libraries(:mtxcommon, :magic, :matroska, :ebml, :boost_regex, :boost_filesystem, :boost_system).
|
|
|
|
only_if(c?(:USE_QT)).
|
|
|
|
sources("src/info/qt_ui.cpp", "src/info/qt_ui.moc.cpp", "src/info/rightclick_tree_widget.moc.cpp", $mkvinfo_ui_files).
|
|
|
|
libraries(:qt).
|
|
|
|
only_if(!c?(:USE_QT) && c?(:USE_WXWIDGETS)).
|
|
|
|
sources("src/info/wxwidgets_ui.cpp").
|
|
|
|
libraries(:wxwidgets).
|
|
|
|
create
|
|
|
|
|
|
|
|
#
|
|
|
|
# mkvextract
|
|
|
|
#
|
|
|
|
|
|
|
|
Application.new("src/mkvextract").
|
2010-07-26 10:56:42 +00:00
|
|
|
description("Build the mkvpropedit executable").
|
2010-07-25 19:41:08 +00:00
|
|
|
aliases(:mkvextract).
|
|
|
|
sources("src/extract", :type => :dir).
|
|
|
|
sources("src/extract/resources.o", :if => c?(:MINGW)).
|
|
|
|
libraries(:mtxcommon, :magic, :matroska, :ebml, :avi, :rmff, :vorbis, :ogg, :z, :compression, :expat, :iconv, :intl, :boost_regex, :boost_filesystem, :boost_system).
|
|
|
|
libraries(:rpcrt4, :if => c?(:MINGW)).
|
|
|
|
create
|
|
|
|
|
|
|
|
#
|
|
|
|
# mkvpropedit
|
|
|
|
#
|
|
|
|
|
|
|
|
Application.new("src/mkvpropedit").
|
2010-07-26 10:56:42 +00:00
|
|
|
description("Build the mkvpropedit executable").
|
2010-07-25 19:41:08 +00:00
|
|
|
aliases(:mkvpropedit).
|
|
|
|
sources("src/propedit", :type => :dir).
|
|
|
|
sources("src/propedit/resources.o", :if => c?(:MINGW)).
|
|
|
|
libraries(:mtxcommon, :magic, :matroska, :ebml, :avi, :rmff, :vorbis, :ogg, :z, :compression, :expat, :iconv, :intl, :boost_regex, :boost_filesystem, :boost_system).
|
|
|
|
libraries(:rpcrt4, :if => c?(:MINGW)).
|
|
|
|
create
|
|
|
|
|
|
|
|
#
|
|
|
|
# mmg
|
|
|
|
#
|
|
|
|
|
|
|
|
if c?(:USE_WXWIDGETS)
|
|
|
|
Application.new("src/mmg/mmg").
|
2010-07-26 10:56:42 +00:00
|
|
|
description("Build the mmg executable").
|
2010-07-25 19:41:08 +00:00
|
|
|
aliases(:mmg).
|
|
|
|
sources("src/mmg", "src/mmg/header_editor", "src/mmg/options", "src/mmg/tabs", :type => :dir).
|
|
|
|
sources("src/propedit/mmg-resources.o", :if => c?(:MINGW)).
|
|
|
|
libraries(:mtxcommon, :magic, :matroska, :ebml, :avi, :rmff, :vorbis, :ogg, :z, :compression, :expat, :iconv, :intl, :wxwidgets,
|
|
|
|
:boost_regex, :boost_filesystem, :boost_system).
|
|
|
|
libraries(:rpcrt4, :ole32, :shell32, "-mwindows", :if => c?(:MINGW)).
|
|
|
|
create
|
|
|
|
end
|