From f3de2dbaf657f9040a4da448c57267de0fef7d33 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 6 Aug 2016 21:03:43 +0200 Subject: CMake: Add basic CMake build system Introduce an initial CMake buildsystem. This build system can build a fully working apt system without translation or documentation. The FindBerkelyDB module is from kdelibs, with some small adjustements to also look in db5 directories. Initial work on this CMake build system started in 2009, and was resumed in August 2016. --- CMake/FindBerkeleyDB.cmake | 48 ++++++++++++++++++++++++++++++++++ CMake/Misc.cmake | 65 ++++++++++++++++++++++++++++++++++++++++++++++ CMake/apti18n.h.in | 30 +++++++++++++++++++++ CMake/config.h.in | 54 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 197 insertions(+) create mode 100644 CMake/FindBerkeleyDB.cmake create mode 100644 CMake/Misc.cmake create mode 100644 CMake/apti18n.h.in create mode 100644 CMake/config.h.in (limited to 'CMake') diff --git a/CMake/FindBerkeleyDB.cmake b/CMake/FindBerkeleyDB.cmake new file mode 100644 index 000000000..44cfd3ddb --- /dev/null +++ b/CMake/FindBerkeleyDB.cmake @@ -0,0 +1,48 @@ +# - Try to find Berkeley DB +# Once done this will define +# +# BERKELEY_DB_FOUND - system has Berkeley DB +# BERKELEY_DB_INCLUDE_DIRS - the Berkeley DB include directory +# BERKELEY_DB_LIBRARIES - Link these to use Berkeley DB +# BERKELEY_DB_DEFINITIONS - Compiler switches required for using Berkeley DB + +# Copyright (c) 2006, Alexander Dymo, +# Copyright (c) 2016, Julian Andres Klode +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +find_path(BERKELEY_DB_INCLUDE_DIRS db.h + /usr/include/db5 + /usr/local/include/db5 + /usr/include/db4 + /usr/local/include/db4 +) + +find_library(BERKELEY_DB_LIBRARIES NAMES db ) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Berkeley "Could not find Berkeley DB >= 4.1" BERKELEY_DB_INCLUDE_DIRS BERKELEY_DB_LIBRARIES) +# show the BERKELEY_DB_INCLUDE_DIRS and BERKELEY_DB_LIBRARIES variables only in the advanced view +mark_as_advanced(BERKELEY_DB_INCLUDE_DIRS BERKELEY_DB_LIBRARIES) diff --git a/CMake/Misc.cmake b/CMake/Misc.cmake new file mode 100644 index 000000000..584a4da2a --- /dev/null +++ b/CMake/Misc.cmake @@ -0,0 +1,65 @@ +include(CheckCXXCompilerFlag) + +# Flatten our header structure +function(flatify target headers) + foreach(header ${headers}) + get_filename_component(tgt ${header} NAME) + configure_file(${header} ${target}/${tgt} @ONLY) + endforeach(header ${headers}) +endfunction() + + +function(add_optional_compile_options flags) + foreach(flag ${flags}) + check_cxx_compiler_flag(-${flag} have-compiler-flag:-${flag}) + if (have-compiler-flag:-${flag}) + add_compile_options("-${flag}") + endif() + endforeach() +endfunction() + +# Substitute vendor references in a file +function(add_vendor_file) + set(options) + set(oneValueArgs OUTPUT INPUT MODE) + set(multiValueArgs VARIABLES) + cmake_parse_arguments(AVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + message(STATUS "Configuring vendor file ${AVF_OUTPUT}") + + FILE(READ ${CMAKE_CURRENT_SOURCE_DIR}/${AVF_INPUT} input) + foreach(variable ${AVF_VARIABLES}) + execute_process(COMMAND ../vendor/getinfo ${variable} OUTPUT_VARIABLE value OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REPLACE "&${variable};" "${value}" input "${input}") + endforeach() + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${AVF_OUTPUT} "${input}") + + execute_process(COMMAND chmod ${AVF_MODE} ${CMAKE_CURRENT_BINARY_DIR}/${AVF_OUTPUT}) +endfunction() + +# Add symbolic links to a file +function(add_slaves destination master) + set(slaves "") + foreach(slave ${ARGN}) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${slave} + COMMAND ${CMAKE_COMMAND} -E create_symlink ${master} ${CMAKE_CURRENT_BINARY_DIR}/${slave}) + list(APPEND slaves ${CMAKE_CURRENT_BINARY_DIR}/${slave}) + endforeach() + + STRING(REPLACE "/" "-" master "${master}") + add_custom_target(${master}-slaves ALL DEPENDS ${slaves}) + install(FILES ${slaves} DESTINATION ${destination}) +endfunction() + +# Generates a simple version script versioning everything with current SOVERSION +function(add_version_script target) + get_target_property(soversion ${target} SOVERSION) + set(script "${CMAKE_CURRENT_BINARY_DIR}/${target}.versionscript") + string(REPLACE "-" "" name "${target}_${soversion}") + string(TOUPPER "${name}" name) + add_custom_command(OUTPUT "${script}" + COMMAND echo "${name} {global: *; };" > "${script}" + VERBATIM ) + add_custom_target(${target}-versionscript DEPENDS "${script}") + target_link_libraries(${target} PRIVATE -Wl,-version-script="${script}") + add_dependencies(${target} ${target}-versionscript) +endfunction() diff --git a/CMake/apti18n.h.in b/CMake/apti18n.h.in new file mode 100644 index 000000000..9c843b037 --- /dev/null +++ b/CMake/apti18n.h.in @@ -0,0 +1,30 @@ +// -*- mode: cpp; mode: fold -*- +// $Id: apti18n.h.in,v 1.6 2003/01/11 07:18:18 jgg Exp $ +/* Internationalization macros for apt. This header should be included last + in each C file. */ + +// Set by autoconf +#cmakedefine USE_NLS + +#ifdef USE_NLS +// apt will use the gettext implementation of the C library +#include +#include +# ifdef APT_DOMAIN +# define _(x) dgettext(APT_DOMAIN,x) +# define P_(msg,plural,n) dngettext(APT_DOMAIN,msg,plural,n) +# else +# define _(x) gettext(x) +# define P_(msg,plural,n) ngettext(msg,plural,n) +# endif +# define N_(x) x +#else +// apt will not use any gettext +# define setlocale(a, b) +# define textdomain(a) +# define bindtextdomain(a, b) +# define _(x) x +# define P_(msg,plural,n) (n == 1 ? msg : plural) +# define N_(x) x +# define dgettext(d, m) m +#endif diff --git a/CMake/config.h.in b/CMake/config.h.in new file mode 100644 index 000000000..7515fc9a6 --- /dev/null +++ b/CMake/config.h.in @@ -0,0 +1,54 @@ +/* Define if your processor stores words with the most significant + byte first (like Motorola and SPARC, unlike Intel and VAX). */ +#cmakedefine WORDS_BIGENDIAN + +/* Define if we have the timegm() function */ +#cmakedefine HAVE_TIMEGM + +/* Define if we have the zlib library for gzip */ +#cmakedefine HAVE_ZLIB + +/* Define if we have the bz2 library for bzip2 */ +#cmakedefine HAVE_BZ2 + +/* Define if we have the lzma library for lzma/xz */ +#cmakedefine HAVE_LZMA + +/* Define if we have the lz4 library for lz4 */ +#cmakedefine HAVE_LZ4 + +/* These two are used by the statvfs shim for glibc2.0 and bsd */ +/* Define if we have sys/vfs.h */ +#cmakedefine HAVE_VFS_H +#cmakedefine HAVE_STRUCT_STATFS_F_TYPE + +/* Define if we have sys/mount.h */ +#cmakedefine HAVE_MOUNT_H + +/* Define if we have enabled pthread support */ +#cmakedefine HAVE_PTHREAD + +/* Check for getresuid() function and similar ones */ +#cmakedefine HAVE_GETRESUID +#cmakedefine HAVE_GETRESGID +#cmakedefine HAVE_SETRESUID +#cmakedefine HAVE_SETRESGID + +/* Define the arch name string */ +#define COMMON_ARCH "${COMMON_ARCH}" + +/* The package name string */ +#define PACKAGE "${PACKAGE}" + +/* The version number string */ +#define PACKAGE_VERSION "${PACKAGE_VERSION}" + +/* The mail address to reach upstream */ +#define PACKAGE_MAIL "deity@lists.debian.org" + +#define APT_8_CLEANER_HEADERS +#define APT_9_CLEANER_HEADERS +#define APT_10_CLEANER_HEADERS + +/* unrolling is faster combined with an optimizing compiler */ +#define SHA2_UNROLL_TRANSFORM -- cgit v1.2.3-70-g09d2 From 7def24826c298df77e34fd17bb72c570a22b04bd Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 6 Aug 2016 21:11:06 +0200 Subject: CMake: Add support for building and installing .mo files Introduce support for building translation domain-specific templates, merging them with the translations, and building a language-specific .mo file. The invocation of xgettext is done in the project source directory, not in the current source directory, and all paths are made relative to the project root, in order to have clean templates. This only supports the C++ source code for now, it unfortunately does not handle the shell scripts of deselect yet. --- CMake/Translations.cmake | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 2 ++ README.cmake | 4 +++- po/CMakeLists.txt | 20 ++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 CMake/Translations.cmake create mode 100644 po/CMakeLists.txt (limited to 'CMake') diff --git a/CMake/Translations.cmake b/CMake/Translations.cmake new file mode 100644 index 000000000..2a1e03d4c --- /dev/null +++ b/CMake/Translations.cmake @@ -0,0 +1,53 @@ +# translations.cmake - Translations using APT's translation system. +# Copyright (C) 2009, 2016 Julian Andres Klode + +function(apt_add_translation_domain domain) + set(targets ${ARGN}) + # Build the list of source files of the target + set(files "") + foreach(target ${targets}) + get_target_property(source_dir ${target} SOURCE_DIR) + get_target_property(sources ${target} SOURCES) + foreach(source ${sources}) + string(SUBSTRING ${source} 0 1 init_char) + string(COMPARE EQUAL ${init_char} "/" is_absolute) + if (${is_absolute}) + set(file "${source}") + else() + set(file "${source_dir}/${source}") + endif() + file(RELATIVE_PATH relfile ${PROJECT_SOURCE_DIR} ${file}) + set(files ${files} ${relfile}) + endforeach() + + target_compile_definitions(${target} PRIVATE -DAPT_DOMAIN="${domain}") + endforeach() + + # Create the template for this specific sub-domain + add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/${domain}.pot + COMMAND xgettext --add-comments --foreign -k_ -kN_ + -o ${PROJECT_BINARY_DIR}/${domain}.pot ${files} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + + # Build .mo files + file(GLOB translations "${PROJECT_SOURCE_DIR}/po/*.po") + list(SORT translations) + foreach(file ${translations}) + get_filename_component(langcode ${file} NAME_WE) + set(outdir ${PROJECT_BINARY_DIR}/locale/${langcode}/LC_MESSAGES) + file(MAKE_DIRECTORY ${outdir}) + # Command to merge and compile the messages + add_custom_command(OUTPUT ${outdir}/${domain}.mo + COMMAND msgmerge -qo - ${file} ${PROJECT_BINARY_DIR}/${domain}.pot | + msgfmt -o ${outdir}/${domain}.mo - + DEPENDS ${file} ${PROJECT_BINARY_DIR}/${domain}.pot + ) + + set(mofiles ${mofiles} ${outdir}/${domain}.mo) + install(FILES ${outdir}/${domain}.mo + DESTINATION "${CMAKE_INSTALL_LOCALEDIR}/${langcode}/LC_MESSAGES") + endforeach(file ${translations}) + + add_custom_target(nls-${domain} ALL DEPENDS ${mofiles}) +endfunction() diff --git a/CMakeLists.txt b/CMakeLists.txt index 90e5272c9..cba893227 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ endif() # Include stuff include(Misc) +include(Translations) include(CheckIncludeFiles) include(CheckFunctionExists) include(CheckStructHasMember) @@ -130,3 +131,4 @@ add_subdirectory(cmdline) add_subdirectory(dselect) add_subdirectory(ftparchive) add_subdirectory(methods) +add_subdirectory(po) diff --git a/README.cmake b/README.cmake index c9347a057..d94a46f12 100644 --- a/README.cmake +++ b/README.cmake @@ -32,5 +32,7 @@ TODO The following features have not been implemented yet: - documentation - - translation + - Translated docbook guides + - dselect translations - unit tests + - update-po diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt new file mode 100644 index 000000000..0dd14839c --- /dev/null +++ b/po/CMakeLists.txt @@ -0,0 +1,20 @@ +apt_add_translation_domain(libapt-pkg${APT_PKG_MAJOR} apt-pkg) + +apt_add_translation_domain(apt # Domain + apt apt-cache apt-get apt-config apt-cdrom + apt-helper apt-mark + apt-private + # Methods + file copy store gpgv cdrom http https ftp rred rsh) + + +apt_add_translation_domain(apt-utils # Domain + apt-sortpkgs + apt-extracttemplates + apt-internal-solver + apt-dump-solver + apt-internal-planner + apt-ftparchive) + +# Add the translations for libapt-inst, and set the translation domain. +apt_add_translation_domain(libapt-inst${APT_INST_MAJOR} apt-inst) -- cgit v1.2.3-70-g09d2 From 9a2aa0e7f21ef33345f6093ca17fab97a678d543 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 6 Aug 2016 21:18:39 +0200 Subject: CMake: Add initial support for documentation building Build HTML docbook guides (untranslated) and manual pages (including translations). Also install the examples in the example subdirectory. Translation of docbook guides has not been implemented yet, but should be easy to do. The code also needs some cleanup to automatically detect the available translations. --- CMake/Documentation.cmake | 134 ++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 1 + README.cmake | 1 - doc/CMakeLists.txt | 21 +++++++ doc/examples/CMakeLists.txt | 4 ++ 5 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 CMake/Documentation.cmake create mode 100644 doc/CMakeLists.txt create mode 100644 doc/examples/CMakeLists.txt (limited to 'CMake') diff --git a/CMake/Documentation.cmake b/CMake/Documentation.cmake new file mode 100644 index 000000000..98e07176b --- /dev/null +++ b/CMake/Documentation.cmake @@ -0,0 +1,134 @@ +# Copyright (C) 2009, 2016 Julian Andres Klode . +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +function(add_docbook target sourcefiles installdest) + foreach(file ${sourcefiles}) + get_filename_component(relfile ${file} NAME) + string(REPLACE ".dbk" "" manual ${relfile}) + get_filename_component(absolute ${file} ABSOLUTE) + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html/ + COMMAND xsltproc --nonet --novalid --xinclude + --stringparam base.dir ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html/ + --path ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/${CURRENT_VENDOR}/ + --path ${CMAKE_CURRENT_SOURCE_DIR}/ + ${CMAKE_CURRENT_SOURCE_DIR}/docbook-html-style.xsl + ${absolute} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${file} + ) + set(commands ${commands} ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html) + if (NOT ${installdest} EQUAL "" ) + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html + DESTINATION ${installdest}) + endif() + endforeach(file ${sourcefiles}) + + add_custom_target(${target} ALL DEPENDS ${commands}) +endfunction() + + +function(add_po4a type master po target deps) + add_custom_command(OUTPUT ${target} + COMMAND po4a-translate --keep 0 -f ${type} -m ${master} + -p ${po} -l ${target} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${deps} ${master} ${po}) +endfunction() + + +# Macro for XML man pages. +function(add_xml_manpages target manpages translations entities) + foreach(manpage ${manpages}) + string(LENGTH ${manpage} manpage_length) + math(EXPR manpage_length ${manpage_length}-1) + string(SUBSTRING ${manpage} ${manpage_length} 1 section) + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${manpage} + COMMAND xsltproc --path ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/${CURRENT_VENDOR}/ + --path ${CMAKE_CURRENT_SOURCE_DIR}/ + ${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl + ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.xml + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.xml + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl + ) + + + set(commands ${commands} ${CMAKE_CURRENT_BINARY_DIR}/${manpage}) + + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${manpage} + DESTINATION ${CMAKE_INSTALL_MANDIR}/man${section}) + + # Add the translations for the manpage. + foreach(translation ${translations}) + set(entities) + # transdir = shortcut to the output directory for translations. + set(transdir ${CMAKE_CURRENT_BINARY_DIR}/${translation}) + + add_po4a(docbook ${manpage}.xml po/${translation}.po + ${transdir}/${manpage}.xml "${ent_cmds}") + + + add_custom_command(OUTPUT ${transdir}/${manpage} + COMMAND xsltproc --path ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/${CURRENT_VENDOR}/ + --path ${CMAKE_CURRENT_SOURCE_DIR}/ + --stringparam l10n.gentext.default.language ${translation} + ${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl + ${transdir}/${manpage}.xml + WORKING_DIRECTORY ${transdir} + DEPENDS ${transdir}/${manpage}.xml + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl) + + set(nls-cmd ${nls-cmd} ${transdir}/${manpage}) + install(FILES ${transdir}/${manpage} + DESTINATION ${CMAKE_INSTALL_MANDIR}/${translation}/man${section}) + + endforeach(translation ${translations}) + endforeach(manpage ${manpages}) + + add_custom_target(${target} ALL DEPENDS ${commands}) + # Sort the list of the translations. + list(SORT nls-cmd) + add_custom_target(nls-${target} ALL DEPENDS ${nls-cmd}) +endfunction() + + +function(add_manpages target manpages translations) + foreach(man ${manpages}) + string(LENGTH ${man} manpage_length) + math(EXPR manpage_length ${manpage_length}-1) + string(SUBSTRING ${man} ${manpage_length} 1 section) + install(FILES ${man} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${section}) + + if (USE_NLS) + foreach(translation ${translations}) + set(transdir ${CMAKE_CURRENT_BINARY_DIR}/${translation}) + add_po4a(man ${man} po/${translation}.po ${transdir}/${man} "") + install(FILES ${transdir}/${man} + DESTINATION ${CMAKE_INSTALL_MANDIR}/${translation}/man${section}) + set(files ${files} ${transdir}/${man}) + endforeach(translation ${translations}) + endif() + endforeach(man ${manpages}) + add_custom_target(${target} ALL DEPENDS ${files}) +endfunction() diff --git a/CMakeLists.txt b/CMakeLists.txt index cba893227..defb4f111 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,6 +128,7 @@ add_subdirectory(apt-pkg) add_subdirectory(apt-private) add_subdirectory(apt-inst) add_subdirectory(cmdline) +add_subdirectory(doc) add_subdirectory(dselect) add_subdirectory(ftparchive) add_subdirectory(methods) diff --git a/README.cmake b/README.cmake index d94a46f12..a993b2589 100644 --- a/README.cmake +++ b/README.cmake @@ -31,7 +31,6 @@ TODO The following features have not been implemented yet: - - documentation - Translated docbook guides - dselect translations - unit tests diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 000000000..bbf5fb046 --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,21 @@ +include(Documentation) + +file(GLOB_RECURSE debiandoc-apt guide*.dbk offline*.dbk) +file(GLOB_RECURSE debiandoc-libapt cache*.dbk design*.dbk dpkg-tech*.dbk + files*.dbk method*.dbk) + + +set(manpages apt.8 apt-cache.8 apt-get.8 apt-cdrom.8 apt.conf.5 sources.list.5 + apt-config.8 apt_preferences.5 apt-sortpkgs.1 apt-ftparchive.1 + apt-extracttemplates.1 apt-key.8 apt-secure.8 apt-mark.8) + +if (WITH_DOC) +add_docbook(debiandoc-apt "${debiandoc-apt}" share/doc/apt-doc) +add_docbook(debiandoc-libapt "${debiandoc-libapt}" share/doc/libapt-pkg-doc) +endif() + +# Build the manpages, and add translations (ja only for now, others broken) +add_xml_manpages(doc-man "${manpages}" "de;es;fr;it;ja;nl;pl;pt_BR;pt" "apt.ent;apt-verbatim.ent") + + +add_subdirectory(examples) diff --git a/doc/examples/CMakeLists.txt b/doc/examples/CMakeLists.txt new file mode 100644 index 000000000..1998867db --- /dev/null +++ b/doc/examples/CMakeLists.txt @@ -0,0 +1,4 @@ +install(FILES apt.conf apt-https-method-example.conf configure-index preferences + DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples) +install(FILES apt-ftparchive.conf ftp-archive.conf + DESTINATION ${CMAKE_INSTALL_DOCDIR}/../apt-utils/examples) -- cgit v1.2.3-70-g09d2 From 7d33e7c79cd6c3f0f053d13532ca73ce3bf7c5ce Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 7 Aug 2016 03:34:18 +0200 Subject: CMake: Improve handling of vendor files First of all, instead of creating the files at configure time, generate the files using normal target. This has the huge advantage that they are rebuilt if their input changes. While we are at it, also add dependencies on the vendor entity files. This also fixes the path to the vendor script, which was given relatively before, which obviously won't work when running from inside a deeper subdirectory. To speed things up, pass the --vendor option to getinfo, so we do not have to find out the current vendor in getinfo all over again. Gbp-Dch: ignore --- CMake/Misc.cmake | 30 ++++++++++++++++++++++-------- CMake/vendor_substitute.cmake | 8 ++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 CMake/vendor_substitute.cmake (limited to 'CMake') diff --git a/CMake/Misc.cmake b/CMake/Misc.cmake index 584a4da2a..3329fc20f 100644 --- a/CMake/Misc.cmake +++ b/CMake/Misc.cmake @@ -24,16 +24,30 @@ function(add_vendor_file) set(oneValueArgs OUTPUT INPUT MODE) set(multiValueArgs VARIABLES) cmake_parse_arguments(AVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - message(STATUS "Configuring vendor file ${AVF_OUTPUT}") - FILE(READ ${CMAKE_CURRENT_SOURCE_DIR}/${AVF_INPUT} input) - foreach(variable ${AVF_VARIABLES}) - execute_process(COMMAND ../vendor/getinfo ${variable} OUTPUT_VARIABLE value OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REPLACE "&${variable};" "${value}" input "${input}") - endforeach() - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${AVF_OUTPUT} "${input}") + set(in ${CMAKE_CURRENT_SOURCE_DIR}/${AVF_INPUT}) + set(out ${CMAKE_CURRENT_BINARY_DIR}/${AVF_OUTPUT}) + + add_custom_command( + OUTPUT ${out} + COMMAND ${CMAKE_COMMAND} -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} + "-DVARS=${AVF_VARIABLES}" + -DCURRENT_VENDOR=${CURRENT_VENDOR} + -DIN=${in} + -DOUT=${out} + -P ${PROJECT_SOURCE_DIR}/CMake/vendor_substitute.cmake + COMMAND chmod ${AVF_MODE} ${out} + DEPENDS ${in} + ${PROJECT_SOURCE_DIR}/doc/apt-verbatim.ent + ${PROJECT_SOURCE_DIR}/vendor/${CURRENT_VENDOR}/apt-vendor.ent + ${PROJECT_SOURCE_DIR}/vendor/getinfo + ${PROJECT_SOURCE_DIR}/CMake/vendor_substitute.cmake + VERBATIM + ) - execute_process(COMMAND chmod ${AVF_MODE} ${CMAKE_CURRENT_BINARY_DIR}/${AVF_OUTPUT}) + # Woud like to use ${AVF_OUTPUT} as target name, but then ninja gets + # cycles. + add_custom_target(vendor-${AVF_OUTPUT} ALL DEPENDS ${out}) endfunction() # Add symbolic links to a file diff --git a/CMake/vendor_substitute.cmake b/CMake/vendor_substitute.cmake new file mode 100644 index 000000000..71449c9e8 --- /dev/null +++ b/CMake/vendor_substitute.cmake @@ -0,0 +1,8 @@ +file(READ ${IN} input) +foreach(variable ${VARS}) + execute_process(COMMAND ${PROJECT_SOURCE_DIR}/vendor/getinfo + --vendor ${CURRENT_VENDOR} ${variable} + OUTPUT_VARIABLE value OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REPLACE "&${variable};" "${value}" input "${input}") +endforeach() +file(WRITE ${OUT} "${input}") -- cgit v1.2.3-70-g09d2 From 33ee08e4dae7851bc3bcbb932a0563c38c933ead Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 7 Aug 2016 15:45:36 +0200 Subject: CMake: Set PACKAGE_MAIL variable This is needed in a lot of places. Also adjust config.h.in to use it instead of the bare email address. Gbp-Dch: ignore --- CMake/config.h.in | 2 +- CMakeLists.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'CMake') diff --git a/CMake/config.h.in b/CMake/config.h.in index 7515fc9a6..3afd9123c 100644 --- a/CMake/config.h.in +++ b/CMake/config.h.in @@ -44,7 +44,7 @@ #define PACKAGE_VERSION "${PACKAGE_VERSION}" /* The mail address to reach upstream */ -#define PACKAGE_MAIL "deity@lists.debian.org" +#define PACKAGE_MAIL "${PACKAGE_MAIL}" #define APT_8_CLEANER_HEADERS #define APT_9_CLEANER_HEADERS diff --git a/CMakeLists.txt b/CMakeLists.txt index 44b301cc2..6baa8f14f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,7 +108,8 @@ if (CMAKE_USE_PTHREADS_INIT) endif() # Configure some variables like package, version and architecture. -set(PACKAGE "apt") +set(PACKAGE ${PROJECT_NAME}) +set(PACKAGE_MAIL "APT Development Team ") execute_process(COMMAND dpkg-parsechangelog -SVersion -l${PROJECT_SOURCE_DIR}/debian/changelog OUTPUT_VARIABLE PACKAGE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) -- cgit v1.2.3-70-g09d2 From ba69ce6d3473debec4b95e02f12670f345c86673 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 7 Aug 2016 13:36:11 +0200 Subject: CMake: Translations: Make po templates depend on input files I wondered why the template was not rebuilt after I changed a file, now I have the answer. Gbp-Dch: ignore --- CMake/Translations.cmake | 3 +++ 1 file changed, 3 insertions(+) (limited to 'CMake') diff --git a/CMake/Translations.cmake b/CMake/Translations.cmake index 2a1e03d4c..3a05d80b0 100644 --- a/CMake/Translations.cmake +++ b/CMake/Translations.cmake @@ -5,6 +5,7 @@ function(apt_add_translation_domain domain) set(targets ${ARGN}) # Build the list of source files of the target set(files "") + set(abs_files "") foreach(target ${targets}) get_target_property(source_dir ${target} SOURCE_DIR) get_target_property(sources ${target} SOURCES) @@ -18,6 +19,7 @@ function(apt_add_translation_domain domain) endif() file(RELATIVE_PATH relfile ${PROJECT_SOURCE_DIR} ${file}) set(files ${files} ${relfile}) + set(abs_files ${abs_files} ${file}) endforeach() target_compile_definitions(${target} PRIVATE -DAPT_DOMAIN="${domain}") @@ -27,6 +29,7 @@ function(apt_add_translation_domain domain) add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/${domain}.pot COMMAND xgettext --add-comments --foreign -k_ -kN_ -o ${PROJECT_BINARY_DIR}/${domain}.pot ${files} + DEPENDS ${abs_files} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) -- cgit v1.2.3-70-g09d2 From 672aa8d90ee1797d74aa3f8fcedc840f578f1d1b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 7 Aug 2016 13:37:15 +0200 Subject: CMake: Translations: Pass some additional arguments to commands This gets rid of the line numbers, adds the plural keyword, and makes msgfmt print statistics, so we know how well translated we are. Gbp-Dch: ignore --- CMake/Translations.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'CMake') diff --git a/CMake/Translations.cmake b/CMake/Translations.cmake index 3a05d80b0..64f5886fb 100644 --- a/CMake/Translations.cmake +++ b/CMake/Translations.cmake @@ -28,6 +28,7 @@ function(apt_add_translation_domain domain) # Create the template for this specific sub-domain add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/${domain}.pot COMMAND xgettext --add-comments --foreign -k_ -kN_ + --add-location=file --keyword=P_:1,2 -o ${PROJECT_BINARY_DIR}/${domain}.pot ${files} DEPENDS ${abs_files} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} @@ -43,7 +44,7 @@ function(apt_add_translation_domain domain) # Command to merge and compile the messages add_custom_command(OUTPUT ${outdir}/${domain}.mo COMMAND msgmerge -qo - ${file} ${PROJECT_BINARY_DIR}/${domain}.pot | - msgfmt -o ${outdir}/${domain}.mo - + msgfmt --statistics -o ${outdir}/${domain}.mo - DEPENDS ${file} ${PROJECT_BINARY_DIR}/${domain}.pot ) -- cgit v1.2.3-70-g09d2 From a331fb701683779d4113c39243f39ffad28cb912 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 7 Aug 2016 15:50:04 +0200 Subject: CMake: Translations: Write a .po file before writing a .mo file This makes debugging things easier. Gbp-Dch: ignore --- CMake/Translations.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'CMake') diff --git a/CMake/Translations.cmake b/CMake/Translations.cmake index 64f5886fb..a26bf1c17 100644 --- a/CMake/Translations.cmake +++ b/CMake/Translations.cmake @@ -42,11 +42,14 @@ function(apt_add_translation_domain domain) set(outdir ${PROJECT_BINARY_DIR}/locale/${langcode}/LC_MESSAGES) file(MAKE_DIRECTORY ${outdir}) # Command to merge and compile the messages - add_custom_command(OUTPUT ${outdir}/${domain}.mo - COMMAND msgmerge -qo - ${file} ${PROJECT_BINARY_DIR}/${domain}.pot | - msgfmt --statistics -o ${outdir}/${domain}.mo - + add_custom_command(OUTPUT ${outdir}/${domain}.po + COMMAND msgmerge -qo ${outdir}/${domain}.po ${file} ${PROJECT_BINARY_DIR}/${domain}.pot DEPENDS ${file} ${PROJECT_BINARY_DIR}/${domain}.pot ) + add_custom_command(OUTPUT ${outdir}/${domain}.mo + COMMAND msgfmt --statistics -o ${outdir}/${domain}.mo ${outdir}/${domain}.po + DEPENDS ${outdir}/${domain}.po + ) set(mofiles ${mofiles} ${outdir}/${domain}.mo) install(FILES ${outdir}/${domain}.mo -- cgit v1.2.3-70-g09d2 From 6ff8727a0641b299ac32bc897d3ac1246b02061e Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 7 Aug 2016 15:52:59 +0200 Subject: CMake: Translations: Add support for shell scripts Rework the arguments to apt_add_translation_domain so a user can specify TARGETS and SCRIPTS, the latter being Shell scripts. For each language (TARGETS being C++, SCRIPTS being Shell), a separate template is generated via xgettext. Those templates are then merged together by using msgcomm. In case there are no Shell scripts in the translation domain, msgcomm will receive /dev/null instead of a shell translation template. This also reintroduces line numbers, as msgcomm would otherwise re-order the merged files not only by filename, but also by message string. It's unclear why it does that, it could just leave strings within a file alone. In contrast to the old build system, we use xgettext for shell scripts instead of bash --dump-strings, as it's just easier to use the same tool for everything. We also create valid headers. --- CMake/Translations.cmake | 54 ++++++++++++++++++++++++++++++++++++++++++------ README.cmake | 1 - po/CMakeLists.txt | 42 +++++++++++++++++++++---------------- 3 files changed, 72 insertions(+), 25 deletions(-) (limited to 'CMake') diff --git a/CMake/Translations.cmake b/CMake/Translations.cmake index a26bf1c17..1b9781d69 100644 --- a/CMake/Translations.cmake +++ b/CMake/Translations.cmake @@ -1,11 +1,30 @@ # translations.cmake - Translations using APT's translation system. # Copyright (C) 2009, 2016 Julian Andres Klode -function(apt_add_translation_domain domain) - set(targets ${ARGN}) +function(apt_add_translation_domain) + set(options) + set(oneValueArgs DOMAIN) + set(multiValueArgs TARGETS SCRIPTS) + cmake_parse_arguments(NLS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) # Build the list of source files of the target set(files "") set(abs_files "") + set(scripts "") + set(abs_scripts "") + set(targets ${NLS_TARGETS}) + set(domain ${NLS_DOMAIN}) + foreach(source ${NLS_SCRIPTS}) + string(SUBSTRING ${source} 0 1 init_char) + string(COMPARE EQUAL ${init_char} "/" is_absolute) + if (${is_absolute}) + set(file "${source}") + else() + set(file "${CMAKE_CURRENT_SOURCE_DIR}/${source}") + endif() + file(RELATIVE_PATH relfile ${PROJECT_SOURCE_DIR} ${file}) + list(APPEND scripts ${relfile}) + list(APPEND abs_scripts ${file}) + endforeach() foreach(target ${targets}) get_target_property(source_dir ${target} SOURCE_DIR) get_target_property(sources ${target} SOURCES) @@ -25,15 +44,38 @@ function(apt_add_translation_domain domain) target_compile_definitions(${target} PRIVATE -DAPT_DOMAIN="${domain}") endforeach() - # Create the template for this specific sub-domain - add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/${domain}.pot + if("${scripts}" STREQUAL "") + set(sh_pot "/dev/null") + else() + set(sh_pot ${PROJECT_BINARY_DIR}/${domain}.sh.pot) + # Create the template for this specific sub-domain + add_custom_command (OUTPUT ${sh_pot} + COMMAND xgettext --add-comments --foreign -L Shell + -o ${sh_pot} ${scripts} + DEPENDS ${abs_scripts} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + endif() + + + add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/${domain}.c.pot COMMAND xgettext --add-comments --foreign -k_ -kN_ - --add-location=file --keyword=P_:1,2 - -o ${PROJECT_BINARY_DIR}/${domain}.pot ${files} + --keyword=P_:1,2 + -o ${PROJECT_BINARY_DIR}/${domain}.c.pot ${files} DEPENDS ${abs_files} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) + add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/${domain}.pot + COMMAND msgcomm --more-than=0 --sort-by-file + ${sh_pot} + ${PROJECT_BINARY_DIR}/${domain}.c.pot + --output=${PROJECT_BINARY_DIR}/${domain}.pot + DEPENDS ${sh_pot} + ${PROJECT_BINARY_DIR}/${domain}.c.pot + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + # Build .mo files file(GLOB translations "${PROJECT_SOURCE_DIR}/po/*.po") list(SORT translations) diff --git a/README.cmake b/README.cmake index a993b2589..1a4d2a448 100644 --- a/README.cmake +++ b/README.cmake @@ -32,6 +32,5 @@ TODO The following features have not been implemented yet: - Translated docbook guides - - dselect translations - unit tests - update-po diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index dc3622156..c7dfcb0fb 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -1,22 +1,28 @@ -apt_add_translation_domain(libapt-pkg${APT_PKG_MAJOR} apt-pkg) - -apt_add_translation_domain(apt # Domain - apt apt-cache apt-get apt-config apt-cdrom - apt-helper apt-mark - apt-private - # Methods - file copy store gpgv cdrom http https ftp rred rsh - mirror +apt_add_translation_domain( + DOMAIN libapt-pkg${APT_PKG_MAJOR} + TARGETS apt-pkg ) +apt_add_translation_domain( + DOMAIN apt + TARGETS apt apt-cache apt-get apt-config apt-cdrom apt-helper apt-mark + apt-private + # Methods + file copy store gpgv cdrom http https ftp rred rsh mirror + SCRIPTS ../dselect/install ../dselect/update +) -apt_add_translation_domain(apt-utils # Domain - apt-sortpkgs - apt-extracttemplates - apt-internal-solver - apt-dump-solver - apt-internal-planner - apt-ftparchive) +apt_add_translation_domain( + DOMAIN apt-utils + TARGETS apt-sortpkgs + apt-extracttemplates + apt-internal-solver + apt-dump-solver + apt-internal-planner + apt-ftparchive +) -# Add the translations for libapt-inst, and set the translation domain. -apt_add_translation_domain(libapt-inst${APT_INST_MAJOR} apt-inst) +apt_add_translation_domain( + DOMAIN libapt-inst${APT_INST_MAJOR} + TARGETS apt-inst +) -- cgit v1.2.3-70-g09d2 From 9a5537fcc6d3ea98909360636a45bd3cf3aba1d1 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 7 Aug 2016 16:01:18 +0200 Subject: CMake: Translations: Build apt-all.pot and update .po files Merge all the per-domain templates into one template file using msgcomm, stripping any line numbers in the input files, and sorting the output per file. This should create reasonably stable .pot and .po files that do not change just because files move around. It should also be resilient against some line changes, as long as one translated line is not moved before/after another translated line. Gbp-Dch: ignore --- CMake/Translations.cmake | 46 ++++++++++++++++++++++++++++++++++++++++++++-- README.cmake | 1 - po/CMakeLists.txt | 10 ++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) (limited to 'CMake') diff --git a/CMake/Translations.cmake b/CMake/Translations.cmake index 1b9781d69..6a9862005 100644 --- a/CMake/Translations.cmake +++ b/CMake/Translations.cmake @@ -13,6 +13,13 @@ function(apt_add_translation_domain) set(abs_scripts "") set(targets ${NLS_TARGETS}) set(domain ${NLS_DOMAIN}) + set(xgettext_params + --add-comments + --foreign + --package-name=${PROJECT_NAME} + --package-version=${PACKAGE_VERSION} + --msgid-bugs-address=${PACKAGE_MAIL} + ) foreach(source ${NLS_SCRIPTS}) string(SUBSTRING ${source} 0 1 init_char) string(COMPARE EQUAL ${init_char} "/" is_absolute) @@ -50,19 +57,21 @@ function(apt_add_translation_domain) set(sh_pot ${PROJECT_BINARY_DIR}/${domain}.sh.pot) # Create the template for this specific sub-domain add_custom_command (OUTPUT ${sh_pot} - COMMAND xgettext --add-comments --foreign -L Shell + COMMAND xgettext ${xgettext_params} -L Shell -o ${sh_pot} ${scripts} DEPENDS ${abs_scripts} + VERBATIM WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) endif() add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/${domain}.c.pot - COMMAND xgettext --add-comments --foreign -k_ -kN_ + COMMAND xgettext ${xgettext_params} -k_ -kN_ --keyword=P_:1,2 -o ${PROJECT_BINARY_DIR}/${domain}.c.pot ${files} DEPENDS ${abs_files} + VERBATIM WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) @@ -100,3 +109,36 @@ function(apt_add_translation_domain) add_custom_target(nls-${domain} ALL DEPENDS ${mofiles}) endfunction() + +# Usage: apt_add_update_po(output domain [domain ...]) +function(apt_add_update_po) + set(options) + set(oneValueArgs TEMPLATE) + set(multiValueArgs DOMAINS) + cmake_parse_arguments(NLS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + set(output ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_TEMPLATE}.pot) + foreach(domain ${NLS_DOMAINS}) + list(APPEND potfiles ${PROJECT_BINARY_DIR}/${domain}.pot) + endforeach() + + get_filename_component(master_name ${output} NAME_WE) + add_custom_target(nls-${master_name} + COMMAND msgcomm --sort-by-file --add-location=file + --more-than=0 --output=${output} + ${potfiles} + DEPENDS ${potfiles}) + + file(GLOB translations "${PROJECT_SOURCE_DIR}/po/*.po") + if (NOT TARGET update-po) + add_custom_target(update-po) + endif() + foreach(translation ${translations}) + get_filename_component(langcode ${translation} NAME_WE) + add_custom_target(update-po-${langcode} + COMMAND msgmerge -q --update --backup=none ${translation} ${output} + DEPENDS nls-${master_name} + ) + add_dependencies(update-po update-po-${langcode}) + endforeach() + add_dependencies(update-po nls-${master_name}) +endfunction() diff --git a/README.cmake b/README.cmake index 1a4d2a448..0ffd08efc 100644 --- a/README.cmake +++ b/README.cmake @@ -33,4 +33,3 @@ The following features have not been implemented yet: - Translated docbook guides - unit tests - - update-po diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index c7dfcb0fb..4fdac3959 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -26,3 +26,13 @@ apt_add_translation_domain( DOMAIN libapt-inst${APT_INST_MAJOR} TARGETS apt-inst ) + +apt_add_update_po( + TEMPLATE + apt-all + DOMAINS + libapt-pkg${APT_PKG_MAJOR} + libapt-inst${APT_INST_MAJOR} + apt + apt-utils +) -- cgit v1.2.3-70-g09d2 From ddf40a42f5a699086466990f85d86e6c4977524a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 9 Aug 2016 11:58:28 +0200 Subject: CMake: Translations: Add a statistics target This is really useful stuff to have. Gbp-Dch: ignore --- CMake/Translations.cmake | 14 ++++++++++++++ po/CMakeLists.txt | 2 ++ 2 files changed, 16 insertions(+) (limited to 'CMake') diff --git a/CMake/Translations.cmake b/CMake/Translations.cmake index 6a9862005..8b657c20f 100644 --- a/CMake/Translations.cmake +++ b/CMake/Translations.cmake @@ -142,3 +142,17 @@ function(apt_add_update_po) endforeach() add_dependencies(update-po nls-${master_name}) endfunction() + +function(apt_add_po_statistics) + add_custom_target(statistics) + file(GLOB translations "${PROJECT_SOURCE_DIR}/po/*.po") + foreach(translation ${translations}) + get_filename_component(langcode ${translation} NAME_WE) + add_custom_command( + TARGET statistics PRE_BUILD + COMMAND printf "%-7s" "${langcode}:" + COMMAND msgfmt --statistics -o /dev/null ${translation} + VERBATIM + ) + endforeach() +endfunction() diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 4fdac3959..92ff39867 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -36,3 +36,5 @@ apt_add_update_po( apt apt-utils ) + +apt_add_po_statistics() -- cgit v1.2.3-70-g09d2 From e164341c20625f62a44be16e6f3fbab66334f130 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 9 Aug 2016 13:10:28 +0200 Subject: CMake: Translations: Avoid rebuilding .mo if .pot did not change Use the witness/byproducts approach to build the translations. A byproduct of a command is like an output, but may be older than the input. Here, we generate a normal template with headers in the normal way as a witness (and for Launchpad translations), but we also generate a .pot-tmp0 template file without a header that gets copied to a .pot-tmp byproduct only if it changed. This way, the .pot-tmp is only updated if an actual string translation changed. We also create a custom target for the .pot file that we'll depend on later in the overall target creating the mo files to ensure that the template is build before we try to build mo files. Then we make the msgmerge depend on the .pot-tmp instead of the .pot file, which means that msgmerge and msgfmt only get re-run if a string change occured. Gbp-Dch: ignore --- CMake/Translations.cmake | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'CMake') diff --git a/CMake/Translations.cmake b/CMake/Translations.cmake index 8b657c20f..584c5c5af 100644 --- a/CMake/Translations.cmake +++ b/CMake/Translations.cmake @@ -75,16 +75,32 @@ function(apt_add_translation_domain) WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) + # We are building a ${domain}.pot with a header for launchpad, but we also + # build a ${domain.pot}-tmp as a byproduct. The msgfmt command than depend + # on the byproduct while their target depends on the output, so that msgfmt + # does not have to be rerun if nothing in the template changed. add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/${domain}.pot + BYPRODUCTS ${PROJECT_BINARY_DIR}/${domain}.pot-tmp COMMAND msgcomm --more-than=0 --sort-by-file ${sh_pot} ${PROJECT_BINARY_DIR}/${domain}.c.pot --output=${PROJECT_BINARY_DIR}/${domain}.pot + COMMAND msgcomm --more-than=0 --omit-header --sort-by-file + ${sh_pot} + ${PROJECT_BINARY_DIR}/${domain}.c.pot + --output=${PROJECT_BINARY_DIR}/${domain}.pot-tmp0 + COMMAND cmake -E copy_if_different + ${PROJECT_BINARY_DIR}/${domain}.pot-tmp0 + ${PROJECT_BINARY_DIR}/${domain}.pot-tmp DEPENDS ${sh_pot} ${PROJECT_BINARY_DIR}/${domain}.c.pot WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) + # We need a target to depend on otherwise, the msgmerge might not get called + # with the make generator + add_custom_target(nls-${domain}-template DEPENDS ${PROJECT_BINARY_DIR}/${domain}.pot) + # Build .mo files file(GLOB translations "${PROJECT_SOURCE_DIR}/po/*.po") list(SORT translations) @@ -92,10 +108,11 @@ function(apt_add_translation_domain) get_filename_component(langcode ${file} NAME_WE) set(outdir ${PROJECT_BINARY_DIR}/locale/${langcode}/LC_MESSAGES) file(MAKE_DIRECTORY ${outdir}) - # Command to merge and compile the messages + # Command to merge and compile the messages. As explained in the custom + # command for msgcomm, this depends on byproduct to avoid reruns add_custom_command(OUTPUT ${outdir}/${domain}.po - COMMAND msgmerge -qo ${outdir}/${domain}.po ${file} ${PROJECT_BINARY_DIR}/${domain}.pot - DEPENDS ${file} ${PROJECT_BINARY_DIR}/${domain}.pot + COMMAND msgmerge -qo ${outdir}/${domain}.po ${file} ${PROJECT_BINARY_DIR}/${domain}.pot-tmp + DEPENDS ${file} ${PROJECT_BINARY_DIR}/${domain}.pot-tmp ) add_custom_command(OUTPUT ${outdir}/${domain}.mo COMMAND msgfmt --statistics -o ${outdir}/${domain}.mo ${outdir}/${domain}.po @@ -107,7 +124,7 @@ function(apt_add_translation_domain) DESTINATION "${CMAKE_INSTALL_LOCALEDIR}/${langcode}/LC_MESSAGES") endforeach(file ${translations}) - add_custom_target(nls-${domain} ALL DEPENDS ${mofiles}) + add_custom_target(nls-${domain} ALL DEPENDS ${mofiles} nls-${domain}-template) endfunction() # Usage: apt_add_update_po(output domain [domain ...]) -- cgit v1.2.3-70-g09d2 From 32a32d7501ace2859ba097ef8fb7ef665ca2f0ed Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 9 Aug 2016 18:14:41 +0200 Subject: CMake: Translations: Allow excluding languages from translation This seems to be needed for the hebrew translations. Gbp-Dch: ignore --- CMake/Translations.cmake | 23 +++++++++++++++++++---- po/CMakeLists.txt | 12 +++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) (limited to 'CMake') diff --git a/CMake/Translations.cmake b/CMake/Translations.cmake index 584c5c5af..9880e68c7 100644 --- a/CMake/Translations.cmake +++ b/CMake/Translations.cmake @@ -4,7 +4,7 @@ function(apt_add_translation_domain) set(options) set(oneValueArgs DOMAIN) - set(multiValueArgs TARGETS SCRIPTS) + set(multiValueArgs TARGETS SCRIPTS EXCLUDE_LANGUAGES) cmake_parse_arguments(NLS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) # Build the list of source files of the target set(files "") @@ -106,6 +106,9 @@ function(apt_add_translation_domain) list(SORT translations) foreach(file ${translations}) get_filename_component(langcode ${file} NAME_WE) + if ("${langcode}" IN_LIST NLS_EXCLUDE_LANGUAGES) + continue() + endif() set(outdir ${PROJECT_BINARY_DIR}/locale/${langcode}/LC_MESSAGES) file(MAKE_DIRECTORY ${outdir}) # Command to merge and compile the messages. As explained in the custom @@ -131,7 +134,7 @@ endfunction() function(apt_add_update_po) set(options) set(oneValueArgs TEMPLATE) - set(multiValueArgs DOMAINS) + set(multiValueArgs DOMAINS EXCLUDE_LANGUAGES) cmake_parse_arguments(NLS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set(output ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_TEMPLATE}.pot) foreach(domain ${NLS_DOMAINS}) @@ -151,6 +154,9 @@ function(apt_add_update_po) endif() foreach(translation ${translations}) get_filename_component(langcode ${translation} NAME_WE) + if ("${langcode}" IN_LIST NLS_EXCLUDE_LANGUAGES) + continue() + endif() add_custom_target(update-po-${langcode} COMMAND msgmerge -q --update --backup=none ${translation} ${output} DEPENDS nls-${master_name} @@ -160,14 +166,23 @@ function(apt_add_update_po) add_dependencies(update-po nls-${master_name}) endfunction() -function(apt_add_po_statistics) +function(apt_add_po_statistics excluded) add_custom_target(statistics) file(GLOB translations "${PROJECT_SOURCE_DIR}/po/*.po") foreach(translation ${translations}) get_filename_component(langcode ${translation} NAME_WE) + if ("${langcode}" IN_LIST excluded) + add_custom_command( + TARGET statistics PRE_BUILD + COMMAND printf "%-6s " "${langcode}:" + COMMAND echo "ignored" + VERBATIM + ) + continue() + endif() add_custom_command( TARGET statistics PRE_BUILD - COMMAND printf "%-7s" "${langcode}:" + COMMAND printf "%-6s " "${langcode}:" COMMAND msgfmt --statistics -o /dev/null ${translation} VERBATIM ) diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 92ff39867..174cc5d41 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -1,6 +1,11 @@ +set(languages_excluded + he ## disabled by translator request #313283 +) + apt_add_translation_domain( DOMAIN libapt-pkg${APT_PKG_MAJOR} TARGETS apt-pkg + EXCLUDE_LANGUAGES ${languages_excluded} ) apt_add_translation_domain( @@ -10,6 +15,7 @@ apt_add_translation_domain( # Methods file copy store gpgv cdrom http https ftp rred rsh mirror SCRIPTS ../dselect/install ../dselect/update + EXCLUDE_LANGUAGES ${languages_excluded} ) apt_add_translation_domain( @@ -20,11 +26,13 @@ apt_add_translation_domain( apt-dump-solver apt-internal-planner apt-ftparchive + EXCLUDE_LANGUAGES ${languages_excluded} ) apt_add_translation_domain( DOMAIN libapt-inst${APT_INST_MAJOR} TARGETS apt-inst + EXCLUDE_LANGUAGES ${languages_excluded} ) apt_add_update_po( @@ -35,6 +43,8 @@ apt_add_update_po( libapt-inst${APT_INST_MAJOR} apt apt-utils + EXCLUDE_LANGUAGES + ${languages_excluded} ) -apt_add_po_statistics() +apt_add_po_statistics("${languages_excluded}") -- cgit v1.2.3-70-g09d2 From 173fa882cf3396ab6d2a9be53c6ea23eda225a1d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 9 Aug 2016 21:52:08 +0200 Subject: CMake: Translations: Build .pot in po binary dir, not project one This was cluttering up things all over the place. Gbp-Dch: ignore --- CMake/Translations.cmake | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'CMake') diff --git a/CMake/Translations.cmake b/CMake/Translations.cmake index 9880e68c7..7bdcab6ab 100644 --- a/CMake/Translations.cmake +++ b/CMake/Translations.cmake @@ -54,7 +54,7 @@ function(apt_add_translation_domain) if("${scripts}" STREQUAL "") set(sh_pot "/dev/null") else() - set(sh_pot ${PROJECT_BINARY_DIR}/${domain}.sh.pot) + set(sh_pot ${CMAKE_CURRENT_BINARY_DIR}/${domain}.sh.pot) # Create the template for this specific sub-domain add_custom_command (OUTPUT ${sh_pot} COMMAND xgettext ${xgettext_params} -L Shell @@ -66,10 +66,10 @@ function(apt_add_translation_domain) endif() - add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/${domain}.c.pot + add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${domain}.c.pot COMMAND xgettext ${xgettext_params} -k_ -kN_ --keyword=P_:1,2 - -o ${PROJECT_BINARY_DIR}/${domain}.c.pot ${files} + -o ${CMAKE_CURRENT_BINARY_DIR}/${domain}.c.pot ${files} DEPENDS ${abs_files} VERBATIM WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} @@ -79,27 +79,27 @@ function(apt_add_translation_domain) # build a ${domain.pot}-tmp as a byproduct. The msgfmt command than depend # on the byproduct while their target depends on the output, so that msgfmt # does not have to be rerun if nothing in the template changed. - add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/${domain}.pot - BYPRODUCTS ${PROJECT_BINARY_DIR}/${domain}.pot-tmp + add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot + BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot-tmp COMMAND msgcomm --more-than=0 --sort-by-file ${sh_pot} - ${PROJECT_BINARY_DIR}/${domain}.c.pot - --output=${PROJECT_BINARY_DIR}/${domain}.pot + ${CMAKE_CURRENT_BINARY_DIR}/${domain}.c.pot + --output=${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot COMMAND msgcomm --more-than=0 --omit-header --sort-by-file ${sh_pot} - ${PROJECT_BINARY_DIR}/${domain}.c.pot - --output=${PROJECT_BINARY_DIR}/${domain}.pot-tmp0 + ${CMAKE_CURRENT_BINARY_DIR}/${domain}.c.pot + --output=${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot-tmp0 COMMAND cmake -E copy_if_different - ${PROJECT_BINARY_DIR}/${domain}.pot-tmp0 - ${PROJECT_BINARY_DIR}/${domain}.pot-tmp + ${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot-tmp0 + ${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot-tmp DEPENDS ${sh_pot} - ${PROJECT_BINARY_DIR}/${domain}.c.pot + ${CMAKE_CURRENT_BINARY_DIR}/${domain}.c.pot WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) # We need a target to depend on otherwise, the msgmerge might not get called # with the make generator - add_custom_target(nls-${domain}-template DEPENDS ${PROJECT_BINARY_DIR}/${domain}.pot) + add_custom_target(nls-${domain}-template DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot) # Build .mo files file(GLOB translations "${PROJECT_SOURCE_DIR}/po/*.po") @@ -109,13 +109,13 @@ function(apt_add_translation_domain) if ("${langcode}" IN_LIST NLS_EXCLUDE_LANGUAGES) continue() endif() - set(outdir ${PROJECT_BINARY_DIR}/locale/${langcode}/LC_MESSAGES) + set(outdir ${CMAKE_CURRENT_BINARY_DIR}/locale/${langcode}/LC_MESSAGES) file(MAKE_DIRECTORY ${outdir}) # Command to merge and compile the messages. As explained in the custom # command for msgcomm, this depends on byproduct to avoid reruns add_custom_command(OUTPUT ${outdir}/${domain}.po - COMMAND msgmerge -qo ${outdir}/${domain}.po ${file} ${PROJECT_BINARY_DIR}/${domain}.pot-tmp - DEPENDS ${file} ${PROJECT_BINARY_DIR}/${domain}.pot-tmp + COMMAND msgmerge -qo ${outdir}/${domain}.po ${file} ${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot-tmp + DEPENDS ${file} ${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot-tmp ) add_custom_command(OUTPUT ${outdir}/${domain}.mo COMMAND msgfmt --statistics -o ${outdir}/${domain}.mo ${outdir}/${domain}.po @@ -138,7 +138,7 @@ function(apt_add_update_po) cmake_parse_arguments(NLS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set(output ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_TEMPLATE}.pot) foreach(domain ${NLS_DOMAINS}) - list(APPEND potfiles ${PROJECT_BINARY_DIR}/${domain}.pot) + list(APPEND potfiles ${CMAKE_CURRENT_BINARY_DIR}/${domain}.pot) endforeach() get_filename_component(master_name ${output} NAME_WE) -- cgit v1.2.3-70-g09d2 From 8c1dbbef35bea4082eacfe4e626e7726b9e84349 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 8 Aug 2016 14:56:53 +0200 Subject: CMake: Check for ptsname_r() again This was dropped in autotools as I found no use of the HAVE_PTSNAME_R macro. Turns out it was typoed as HAVE_PTS_NAME_R. Fix the #ifdef and add checks to CMake for it. Closes: #833674 --- CMake/config.h.in | 3 +++ CMakeLists.txt | 1 + apt-pkg/deb/dpkgpm.cc | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) (limited to 'CMake') diff --git a/CMake/config.h.in b/CMake/config.h.in index 3afd9123c..e929646fa 100644 --- a/CMake/config.h.in +++ b/CMake/config.h.in @@ -34,6 +34,9 @@ #cmakedefine HAVE_SETRESUID #cmakedefine HAVE_SETRESGID +/* Check for ptsname_r() */ +#cmakedefine HAVE_PTSNAME_R + /* Define the arch name string */ #define COMMON_ARCH "${COMMON_ARCH}" diff --git a/CMakeLists.txt b/CMakeLists.txt index 254e34869..7e432bca3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,7 @@ check_function_exists(getresuid HAVE_GETRESUID) check_function_exists(getresgid HAVE_GETRESGID) check_function_exists(setresuid HAVE_SETRESUID) check_function_exists(setresgid HAVE_SETRESGID) +check_function_exists(ptsname_r HAVE_PTSNAME_R) check_function_exists(timegm HAVE_TIMEGM) test_big_endian(WORDS_BIGENDIAN) diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index c1b9a28f4..ccfc77d6a 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1086,7 +1086,7 @@ void pkgDPkgPM::StartPtyMagic() /*{{{*/ _error->Errno("unlockpt", "Unlocking the slave of master fd %d failed!", d->master); else { -#ifdef HAVE_PTS_NAME_R +#ifdef HAVE_PTSNAME_R char slave_name[64]; // 64 is used by bionic if (ptsname_r(d->master, slave_name, sizeof(slave_name)) != 0) #else -- cgit v1.2.3-70-g09d2 From 0d04a4987feb9ec45ddfa03270e20f76cae02a84 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 8 Aug 2016 21:53:05 +0200 Subject: CMake: Misc: Extract command path_join() from Translations This abstracts the joining of paths a bit better than having basically the same code twice in the Translations module. Gbp-Dch: ignore --- CMake/Misc.cmake | 9 +++++++++ CMake/Translations.cmake | 16 ++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) (limited to 'CMake') diff --git a/CMake/Misc.cmake b/CMake/Misc.cmake index 3329fc20f..79587b068 100644 --- a/CMake/Misc.cmake +++ b/CMake/Misc.cmake @@ -77,3 +77,12 @@ function(add_version_script target) target_link_libraries(${target} PRIVATE -Wl,-version-script="${script}") add_dependencies(${target} ${target}-versionscript) endfunction() + +function(path_join out path1 path2) + string(SUBSTRING ${path2} 0 1 init_char) + if ("${init_char}" STREQUAL "/") + set(${out} "${path2}" PARENT_SCOPE) + else() + set(${out} "${path1}/${path2}" PARENT_SCOPE) + endif() +endfunction() diff --git a/CMake/Translations.cmake b/CMake/Translations.cmake index 7bdcab6ab..509e4e378 100644 --- a/CMake/Translations.cmake +++ b/CMake/Translations.cmake @@ -21,13 +21,7 @@ function(apt_add_translation_domain) --msgid-bugs-address=${PACKAGE_MAIL} ) foreach(source ${NLS_SCRIPTS}) - string(SUBSTRING ${source} 0 1 init_char) - string(COMPARE EQUAL ${init_char} "/" is_absolute) - if (${is_absolute}) - set(file "${source}") - else() - set(file "${CMAKE_CURRENT_SOURCE_DIR}/${source}") - endif() + path_join(file "${CMAKE_CURRENT_SOURCE_DIR}" "${source}") file(RELATIVE_PATH relfile ${PROJECT_SOURCE_DIR} ${file}) list(APPEND scripts ${relfile}) list(APPEND abs_scripts ${file}) @@ -36,13 +30,7 @@ function(apt_add_translation_domain) get_target_property(source_dir ${target} SOURCE_DIR) get_target_property(sources ${target} SOURCES) foreach(source ${sources}) - string(SUBSTRING ${source} 0 1 init_char) - string(COMPARE EQUAL ${init_char} "/" is_absolute) - if (${is_absolute}) - set(file "${source}") - else() - set(file "${source_dir}/${source}") - endif() + path_join(file "${source_dir}" "${source}") file(RELATIVE_PATH relfile ${PROJECT_SOURCE_DIR} ${file}) set(files ${files} ${relfile}) set(abs_files ${abs_files} ${file}) -- cgit v1.2.3-70-g09d2 From 10ec2d23f14cf5d3e4835d9bcb57d0937f803e6a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 8 Aug 2016 21:53:46 +0200 Subject: CMake: Rewrite existing Documentation support and add doxygen This can now build all documentation. It should also be fairly reusable for other projects, as long as they follow the same naming scheme for the po4a output files and set the PACKAGE_* variables used here. We could have done all translations in a single call to po4a like the makefile based buildsystem does. While that would have made the output slightly nicer, this solution offers a huge performance gain because it can translate the documents in parallel, which also means that the xsltproc stage does not have to wait for all translations to be done first. You might think that the add_custom_command() should list the actual output files as BYPRODUCTS. This is not true however: Because the files are not always generated, Ninja will think missing byproducts mean that the target is out of date - which is not what we want. Finally, also add the missing doxygen support. Note that the packaging script cleans up some md5 and map files created by doxygen, otherwise it is fairly boring. --- CMake/Documentation.cmake | 335 +++++++++++++++++++++++++++++++++------------- CMake/run_if_exists.sh | 16 +++ CMakeLists.txt | 5 +- README.cmake | 7 - debian/rules | 2 + doc/CMakeLists.txt | 86 ++++++++++-- doc/Doxyfile.in | 12 +- 7 files changed, 346 insertions(+), 117 deletions(-) create mode 100755 CMake/run_if_exists.sh (limited to 'CMake') diff --git a/CMake/Documentation.cmake b/CMake/Documentation.cmake index 98e07176b..9e7135ea4 100644 --- a/CMake/Documentation.cmake +++ b/CMake/Documentation.cmake @@ -1,4 +1,7 @@ -# Copyright (C) 2009, 2016 Julian Andres Klode . +# po4a/docbook documentation support for CMake +# - see documentation of add_docbook() +# +# Copyright (C) 2016 Julian Andres Klode . # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files @@ -20,115 +23,263 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -function(add_docbook target sourcefiles installdest) - foreach(file ${sourcefiles}) - get_filename_component(relfile ${file} NAME) - string(REPLACE ".dbk" "" manual ${relfile}) - get_filename_component(absolute ${file} ABSOLUTE) - - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html/ - COMMAND xsltproc --nonet --novalid --xinclude - --stringparam base.dir ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html/ - --path ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/${CURRENT_VENDOR}/ - --path ${CMAKE_CURRENT_SOURCE_DIR}/ - ${CMAKE_CURRENT_SOURCE_DIR}/docbook-html-style.xsl - ${absolute} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${file} - ) - set(commands ${commands} ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html) - if (NOT ${installdest} EQUAL "" ) - install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html - DESTINATION ${installdest}) - endif() - endforeach(file ${sourcefiles}) - add_custom_target(${target} ALL DEPENDS ${commands}) +# Split up a string of the form DOCUMENT[.DOCUMENT][.LANGUAGE][.SECTION].EXTENSION +# +# There might be up to two parts in the document name. The language must be +# a two char language code like de, or a 5 char code of the form de_DE. +function(po4a_components doc lang sec ext translated_full_document) + get_filename_component(name ${translated_full_document} NAME) + string(REPLACE "." ";" name "${name}") # Make it a list + + list(GET name 0 _doc) # First element is always the document + list(GET name 1 _lang) # Second *might* be a language + list(GET name -2 _sec) # Second-last *might* be a section + list(GET name -1 _ext) # Last element is always the file type + + # If the language code is neither a file type, nor a section, nor a language + # assume it is part of the file name and use the next component as the lang. + if(_lang AND NOT _lang MATCHES "^(xml|dbk|[0-9]|[a-z][a-z]|[a-z][a-z]_[A-Z][A-Z])$") + set(_doc "${_doc}.${_lang}") + list(GET name 2 _lang) + endif() + # If no language is present, we get a section; both not present => type + if(_lang MATCHES "xml|dbk|[0-9]") + set(_lang "") + endif() + if(NOT _sec MATCHES "^[0-9]$") # A (manpage) section must be a number + set(_sec "") + endif() + + set(${doc} ${_doc} PARENT_SCOPE) + set(${lang} ${_lang} PARENT_SCOPE) + set(${sec} ${_sec} PARENT_SCOPE) + set(${ext} ${_ext} PARENT_SCOPE) endfunction() -function(add_po4a type master po target deps) - add_custom_command(OUTPUT ${target} - COMMAND po4a-translate --keep 0 -f ${type} -m ${master} - -p ${po} -l ${target} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${deps} ${master} ${po}) +# Process one document +function(po4a_one stamp_out out full_document language deps) + path_join(full_path "${CMAKE_CURRENT_SOURCE_DIR}" "${full_document}") + po4a_components(document _ section ext "${full_document}") + + # Calculate target file name + set(dest "${language}/${document}.${language}") + if(section) + set(dest "${dest}.${section}") + endif() + + # po4a might drop files not translated enough, so build a stamp file + set(stamp ${CMAKE_CURRENT_BINARY_DIR}/${dest}.po4a-stamp) + add_custom_command( + OUTPUT ${stamp} + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${language} + COMMAND po4a --previous --no-backups + --package-name='${PROJECT}-doc' + --package-version='${PACKAGE_VERSION}' + --msgid-bugs-address='${PACKAGE_MAIL}' + --translate-only ${dest}.${ext} + --srcdir ${CMAKE_CURRENT_SOURCE_DIR} + --destdir ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/po4a.conf + COMMAND ${CMAKE_COMMAND} -E touch ${stamp} + COMMENT "Generating ${dest}.${ext} (or dropping it)" + DEPENDS ${full_document} ${deps} po/${language}.po + ) + # Return result + set(${stamp_out} ${stamp} PARENT_SCOPE) + set(${out} ${CMAKE_CURRENT_BINARY_DIR}/${dest}.${ext} PARENT_SCOPE) endfunction() +function(xsltproc_one) + set(generated "") + set(options HTML TEXT MANPAGE) + set(oneValueArgs STAMP STAMP_OUT FULL_DOCUMENT) + set(multiValueArgs INSTALL DEPENDS) + cmake_parse_arguments(DOC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) -# Macro for XML man pages. -function(add_xml_manpages target manpages translations entities) - foreach(manpage ${manpages}) - string(LENGTH ${manpage} manpage_length) - math(EXPR manpage_length ${manpage_length}-1) - string(SUBSTRING ${manpage} ${manpage_length} 1 section) - - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${manpage} - COMMAND xsltproc --path ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/${CURRENT_VENDOR}/ - --path ${CMAKE_CURRENT_SOURCE_DIR}/ - ${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl - ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.xml - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.xml - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl - ) + po4a_components(document language section ext "${DOC_FULL_DOCUMENT}") + + # Default parameters + set(params + --nonet + --xinclude + --stringparam chunk.quietly yes + --stringparam man.output.quietly yes + --path ${PROJECT_SOURCE_DIR}/vendor/${CURRENT_VENDOR}/ + --path ${CMAKE_CURRENT_SOURCE_DIR}/ + ) + + # Parameters if localized + if(language) + list(APPEND params -stringparam l10n.gentext.default.language ${language}) + endif() + + path_join(full_input_path ${CMAKE_CURRENT_SOURCE_DIR} ${DOC_FULL_DOCUMENT}) + + if (DOC_MANPAGE) + if (language) + set(manpage_output "${CMAKE_CURRENT_BINARY_DIR}/${language}/${document}.${section}") + else() + set(manpage_output "${CMAKE_CURRENT_BINARY_DIR}/${document}.${section}") + endif() + set(manpage_stylesheet "${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl") + + install(FILES ${manpage_output} + DESTINATION ${CMAKE_INSTALL_MANDIR}/${language}/man${section} + OPTIONAL) + endif() + if (DOC_HTML) + if (language) + set(html_output "${CMAKE_CURRENT_BINARY_DIR}/${language}/${document}.${language}.html") + else() + set(html_output "${CMAKE_CURRENT_BINARY_DIR}/${document}.html") + endif() + set(html_params --stringparam base.dir ${html_output}) + set(html_stylesheet "${CMAKE_CURRENT_SOURCE_DIR}/docbook-html-style.xsl") + install(DIRECTORY ${html_output} + DESTINATION ${DOC_INSTALL} + OPTIONAL) + endif() + if (DOC_TEXT) + if (language) + set(text_output "${CMAKE_CURRENT_BINARY_DIR}/${language}/${document}.${language}.text") + else() + set(text_output "${CMAKE_CURRENT_BINARY_DIR}/${document}.text") + endif() + set(text_params --stringparam base.dir ${text_output}) + set(text_stylesheet "${CMAKE_CURRENT_SOURCE_DIR}/docbook-text-style.xsl") - set(commands ${commands} ${CMAKE_CURRENT_BINARY_DIR}/${manpage}) + file(RELATIVE_PATH text_output_relative ${CMAKE_CURRENT_BINARY_DIR} ${text_output}) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${manpage} - DESTINATION ${CMAKE_INSTALL_MANDIR}/man${section}) + add_custom_command(OUTPUT ${text_output}.w3m-stamp + COMMAND ${PROJECT_SOURCE_DIR}/CMake/run_if_exists.sh + --stdout ${text_output} + ${text_output}.html + env LC_ALL=C.UTF-8 w3m -cols 78 -dump + -o display_charset=UTF-8 + -no-graph -T text/html ${text_output}.html + COMMAND ${CMAKE_COMMAND} -E touch ${text_output}.w3m-stamp + COMMENT "Generating ${text_output_relative} (if not dropped by po4a)" + DEPENDS "${text_output}.html.xsltproc-stamp" + ) + list(APPEND generated ${text_output}.w3m-stamp) - # Add the translations for the manpage. - foreach(translation ${translations}) - set(entities) - # transdir = shortcut to the output directory for translations. - set(transdir ${CMAKE_CURRENT_BINARY_DIR}/${translation}) + install(FILES ${text_output} + DESTINATION ${DOC_INSTALL} + OPTIONAL) + set(text_output "${text_output}.html") + endif() - add_po4a(docbook ${manpage}.xml po/${translation}.po - ${transdir}/${manpage}.xml "${ent_cmds}") + foreach(type in manpage html text) + if (NOT ${type}_output) + continue() + endif() + set(output ${${type}_output}) + set(stylesheet ${${type}_stylesheet}) + set(type_params ${${type}_params}) + file(RELATIVE_PATH output_relative ${CMAKE_CURRENT_BINARY_DIR} ${output}) - add_custom_command(OUTPUT ${transdir}/${manpage} - COMMAND xsltproc --path ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/${CURRENT_VENDOR}/ - --path ${CMAKE_CURRENT_SOURCE_DIR}/ - --stringparam l10n.gentext.default.language ${translation} - ${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl - ${transdir}/${manpage}.xml - WORKING_DIRECTORY ${transdir} - DEPENDS ${transdir}/${manpage}.xml - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl) + add_custom_command(OUTPUT ${output}.xsltproc-stamp + COMMAND ${PROJECT_SOURCE_DIR}/CMake/run_if_exists.sh + ${full_input_path} + xsltproc ${params} ${type_params} -o ${output} + ${stylesheet} + ${full_input_path} + COMMAND ${CMAKE_COMMAND} -E touch ${output}.xsltproc-stamp + COMMENT "Generating ${output_relative} (if not dropped by po4a)" + DEPENDS ${DOC_STAMP} ${DOC_DEPENDS}) - set(nls-cmd ${nls-cmd} ${transdir}/${manpage}) - install(FILES ${transdir}/${manpage} - DESTINATION ${CMAKE_INSTALL_MANDIR}/${translation}/man${section}) + list(APPEND generated ${output}.xsltproc-stamp) + endforeach() + + set(${DOC_STAMP_OUT} ${generated} PARENT_SCOPE) +endfunction() - endforeach(translation ${translations}) - endforeach(manpage ${manpages}) - add_custom_target(${target} ALL DEPENDS ${commands}) - # Sort the list of the translations. - list(SORT nls-cmd) - add_custom_target(nls-${target} ALL DEPENDS ${nls-cmd}) +# add_docbook(Name [ALL] [HTML] [TEXT] [MANPAGE] +# [INSTALL install dir] +# [DEPENDS depend ...] +# [DOCUMENTS documents ...] +# [LINGUAS lingua ...]) +# +# Generate a target called name with all the documents being converted to +# the chosen output formats and translated to the chosen languages using po4a. +# +# For the translation support, the po4a.conf must be written so that +# translations for a document guide.xml are written to LANG/guide.LANG.xml, +# and for a manual page man.5.xml to a file called LANG/man.LANG.5.xml. +# +# The guide and manual page names may also contain a second component separated +# by a dot, it must however not be a valid language code. +# +# Note that po4a might chose not to generate a translated manual page for a +# given language if the translation rate is not high enough. We deal with this +# by creating stamp files. +function(add_docbook target) + set(generated "") + set(options HTML TEXT MANPAGE ALL) + set(multiValueArgs INSTALL DOCUMENTS LINGUAS DEPENDS) + cmake_parse_arguments(DOC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (DOC_HTML) + list(APPEND formats HTML) + endif() + if (DOC_TEXT) + list(APPEND formats TEXT) + endif() + if (DOC_MANPAGE) + list(APPEND formats MANPAGE) + endif() + + foreach(document ${DOC_DOCUMENTS}) + foreach(lang ${DOC_LINGUAS}) + po4a_one(po4a_stamp po4a_out ${document} "${lang}" "${DOC_DEPENDS}") + xsltproc_one(STAMP_OUT xslt_stamp + STAMP ${po4a_stamp} + FULL_DOCUMENT ${po4a_out} + INSTALL ${DOC_INSTALL} + ${formats}) + + list(APPEND stamps ${xslt_stamp}) + endforeach() + xsltproc_one(STAMP_OUT xslt_stamp + STAMP ${document} + FULL_DOCUMENT ${document} + INSTALL ${DOC_INSTALL} + ${formats}) + + list(APPEND stamps ${xslt_stamp}) + endforeach() + + if (DOC_ALL) + add_custom_target(${target} ALL DEPENDS ${stamps}) + else() + add_custom_target(${target} DEPENDS ${stamps}) + endif() endfunction() +# Add an update-po4a target +function(add_update_po4a target pot header) + set(WRITE_HEADER "") -function(add_manpages target manpages translations) - foreach(man ${manpages}) - string(LENGTH ${man} manpage_length) - math(EXPR manpage_length ${manpage_length}-1) - string(SUBSTRING ${man} ${manpage_length} 1 section) - install(FILES ${man} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${section}) - - if (USE_NLS) - foreach(translation ${translations}) - set(transdir ${CMAKE_CURRENT_BINARY_DIR}/${translation}) - add_po4a(man ${man} po/${translation}.po ${transdir}/${man} "") - install(FILES ${transdir}/${man} - DESTINATION ${CMAKE_INSTALL_MANDIR}/${translation}/man${section}) - set(files ${files} ${transdir}/${man}) - endforeach(translation ${translations}) - endif() - endforeach(man ${manpages}) - add_custom_target(${target} ALL DEPENDS ${files}) + if (header) + set(WRITE_HEADER + COMMAND sed -n "/^\#$/,$p" ${pot} > ${pot}.headerfree + COMMAND cat ${header} ${pot}.headerfree > ${pot} + COMMAND rm ${pot}.headerfree + ) + endif() + add_custom_target(${target} + COMMAND po4a --previous --no-backups --force --no-translations + --msgmerge-opt --add-location=file + --porefs noline,wrap + --package-name=${PROJECT_NAME}-doc --package-version=${PACKAGE_VERSION} + --msgid-bugs-address=${PACKAGE_MAIL} po4a.conf + ${WRITE_HEADER} + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) endfunction() diff --git a/CMake/run_if_exists.sh b/CMake/run_if_exists.sh new file mode 100755 index 000000000..97edd4c1a --- /dev/null +++ b/CMake/run_if_exists.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# Small helper for running a command +out="" +if [ "$1" = "--stdout" ]; then + out="$2" + shift 2 +fi + +if [ -e "$1" ]; then + shift + if [ "$out" ]; then + exec "$@" > $out + else + exec "$@" + fi +fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e432bca3..aed0b506d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.4.0) enable_testing() -option(WITH_DOC "Build documentation." OFF) +option(WITH_DOC "Build documentation." ON) option(USE_NLS "Localisation support." ON) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake") @@ -142,3 +142,6 @@ add_subdirectory(ftparchive) add_subdirectory(methods) add_subdirectory(po) add_subdirectory(test) + +# Link update-po4a into the update-po target +add_dependencies(update-po update-po4a) diff --git a/README.cmake b/README.cmake index 5afe0449f..06db22c96 100644 --- a/README.cmake +++ b/README.cmake @@ -25,10 +25,3 @@ To build a subdirectory; for example, apt-pkg, use one of: Ninja automatically parallelizes, make needs an explicit -j switch. The travis system uses the make generator, the packaging as well. - -TODO ----- - -The following features have not been implemented yet: - - - Translated docbook guides diff --git a/debian/rules b/debian/rules index c1dba72af..9537ecd93 100755 --- a/debian/rules +++ b/debian/rules @@ -15,6 +15,8 @@ override_dh_install-indep: dh_movefiles dh_install --list-missing + find debian/libapt-pkg-doc/usr/share/doc/libapt-pkg-doc/html \( -name '*.md5' -o -name '*.map' \) -delete + override_dh_install-arch: dh_movefiles dh_install --fail-missing diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index bbf5fb046..d54303deb 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,21 +1,85 @@ include(Documentation) -file(GLOB_RECURSE debiandoc-apt guide*.dbk offline*.dbk) -file(GLOB_RECURSE debiandoc-libapt cache*.dbk design*.dbk dpkg-tech*.dbk - files*.dbk method*.dbk) +set(LINGUAS + de + es + fr + it + ja + nl + pl + pt_BR + pt +) +set(ENTITIES + apt.ent + apt-verbatim.ent + ../vendor/${CURRENT_VENDOR}/apt-vendor.ent +) -set(manpages apt.8 apt-cache.8 apt-get.8 apt-cdrom.8 apt.conf.5 sources.list.5 - apt-config.8 apt_preferences.5 apt-sortpkgs.1 apt-ftparchive.1 - apt-extracttemplates.1 apt-key.8 apt-secure.8 apt-mark.8) +if(WITH_DOC) +add_docbook(apt-doc HTML TEXT ALL + DOCUMENTS + guide.dbk + offline.dbk + INSTALL ${CMAKE_INSTALL_DOCDIR}/../apt-doc + LINGUAS ${LINGUAS} + DEPENDS ${ENTITIES} +) + +add_docbook(libapt-pkg-doc HTML TEXT ALL + DOCUMENTS + design.dbk + dpkg-tech.dbk + files.dbk + method.dbk + INSTALL ${CMAKE_INSTALL_DOCDIR}/../libapt-pkg-doc + LINGUAS ${LINGUAS} + DEPENDS ${ENTITIES} +) + +find_package(Doxygen) + +file(GLOB_RECURSE apt_pkg "../apt-pkg/*.h" "../apt-pkg/*.cc") +configure_file(Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doxygen.stamp + COMMAND doxygen ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/doxygen.stamp + DEPENDS ${apt_pkg} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile +) + +add_custom_target(apt-doxygen ALL + DEPENDS ${PROJECT_BINARY_DIR}/doc/doxygen.stamp +) + +install(DIRECTORY ${PROJECT_BINARY_DIR}/doc/doxygen/html + DESTINATION ${CMAKE_INSTALL_DOCDIR}/../libapt-pkg-doc) -if (WITH_DOC) -add_docbook(debiandoc-apt "${debiandoc-apt}" share/doc/apt-doc) -add_docbook(debiandoc-libapt "${debiandoc-libapt}" share/doc/libapt-pkg-doc) endif() -# Build the manpages, and add translations (ja only for now, others broken) -add_xml_manpages(doc-man "${manpages}" "de;es;fr;it;ja;nl;pl;pt_BR;pt" "apt.ent;apt-verbatim.ent") +add_docbook(apt-man MANPAGE ALL + DOCUMENTS + apt.8.xml + apt-cache.8.xml + apt-cdrom.8.xml + apt.conf.5.xml + apt-config.8.xml + apt-extracttemplates.1.xml + apt-ftparchive.1.xml + apt-get.8.xml + apt-key.8.xml + apt-mark.8.xml + apt_preferences.5.xml + apt-secure.8.xml + apt-sortpkgs.1.xml + sources.list.5.xml + DEPENDS ${ENTITIES} + LINGUAS ${LINGUAS} +) +add_update_po4a(update-po4a po/${PROJECT_NAME}-doc.pot "po/header.pot.txt") add_subdirectory(examples) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index ab3fc0a7c..b6521feb8 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -58,7 +58,7 @@ PROJECT_LOGO = # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = ../build/doc/doxygen +OUTPUT_DIRECTORY = @PROJECT_BINARY_DIR@/doc/doxygen # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and @@ -152,7 +152,7 @@ FULL_PATH_NAMES = YES # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. -STRIP_FROM_PATH = @top_srcdir@ +STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@ # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which @@ -161,7 +161,7 @@ STRIP_FROM_PATH = @top_srcdir@ # specify the list of include paths that are normally passed to the compiler # using the -I flag. -STRIP_FROM_INC_PATH = @top_srcdir@ +STRIP_FROM_INC_PATH = @PROJECT_SOURCE_DIR@ # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't @@ -754,7 +754,7 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -INPUT = ../apt-pkg +INPUT = ${PROJECT_SOURCE_DIR}/apt-pkg # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -2057,7 +2057,7 @@ HIDE_UNDOC_RELATIONS = YES # set to NO # The default value is: YES. -HAVE_DOT = @HAVE_DOT@ +HAVE_DOT = @DOXYGEN_DOT_FOUND@ # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed # to run in parallel. When set to 0 doxygen will base this on the number of @@ -2231,7 +2231,7 @@ INTERACTIVE_SVG = YES # found. If left blank, it is assumed the dot tool can be found in the path. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_PATH = @DOTDIR@ +DOT_PATH = @DOXYGEN_DOT_PATH@ # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the \dotfile -- cgit v1.2.3-70-g09d2 From fa1b5d86bf5ba20047774014b422e7c30ee13a9c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 9 Aug 2016 17:39:25 +0200 Subject: Add statvfs.h.in to CMake directory Gbp-Dch: ignore --- CMake/statvfs.h.in | 13 +++++++++++++ CMakeLists.txt | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 CMake/statvfs.h.in (limited to 'CMake') diff --git a/CMake/statvfs.h.in b/CMake/statvfs.h.in new file mode 100644 index 000000000..d0ec238ad --- /dev/null +++ b/CMake/statvfs.h.in @@ -0,0 +1,13 @@ +/* Compatibility for systems with out Single Unix Spec statvfs */ +#include + +#ifdef HAVE_VFS_H +#include +#endif + +#ifdef HAVE_MOUNT_H +#include +#include +#endif + +#define statvfs statfs diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f9ca02b8..80b9c380c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,7 +92,7 @@ if (NOT HAVE_STATVFS) if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H) message(FATAL_ERROR "Can find neither statvfs() nor statfs()") endif() - configure_file(buildlib/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h @ONLY) + configure_file(CMake/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h @ONLY) endif() CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE) -- cgit v1.2.3-70-g09d2