diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-10-26 12:10:05 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-10-26 12:10:05 +0100 |
commit | a3c012dfddd24ea0990ac66357d1ec5211c906a0 (patch) | |
tree | 1fbce8d79376d671010533fe5045475464b3ec64 | |
parent | d720a7987adee52f4da1d316270be5188331d6f8 (diff) | |
parent | e672e51267ff87405700cbb80807aa6a678a06a5 (diff) | |
download | ayatana-indicator-bluetooth-a3c012dfddd24ea0990ac66357d1ec5211c906a0.tar.gz ayatana-indicator-bluetooth-a3c012dfddd24ea0990ac66357d1ec5211c906a0.tar.bz2 ayatana-indicator-bluetooth-a3c012dfddd24ea0990ac66357d1ec5211c906a0.zip |
Merge branch 'sunweaver-pr/cmake-port'
Attributes GH PR #9: https://github.com/AyatanaIndicators/ayatana-indicator-bluetooth/pull/9
-rw-r--r-- | CMakeLists.txt | 59 | ||||
-rw-r--r-- | Makefile.am | 9 | ||||
-rwxr-xr-x | autogen.sh | 12 | ||||
-rw-r--r-- | cmake/COPYING-CMAKE-SCRIPTS | 22 | ||||
-rw-r--r-- | cmake/FindGObjectIntrospection.cmake | 61 | ||||
-rw-r--r-- | cmake/FindVala.cmake | 57 | ||||
-rw-r--r-- | cmake/UseGObjectIntrospection.cmake | 100 | ||||
-rw-r--r-- | cmake/UseVala.cmake | 241 | ||||
-rw-r--r-- | config.h.in | 25 | ||||
-rw-r--r-- | configure.ac | 73 | ||||
-rw-r--r-- | data/CMakeLists.txt | 76 | ||||
-rw-r--r-- | data/Makefile.am | 40 | ||||
-rw-r--r-- | data/ayatana-indicator-bluetooth.desktop.in | 2 | ||||
-rw-r--r-- | data/ayatana-indicator-bluetooth.service.in | 2 | ||||
-rw-r--r-- | debian/control | 4 | ||||
-rwxr-xr-x | debian/rules | 15 | ||||
-rw-r--r-- | po/CMakeLists.txt | 6 | ||||
-rw-r--r-- | po/POTFILES.skip | 6 | ||||
-rw-r--r-- | src/CMakeLists.txt | 180 | ||||
-rw-r--r-- | src/Makefile.am | 39 |
20 files changed, 838 insertions, 191 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2318395 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,59 @@ +project(ayatana-indicator-bluetooth C CXX) +cmake_minimum_required(VERSION 2.8.9) + +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}") + +set(PACKAGE ${CMAKE_PROJECT_NAME}) +set(PROJECT_VERSION 0.8.0) +find_package(PkgConfig REQUIRED) +include(GNUInstallDirs) +include(UseVala) + +set(GETTEXT_PACKAGE "ayatana-indicator-bluetooth") +set(LOCALEDIR "${CMAKE_INSTALL_FULL_DATADIR}/locale") +add_definitions( -DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}" ) + +set(SOURCE_DIR "${CMAKE_SOURCE_DIR}/src") +set(SOURCE_BINARY_DIR "${CMAKE_BINARY_DIR}/src") + +set(GLIB_2_0_REQUIRED_VERSION 2.32) +set(GIO_2_0_REQUIRED_VERSION 2.25.13) + +pkg_check_modules( + BLUETOOTHSERVICE REQUIRED + glib-2.0>=${GLIB_2_0_REQUIRED_VERSION} + gio-unix-2.0>=${GIO_2_0_REQUIRED_VERSION} +) + +include_directories(${BLUETOOTHSERVICE_INCLUDE_DIRS}) + +set(URL_DISPATCHER_REQUIRED_VERSION 0.1) + +pkg_check_modules( + URLDISPATCHER + lomiri-url-dispatcher>=${URL_DISPATCHER_REQUIRED_VERSION} +) +include_directories(${URLDISPATCHER_INCLUDE_DIRS}) + +find_package(Vala 0.20) + +find_package(GObjectIntrospection 0.9.12) + +include_directories(${SOURCE_DIR}) +include_directories(${SOURCE_BINARY_DIR}) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + +add_definitions( + -Wall +) + +configure_file( + "config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/config.h" +) + +add_subdirectory(data) +add_subdirectory(src) +add_subdirectory(po) diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 4772941..0000000 --- a/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -SUBDIRS = data po src - -EXTRA_DIST = \ - autogen.sh \ - NEWS \ - vapi/config.vapi \ - vapi/rfkill.vapi - -DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 82480e7..0000000 --- a/autogen.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -PKG_NAME="indicator-bluetooth" - -which gnome-autogen.sh || { - echo "You need gnome-common" - exit 1 -} - -USE_GNOME2_MACROS=1 \ -. gnome-autogen.sh - diff --git a/cmake/COPYING-CMAKE-SCRIPTS b/cmake/COPYING-CMAKE-SCRIPTS new file mode 100644 index 0000000..4b41776 --- /dev/null +++ b/cmake/COPYING-CMAKE-SCRIPTS @@ -0,0 +1,22 @@ +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. diff --git a/cmake/FindGObjectIntrospection.cmake b/cmake/FindGObjectIntrospection.cmake new file mode 100644 index 0000000..2073c3c --- /dev/null +++ b/cmake/FindGObjectIntrospection.cmake @@ -0,0 +1,61 @@ +# - try to find gobject-introspection +# +# Once done this will define +# +# INTROSPECTION_FOUND - system has gobject-introspection +# INTROSPECTION_SCANNER - the gobject-introspection scanner, g-ir-scanner +# INTROSPECTION_COMPILER - the gobject-introspection compiler, g-ir-compiler +# INTROSPECTION_GENERATE - the gobject-introspection generate, g-ir-generate +# INTROSPECTION_GIRDIR +# INTROSPECTION_TYPELIBDIR +# INTROSPECTION_CFLAGS +# INTROSPECTION_LIBS +# +# Copyright (C) 2010, Pino Toscano, <pino@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +macro(_GIR_GET_PKGCONFIG_VAR _outvar _varname) + execute_process( + COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_varname} gobject-introspection-1.0 + OUTPUT_VARIABLE _result + RESULT_VARIABLE _null + ) + + if (_null) + else() + string(REGEX REPLACE "[\r\n]" " " _result "${_result}") + string(REGEX REPLACE " +$" "" _result "${_result}") + separate_arguments(_result) + set(${_outvar} ${_result} CACHE INTERNAL "") + endif() +endmacro(_GIR_GET_PKGCONFIG_VAR) + +find_package(PkgConfig) +if(PKG_CONFIG_FOUND) + if(PACKAGE_FIND_VERSION_COUNT GREATER 0) + set(_gir_version_cmp ">=${PACKAGE_FIND_VERSION}") + endif() + pkg_check_modules(_pc_gir gobject-introspection-1.0${_gir_version_cmp}) + if(_pc_gir_FOUND) + set(INTROSPECTION_FOUND TRUE) + _gir_get_pkgconfig_var(INTROSPECTION_SCANNER "g_ir_scanner") + _gir_get_pkgconfig_var(INTROSPECTION_COMPILER "g_ir_compiler") + _gir_get_pkgconfig_var(INTROSPECTION_GENERATE "g_ir_generate") + _gir_get_pkgconfig_var(INTROSPECTION_GIRDIR "girdir") + _gir_get_pkgconfig_var(INTROSPECTION_TYPELIBDIR "typelibdir") + set(INTROSPECTION_CFLAGS "${_pc_gir_CFLAGS}") + set(INTROSPECTION_LIBS "${_pc_gir_LIBS}") + endif() +endif() + +mark_as_advanced( + INTROSPECTION_SCANNER + INTROSPECTION_COMPILER + INTROSPECTION_GENERATE + INTROSPECTION_GIRDIR + INTROSPECTION_TYPELIBDIR + INTROSPECTION_CFLAGS + INTROSPECTION_LIBS +) diff --git a/cmake/FindVala.cmake b/cmake/FindVala.cmake new file mode 100644 index 0000000..a638735 --- /dev/null +++ b/cmake/FindVala.cmake @@ -0,0 +1,57 @@ +# - Find Vala +# This module looks for valac. +# This module defines the following values: +# VALA_FOUND +# VALA_COMPILER +# VALA_VERSION +# VAPI_GEN +# VAPI_GEN_VERSION + +#============================================================================= +# Copyright Přemysl Janouch 2011 +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``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 COPYRIGHT HOLDERS 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_program (VALA_COMPILER "valac") + +if (VALA_COMPILER) + execute_process (COMMAND ${VALA_COMPILER} --version + OUTPUT_VARIABLE VALA_VERSION) + string (REGEX MATCH "[.0-9]+" VALA_VERSION "${VALA_VERSION}") +endif (VALA_COMPILER) + +find_program (VAPI_GEN "vapigen") + +if (VAPI_GEN) + execute_process (COMMAND ${VAPI_GEN} --version + OUTPUT_VARIABLE VAPI_GEN_VERSION) + string (REGEX MATCH "[.0-9]+" VAPI_GEN_VERSION "${VAPI_GEN_VERSION}") +endif (VAPI_GEN) + +include (FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS (Vala + REQUIRED_VARS VALA_COMPILER + VERSION_VAR VALA_VERSION) + +mark_as_advanced (VALA_COMPILER VALA_VERSION VAPI_GEN) + diff --git a/cmake/UseGObjectIntrospection.cmake b/cmake/UseGObjectIntrospection.cmake new file mode 100644 index 0000000..d6d1810 --- /dev/null +++ b/cmake/UseGObjectIntrospection.cmake @@ -0,0 +1,100 @@ +# Copyright (C) 2010, Pino Toscano, <pino@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +include(ListOperations) + +macro(_gir_list_prefix _outvar _listvar _prefix) + set(${_outvar}) + foreach(_item IN LISTS ${_listvar}) + list(APPEND ${_outvar} ${_prefix}${_item}) + endforeach() +endmacro(_gir_list_prefix) + +macro(gir_add_introspections introspections_girs) + + foreach(gir IN LISTS ${introspections_girs}) + + set(_gir_name "${gir}") + + ## Transform the gir filename to something which can reference through a variable + ## without automake/make complaining, eg Gtk-2.0.gir -> Gtk_2_0_gir + string(REPLACE "-" "_" _gir_name "${_gir_name}") + string(REPLACE "." "_" _gir_name "${_gir_name}") + + # Namespace and Version is either fetched from the gir filename + # or the _NAMESPACE/_VERSION variable combo + set(_gir_namespace "${${_gir_name}_NAMESPACE}") + if (_gir_namespace STREQUAL "") + string(REGEX REPLACE "([^-]+)-.*" "\\1" _gir_namespace "${gir}") + endif () + set(_gir_version "${${_gir_name}_VERSION}") + if (_gir_version STREQUAL "") + string(REGEX REPLACE ".*-([^-]+).gir" "\\1" _gir_version "${gir}") + endif () + + # _PROGRAM is an optional variable which needs it's own --program argument + set(_gir_program "${${_gir_name}_PROGRAM}") + if (NOT _gir_program STREQUAL "") + set(_gir_program "--program=${_gir_program}") + endif () + + # Variables which provides a list of things + _gir_list_prefix(_gir_libraries ${_gir_name}_LIBS "--library=") + _gir_list_prefix(_gir_packages ${_gir_name}_PACKAGES "--pkg=") + _gir_list_prefix(_gir_includes ${_gir_name}_INCLUDES "--include=") + _gir_list_prefix(_gir_export_packages ${_gir_name}_EXPORT_PACKAGES "--pkg-export=") + + # Reuse the LIBTOOL variable from by automake if it's set + set(_gir_libtool "--no-libtool") + + add_custom_command( + COMMAND ${INTROSPECTION_SCANNER} + ${INTROSPECTION_SCANNER_ARGS} + --namespace=${_gir_namespace} + --nsversion=${_gir_version} + ${_gir_libtool} + ${_gir_program} + ${_gir_libraries} + ${_gir_packages} + ${_gir_includes} + ${_gir_export_packages} + ${${_gir_name}_SCANNERFLAGS} + ${${_gir_name}_CFLAGS} + ${${_gir_name}_FILES} + --output ${CMAKE_CURRENT_BINARY_DIR}/${gir} + DEPENDS ${${_gir_name}_FILES} + ${${_gir_name}_LIBS} + OUTPUT ${gir} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + VERBATIM + ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${gir} DESTINATION share/gir-1.0) + + string(REPLACE ".gir" ".typelib" _typelib "${gir}") + add_custom_command( + COMMAND ${INTROSPECTION_COMPILER} + ${INTROSPECTION_COMPILER_ARGS} + --includedir=. + ${CMAKE_CURRENT_BINARY_DIR}/${gir} + -o ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir} + OUTPUT ${_typelib} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DESTINATION ${CMAKE_INSTALL_LIBDIR}/girepository-1.0) + + add_custom_target(gir-${gir} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir}) + add_custom_target(gir-typelibs-${_typelib} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_typelib}) + endforeach() + +endmacro(gir_add_introspections) + +macro(gir_get_cflags _output) + get_directory_property(_tmp_includes INCLUDE_DIRECTORIES) + list_prefix(_includes _tmp_includes "-I") + get_directory_property(_tmp_compile_definitions COMPILE_DEFINITIONS) + list_prefix(_compile_definitions _tmp_compile_definitions "-D") + set(${_output} ${_includes} ${_compile_definitions}) +endmacro(gir_get_cflags) diff --git a/cmake/UseVala.cmake b/cmake/UseVala.cmake new file mode 100644 index 0000000..f0202e2 --- /dev/null +++ b/cmake/UseVala.cmake @@ -0,0 +1,241 @@ +# - Precompilation of Vala/Genie source files into C sources +# Makes use of the parallel build ability introduced in Vala 0.11. Derived +# from a similar module by Jakob Westhoff and the original GNU Make rules. +# Might be a bit oversimplified. +# +# This module defines three functions. The first one: +# +# vala_init (id +# [DIRECTORY dir] - Output directory (binary dir by default) +# [PACKAGES package...] - Package dependencies +# [OPTIONS option...] - Extra valac options +# [CUSTOM_VAPIS file...]) - Custom vapi files to include in the build +# [DEPENDS targets...]) - Extra dependencies for code generation +# +# initializes a single precompilation unit using the given arguments. +# You can put files into it via the following function: +# +# vala_add (id source.vala +# [DEPENDS source...]) - Vala/Genie source or .vapi dependencies +# +# Finally retrieve paths for generated C files by calling: +# +# vala_finish (id +# [SOURCES sources_var] - Input Vala/Genie sources +# [OUTPUTS outputs_var] - Output C sources +# [GENERATE_HEADER id.h - Generate id.h and id_internal.h +# [GENERATE_VAPI id.vapi] - Generate a vapi file +# [GENERATE_SYMBOLS id.def]]) - Generate a list of public symbols +# + +#============================================================================= +# Copyright Přemysl Janouch 2011 +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``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 COPYRIGHT HOLDERS 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_package (Vala 0.20 REQUIRED) +include (CMakeParseArguments) + +function (vala_init id) + set (_multi_value PACKAGES OPTIONS CUSTOM_VAPIS DEPENDS) + cmake_parse_arguments (arg "" "DIRECTORY" "${_multi_value}" ${ARGN}) + + if (arg_DIRECTORY) + set (directory ${arg_DIRECTORY}) + if (NOT IS_DIRECTORY ${directory}) + file (MAKE_DIRECTORY ${directory}) + endif (NOT IS_DIRECTORY ${directory}) + else (arg_DIRECTORY) + set (directory ${CMAKE_CURRENT_BINARY_DIR}) + endif (arg_DIRECTORY) + + set (pkg_opts) + foreach (pkg ${arg_PACKAGES}) + list (APPEND pkg_opts "--pkg=${pkg}") + endforeach (pkg) + + set (VALA_${id}_DIR "${directory}" PARENT_SCOPE) + set (VALA_${id}_ARGS ${pkg_opts} ${arg_OPTIONS} + ${arg_CUSTOM_VAPIS} PARENT_SCOPE) + set (VALA_${id}_DEPENDS ${arg_DEPENDS} + PARENT_SCOPE) + + set (VALA_${id}_SOURCES "" PARENT_SCOPE) + set (VALA_${id}_OUTPUTS "" PARENT_SCOPE) + set (VALA_${id}_FAST_VAPI_FILES "" PARENT_SCOPE) + set (VALA_${id}_FAST_VAPI_ARGS "" PARENT_SCOPE) +endfunction (vala_init) + +function (vala_add id file) + cmake_parse_arguments (arg "" "" "DEPENDS" ${ARGN}) + + if (NOT IS_ABSOLUTE "${file}") + set (file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") + endif (NOT IS_ABSOLUTE "${file}") + + get_filename_component (output_name "${file}" NAME) + get_filename_component (output_base "${file}" NAME_WE) + set (output_base "${VALA_${id}_DIR}/${output_base}") + + # XXX: It would be best to have it working without touching the vapi + # but it appears this cannot be done in CMake. + add_custom_command (OUTPUT "${output_base}.vapi" + COMMAND ${VALA_COMPILER} "${file}" "--fast-vapi=${output_base}.vapi" + COMMAND ${CMAKE_COMMAND} -E touch "${output_base}.vapi" + DEPENDS "${file}" + COMMENT "Generating a fast vapi for ${output_name}" VERBATIM) + + set (vapi_opts) + set (vapi_depends) + foreach (vapi ${arg_DEPENDS}) + if (NOT IS_ABSOLUTE "${vapi}") + set (vapi "${VALA_${id}_DIR}/${vapi}.vapi") + endif (NOT IS_ABSOLUTE "${vapi}") + + list (APPEND vapi_opts "--use-fast-vapi=${vapi}") + list (APPEND vapi_depends "${vapi}") + endforeach (vapi) + + add_custom_command (OUTPUT "${output_base}.c" + COMMAND ${VALA_COMPILER} "${file}" -C ${vapi_opts} ${VALA_${id}_ARGS} + COMMAND ${CMAKE_COMMAND} -E touch "${output_base}.c" + DEPENDS "${file}" ${vapi_depends} ${VALA_${id}_DEPENDS} + WORKING_DIRECTORY "${VALA_${id}_DIR}" + COMMENT "Precompiling ${output_name}" VERBATIM) + + set (VALA_${id}_SOURCES ${VALA_${id}_SOURCES} + "${file}" PARENT_SCOPE) + set (VALA_${id}_OUTPUTS ${VALA_${id}_OUTPUTS} + "${output_base}.c" PARENT_SCOPE) + set (VALA_${id}_FAST_VAPI_FILES ${VALA_${id}_FAST_VAPI_FILES} + "${output_base}.vapi" PARENT_SCOPE) + set (VALA_${id}_FAST_VAPI_ARGS ${VALA_${id}_FAST_VAPI_ARGS} + "--use-fast-vapi=${output_base}.vapi" PARENT_SCOPE) +endfunction (vala_add) + +function (vala_finish id) + set (_one_value SOURCES OUTPUTS + GENERATE_VAPI GENERATE_HEADER GENERATE_SYMBOLS) + cmake_parse_arguments (arg "" "${_one_value}" "" ${ARGN}) + + if (arg_SOURCES) + set (${arg_SOURCES} ${VALA_${id}_SOURCES} PARENT_SCOPE) + endif (arg_SOURCES) + + if (arg_OUTPUTS) + set (${arg_OUTPUTS} ${VALA_${id}_OUTPUTS} PARENT_SCOPE) + endif (arg_OUTPUTS) + + set (outputs) + set (export_args) + + if (arg_GENERATE_VAPI) + if (NOT IS_ABSOLUTE "${arg_GENERATE_VAPI}") + set (arg_GENERATE_VAPI + "${VALA_${id}_DIR}/${arg_GENERATE_VAPI}") + endif (NOT IS_ABSOLUTE "${arg_GENERATE_VAPI}") + + list (APPEND outputs "${arg_GENERATE_VAPI}") + list (APPEND export_args "--internal-vapi=${arg_GENERATE_VAPI}") + + if (NOT arg_GENERATE_HEADER) + message (FATAL_ERROR "Header generation required for vapi") + endif (NOT arg_GENERATE_HEADER) + endif (arg_GENERATE_VAPI) + + if (arg_GENERATE_SYMBOLS) + if (NOT IS_ABSOLUTE "${arg_GENERATE_SYMBOLS}") + set (arg_GENERATE_SYMBOLS + "${VALA_${id}_DIR}/${arg_GENERATE_SYMBOLS}") + endif (NOT IS_ABSOLUTE "${arg_GENERATE_SYMBOLS}") + + list (APPEND outputs "${arg_GENERATE_SYMBOLS}") + list (APPEND export_args "--symbols=${arg_GENERATE_SYMBOLS}") + + if (NOT arg_GENERATE_HEADER) + message (FATAL_ERROR "Header generation required for symbols") + endif (NOT arg_GENERATE_HEADER) + endif (arg_GENERATE_SYMBOLS) + + if (arg_GENERATE_HEADER) + if (NOT IS_ABSOLUTE "${arg_GENERATE_HEADER}") + set (arg_GENERATE_HEADER + "${VALA_${id}_DIR}/${arg_GENERATE_HEADER}") + endif (NOT IS_ABSOLUTE "${arg_GENERATE_HEADER}") + + get_filename_component (header_path "${arg_GENERATE_HEADER}" PATH) + get_filename_component (header_name "${arg_GENERATE_HEADER}" NAME_WE) + set (header_base "${header_path}/${header_name}") + get_filename_component (header_ext "${arg_GENERATE_HEADER}" EXT) + + list (APPEND outputs + "${header_base}${header_ext}" + "${header_base}_internal${header_ext}") + list (APPEND export_args + "--header=${header_base}${header_ext}" + "--internal-header=${header_base}_internal${header_ext}") + endif (arg_GENERATE_HEADER) + + if (outputs) + add_custom_command (OUTPUT ${outputs} + COMMAND ${VALA_COMPILER} -C ${VALA_${id}_ARGS} + ${export_args} ${VALA_${id}_FAST_VAPI_ARGS} + DEPENDS ${VALA_${id}_FAST_VAPI_FILES} + COMMENT "Generating vapi/headers/symbols" VERBATIM) + endif (outputs) +endfunction (vala_finish id) + + +function (vapi_gen id) + set (_one_value LIBRARY INPUT) + set (_multi_value PACKAGES) + cmake_parse_arguments (arg "" "${_one_value}" "${_multi_value}" ${ARGN}) + + set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${id}.vapi") + if (arg_LIBRARY) + set (OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${arg_LIBRARY}.vapi") + endif (arg_LIBRARY) + + set("${id}_OUTPUT" ${OUTPUT} PARENT_SCOPE) + + set(PACKAGE_LIST) + foreach(PACKAGE ${arg_PACKAGES}) + list(APPEND PACKAGE_LIST "--pkg" ${PACKAGE}) + endforeach() + + add_custom_command( + OUTPUT + ${OUTPUT} + COMMAND + ${VAPI_GEN} + ${PACKAGE_LIST} + --library=${arg_LIBRARY} + ${arg_INPUT} + DEPENDS + ${arg_INPUT} + VERBATIM + ) + + add_custom_target(${id} ALL DEPENDS ${OUTPUT}) +endfunction (vapi_gen id) + diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..ffc2202 --- /dev/null +++ b/config.h.in @@ -0,0 +1,25 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Author: Pete Woods <pete.woods@canonical.com> + */ + +#ifndef AYATANA_INDICATOR_BLUETOOTH_CONFIG_H_ +#define AYATANA_INDICATOR_BLUETOOTH_CONFIG_H_ + +#define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@" +#define LOCALEDIR "@LOCALEDIR@" + +#endif // AYATANA_INDICATOR_BLUETOOTH_CONFIG_H_ diff --git a/configure.ac b/configure.ac deleted file mode 100644 index c5e9aa9..0000000 --- a/configure.ac +++ /dev/null @@ -1,73 +0,0 @@ -AC_INIT([ayatana-indicator-bluetooth],[13.10.0]) -AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz foreign]) -AC_CONFIG_HEADERS([config.h]) -AM_SILENT_RULES([yes]) -AM_MAINTAINER_MODE - -AM_PROG_VALAC([0.16.0]) -AM_PROG_CC_C_O -LT_INIT - -GLIB_GSETTINGS - -dnl ########################################################################### -dnl Dependencies -dnl ########################################################################### - -GLIB_REQUIRED_VERSION=2.36 -GIO_REQUIRED_VERSION=2.36 -URL_DISPATCHER_1_REQUIRED_VERSION=1 - -PKG_CHECK_MODULES(SERVICE_DEPS, [glib-2.0 >= $GLIB_REQUIRED_VERSION - gio-unix-2.0 >= $GIO_REQUIRED_VERSION]) - -PKG_CHECK_EXISTS(url-dispatcher-1, - [have_urldispatcher="yes"], - [have_urldispatcher="no"]) - -if test "x$have_urldispatcher" == "xyes"; then - PKG_CHECK_MODULES(URL_DISPATCHER, [url-dispatcher-1 >= $URL_DISPATCHER_1_REQUIRED_VERSION]) -fi - -SYSTEMD_USERDIR=`$PKG_CONFIG --variable=systemduserunitdir systemd` -AC_SUBST(SYSTEMD_USERDIR) - -dnl ############################## -dnl # Custom Junk -dnl ############################## - -AC_DEFUN([AC_DEFINE_PATH], [ - test "x$prefix" = xNONE && prefix="$ac_default_prefix" - test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - ac_define_path=`eval echo [$]$2` - ac_define_path=`eval echo [$]ac_define_path` - $1="$ac_define_path" - AC_SUBST($1) - ifelse($3, , - AC_DEFINE_UNQUOTED($1, "$ac_define_path"), - AC_DEFINE_UNQUOTED($1, "$ac_define_path", $3)) -]) - -dnl ########################### -dnl # Internationalization -dnl ########################### - -IT_PROG_INTLTOOL([0.41.0]) - -GETTEXT_PACKAGE=ayatana-indicator-bluetooth -AC_SUBST(GETTEXT_PACKAGE) -AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Name of the default get text domain]) -AC_DEFINE_PATH(LOCALEDIR, "${datadir}/locale", [locale directory]) - -AM_GLIB_GNU_GETTEXT - -dnl ########################################################################### -dnl Files to generate -dnl ########################################################################### - -AC_OUTPUT([ -Makefile -data/Makefile -po/Makefile.in -src/Makefile -]) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt new file mode 100644 index 0000000..a423f5b --- /dev/null +++ b/data/CMakeLists.txt @@ -0,0 +1,76 @@ + +find_package(GSettings) + +########################### +# Indicator service +########################### + +set( + INDICATOR_DIR + "${CMAKE_INSTALL_DATADIR}/ayatana/indicators" + CACHE FILEPATH "Ayatana Indicators Directory" +) + +install( + FILES "org.ayatana.indicator.bluetooth" + DESTINATION "${INDICATOR_DIR}" +) + +########################### +# Systemd Job +########################### + +pkg_check_modules(SYSTEMD systemd) +if (${SYSTEMD_FOUND}) + + # where to install + pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir) + message (STATUS "${SYSTEMD_USER_DIR} is the systemd user unit file install dir") + + set (SYSTEMD_USER_NAME "${CMAKE_PROJECT_NAME}.service") + set (SYSTEMD_USER_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SYSTEMD_USER_NAME}") + set (SYSTEMD_USER_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${SYSTEMD_USER_NAME}.in") + + # build it + set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") + configure_file ("${SYSTEMD_USER_FILE_IN}" "${SYSTEMD_USER_FILE}") + + # install it + install (FILES "${SYSTEMD_USER_FILE}" + DESTINATION "${SYSTEMD_USER_DIR}") +endif() + +########################### +# XDG Autostart +########################### + +set( + INDICATOR_BLUETOOTH_XDG_AUTOSTART + "${CMAKE_CURRENT_BINARY_DIR}/ayatana-indicator-bluetooth.desktop" +) + +configure_file( + "ayatana-indicator-bluetooth.desktop.in" + ${INDICATOR_BLUETOOTH_XDG_AUTOSTART} + @ONLY +) + +install( + FILES "${INDICATOR_BLUETOOTH_XDG_AUTOSTART}" + DESTINATION "/etc/xdg/autostart" +) + +########################### +# GSettings +########################### + +set (SCHEMA_NAME "org.ayatana.indicator.bluetooth.gschema.xml") +set (SCHEMA_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME}") +set (SCHEMA_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME}.in") + +# generate the .xml file using intltool +set (ENV{LC_ALL} "C") +execute_process (COMMAND intltool-merge -quiet --xml-style --utf8 --no-translations "${SCHEMA_FILE_IN}" "${SCHEMA_FILE}") + +# let UseGSettings do the rest +add_schema (${SCHEMA_NAME}) diff --git a/data/Makefile.am b/data/Makefile.am deleted file mode 100644 index e9ef0b9..0000000 --- a/data/Makefile.am +++ /dev/null @@ -1,40 +0,0 @@ -BUILT_SOURCES = -EXTRA_DIST = -CLEANFILES = - -# the indicator bus file -indicatorsdir = $(datadir)/ayatana/indicators -dist_indicators_DATA = org.ayatana.indicator.bluetooth - -# the systemd unit file -systemddir = $(SYSTEMD_USERDIR) -systemd_DATA = ayatana-indicator-bluetooth.service -systemd_in = $(systemd_DATA:.service=.service.in) -$(systemd_DATA): $(systemd_in) - $(AM_V_GEN) $(SED) -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ -BUILT_SOURCES += $(systemd_DATA) -EXTRA_DIST += $(systemd_in) -CLEANFILES += $(systemd_DATA) - -# the xdg autostart job file -xdg_autostartdir = /etc/xdg/autostart -xdg_autostart_DATA = ayatana-indicator-bluetooth.desktop -xdg_autostart_in = $(xdg_autostart_DATA:.desktop=.desktop.in) -$(xdg_autostart_DATA): $(xdg_autostart_in) - $(AM_V_GEN) $(SED) -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ -BUILT_SOURCES += $(xdg_autostart_DATA) -EXTRA_DIST += $(xdg_autostart_in) -CLEANFILES += $(xdg_autostart_DATA) - -# the gsettings schema -gsettings_SCHEMAS = org.ayatana.indicator.bluetooth.gschema.xml -@INTLTOOL_XML_NOMERGE_RULE@ -@GSETTINGS_RULES@ - -EXTRA_DIST += \ - org.ayatana.indicator.bluetooth.gschema.xml.in \ - ayatana-indicator-bluetooth.desktop.in - -CLEANFILES += \ - $(dbus_services_DATA) \ - $(gsettings_SCHEMAS) diff --git a/data/ayatana-indicator-bluetooth.desktop.in b/data/ayatana-indicator-bluetooth.desktop.in index 8eb5e1f..871e80a 100644 --- a/data/ayatana-indicator-bluetooth.desktop.in +++ b/data/ayatana-indicator-bluetooth.desktop.in @@ -1,7 +1,7 @@ [Desktop Entry] Type=Application Name=Ayatana Indicator Bluetooth -Exec=@pkglibexecdir@/ayatana-indicator-bluetooth/ayatana-indicator-bluetooth-service +Exec=@CMAKE_INSTALL_FULL_LIBEXECDIR@/ayatana-indicator-bluetooth/ayatana-indicator-bluetooth-service NoDisplay=true StartupNotify=false Terminal=false diff --git a/data/ayatana-indicator-bluetooth.service.in b/data/ayatana-indicator-bluetooth.service.in index 92344c8..aa513b6 100644 --- a/data/ayatana-indicator-bluetooth.service.in +++ b/data/ayatana-indicator-bluetooth.service.in @@ -4,7 +4,7 @@ PartOf=graphical-session.target PartOf=ayatana-indicators.target [Service] -ExecStart=@pkglibexecdir@/ayatana-indicator-bluetooth/ayatana-indicator-bluetooth-service +ExecStart=@CMAKE_INSTALL_FULL_LIBEXECDIR@/ayatana-indicator-bluetooth/ayatana-indicator-bluetooth-service Restart=on-failure [Install] diff --git a/debian/control b/debian/control index a66d6fe..56c2823 100644 --- a/debian/control +++ b/debian/control @@ -3,9 +3,9 @@ Section: gnome Priority: optional Maintainer: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Build-Depends: debhelper (>= 9.0), - dh-autoreconf, dh-systemd, - gnome-common, + cmake, + cmake-extras (>= 0.10), libglib2.0-dev (>= 2.32.0), liburl-dispatcher1-dev | hello, systemd [linux-any], diff --git a/debian/rules b/debian/rules index 542fd05..decbbae 100755 --- a/debian/rules +++ b/debian/rules @@ -5,15 +5,14 @@ NULL = export DPKG_GENSYMBOLS_CHECK_LEVEL=4 %: - dh $@ --parallel --with systemd --with autoreconf + dh $@ --parallel --with systemd -override_dh_autoreconf: - NOCONFIGURE=1 dh_autoreconf ./autogen.sh - -override_dh_install: - dh_install - find debian/ayatana-indicator-bluetooth/usr/lib -name *.la -delete - find debian/ayatana-indicator-bluetooth/usr/lib -name *.a -delete +override_dh_auto_configure: + # Debian defines CMAKE_INSTALL_LOCALSTATEDIR as /usr/var, which is wrong. + # So until Debian bug 719148 is fixed, do it ourselves. + dh_auto_configure -- -DCMAKE_INSTALL_LOCALSTATEDIR="/var" \ + -Denable_tests=off \ + $(NULL) override_dh_missing: dh_missing --fail-missing diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt new file mode 100644 index 0000000..0b2b2a1 --- /dev/null +++ b/po/CMakeLists.txt @@ -0,0 +1,6 @@ +find_package(Intltool REQUIRED) + +intltool_install_translations( + ALL + GETTEXT_PACKAGE ${GETTEXT_PACKAGE} +) diff --git a/po/POTFILES.skip b/po/POTFILES.skip index d18c96e..e69de29 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -1,6 +0,0 @@ -src/bluez.c -src/desktop.c -src/indicator-bluetooth.c -src/indicator-bluetooth-service.c -src/phone.c -src/profile.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..d718180 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,180 @@ +########################### +# Vala Generation +########################### + +set(HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/ayatana-indicator-bluetooth-service.h") +set(SYMBOLS_PATH "${CMAKE_CURRENT_BINARY_DIR}/ayatana-indicator-bluetooth-service.def") +set(VAPI_PATH "${CMAKE_CURRENT_BINARY_DIR}/ayatana-indicator-bluetooth-service.vapi") + +if(URLDISPATCHER_FOUND) + set (VALA_DEFINE_URLDISPATCHER "--define=HAS_URLDISPATCHER") + set (VALA_PKG_URLDISPATCHER "url-dispatcher") +endif() + +vala_init(ayatana-indicator-bluetooth-service + DEPENDS + PACKAGES + config + rfkill + posix + gio-2.0 + gio-unix-2.0 + ${VALA_PKG_URLDISPATCHER} + OPTIONS + --ccode + --target-glib=${GLIB_2_0_REQUIRED_VERSION} + --vapidir=${CMAKE_SOURCE_DIR}/vapi/ + --vapidir=. + ${VALA_DEFINE_URLDISPATCHER} +) + +vala_add(ayatana-indicator-bluetooth-service +main.vala + DEPENDS + service + bluetooth + device + bluez + killswitch +) + +vala_add(ayatana-indicator-bluetooth-service + bluetooth.vala + DEPENDS + device +) + +vala_add(ayatana-indicator-bluetooth-service + bluez.vala + DEPENDS + bluetooth + killswitch + device +) + +vala_add(ayatana-indicator-bluetooth-service + desktop.vala + DEPENDS + profile + bluetooth + device +) + +vala_add(ayatana-indicator-bluetooth-service + device.vala +) + +vala_add(ayatana-indicator-bluetooth-service + killswitch.vala +) + +vala_add(ayatana-indicator-bluetooth-service + phone.vala + DEPENDS + profile + bluetooth + device +) + +vala_add(ayatana-indicator-bluetooth-service + profile.vala + DEPENDS + bluetooth + device +) + +vala_add(ayatana-indicator-bluetooth-service + service.vala + DEPENDS + bluetooth + profile + device + phone + desktop +) + +vala_finish(ayatana-indicator-bluetooth-service + SOURCES + project_VALA_SOURCES + OUTPUTS + project_VALA_C + GENERATE_HEADER + ${HEADER_PATH} + GENERATE_SYMBOLS + ${SYMBOLS_PATH} + GENERATE_VAPI + ${VAPI_PATH} +) + +set_source_files_properties( + ${project_VALA_SOURCES} + PROPERTIES + HEADER_FILE_ONLY TRUE +) + +set( + INDICATOR_BLUETOOTH_SOURCES + ${project_VALA_SOURCES} + ${project_VALA_C} + ${SYMBOLS_PATH} +) + +########################### +# Lib +########################### + +add_definitions( + -w + -DG_LOG_DOMAIN="ayatana-indicator-bluetooth" +) + +add_library( + ayatana-indicator-bluetooth-service-lib STATIC + ${INDICATOR_BLUETOOTH_SOURCES} +) + +target_link_libraries( + ayatana-indicator-bluetooth-service-lib + ${BLUETOOTHSERVICE_LIBRARIES} + ${URLDISPATCHER_LIBRARIES} + -lm +) + +########################### +# Executable +########################### + +include_directories(${CMAKE_BINARY_DIR}) + +add_executable( + ayatana-indicator-bluetooth-service-bin + ${project_VALA_C} +) + +set_target_properties( + ayatana-indicator-bluetooth-service-bin + PROPERTIES + OUTPUT_NAME "ayatana-indicator-bluetooth-service" +) + +target_link_libraries( + ayatana-indicator-bluetooth-service-bin + ayatana-indicator-bluetooth-service-lib +) + +########################### +# Installation +########################### + +install( + TARGETS ayatana-indicator-bluetooth-service-bin + RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/ayatana-indicator-bluetooth/ +) + +# coverage reporting +set(COVERAGE_TARGETS + ${COVERAGE_TARGETS} + ayatana-indicator-bluetooth-service-lib + ayatana-indicator-bluetooth-service-bin + PARENT_SCOPE +) diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index 44d6406..0000000 --- a/src/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -pkglibexec_PROGRAMS = ayatana-indicator-bluetooth-service - -ayatana_indicator_bluetooth_service_SOURCES = \ - bluetooth.vala \ - bluez.vala \ - desktop.vala \ - device.vala \ - main.vala \ - phone.vala \ - profile.vala \ - killswitch.vala \ - service.vala - -ayatana_indicator_bluetooth_service_VALAFLAGS = \ - --ccode \ - --vapidir=$(top_srcdir)/vapi/ \ - --vapidir=./ \ - --pkg config \ - --pkg rfkill \ - --pkg url-dispatcher \ - --pkg posix \ - --pkg glib-2.0 \ - --pkg gio-2.0 - -# -w to disable warnings for vala-generated code -ayatana_indicator_bluetooth_service_CFLAGS = \ - -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \ - -DLOCALE_DIR=\"$(datadir)/locale\" \ - -w \ - $(URL_DISPATCHER_CFLAGS) \ - $(SERVICE_DEPS_CFLAGS) - -ayatana_indicator_bluetooth_service_LDADD = \ - $(URL_DISPATCHER_LIBS) \ - $(SERVICE_DEPS_LIBS) - -CLEANFILES = \ - $(patsubst %.vala,%.c,$(filter %.vala, $(SOURCES))) \ - *_vala.stamp |