Commit 08420ddd authored by Urs Fleisch's avatar Urs Fleisch
Browse files

make Qt4 versions for Linux, Windows and Mac OS X buildable using CMake

parent acfada49
# Build Kid3 using CMake
#
# Linux:
# cmake -D CMAKE_BUILD_TYPE=Release -D WITH_KDE=OFF -D CMAKE_INSTALL_PREFIX=/usr ../kid3
# make
# make install/strip DESTDIR=$(pwd)/inst # or
# cpack
#
# Windows:
# set INCLUDE=%MSYSDIR%\local\include
# set LIB=%MSYSDIR%\local\lib
# cmake -G "MinGW Makefiles" -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX= -D WITH_TUNEPIMP=OFF ..\kid3
# mingw32-make
# cpack
#
# Mac OS X:
# cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX= -D WITH_TUNEPIMP=OFF ../kid3
# make
# cpack
project(kid3)
set(WITH_TAGLIB ON CACHE BOOL "build with TagLib")
......@@ -6,41 +26,137 @@ set(WITH_ID3LIB ON CACHE BOOL "build with id3lib")
set(WITH_VORBIS ON CACHE BOOL "build with Ogg/Vorbis")
set(WITH_FLAC ON CACHE BOOL "build with FLAC")
set(WITH_TUNEPIMP ON CACHE BOOL "build with TunePimp")
set(WITH_KDE ON CACHE BOOL "build with KDE libraries")
if (APPLE OR WIN32)
set(WITH_KDE OFF CACHE BOOL "build with KDE libraries")
else (APPLE OR WIN32)
set(WITH_KDE ON CACHE BOOL "build with KDE libraries")
endif (APPLE OR WIN32)
if (WITH_KDE)
find_package(KDE4 REQUIRED)
find_package(Phonon)
include (KDE4Defaults)
include (MacroEnsureVersion)
else (WITH_KDE)
find_package(Threads)
# Platform specific default installation paths
if (APPLE)
set(WITH_DATAROOTDIR_DEFAULT "kid3.app/Contents/Resources")
set(WITH_DOCDIR_DEFAULT "kid3.app/Contents/Resources")
set(WITH_TRANSLATIONSDIR_DEFAULT "kid3.app/Contents/Resources")
set(WITH_BINDIR_DEFAULT ".")
elseif (WIN32)
set(WITH_DATAROOTDIR_DEFAULT ".")
set(WITH_DOCDIR_DEFAULT ".")
set(WITH_TRANSLATIONSDIR_DEFAULT ".")
set(WITH_BINDIR_DEFAULT ".")
else (APPLE)
set(WITH_DATAROOTDIR_DEFAULT "share")
set(WITH_DOCDIR_DEFAULT "share/doc/kid3-qt")
set(WITH_TRANSLATIONSDIR_DEFAULT "share/kid3-qt/translations")
set(WITH_BINDIR_DEFAULT "bin")
endif (APPLE)
set(WITH_DBUS ON CACHE BOOL "build with QtDBus")
set(WITH_PHONON ON CACHE BOOL "build with Phonon")
set(WITH_DATAROOTDIR ${WITH_DATAROOTDIR_DEFAULT} CACHE STRING
"data root directory relative to CMAKE_INSTALL_PREFIX")
set(WITH_DOCDIR ${WITH_DOCDIR_DEFAULT} CACHE STRING
"documentation directory relative to CMAKE_INSTALL_PREFIX")
set(WITH_TRANSLATIONSDIR ${WITH_TRANSLATIONSDIR_DEFAULT} CACHE STRING
"translations directory relative to CMAKE_INSTALL_PREFIX")
set(WITH_BINDIR ${WITH_BINDIR_DEFAULT} CACHE STRING
"binary directory relative to CMAKE_INSTALL_PREFIX")
if (CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX_SLASH "${CMAKE_INSTALL_PREFIX}/")
else (CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX_SLASH "")
endif (CMAKE_INSTALL_PREFIX)
set(CFG_DATAROOTDIR ${CMAKE_INSTALL_PREFIX_SLASH}${WITH_DATAROOTDIR})
set(CFG_DOCDIR ${CMAKE_INSTALL_PREFIX_SLASH}${WITH_DOCDIR})
set(CFG_TRANSLATIONSDIR ${CMAKE_INSTALL_PREFIX_SLASH}${WITH_TRANSLATIONSDIR})
cmake_minimum_required(VERSION 2.8)
set(_QT4_COMPONENTS QtCore QtGui QtNetwork QtXml)
if(WITH_PHONON)
list(APPEND _QT4_COMPONENTS phonon)
endif(WITH_PHONON)
if (WIN32)
set(QT_USE_QTMAIN TRUE)
endif (WIN32)
if (NOT WITH_DBUS)
set(QT_USE_QTDBUS OFF)
endif (NOT WITH_DBUS)
find_package(Qt4 COMPONENTS ${_QT4_COMPONENTS} REQUIRED)
include (${QT_USE_FILE})
include (CheckCXXSourceCompiles)
find_package(Perl REQUIRED)
### Check for xsltproc
find_program(XSLTPROC xsltproc DOC "xsltproc transforms XML via XSLT"
PATHS $ENV{XSLTPROCDIR})
if (NOT XSLTPROC)
message(FATAL_ERROR "Could not find xsltproc")
endif (NOT XSLTPROC)
### Check for HTML docbook.xsl
find_path(DOCBOOK_XSL_DIR html/docbook.xsl
PATHS /usr/share/xml/docbook/stylesheet/nwalsh
/usr/share/apps/ksgmltools2/docbook/xsl
$ENV{DOCBOOKDIR}
$ENV{HOME}/docbook-xsl-1.72.0
NO_DEFAULT_PATH)
if (NOT DOCBOOK_XSL_DIR)
message(FATAL_ERROR "Could not find HTML docbook.xsl")
endif (NOT DOCBOOK_XSL_DIR)
endif (WITH_KDE)
include (CheckLibraryExists)
if(WITH_KDE)
if (WITH_KDE)
set(CONFIG_USE_KDE 1)
set(BASIC_LIBRARIES ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${PHONON_LIBS})
else(WITH_KDE)
set(BASIC_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTDBUS_LIBRARY})
endif(WITH_KDE)
else (WITH_KDE)
set(BASIC_LIBRARIES ${QT_LIBRARIES})
endif (WITH_KDE)
if (WIN32)
link_directories($ENV{LIB})
endif (WIN32)
### Check for taglib
set(TAGLIB_LIBRARIES)
set(TAGLIB_CFLAGS)
if(WITH_TAGLIB)
if (WIN32)
find_library(TAGLIB_LIBRARIES NAMES tag)
find_path(TAGLIB_INCLUDE_DIR taglib.h PATHS $ENV{INCLUDE}/taglib)
if (TAGLIB_LIBRARIES AND TAGLIB_INCLUDE_DIR)
set(TAGLIB_CFLAGS -I${TAGLIB_INCLUDE_DIR} -DTAGLIB_STATIC)
set(HAVE_TAGLIB 1)
endif (TAGLIB_LIBRARIES AND TAGLIB_INCLUDE_DIR)
else (WIN32)
find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS /usr/bin /usr/local/bin ${BIN_INSTALL_DIR})
if(TAGLIBCONFIG_EXECUTABLE)
exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES)
exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS)
exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION)
if(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS AND TAGLIB_VERSION)
MACRO_ENSURE_VERSION2("1.4" ${TAGLIB_VERSION} TAGLIB_INSTALLED_VERSION_OK)
if(TAGLIB_INSTALLED_VERSION_OK)
if(NOT ${TAGLIB_VERSION} VERSION_LESS 1.4)
set(HAVE_TAGLIB 1)
message(STATUS "TagLib found: ${TAGLIB_LIBRARIES}")
endif(TAGLIB_INSTALLED_VERSION_OK)
endif(NOT ${TAGLIB_VERSION} VERSION_LESS 1.4)
endif(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS AND TAGLIB_VERSION)
endif(TAGLIBCONFIG_EXECUTABLE)
if (NOT HAVE_TAGLIB)
message(FATAL_ERROR "Could not find Taglib")
endif (NOT HAVE_TAGLIB)
endif (WIN32)
endif(WITH_TAGLIB)
### Check for mp4v2
......@@ -91,20 +207,35 @@ endif(WITH_MP4V2)
### Check for id3lib
set(ID3LIB_LIBRARIES)
set(ID3LIB_DEFINITIONS)
if(WITH_ID3LIB)
find_path(ID3LIB_INCLUDE_DIR id3/tag.h)
find_library(ID3LIB_LIBRARIES NAMES id3)
if(ID3LIB_INCLUDE_DIR AND ID3LIB_LIBRARIES)
message(STATUS "id3lib found: ${ID3LIB_LIBRARIES}")
set(HAVE_ID3LIB 1)
if (WIN32)
find_library(_ZLIB_PATH_NAME z)
if (_ZLIB_PATH_NAME)
get_filename_component(_ZLIB_PATH ${_ZLIB_PATH_NAME} PATH)
else (_ZLIB_PATH_NAME)
message(FATAL_ERROR "Could not find zlib")
endif (_ZLIB_PATH_NAME)
set(ID3LIB_DEFINITIONS -DID3LIB_LINKOPTION=1)
set(ID3LIB_LIBRARIES ${ID3LIB_LIBRARIES} "-L${_ZLIB_PATH}" -lz -lstdc++)
elseif (APPLE)
set(ID3LIB_LIBRARIES ${ID3LIB_LIBRARIES} -lz -liconv)
endif (WIN32)
set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ID3LIB_LIBRARIES} -lz -lstdc++)
set(_CMAKE_REQUIRED_INCLUDES_TMP ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ID3LIB_INCLUDE_DIR})
set(_CMAKE_REQUIRED_DEFINITIONS_TMP ${CMAKE_REQUIRED_DEFINITIONS})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${ID3LIB_DEFINITIONS})
CHECK_CXX_SOURCE_COMPILES("#include <id3/globals.h>\nint main() {\n Mp3_Headerinfo info;\n info.vbr_bitrate = 0;\n return 0;\n}\n" ID3LIB_VBR_SUPPORT_FOUND)
set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_TMP})
set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_TMP})
if(NOT ID3LIB_VBR_SUPPORT_FOUND)
set(HAVE_NO_ID3LIB_VBR 1)
......@@ -157,6 +288,7 @@ endif(WITH_VORBIS)
### Check for FLAC++
set(FLAC_LIBRARIES)
set(FLAC_DEFINITIONS)
if(WITH_FLAC)
find_path(FLACPP_INCLUDE_DIR FLAC++/metadata.h)
find_library(FLAC_LIBRARY NAMES FLAC)
......@@ -165,15 +297,21 @@ if(WITH_FLAC)
set(FLAC_LIBRARIES ${FLACPP_LIBRARY} ${FLAC_LIBRARY})
message(STATUS "FLAC++ found: ${FLAC_LIBRARIES}")
set(HAVE_FLAC 1)
if (WIN32)
set(FLAC_DEFINITIONS -DFLAC__NO_DLL)
set(FLAC_LIBRARIES ${FLAC_LIBRARIES} ws2_32)
endif (WIN32)
set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${FLAC_LIBRARIES} ${OGG_LIBRARY})
set(_CMAKE_REQUIRED_INCLUDES_TMP ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${FLACPP_INCLUDE_DIR})
set(_CMAKE_REQUIRED_DEFINITIONS_TMP ${CMAKE_REQUIRED_DEFINITIONS})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${FLAC_DEFINITIONS})
CHECK_CXX_SOURCE_COMPILES("#include <FLAC++/metadata.h>\nint main() {\n FLAC::Metadata::VorbisComment vc;\n const ::FLAC__StreamMetadata* fsmd = vc;\n return 0;\n}\n" FLAC_STREAMMETADATA_OPERATOR_FOUND)
CHECK_CXX_SOURCE_COMPILES("#include <FLAC++/metadata.h>\nint main() {\n FLAC::Metadata::Picture pic;\n return 0;\n}\n" FLAC_METADATA_PICTURE_FOUND)
set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_TMP})
set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_TMP})
if(NOT FLAC_STREAMMETADATA_OPERATOR_FOUND)
set(HAVE_NO_FLAC_STREAMMETADATA_OPERATOR 1)
......@@ -187,9 +325,11 @@ if(WITH_FLAC)
endif(WITH_FLAC)
### Check for libQtDBus
if(QT_QTDBUS_LIBRARY)
if (WITH_DBUS AND QT_QTDBUS_LIBRARY)
set(HAVE_QTDBUS 1)
endif(QT_QTDBUS_LIBRARY)
endif (WITH_DBUS AND QT_QTDBUS_LIBRARY)
if (WITH_KDE)
### Check for Phonon
if(PHONON_FOUND)
......@@ -199,8 +339,57 @@ endif(PHONON_FOUND)
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS} ${TAGLIB_CFLAGS} -DHAVE_CONFIG_H=1 -DKDE_NO_COMPAT)
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${QT_INCLUDES} ${PHONON_INCLUDES} ${MP4V2_INCLUDE_DIR} ${ID3LIB_INCLUDE_DIR} ${TUNEPIMP_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR} ${FLACPP_INCLUDE_DIR})
else (WITH_KDE)
### Check for Phonon
if (QT_USE_PHONON AND QT_PHONON_FOUND)
set(HAVE_PHONON 1)
endif (QT_USE_PHONON AND QT_PHONON_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -D_REENTRANT")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -D_REENTRANT")
add_definitions(${QT_DEFINITIONS} ${TAGLIB_CFLAGS} ${ID3LIB_DEFINITIONS} ${FLAC_DEFINITIONS} -DHAVE_CONFIG_H=1)
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${QT_INCLUDES} ${MP4V2_INCLUDE_DIR} ${ID3LIB_INCLUDE_DIR} ${TUNEPIMP_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR} ${FLACPP_INCLUDE_DIR})
if (UNIX AND NOT APPLE)
set(KID3_EXECUTABLE kid3-qt)
else (UNIX AND NOT APPLE)
set(KID3_EXECUTABLE kid3)
endif (UNIX AND NOT APPLE)
endif (WITH_KDE)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
add_subdirectory(kid3)
add_subdirectory(doc)
add_subdirectory(po)
# To create a package, run cpack
if (APPLE)
set(CPACK_BINARY_DRAGNDROP ON)
set(CPACK_GENERATOR DragNDrop)
elseif (WIN32)
set(CPACK_GENERATOR ZIP)
else (APPLE)
set(CPACK_GENERATOR DEB)
endif (APPLE)
if (WITH_KDE OR APPLE OR WIN32)
set(CPACK_PACKAGE_NAME "kid3")
set(CPACK_DEBIAN_PACKAGE_SECTION "kde")
else (WITH_KDE OR APPLE OR WIN32)
set(CPACK_PACKAGE_NAME "kid3-qt")
set(CPACK_DEBIAN_PACKAGE_SECTION "sound")
endif (WITH_KDE OR APPLE OR WIN32)
set(CPACK_PACKAGE_VERSION_MAJOR 1)
set(CPACK_PACKAGE_VERSION_MINOR 6)
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_PACKAGE_CONTACT "ufleisch@users.sourceforge.net")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Audio tag editor")
set(CPACK_STRIP_FILES ON)
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://kid3.sourceforge.net/")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
include(CPack)
......@@ -36,3 +36,7 @@
/* Define if you have Phonon installed */
#cmakedefine HAVE_PHONON 1
#cmakedefine CFG_DATAROOTDIR "@CFG_DATAROOTDIR@"
#cmakedefine CFG_DOCDIR "@CFG_DOCDIR@"
#cmakedefine CFG_TRANSLATIONSDIR "@CFG_TRANSLATIONSDIR@"
if (NOT WITH_KDE)
# Create HTML handbook from DocBook file in language directory
macro (kid3_create_handbook _docbook)
get_filename_component(_input ${_docbook} ABSOLUTE)
get_filename_component(_lang ${CMAKE_CURRENT_SOURCE_DIR} NAME)
set(_output ${CMAKE_CURRENT_BINARY_DIR}/kid3_${_lang}.html)
set(_fixdocbook_pl ${CMAKE_CURRENT_SOURCE_DIR}/../fixdocbook.pl)
set(_fixhtml_pl ${CMAKE_CURRENT_SOURCE_DIR}/../fixhtml.pl)
set(_docbook_xsl ${DOCBOOK_XSL_DIR}/html/docbook.xsl)
if (WIN32)
# The expressions in pipes do not work for Windows,
# so temporary files are used.
set(_tmp_xml ${CMAKE_CURRENT_BINARY_DIR}/tmp.xml)
set(_tmp_html ${CMAKE_CURRENT_BINARY_DIR}/tmp.html)
add_custom_command(OUTPUT ${_tmp_xml}
COMMAND ${PERL_EXECUTABLE} ${_fixdocbook_pl} <${_input} >${_tmp_xml}
DEPENDS ${_input}
)
add_custom_command(OUTPUT ${_tmp_html}
COMMAND ${XSLTPROC} ${_docbook_xsl} ${_tmp_xml} >${_tmp_html}
DEPENDS ${_tmp_xml}
)
add_custom_command(OUTPUT ${_output}
COMMAND ${PERL_EXECUTABLE} -n ${_fixhtml_pl} <${_tmp_html} >${_output}
DEPENDS ${_tmp_html}
)
else (WIN32)
add_custom_command(OUTPUT ${_output}
COMMAND
${PERL_EXECUTABLE} ${_fixdocbook_pl} <${_input} |
${XSLTPROC} ${_docbook_xsl} - |
${PERL_EXECUTABLE} -n ${_fixhtml_pl} >${_output}
DEPENDS ${_input}
)
endif (WIN32)
add_custom_target("${_lang}-handbook" ALL DEPENDS ${_output})
install(FILES ${_output} DESTINATION ${WITH_DOCDIR})
endmacro (kid3_create_handbook)
endif (NOT WITH_KDE)
add_subdirectory(en)
add_subdirectory(de)
if (WITH_KDE)
kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/de SUBDIR kid3)
else (WITH_KDE)
kid3_create_handbook(index.docbook)
endif (WITH_KDE)
......@@ -37,7 +37,7 @@ isEmpty(CFG_DB2HTML) {
PERL = perl
}
contains(CFG_DB2HTML, jw) {
db2html.commands = $$PERL -n ../fixdocbook.pl <${QMAKE_FILE_NAME} >${QMAKE_FILE_BASE}.sgml; jw -f docbook -b html -u ${QMAKE_FILE_BASE}.sgml; $$PERL -n ../fixhtml.pl ${QMAKE_FILE_BASE}.html >${QMAKE_FILE_OUT}
db2html.commands = $$PERL -n $$PWD/fixdocbook.pl <${QMAKE_FILE_NAME} >${QMAKE_FILE_BASE}.sgml; jw -f docbook -b html -u ${QMAKE_FILE_BASE}.sgml; $$PERL -n $$PWD/fixhtml.pl ${QMAKE_FILE_BASE}.html >${QMAKE_FILE_OUT}
} else {
isEmpty(CFG_XSL_STYLESHEET) {
exists(/usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl) {
......@@ -47,11 +47,11 @@ contains(CFG_DB2HTML, jw) {
}
}
contains(CFG_DB2HTML, xsltproc) {
db2html.commands = $$PERL -n ../fixdocbook.pl <${QMAKE_FILE_NAME} | $$CFG_DB2HTML $$CFG_XSL_STYLESHEET - | $$PERL -n ../fixhtml.pl >${QMAKE_FILE_OUT}
db2html.commands = $$PERL -n $$PWD/fixdocbook.pl <${QMAKE_FILE_NAME} | $$CFG_DB2HTML $$CFG_XSL_STYLESHEET - | $$PERL -n $$PWD/fixhtml.pl >${QMAKE_FILE_OUT}
} else:contains(CFG_DB2HTML, xalan) {
db2html.commands = $$PERL -n ../fixdocbook.pl <${QMAKE_FILE_NAME} | $$CFG_DB2HTML -xsl $$CFG_XSL_STYLESHEET -out ${QMAKE_FILE_BASE}.html; $$PERL -n ../fixhtml.pl ${QMAKE_FILE_BASE}.html >${QMAKE_FILE_OUT}
db2html.commands = $$PERL -n $$PWD/fixdocbook.pl <${QMAKE_FILE_NAME} | $$CFG_DB2HTML -xsl $$CFG_XSL_STYLESHEET -out ${QMAKE_FILE_BASE}.html; $$PERL -n $$PWD/fixhtml.pl ${QMAKE_FILE_BASE}.html >${QMAKE_FILE_OUT}
} else {
db2html.commands = $$PERL -n ../fixdocbook.pl <${QMAKE_FILE_NAME} | $$CFG_DB2HTML $$CFG_XSL_STYLESHEET - | $$PERL -n ../fixhtml.pl >${QMAKE_FILE_OUT}
db2html.commands = $$PERL -n $$PWD/fixdocbook.pl <${QMAKE_FILE_NAME} | $$CFG_DB2HTML $$CFG_XSL_STYLESHEET - | $$PERL -n $$PWD/fixhtml.pl >${QMAKE_FILE_OUT}
}
}
......
if (WITH_KDE)
kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR kid3)
else (WITH_KDE)
kid3_create_handbook(index.docbook)
endif (WITH_KDE)
#!/usr/bin/perl -n
s/"-\/\/KDE\/\/DTD DocBook XML V4.2-Based Variant V1.1\/\/EN" "dtd\/kdex.dtd"/"-\/\/OASIS\/\/DTD DocBook XML V4.2\/\/EN" "http:\/\/www.oasis-open.org\/docbook\/xml\/4.2\/docbookx.dtd"/;
s/<!ENTITY % German "INCLUDE">/<!ENTITY language "de">/;
s/<!ENTITY % English "INCLUDE">/<!ENTITY language "en">/;
s/ufleisch@/ufleisch at /g;
s/&FDLNotice;/<para><ulink url="http:\/\/www.gnu.org\/licenses\/licenses.html#FDL">FDL<\/ulink><\/para>/g;
s/&underFDL;/<para><ulink url="http:\/\/www.gnu.org\/licenses\/licenses.html#FDL">FDL<\/ulink><\/para>/g;
s/&underGPL;/<para><ulink url="http:\/\/www.gnu.org\/licenses\/licenses.html#GPL">GPL<\/ulink><\/para>/g;
s/&documentation.index;//g;
print;
#!/usr/bin/perl -n
s/^><TITLE$/><meta http-equiv="content-type" content="text\/html; charset=UTF-8"\n><TITLE/ms;
s/<\/title/<\/title>\
<style type="text\/css">\
body { font-family: Arial, Helvetica, sans-serif; color: #000000; background: #ffffff; }\
h1, h2, h3, h4 { text-align: left; font-weight: bold; color: #f7800a; background: transparent; }\
a:link { color: #0057ae; }\
pre { display: block; color: #000000; background: #f9f9f9; border: #2f6fab dashed; border-width: 1px; overflow: auto; line-height: 1.1em; }\
dt { font-weight: bold; color: #0057ae; }\
p { text-align: justify; }\
li { text-align: left; }\
.guibutton, .guilabel, .guimenu, .guimenuitem { font-family: Arial, Helvetica, sans-serif; color: #000000; background: #dcdcdc; }\
.application { font-weight: bold; }\
.command { font-family: "Courier New", Courier, monospace; }\
.filename { font-style: italic; }\
<\/style/i;
print;
......@@ -10,145 +10,13 @@ use File::Basename;
use File::Spec;
use File::Copy;
my $topdir = File::Spec->rel2abs(dirname($0). "/..");
my $lupdate_cmd = "lupdate";
# Read all source files given in the parameter list and copy them to the
# current directory, replaceing i18n by tr and I18N_NOOP by QT_TRANSLATE_NOOP.
sub createTranslateSources(@)
{
my @sources = @_;
foreach my $file (@sources) {
open IF, $file or die "Could not open $file: $!\n";
my $outfn = basename($file);
open OF, ">$outfn" or die "Could not create $outfn: $!\n";
while (<IF>) {
s/i18n\(/tr(/g;
s/KCM_i18n1\(([^,]+), ([^)]+)\)/tr($1).arg($2)/g;
s/KCM_i18n2\(([^,]+), ([^,]+), ([^)]+)\)/tr($1).arg($2).arg($3)/g;
s/I18N_NOOP\(/QT_TRANSLATE_NOOP("\@default", /g;
print OF $_;
}
close OF;
close IF;
}
}
# Read all translations from a .po file, fill them into an associative
# array.
sub getPoTranslations($)
{
my $fn = shift;
my $msgid;
my $msgstr;
my $in_msgid = 0;
my $in_msgstr = 0;
my %trans;
open IF, $fn or die "Could not open $fn: $!\n";
while (<IF>) {
s/\r\n/\n/;
if (/^msgid "(.*)"$/) {
if ($msgid) {
$trans{$msgid} = $msgstr;
}
$msgid = $1;
$msgstr = "";
$in_msgid = 1;
$in_msgstr = 0;
}
if (/^msgstr "(.*)"$/) {
$msgstr = $1;
$in_msgid = 0;
$in_msgstr = 1;
}
if (/^"(.+)"$/) {
if ($in_msgid) {
$msgid .= $1;
} elsif ($in_msgstr) {
$msgstr .= $1;
}
}
}
close IF;
if ($msgid) {
$trans{$msgid} = $msgstr;
}
return %trans;
}
# Set the translations in a .ts file replacing & by &amp;, < by &lt; and > by &gt;.
sub setTsTranslations($$%)
{
my $infn = shift;
my $outfn = shift;
my %trans = @_;
my $source;
my $translation;
my $in_source = 0;
open IF, $infn or die "Could not open $infn: $!\n";
open OF, ">$outfn" or die "Could not create $outfn: $!\n";
while (<IF>) {
s/\r\n/\n/;
if (/<source>(.*)<\/source>/) {
$source = $1;
$in_source = 0;
} elsif (/<source>(.*)$/) {
$source = $1;
$in_source = 1;
} elsif ($in_source) {
if (/^(.*)<\/source>/) {
$source .= "\n$1";
$in_source = 0;
} else {
my $line = $_;
chomp $line;
$source .= "\n$line";
}
} elsif (/<translation/) {
$source =~ s/&amp;/&/g;
$source =~ s/&lt;/</g;
$source =~ s/&gt;/>/g;
$source =~ s/\n/\\n/g;
if (exists $trans{$source}) {
$translation = $trans{$source};
$translation =~ s/&/&amp;/g;
$translation =~ s/</&lt;/g;
$translation =~ s/>/&gt;/g;
$translation =~ s/\\"/&quot;/g;
$translation =~ s/\\n/\n/g;
s/ type="unfinished"//;
s/<\/translation>/$translation<\/translation>/;
} else {
print "Could not find translation for \"$source\"\n";
}
}
print OF $_;
}
close OF;
close IF;
my $topdir;
my $lupdate_cmd;
BEGIN {
$topdir = File::Spec->rel2abs(dirname($0). "/..");
$lupdate_cmd = "lupdate";
}
# Generate .ts files from .po files.
sub generateTs()
{
my @pofiles = glob "$topdir/po/*.po";
my @languages = map { /^.*\W(\w+)\.po$/ } @pofiles;
my $tmpdir = ".tsdir";
mkdir $tmpdir unless -d $tmpdir;
mkdir "po" unless -d "po";
chdir $tmpdir or die "Could not change to $tmpdir: $!\n";
my @sources = glob "$topdir/kid3/*.cpp";
createTranslateSources(@sources);
system "$lupdate_cmd " . join ' ', glob "*.cpp" . " -ts ". join ' ', map { "kid3_". $_ . ".ts" } @languages;
foreach my $lang (@languages) {
setTsTranslations("kid3_$lang.ts", "../po/kid3_$lang.ts",
getPoTranslations("$topdir/po/$lang.po"));
}
unlink <*>;
chdir "..";
rmdir $tmpdir;
}
require "$topdir/po/po2ts.pl";
my $have_vorbis = 1;
my $have_flac = 1;
......@@ -598,51 +466,12 @@ copy("$topdir/kid3/hi32-app-kid3.png", "kid3/hi32-app-kid3-qt.png");
copy("$topdir/kid3/hi48-app-kid3.png", "kid3/hi48-app-kid3-qt.png");
copy("$topdir/kid3/hisc-app-kid3.svgz", "kid3/hisc-app-kid3-qt.svgz");
mkdir "doc" unless -d "doc";
$fn = "doc/fixdocbook.pl";
open OF, ">$fn" or die "Cannot open $fn: $!\n";
print OF <<"EOF";
#!/usr/bin/perl -n
s/"-\\/\\/KDE\\/\\/DTD DocBook XML V4.2-Based Variant V1.1\\/\\/EN" "dtd\\/kdex.dtd"/"-\\/\\/OASIS\\/\\/DTD DocBook XML V4.2\\/\\/EN" "http:\\/\\/www.oasis-open.org\\/docbook\\/xml\\/4.2\\/docbookx.dtd"/;
s/<!ENTITY % German "INCLUDE">/<!ENTITY language "de">/;
s/<!ENTITY % English "INCLUDE">/<!ENTITY language "en">/;
s/ufleisch@/ufleisch at /g;
s/&FDLNotice;/<para><ulink url="http:\\/\\/www.gnu.org\\/licenses\\/licenses.html#FDL">FDL<\\/ulink><\\/para>/g;
s/&underFDL;/<para><ulink url="http:\\/\\/www.gnu.org\\/licenses\\/licenses.html#FDL">FDL<\\/ulink><\\/para>/g;
s/&underGPL;/<para><ulink url="http:\\/\\/www.gnu.org\\/licenses\\/licenses.html#GPL">GPL<\\/ulink><\\/para>/g;
s/&documentation.index;//g;
print;
EOF
print "creating $fn\n";
close OF;
$fn = "doc/fixhtml.pl";
open OF, ">$fn" or die "Cannot open $fn: $!\n";
print OF <<"EOF";
#!/usr/bin/perl -n
s/^><TITLE\$/><meta http-equiv="content-type" content="text\\/html; charset=UTF-8"\\n><TITLE/ms;
s/<\\/title/<\\/title>\\
<style type="text\\/css">\\
body { font-family: Arial, Helvetica, sans-serif; color: #000000; background: #ffffff; }\\
h1, h2, h3, h4 { text-align: left; font-weight: bold; color: #f7800a; background: transparent; }\\
a:link { color: #0057ae; }\\
pre { display: block; color: #000000; background: #f9f9f9; border: #2f6fab dashed; border-width: 1px; overflow: auto; line-height: 1.1em; }\\