diff --git a/.travis.yml b/.travis.yml index 773513fd..e6895f74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: cpp +os: + - linux + - osx + compiler: - gcc - clang @@ -9,39 +13,34 @@ sudo: false git: depth: 1 -env: - global: - - LLVM_VERSION=3.7.0 - - LLVM_ARCHIVE_PATH=$HOME/clang+llvm.tar.xz - before_install: - - wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-14.04.tar.xz -O $LLVM_ARCHIVE_PATH - - mkdir $HOME/clang+llvm - - tar xf $LLVM_ARCHIVE_PATH -C $HOME/clang+llvm --strip-components 1 - - export PATH=$HOME/clang+llvm/bin:$PATH - - ln -s $HOME/clang+llvm/bin/clang++ $HOME/clang+llvm/bin/clang++-3.7 + - gem install md2man --no-rdoc --no-ri + - chmod +x ./install-dependencies.sh + - ./install-dependencies.sh addons: apt: sources: - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.7 packages: - - g++-5 - gcc-5 + - g++-5 + - clang-3.7 + - gettext - libhiredis-dev install: # install some packages from Ubuntu's default sources - - if [ "$CXX" = "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi - - if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi + - if [[ $CXX == 'g++' ]]; then export CXX="g++-5" CC="gcc-5"; fi + - if [[ $CXX == 'clang++' ]]; then export CXX="clang++-3.7"; fi +#FIXME: removes -Werror flag for osx check script: # make distcheck still does not work on travis - mkdir build && cd build && cmake .. - -DCMAKE_C_FLAGS="-Werror" - -DCMAKE_CXX_FLAGS="-Werror" && make VERBOSE=1 && (make test || true) @@ -49,4 +48,4 @@ after_script: - if test -f ./Testing/Temporary/LastTest.log; then echo "cat test logs:"; cat ./Testing/Temporary/LastTest.log; - fi + fi \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index fb21a08f..eb7cec71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required (VERSION 2.8) cmake_policy(VERSION 2.8) project(libonion) +set(CMAKE_MACOSX_RPATH 1) + # Some tweak parameters SET(ONION_USE_SSL true CACHE BOOL "Use SSL, requires GnuTLS") SET(ONION_USE_PAM true CACHE BOOL "Compile PAM handler. Needs libpam") @@ -19,7 +21,10 @@ SET(ONION_USE_BINDINGS_CPP true CACHE BOOL "Compile the CPP bindings") SET(ONION_POLLER default CACHE string "Default poller to use: default | epoll | libev | libevent") ######## +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules") + MESSAGE("CMAKE_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}") + execute_process( COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/git-version-gen" "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE ONION_VERSION) @@ -79,36 +84,35 @@ endif (${ONION_POLLER} STREQUAL "default") message(STATUS "Using ${ONION_POLLER} as poller") - if (${ONION_USE_SSL}) - find_library(GNUTLS_LIB NAMES gnutls PATH ${LIBPATH}) - find_library(GCRYPT_LIB NAMES gcrypt PATH ${LIBPATH}) - if (GNUTLS_LIB AND GCRYPT_LIB) + find_package(GnuTLS) + find_package(GCrypt) + if (GNUTLS_FOUND AND GCRYPT_FOUND) set(GNUTLS_ENABLED true) - message(STATUS "Gnutls found. SSL support is compiled in.") - else(GNUTLS_LIB AND GCRYPT_LIB) + message(STATUS "SSL support is compiled in.") + else(GNUTLS_FOUND AND GCRYPT_FOUND) message("Gnutls or gcrypt not found. SSL support is not compiled in.") - endif(GNUTLS_LIB AND GCRYPT_LIB) + endif(GNUTLS_FOUND AND GCRYPT_FOUND) endif(${ONION_USE_SSL}) if (${ONION_USE_SQLITE3}) - find_library(SQLITE3_LIB NAMES sqlite3 PATH ${LIBPATH}) - if (SQLITE3_LIB) + find_package(SQLite3) + if (SQLITE3_FOUND) set(SQLITE3_ENABLED true) - message(STATUS "SQLite found. Sqlite session support is compiled in.") - else(SQLITE3_LIB) - message("SQLite not found. Sqlite session support is not compiled in.") - endif(SQLITE3_LIB) + message(STATUS "SQLite session support is compiled in.") + else(SQLITE3_FOUND) + message("SQLite session support is not compiled in.") + endif(SQLITE3_FOUND) endif(${ONION_USE_SQLITE3}) if (${ONION_USE_REDIS}) - find_library(REDIS_LIB NAMES hiredis PATH ${LIBPATH}) - if(REDIS_LIB) + find_package(HiRedis) + if(HIREDIS_FOUND) set(REDIS_ENABLED true) - message(STATUS "Hiredis found. Redis session support is compiled in.") - else(REDIS_LIB) + message(STATUS "Redis session support is compiled in.") + else(HIREDIS_FOUND) message("Hiredis not found. Redis session support is not compiled in.") - endif(REDIS_LIB) + endif(HIREDIS_FOUND) endif(${ONION_USE_REDIS}) if (${ONION_USE_PTHREADS}) @@ -122,97 +126,89 @@ if (${ONION_USE_PTHREADS}) endif(${ONION_USE_PTHREADS}) if (${ONION_USE_XML2}) - find_library(XML2_LIB NAMES xml2 PATH ${LIBPATH}) - find_library(Z_LIB NAMES z PATH ${LIBPATH}) - find_path(XML2_HEADERS NAMES libxml/xmlwriter.h HINTS ${INCLUDE_PATH} PATH_SUFFIXES libxml2) - if(XML2_HEADERS) - message(STATUS "libxml2 found. WebDAV support is compiled in.") + find_package(LibXml2) + if(LIBXML2_FOUND) + message(STATUS "WebDAV support is compiled in.") set(XML2_ENABLED true) - else(XML2_HEADERS) - message("libxml2 not found. WebDAV is not supported. ${XML2_HEADERS} ${XML2_LIB}") - endif(XML2_HEADERS) + else(LIBXML2_FOUND) + message("libxml2 not found. WebDAV is not supported.") + endif(LIBXML2_FOUND) endif(${ONION_USE_XML2}) if (${ONION_USE_PAM}) - find_library(PAM_LIB NAMES pam pam_misc PATH ${LIBPATH}) - if (PAM_LIB) + find_package(PAM) + if (PAM_FOUND) set(PAM_ENABLED true) - message(STATUS "pam found. PAM support is compiled in in handlers.") - else (PAM_LIB) - message("pam not found. No PAM support.") - endif (PAM_LIB) + message(STATUS "PAM support is compiled in handlers.") + else (PAM_FOUND) + message("No PAM support.") + endif (PAM_FOUND) endif (${ONION_USE_PAM}) if (${ONION_USE_PNG}) - find_library(PNG_LIB NAMES png PATH ${LIBPATH}) - find_file(PNG_HEADER png.h ${INCLUDE_PATH}) - if (PNG_LIB) + find_package(PNG) + if (PNG_FOUND) set(PNG_ENABLED true) - set(PNG_LIB ${PNG_LIB}) message(STATUS "libpng found. png support is compiled in at extras.") - find_library(CAIRO_LIB NAMES cairo PATH ${LIBPATH}) - find_file(CAIRO_HEADER cairo/cairo.h ${INCLUDE_PATH}) - if (CAIRO_HEADER) + find_package(Cairo) + if (CAIRO_FOUND) set(CAIRO_ENABLED true) - set(CAIRO_LIB ${CAIRO_LIB}) - message(STATUS "libcairo found. Adding cairo examples. ${CAIRO_LIB}") - else (CAIRO_HEADER) - message(STATUS "libcairo NOT found.") - endif (CAIRO_HEADER) + message(STATUS "Adding cairo examples.") + else (CAIRO_FOUND) + message(WARNING "Some examples are disabled as you dont have cairo: cairo") + endif (CAIRO_FOUND) else (PNG_LIB) message("libpng not found. No png support.") - endif (PNG_LIB) + endif (PNG_FOUND) endif (${ONION_USE_PNG}) if (${ONION_USE_JPEG}) - find_library(JPEG_LIB NAMES jpeg PATH ${LIBPATH}) - find_file(JPEG_HEADER jpeg.h ${INCLUDE_PATH}) - if (JPEG_LIB) + find_package(JPEG) + if (JPEG_FOUND) set(JPEG_ENABLED true) - set(JPEG_LIB ${JPEG_LIB}) - message(STATUS "libjpeg found. jpeg support is compiled in at extras.") - else (JPEG_LIB) + message(STATUS "jpeg support is compiled in at extras.") + else (JPEG_FOUND) message("libjpeg not found. No jpeg support.") - endif (JPEG_LIB) + endif (JPEG_FOUND) endif (${ONION_USE_JPEG}) if (${ONION_USE_GC}) - find_library(GC_LIB NAMES gc PATH ${LIBPATH}) - find_file(GC_HEADER gc.h ${INCLUDE_PATH}) - if (GC_LIB AND GC_HEADER) - message(STATUS "libgc found, compiling Boehm GC examples") + find_package(BoehmGC) + if (BOEHM_GC_FOUND) + message(STATUS "compiling Boehm GC examples") set(GC_ENABLED true) - else (GC_LIB AND GC_HEADER) - message(STATUS "libgc not found, NOT compiling Boehm GC examples") - endif (GC_LIB AND GC_HEADER) + else (BOEHM_GC_FOUND) + message(STATUS "NOT compiling Boehm GC examples") + endif (BOEHM_GC_FOUND) endif (${ONION_USE_GC}) -find_library(CURL_LIB NAMES curl PATH ${LIBPATH}) -if(CURL_LIB) - message(STATUS "curl found. Some extra test are compiled.") +find_package(CURL) +if(CURL_FOUND) + message(STATUS "Some extra test are compiled.") set(CURL true) -else(CURL_LIB) +else(CURL_FOUND) message("curl not found. Some examples wil not be built.") -endif(CURL_LIB) +endif(CURL_FOUND) if (${ONION_USE_SYSTEMD}) - find_library(SD_DAEMON_LIB NAMES systemd PATH ${LIBPATH}) - if (SD_DAEMON_LIB) + find_package(Systemd) + if (SYSTEMD_FOUND) set(SYSTEMD_ENABLED true) - message(STATUS "libsystemd found. Systemd support compiled in.") - else(SD_DAEMON_LIB) - message("libsystemd not found. Systemd support is not compiled in. Install libsystemd-dev | systemd-devel") - endif(SD_DAEMON_LIB) + message(STATUS "Systemd support compiled in.") + else(SYSTEMD_FOUND) + message("Systemd support is not compiled in. Install libsystemd-dev | systemd-devel") + endif(SYSTEMD_FOUND) endif(${ONION_USE_SYSTEMD}) -find_library(GETTEXT_LIB NAMES gettext PATH ${LIBPATH}) -if (GETTEXT_LIB) +find_package(Intl) +if (INTL_FOUND) set(GETTEXT_ENABLED true) - message(STATUS "gettext found. gettext support is compiled in otemplate.") -else (GETTEXT_LIB) - message(STATUS "gettext not found. No gettext support.") -endif (GETTEXT_LIB) + include_directories(${INTL_INCLUDE_DIRS}) + message(STATUS "gettext support is compiled in otemplate.") +else (INTL_FOUND) + message(STATUS "No gettext support.") +endif (INTL_FOUND) FIND_PROGRAM(MD2MAN md2man-roff) if(MD2MAN) @@ -225,6 +221,7 @@ endif(MD2MAN) # defines if (GNUTLS_ENABLED) add_definitions(-DHAVE_GNUTLS) + add_definitions(${GNUTLS_DEFINITIONS}) endif(GNUTLS_ENABLED) if (PTHREADS) add_definitions(-DHAVE_PTHREADS) @@ -234,15 +231,18 @@ if (PAM_ENABLED) endif(PAM_ENABLED) if (XML2_ENABLED) add_definitions(-DHAVE_WEBDAV) + add_definitions(${LIBXML2_DEFINITIONS}) endif(XML2_ENABLED) if (SYSTEMD_ENABLED) add_definitions(-DHAVE_SYSTEMD) + add_definitions(${SYSTEMD_DEFINITIONS}) endif (SYSTEMD_ENABLED) if (GETTEXT_ENABLED) add_definitions(-DHAVE_GETTEXT) endif(GETTEXT_ENABLED) if (SQLITE3_ENABLED) add_definitions(-DHAVE_SQLITE3) + add_definitions(${SQLITE3_DEFINITIONS}) endif (SQLITE3_ENABLED) if (REDIS_ENABLED) add_definitions(-DHAVE_REDIS) @@ -253,6 +253,7 @@ add_definitions(-D_POSIX_C_SOURCE=200112L) add_definitions(-D_ISOC99_SOURCE) if(PNG_ENABLED) add_definitions(-DPNG_ENABLED) + add_definitions(${PNG_DEFINITIONS}) endif(PNG_ENABLED) if(JPEG_ENABLED) add_definitions(-DJPEG_ENABLED) @@ -277,8 +278,7 @@ project (onion) INCLUDE(CPackConfig.cmake) INCLUDE(CPack) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules") +INCLUDE(CTest) add_subdirectory(src) add_subdirectory(tools) diff --git a/CMakeModules/COPYING-CMAKE-SCRIPTS b/CMakeModules/COPYING-CMAKE-SCRIPTS new file mode 100644 index 00000000..4b417765 --- /dev/null +++ b/CMakeModules/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/CMakeModules/FindBoehmGC.cmake b/CMakeModules/FindBoehmGC.cmake new file mode 100644 index 00000000..bdb7240e --- /dev/null +++ b/CMakeModules/FindBoehmGC.cmake @@ -0,0 +1,108 @@ +# - Try to find Boehm GC +# Once done, this will define +# +# BOEHM_GC_FOUND - system has Boehm GC +# BOEHM_GC_INCLUDE_DIR - the Boehm GC include directories +# BOEHM_GC_LIBRARIES - link these to use Boehm GC +# +# Copyright (c) 2010-2015 Takashi Kato +# +# 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 above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. 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 +# OWNER OR CONTRIBUTORS 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. +# +# $Id: $ +# + +# CMake module to find Boehm GC + +# use pkg-config if available +FIND_PACKAGE(PkgConfig) +PKG_CHECK_MODULES(PC_BDW_GC QUIET bdw-gc) + +# try newer one first in case of gc.h is overwritten. +FIND_PATH(BOEHM_GC_INCLUDE_DIR gc/gc.h + HINTS ${PC_BDW_GC_INCLUDEDIR} ${PC_BDW_GC_INCLUDE_DIRS}) + +IF (NOT BOEHM_GC_INCLUDE_DIR) + FIND_PATH(BOEHM_GC_INCLUDE_DIR gc.h + HINTS ${PC_BDW_GC_INCLUDEDIR} ${PC_BDW_GC_INCLUDE_DIRS}) + IF (BOEHM_GC_INCLUDE_DIR) + SET(HAVE_GC_H TRUE) + ENDIF() +ELSE() + SET(HAVE_GC_GC_H TRUE) +ENDIF() + +# For FreeBSD we need to use gc-threaded +IF (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + # checks if 'gc' supports 'GC_get_parallel' and if it does + # then use it + INCLUDE(${CMAKE_ROOT}/Modules/CheckCSourceCompiles.cmake) + # not sure if this links properly... + FIND_LIBRARY(BOEHM_GC_LIBRARIES NAMES gc + HINTS ${PC_BDW_GC_LIBDIR} ${PC_BDW_GC_LIBRARY_DIRS}) + MESSAGE(STATUS "GC library ${BOEHM_GC_LIBRARIES}") + SET(CMAKE_REQUIRED_LIBRARIES "gc") + SET(CMAKE_REQUIRED_DEFINITIONS "-DGC_THREADS") + SET(CMAKE_REQUIRED_INCLUDES "${BOEHM_GC_INCLUDE_DIR}") + SET(CMAKE_REQUIRED_FLAGS "-L${PC_BDW_GC_LIBRARY_DIRS}") + MESSAGE(STATUS "Boehm GC include dir: ${CMAKE_REQUIRED_INCLUDES}") + CHECK_C_SOURCE_RUNS( + "#include +int main() { +int i= GC_get_parallel(); +return 0; +} +" GC_GET_PARALLEL_WORKS) + IF (NOT GC_GET_PARALLEL_WORKS) + MESSAGE(STATUS "Try gc-threaded") + + # bdw-gc-threaded is the proper name for FreeBSD pkg-config + PKG_CHECK_MODULES(PC_BDW_GC_THREADED bdw-gc-threaded) + FIND_LIBRARY(BOEHM_GC_THREADED_LIBRARIES NAMES gc-threaded + HINTS ${PC_BDW_GC_THREADED_LIBDIR} ${PC_BDW_GC_THREADED_THREADED_DIRS}) + + MESSAGE(STATUS "GC threaded library ${BOEHM_GC_THREADED_LIBRARIES}") + IF (BOEHM_GC_THREADED_LIBRARIES) + # OK just use it + SET(BOEHM_GC_LIBRARIES "${BOEHM_GC_THREADED_LIBRARIES}") + ENDIF() + ENDIF() +ELSE() + FIND_LIBRARY(BOEHM_GC_LIBRARIES NAMES gc + HINTS ${PC_BDW_GC_LIBDIR} ${PC_BDW_GC_LIBRARY_DIRS}) + # OpenSolaris uses bgc as Boehm GC runtime in its package manager. + # so try it + IF (NOT BOEHM_GC_LIBRARIES) + FIND_LIBRARY(BOEHM_GC_LIBRARIES NAMES bgc + HINTS ${PC_BDW_GC_LIBDIR} ${PC_BDW_GC_LIBRARY_DIRS}) + ENDIF() +ENDIF() + +MESSAGE(STATUS "Found GC library: ${BOEHM_GC_LIBRARIES}") + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Boehm_GC DEFAULT_MSG + BOEHM_GC_LIBRARIES BOEHM_GC_INCLUDE_DIR) + +MARK_AS_ADVANCED(BOEHM_GC_LIBRARIES BOEHM_GC_INCLUDE_DIR) diff --git a/CMakeModules/FindCairo.cmake b/CMakeModules/FindCairo.cmake new file mode 100644 index 00000000..cea95b9f --- /dev/null +++ b/CMakeModules/FindCairo.cmake @@ -0,0 +1,65 @@ +# - Try to find Cairo +# Once done, this will define +# +# CAIRO_FOUND - system has Cairo +# CAIRO_INCLUDE_DIRS - the Cairo include directories +# CAIRO_LIBRARIES - link these to use Cairo +# +# Copyright (C) 2012 Raphael Kubo da Costa +# +# 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 above copyright +# notice, this list of conditions and the following disclaimer. +# 2. 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 HOLDER AND ITS 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 HOLDER OR ITS +# CONTRIBUTORS 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(PkgConfig) +PKG_CHECK_MODULES(PC_CAIRO cairo QUIET) + +FIND_PATH(CAIRO_INCLUDE_DIRS + NAMES cairo.h + HINTS ${PC_CAIRO_INCLUDEDIR} + ${PC_CAIRO_INCLUDE_DIRS} + PATH_SUFFIXES cairo +) + +FIND_LIBRARY(CAIRO_LIBRARIES + NAMES cairo + HINTS ${PC_CAIRO_LIBDIR} + ${PC_CAIRO_LIBRARY_DIRS} +) + +IF (CAIRO_INCLUDE_DIRS) + IF (EXISTS "${CAIRO_INCLUDE_DIRS}/cairo-version.h") + FILE(READ "${CAIRO_INCLUDE_DIRS}/cairo-version.h" CAIRO_VERSION_CONTENT) + + STRING(REGEX MATCH "#define +CAIRO_VERSION_MAJOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}") + SET(CAIRO_VERSION_MAJOR "${CMAKE_MATCH_1}") + + STRING(REGEX MATCH "#define +CAIRO_VERSION_MINOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}") + SET(CAIRO_VERSION_MINOR "${CMAKE_MATCH_1}") + + STRING(REGEX MATCH "#define +CAIRO_VERSION_MICRO +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}") + SET(CAIRO_VERSION_MICRO "${CMAKE_MATCH_1}") + + SET(CAIRO_VERSION "${CAIRO_VERSION_MAJOR}.${CAIRO_VERSION_MINOR}.${CAIRO_VERSION_MICRO}") + ENDIF () +ENDIF () + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cairo DEFAULT_MSG CAIRO_INCLUDE_DIRS CAIRO_LIBRARIES) diff --git a/CMakeModules/FindGCrypt.cmake b/CMakeModules/FindGCrypt.cmake new file mode 100644 index 00000000..762a59c3 --- /dev/null +++ b/CMakeModules/FindGCrypt.cmake @@ -0,0 +1,75 @@ +# - Try to find GCrypt +# Once done this will define +# +# GCRYPT_FOUND - system has GCrypt +# GCRYPT_INCLUDE_DIRS - the GCrypt include directory +# GCRYPT_LIBRARIES - Link these to use GCrypt +# GCRYPT_DEFINITIONS - Compiler switches required for using GCrypt +# +#============================================================================= +# Copyright (c) 2009-2011 Andreas Schneider +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# + +set(_GCRYPT_ROOT_HINTS + $ENV{GCRYTPT_ROOT_DIR} + ${GCRYPT_ROOT_DIR}) + +set(_GCRYPT_ROOT_PATHS + "$ENV{PROGRAMFILES}/libgcrypt") + +set(_GCRYPT_ROOT_HINTS_AND_PATHS + HINTS ${_GCRYPT_ROOT_HINTS} + PATHS ${_GCRYPT_ROOT_PATHS}) + + +find_path(GCRYPT_INCLUDE_DIR + NAMES + gcrypt.h + HINTS + ${_GCRYPT_ROOT_HINTS_AND_PATHS} +) + +find_library(GCRYPT_LIBRARY + NAMES + gcrypt + gcrypt11 + libgcrypt-11 + HINTS + ${_GCRYPT_ROOT_HINTS_AND_PATHS} +) +set(GCRYPT_LIBRARIES ${GCRYPT_LIBRARY}) + +if (GCRYPT_INCLUDE_DIR) + file(STRINGS "${GCRYPT_INCLUDE_DIR}/gcrypt.h" _gcrypt_version_str REGEX "^#define GCRYPT_VERSION \"[0-9]+.[0-9]+.[0-9]+\"") + + string(REGEX REPLACE "^.*GCRYPT_VERSION.*([0-9]+.[0-9]+.[0-9]+).*" "\\1" GCRYPT_VERSION "${_gcrypt_version_str}") +endif (GCRYPT_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +if (GCRYPT_VERSION) + find_package_handle_standard_args(GCrypt + REQUIRED_VARS + GCRYPT_INCLUDE_DIR + GCRYPT_LIBRARIES + VERSION_VAR + GCRYPT_VERSION + FAIL_MESSAGE + "Could NOT find GCrypt, try to set the path to GCrypt root folder in the system variable GCRYPT_ROOT_DIR" + ) +else (GCRYPT_VERSION) + find_package_handle_standard_args(GCrypt + "Could NOT find GCrypt, try to set the path to GCrypt root folder in the system variable GCRYPT_ROOT_DIR" + GCRYPT_INCLUDE_DIR + GCRYPT_LIBRARIES) +endif (GCRYPT_VERSION) + +# show the GCRYPT_INCLUDE_DIRS and GCRYPT_LIBRARIES variables only in the advanced view +mark_as_advanced(GCRYPT_INCLUDE_DIR GCRYPT_LIBRARIES) diff --git a/CMakeModules/FindGnuTLS.cmake b/CMakeModules/FindGnuTLS.cmake new file mode 100644 index 00000000..7315f1dd --- /dev/null +++ b/CMakeModules/FindGnuTLS.cmake @@ -0,0 +1,69 @@ +# - Try to find the GNU Transport Layer Security library (gnutls) +# +# Once done this will define +# +# GNUTLS_FOUND - System has gnutls +# GNUTLS_INCLUDE_DIR - The gnutls include directory +# GNUTLS_LIBRARIES - The libraries needed to use gnutls +# GNUTLS_DEFINITIONS - Compiler switches required for using gnutls + +#============================================================================= +# Copyright 2009 Kitware, Inc. +# Copyright 2009 Philip Lowman +# Copyright 2009 Brad Hards +# Copyright 2006 Alexander Neundorf +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Note that this doesn't try to find the gnutls-extra package. + + +if (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARY) + # in cache already + set(gnutls_FIND_QUIETLY TRUE) +endif () + +if (NOT WIN32) + # try using pkg-config to get the directories and then use these values + # in the find_path() and find_library() calls + # also fills in GNUTLS_DEFINITIONS, although that isn't normally useful + find_package(PkgConfig QUIET) + PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls) + set(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER}) + set(GNUTLS_VERSION_STRING ${PC_GNUTLS_VERSION}) +endif () + +find_path(GNUTLS_INCLUDE_DIR gnutls/gnutls.h + HINTS + ${PC_GNUTLS_INCLUDEDIR} + ${PC_GNUTLS_INCLUDE_DIRS} + ) + +find_library(GNUTLS_LIBRARY NAMES gnutls libgnutls + HINTS + ${PC_GNUTLS_LIBDIR} + ${PC_GNUTLS_LIBRARY_DIRS} + ) + +mark_as_advanced(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY) + +# handle the QUIETLY and REQUIRED arguments and set GNUTLS_FOUND to TRUE if +# all listed variables are TRUE +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS + REQUIRED_VARS GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR + VERSION_VAR GNUTLS_VERSION_STRING) + +if(GNUTLS_FOUND) + set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY}) + set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR}) +endif() + diff --git a/CMakeModules/FindHiRedis.cmake b/CMakeModules/FindHiRedis.cmake new file mode 100644 index 00000000..757baa7d --- /dev/null +++ b/CMakeModules/FindHiRedis.cmake @@ -0,0 +1,41 @@ +# - Find Redis client db (hiredis from https://github.com/antirez/hiredis) +# Find the hiredis includes and client library +# This module defines +# HIREDIS_INCLUDE_DIR, where to find hiredis/hiredis.h +# HIREDIS_LIBRARIES, the libraries needed to use redis. +# HIREDIS_FOUND, If false, do not try to use redis. +# +# Copyright (c) 2012, Lothar Braun, +# + +# Add the redis include paths here +IF (HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARIES) + SET (HIREDIS_FOUND TRUE) +ELSE(HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARIES) + FIND_PATH(HIREDIS_INCLUDE_DIR hiredis/hiredis.h + /usr/include/ + /usr/include/hiredis + /usr/local/include/ + /usr/local/include/hiredis + /opt/local/include/ + /opt/local/include/hiredis + ) + + FIND_LIBRARY(HIREDIS_LIBRARIES NAMES hiredis libhiredis + PATHS + /usr/lib + /usr/local/lib + /opt/local/lib + ) + + IF(HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARIES) + SET(HIREDIS_FOUND TRUE) + MESSAGE(STATUS "Found hiredis: ${HIREDIS_INCLUDE_DIR}, ${HIREDIS_LIBRARIES}") + INCLUDE_DIRECTORIES(${HIREDIS_INCLUDE_DIR}) + ELSE(HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARIES) + SET(HIREDIS_FOUND FALSE) + MESSAGE(STATUS "hiredis client library not found.") + ENDIF(HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARIES) + + MARK_AS_ADVANCED(HIREDIS_INCLUDE_DIR HIREDIS_LIBRARIES) +ENDIF(HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARIES) diff --git a/CMakeModules/FindIntl.cmake b/CMakeModules/FindIntl.cmake new file mode 100644 index 00000000..c89bc570 --- /dev/null +++ b/CMakeModules/FindIntl.cmake @@ -0,0 +1,68 @@ +#.rst: +# FindIntl +# -------- +# +# Find the Gettext libintl headers and libraries. +# +# This module reports information about the Gettext libintl +# installation in several variables. General variables:: +# +# INTL_FOUND - true if the libintl headers and libraries were found +# INTL_INCLUDE_DIRS - the directory containing the libintl headers +# INTL_LIBRARIES - libintl libraries to be linked +# +# The following cache variables may also be set:: +# +# INTL_INCLUDE_DIR - the directory containing the libintl headers +# INTL_LIBRARY - the libintl library (if any) +# +# .. note:: +# On some platforms, such as Linux with GNU libc, the gettext +# functions are present in the C standard library and libintl +# is not required. ``INTL_LIBRARIES`` will be empty in this +# case. +# +# .. note:: +# If you wish to use the Gettext tools (``msgmerge``, +# ``msgfmt``, etc.), use :module:`FindGettext`. + + +# Written by Roger Leigh + +#============================================================================= +# Copyright 2014 Roger Leigh +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Find include directory +find_path(INTL_INCLUDE_DIR + NAMES "libintl.h" + DOC "libintl include directory") +mark_as_advanced(INTL_INCLUDE_DIR) + +# Find all Intl libraries +find_library(INTL_LIBRARY "intl" + DOC "libintl libraries (if not in the C library)") +mark_as_advanced(INTL_LIBRARY) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Intl + REQUIRED_VARS INTL_INCLUDE_DIR + FAIL_MESSAGE "Failed to find Gettext libintl") + +if (INTL_FOUND) + set(INTL_INCLUDE_DIRS "${INTL_INCLUDE_DIR}") + if (INTL_LIBRARY) + set(INTL_LIBRARIES "${INTL_LIBRARY}") + else () + unset(INTL_LIBRARIES) + endif () +endif () diff --git a/CMakeModules/FindLibEv.cmake b/CMakeModules/FindLibEv.cmake new file mode 100644 index 00000000..712251c7 --- /dev/null +++ b/CMakeModules/FindLibEv.cmake @@ -0,0 +1,46 @@ +# - Try to find LibEv +# Once done this will define +# +# LIBEV_FOUND - system has libev +# LIBEV_INCLUDE_DIR - the libev include directory +# LIBEV_LIBRARIES - Link these to use libev +# + +set(_LIBEV_ROOT_HINTS + $ENV{GCRYTPT_ROOT_DIR} + ${LIBEV_ROOT_DIR}) + +set(_LIBEV_ROOT_PATHS + "$ENV{PROGRAMFILES}/libev") + +set(_LIBEV_ROOT_HINTS_AND_PATHS + HINTS ${_LIBEV_ROOT_HINTS} + PATHS ${_LIBEV_ROOT_PATHS}) + + +find_path(LIBEV_INCLUDE_DIR + NAMES + ev.h + HINTS + ${_LIBEV_ROOT_HINTS_AND_PATHS} +) + +find_library(LIBEV_LIBRARY + NAMES + ev + HINTS + ${_LIBEV_ROOT_HINTS_AND_PATHS} +) +set(LIBEV_LIBRARIES ${LIBEV_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibEv + REQUIRED_VARS + LIBEV_INCLUDE_DIR + LIBEV_LIBRARIES + FAIL_MESSAGE + "Could NOT find LibEv, try to set the path to LibEv root folder in the system variable LIBEV_ROOT_DIR" +) + +# show the LIBEV_INCLUDE_DIRS and LIBEV_LIBRARIES variables only in the advanced view +mark_as_advanced(LIBEV_INCLUDE_DIR LIBEV_LIBRARIES) diff --git a/CMakeModules/FindLibEvent.cmake b/CMakeModules/FindLibEvent.cmake new file mode 100644 index 00000000..dce50520 --- /dev/null +++ b/CMakeModules/FindLibEvent.cmake @@ -0,0 +1,59 @@ +# - Find libevent +# Find the native libevent includes and library. +# Once done this will define +# +# LIBEVENT_INCLUDE_DIRS - where to find event2/event.h, etc. +# LIBEVENT_LIBRARIES - List of libraries when using libevent. +# LIBEVENT_FOUND - True if libevent found. +# +# LIBEVENT_VERSION_STRING - The version of libevent found (x.y.z) +# LIBEVENT_VERSION_MAJOR - The major version +# LIBEVENT_VERSION_MINOR - The minor version +# LIBEVENT_VERSION_PATCH - The patch version +# +# Avaliable components: +# core +# pthreads +# extra +# openssl +# + +SET(LIBEVENT_core_LIBRARY "NOTREQ") +SET(LIBEVENT_pthreads_LIBRARY "NOTREQ") +SET(LIBEVENT_extra_LIBRARY "NOTREQ") +SET(LIBEVENT_openssl_LIBRARY "NOTREQ") + +FIND_PATH(LIBEVENT_INCLUDE_DIR NAMES event2/event.h) + +IF(LIBEVENT_INCLUDE_DIR AND EXISTS "${LIBEVENT_INCLUDE_DIR}/event2/event-config.h") + # Read and parse libevent version header file for version number + file(READ "${LIBEVENT_INCLUDE_DIR}/event2/event-config.h" _libevent_HEADER_CONTENTS) + + string(REGEX REPLACE ".*#define _EVENT_VERSION +\"([0-9]+).*" "\\1" LIBEVENT_VERSION_MAJOR "${_libevent_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define _EVENT_VERSION +\"[0-9]+\\.([0-9]+).*" "\\1" LIBEVENT_VERSION_MINOR "${_libevent_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define _EVENT_VERSION +\"[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" LIBEVENT_VERSION_PATCH "${_libevent_HEADER_CONTENTS}") + + SET(LIBEVENT_VERSION_STRING "${LIBEVENT_VERSION_MAJOR}.${LIBEVENT_VERSION_MINOR}.${LIBEVENT_VERSION_PATCH}") +ENDIF() + +FOREACH(component ${Libevent_FIND_COMPONENTS}) + UNSET(LIBEVENT_${component}_LIBRARY) + FIND_LIBRARY(LIBEVENT_${component}_LIBRARY NAMES event_${component} PATH_SUFFIXES event2) +ENDFOREACH() + +# handle the QUIETLY and REQUIRED arguments and set LIBEVENT_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libevent + REQUIRED_VARS LIBEVENT_core_LIBRARY LIBEVENT_pthreads_LIBRARY LIBEVENT_extra_LIBRARY LIBEVENT_openssl_LIBRARY LIBEVENT_INCLUDE_DIR + VERSION_VAR LIBEVENT_VERSION_STRING + ) + +IF(LIBEVENT_FOUND) + SET(LIBEVENT_INCLUDE_DIRS ${LIBEVENT_INCLUDE_DIR}) + FOREACH(component ${Libevent_FIND_COMPONENTS}) + LIST(APPEND LIBEVENT_LIBRARIES ${LIBEVENT_${component}_LIBRARY}) + ENDFOREACH() +ENDIF() + +MARK_AS_ADVANCED(LIBEVENT_core_LIBRARY LIBEVENT_pthreads_LIBRARY LIBEVENT_extra_LIBRARY LIBEVENT_openssl_LIBRARY LIBEVENT_INCLUDE_DIR) diff --git a/CMakeModules/FindLibXml2.cmake b/CMakeModules/FindLibXml2.cmake new file mode 100644 index 00000000..73224286 --- /dev/null +++ b/CMakeModules/FindLibXml2.cmake @@ -0,0 +1,73 @@ +#.rst: +# FindLibXml2 +# ----------- +# +# Try to find the LibXml2 xml processing library +# +# Once done this will define +# +# :: +# +# LIBXML2_FOUND - System has LibXml2 +# LIBXML2_INCLUDE_DIR - The LibXml2 include directory +# LIBXML2_LIBRARIES - The libraries needed to use LibXml2 +# LIBXML2_DEFINITIONS - Compiler switches required for using LibXml2 +# LIBXML2_XMLLINT_EXECUTABLE - The XML checking tool xmllint coming with LibXml2 +# LIBXML2_VERSION_STRING - the version of LibXml2 found (since CMake 2.8.8) + +#============================================================================= +# Copyright 2006-2009 Kitware, Inc. +# Copyright 2006 Alexander Neundorf +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# use pkg-config to get the directories and then use these values +# in the find_path() and find_library() calls +find_package(PkgConfig QUIET) +PKG_CHECK_MODULES(PC_LIBXML QUIET libxml-2.0) +set(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER}) + +find_path(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h + HINTS + ${PC_LIBXML_INCLUDEDIR} + ${PC_LIBXML_INCLUDE_DIRS} + PATH_SUFFIXES libxml2 + ) + +find_library(LIBXML2_LIBRARIES NAMES xml2 libxml2 + HINTS + ${PC_LIBXML_LIBDIR} + ${PC_LIBXML_LIBRARY_DIRS} + ) + +find_program(LIBXML2_XMLLINT_EXECUTABLE xmllint) +# for backwards compat. with KDE 4.0.x: +set(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}") + +if(PC_LIBXML_VERSION) + set(LIBXML2_VERSION_STRING ${PC_LIBXML_VERSION}) +elseif(LIBXML2_INCLUDE_DIR AND EXISTS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h") + file(STRINGS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h" libxml2_version_str + REGEX "^#define[\t ]+LIBXML_DOTTED_VERSION[\t ]+\".*\"") + + string(REGEX REPLACE "^#define[\t ]+LIBXML_DOTTED_VERSION[\t ]+\"([^\"]*)\".*" "\\1" + LIBXML2_VERSION_STRING "${libxml2_version_str}") + unset(libxml2_version_str) +endif() + +# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if +# all listed variables are TRUE +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 + REQUIRED_VARS LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR + VERSION_VAR LIBXML2_VERSION_STRING) + +mark_as_advanced(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE) diff --git a/CMakeModules/FindPAM.cmake b/CMakeModules/FindPAM.cmake new file mode 100644 index 00000000..25307bd3 --- /dev/null +++ b/CMakeModules/FindPAM.cmake @@ -0,0 +1,71 @@ +# - Try to find the PAM libraries +# Once done this will define +# +# PAM_FOUND - system has pam +# PAM_INCLUDE_DIR - the pam include directory +# PAM_LIBRARIES - libpam library + +if (PAM_INCLUDE_DIR AND PAM_LIBRARY) + # Already in cache, be silent + set(PAM_FIND_QUIETLY TRUE) +endif (PAM_INCLUDE_DIR AND PAM_LIBRARY) + +find_path(PAM_INCLUDE_DIR NAMES security/pam_appl.h pam/pam_appl.h) +find_library(PAM_LIBRARY pam) +find_library(DL_LIBRARY dl) + +if (PAM_INCLUDE_DIR AND PAM_LIBRARY) + set(PAM_FOUND TRUE) + if (DL_LIBRARY) + set(PAM_LIBRARIES ${PAM_LIBRARY} ${DL_LIBRARY}) + else (DL_LIBRARY) + set(PAM_LIBRARIES ${PAM_LIBRARY}) + endif (DL_LIBRARY) + + if (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h) + # darwin claims to be something special + set(HAVE_PAM_PAM_APPL_H 1) + endif (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h) + + if (NOT DEFINED PAM_MESSAGE_CONST) + include(CheckCXXSourceCompiles) + # XXX does this work with plain c? + check_cxx_source_compiles(" +#if ${HAVE_PAM_PAM_APPL_H}+0 +# include +#else +# include +#endif +static int PAM_conv( + int num_msg, + const struct pam_message **msg, /* this is the culprit */ + struct pam_response **resp, + void *ctx) +{ + return 0; +} +int main(void) +{ + struct pam_conv PAM_conversation = { + &PAM_conv, /* this bombs out if the above does not match */ + 0 + }; + return 0; +} +" PAM_MESSAGE_CONST) + endif (NOT DEFINED PAM_MESSAGE_CONST) + set(PAM_MESSAGE_CONST ${PAM_MESSAGE_CONST} CACHE BOOL "PAM expects a conversation function with const pam_message") + +endif (PAM_INCLUDE_DIR AND PAM_LIBRARY) + +if (PAM_FOUND) + if (NOT PAM_FIND_QUIETLY) + message(STATUS "Found PAM: ${PAM_LIBRARIES}") + endif (NOT PAM_FIND_QUIETLY) +else (PAM_FOUND) + if (PAM_FIND_REQUIRED) + message(FATAL_ERROR "PAM was not found") + endif(PAM_FIND_REQUIRED) +endif (PAM_FOUND) + +mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY DL_LIBRARY PAM_MESSAGE_CONST) diff --git a/CMakeModules/FindPackageHandleStandardArgs.cmake b/CMakeModules/FindPackageHandleStandardArgs.cmake new file mode 100644 index 00000000..1acb021e --- /dev/null +++ b/CMakeModules/FindPackageHandleStandardArgs.cmake @@ -0,0 +1,260 @@ +# FIND_PACKAGE_HANDLE_STANDARD_ARGS( ... ) +# +# This function is intended to be used in FindXXX.cmake modules files. +# It handles the REQUIRED, QUIET and version-related arguments to FIND_PACKAGE(). +# It also sets the _FOUND variable. +# The package is considered found if all variables ... listed contain +# valid results, e.g. valid filepaths. +# +# There are two modes of this function. The first argument in both modes is +# the name of the Find-module where it is called (in original casing). +# +# The first simple mode looks like this: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS( (DEFAULT_MSG|"Custom failure message") ... ) +# If the variables to are all valid, then _FOUND +# will be set to TRUE. +# If DEFAULT_MSG is given as second argument, then the function will generate +# itself useful success and error messages. You can also supply a custom error message +# for the failure case. This is not recommended. +# +# The second mode is more powerful and also supports version checking: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [REQUIRED_VARS ...] +# [VERSION_VAR +# [CONFIG_MODE] +# [FAIL_MESSAGE "Custom failure message"] ) +# +# As above, if through are all valid, _FOUND +# will be set to TRUE. +# After REQUIRED_VARS the variables which are required for this package are listed. +# Following VERSION_VAR the name of the variable can be specified which holds +# the version of the package which has been found. If this is done, this version +# will be checked against the (potentially) specified required version used +# in the find_package() call. The EXACT keyword is also handled. The default +# messages include information about the required version and the version +# which has been actually found, both if the version is ok or not. +# Use the option CONFIG_MODE if your FindXXX.cmake module is a wrapper for +# a find_package(... NO_MODULE) call, in this case all the information +# provided by the config-mode of find_package() will be evaluated +# automatically. +# Via FAIL_MESSAGE a custom failure message can be specified, if this is not +# used, the default message will be displayed. +# +# Example for mode 1: +# +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) +# +# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and +# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE. +# If it is not found and REQUIRED was used, it fails with FATAL_ERROR, +# independent whether QUIET was used or not. +# If it is found, success will be reported, including the content of . +# On repeated Cmake runs, the same message won't be printed again. +# +# Example for mode 2: +# +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON REQUIRED_VARS BISON_EXECUTABLE +# VERSION_VAR BISON_VERSION) +# In this case, BISON is considered to be found if the variable(s) listed +# after REQUIRED_VAR are all valid, i.e. BISON_EXECUTABLE in this case. +# Also the version of BISON will be checked by using the version contained +# in BISON_VERSION. +# Since no FAIL_MESSAGE is given, the default messages will be printed. +# +# Another example for mode 2: +# +# FIND_PACKAGE(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(Automoc4 CONFIG_MODE) +# In this case, FindAutmoc4.cmake wraps a call to FIND_PACKAGE(Automoc4 NO_MODULE) +# and adds an additional search directory for automoc4. +# The following FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper +# success/error message. + +#============================================================================= +# Copyright 2007-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +INCLUDE(FindPackageMessage) +INCLUDE(CMakeParseArguments) + +# internal helper macro +MACRO(_FPHSA_FAILURE_MESSAGE _msg) + IF (${_NAME}_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "${_msg}") + ELSE (${_NAME}_FIND_REQUIRED) + IF (NOT ${_NAME}_FIND_QUIETLY) + MESSAGE(STATUS "${_msg}") + ENDIF (NOT ${_NAME}_FIND_QUIETLY) + ENDIF (${_NAME}_FIND_REQUIRED) +ENDMACRO(_FPHSA_FAILURE_MESSAGE _msg) + + +# internal helper macro to generate the failure message when used in CONFIG_MODE: +MACRO(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) + # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: + IF(${_NAME}_CONFIG) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") + ELSE(${_NAME}_CONFIG) + # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. + # List them all in the error message: + IF(${_NAME}_CONSIDERED_CONFIGS) + SET(configsText "") + LIST(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) + MATH(EXPR configsCount "${configsCount} - 1") + FOREACH(currentConfigIndex RANGE ${configsCount}) + LIST(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) + LIST(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) + SET(configsText "${configsText} ${filename} (version ${version})\n") + ENDFOREACH(currentConfigIndex) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") + + ELSE(${_NAME}_CONSIDERED_CONFIGS) + # Simple case: No Config-file was found at all: + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") + ENDIF(${_NAME}_CONSIDERED_CONFIGS) + ENDIF(${_NAME}_CONFIG) +ENDMACRO(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) + + +FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) + +# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in +# new extended or in the "old" mode: + SET(options CONFIG_MODE) + SET(oneValueArgs FAIL_MESSAGE VERSION_VAR) + SET(multiValueArgs REQUIRED_VARS) + SET(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) + LIST(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) + + IF(${INDEX} EQUAL -1) + SET(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) + SET(FPHSA_REQUIRED_VARS ${ARGN}) + SET(FPHSA_VERSION_VAR) + ELSE(${INDEX} EQUAL -1) + + CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) + + IF(FPHSA_UNPARSED_ARGUMENTS) + MESSAGE(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") + ENDIF(FPHSA_UNPARSED_ARGUMENTS) + + IF(NOT FPHSA_FAIL_MESSAGE) + SET(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") + ENDIF(NOT FPHSA_FAIL_MESSAGE) + ENDIF(${INDEX} EQUAL -1) + +# now that we collected all arguments, process them + + IF("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") + SET(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") + ENDIF("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") + + # In config-mode, we rely on the variable _CONFIG, which is set by find_package() + # when it successfully found the config-file, including version checking: + IF(FPHSA_CONFIG_MODE) + LIST(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) + LIST(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) + SET(FPHSA_VERSION_VAR ${_NAME}_VERSION) + ENDIF(FPHSA_CONFIG_MODE) + + IF(NOT FPHSA_REQUIRED_VARS) + MESSAGE(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") + ENDIF(NOT FPHSA_REQUIRED_VARS) + + LIST(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + + STRING(TOUPPER ${_NAME} _NAME_UPPER) + STRING(TOLOWER ${_NAME} _NAME_LOWER) + + # collect all variables which were not found, so they can be printed, so the + # user knows better what went wrong (#6375) + SET(MISSING_VARS "") + SET(DETAILS "") + SET(${_NAME_UPPER}_FOUND TRUE) + # check if all passed variables are valid + FOREACH(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) + IF(NOT ${_CURRENT_VAR}) + SET(${_NAME_UPPER}_FOUND FALSE) + SET(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") + ELSE(NOT ${_CURRENT_VAR}) + SET(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") + ENDIF(NOT ${_CURRENT_VAR}) + ENDFOREACH(_CURRENT_VAR) + + + # version handling: + SET(VERSION_MSG "") + SET(VERSION_OK TRUE) + SET(VERSION ${${FPHSA_VERSION_VAR}} ) + IF (${_NAME}_FIND_VERSION) + + IF(VERSION) + + IF(${_NAME}_FIND_VERSION_EXACT) # exact version required + IF (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + SET(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") + SET(VERSION_OK FALSE) + ELSE (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + SET(VERSION_MSG "(found suitable exact version \"${VERSION}\")") + ENDIF (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + + ELSE(${_NAME}_FIND_VERSION_EXACT) # minimum version specified: + IF ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + SET(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") + SET(VERSION_OK FALSE) + ELSE ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + SET(VERSION_MSG "(found suitable version \"${VERSION}\", required is \"${${_NAME}_FIND_VERSION}\")") + ENDIF ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + ENDIF(${_NAME}_FIND_VERSION_EXACT) + + ELSE(VERSION) + + # if the package was not found, but a version was given, add that to the output: + IF(${_NAME}_FIND_VERSION_EXACT) + SET(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") + ELSE(${_NAME}_FIND_VERSION_EXACT) + SET(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") + ENDIF(${_NAME}_FIND_VERSION_EXACT) + + ENDIF(VERSION) + ELSE (${_NAME}_FIND_VERSION) + IF(VERSION) + SET(VERSION_MSG "(found version \"${VERSION}\")") + ENDIF(VERSION) + ENDIF (${_NAME}_FIND_VERSION) + + IF(VERSION_OK) + SET(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]") + ELSE(VERSION_OK) + SET(${_NAME_UPPER}_FOUND FALSE) + ENDIF(VERSION_OK) + + + # print the result: + IF (${_NAME_UPPER}_FOUND) + FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG}" "${DETAILS}") + ELSE (${_NAME_UPPER}_FOUND) + + IF(FPHSA_CONFIG_MODE) + _FPHSA_HANDLE_FAILURE_CONFIG_MODE() + ELSE(FPHSA_CONFIG_MODE) + IF(NOT VERSION_OK) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + ELSE(NOT VERSION_OK) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") + ENDIF(NOT VERSION_OK) + ENDIF(FPHSA_CONFIG_MODE) + + ENDIF (${_NAME_UPPER}_FOUND) + + SET(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE) + +ENDFUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _FIRST_ARG) diff --git a/CMakeModules/FindSQLite3.cmake b/CMakeModules/FindSQLite3.cmake new file mode 100644 index 00000000..77b8eb4e --- /dev/null +++ b/CMakeModules/FindSQLite3.cmake @@ -0,0 +1,86 @@ +# - Try to find Sqlite3 +# Once done this will define +# +# SQLITE3_FOUND - system has Sqlite3 +# SQLITE3_INCLUDE_DIRS - the Sqlite3 include directory +# SQLITE3_LIBRARIES - Link these to use Sqlite3 +# SQLITE3_DEFINITIONS - Compiler switches required for using Sqlite3 +# +# Copyright (c) 2008 Andreas Schneider +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + + +if (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) + # in cache already + set(SQLITE3_FOUND TRUE) +else (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + include(UsePkgConfig) + pkgconfig(sqlite3 _SQLITE3_INCLUDEDIR _SQLITE3_LIBDIR _SQLITE3_LDFLAGS _SQLITE3_CFLAGS) + else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(_SQLITE3 sqlite3) + endif (PKG_CONFIG_FOUND) + endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_path(SQLITE3_INCLUDE_DIR + NAMES + sqlite3.h + PATHS + ${_SQLITE3_INCLUDEDIR} + /usr/include + /usr/local/include + /opt/local/include + /sw/include + ) + + find_library(SQLITE3_LIBRARY + NAMES + sqlite3 + PATHS + ${_SQLITE3_LIBDIR} + /usr/lib + /usr/local/lib + /opt/local/lib + /sw/lib + ) + + if (SQLITE3_LIBRARY) + set(SQLITE3_FOUND TRUE) + endif (SQLITE3_LIBRARY) + + set(SQLITE3_INCLUDE_DIRS + ${SQLITE3_INCLUDE_DIR} + ) + + if (SQLITE3_FOUND) + set(SQLITE3_LIBRARIES + ${SQLITE3_LIBRARIES} + ${SQLITE3_LIBRARY} + ) + endif (SQLITE3_FOUND) + + if (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES) + set(SQLITE3_FOUND TRUE) + endif (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES) + + if (SQLITE3_FOUND) + if (NOT Sqlite3_FIND_QUIETLY) + message(STATUS "Found Sqlite3: ${SQLITE3_LIBRARIES}") + endif (NOT Sqlite3_FIND_QUIETLY) + else (SQLITE3_FOUND) + if (Sqlite3_FIND_REQUIRED) + message(FATAL_ERROR "Could not find Sqlite3") + endif (Sqlite3_FIND_REQUIRED) + endif (SQLITE3_FOUND) + + # show the SQLITE3_INCLUDE_DIRS and SQLITE3_LIBRARIES variables only in the advanced view + mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES) + +endif (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) diff --git a/CMakeModules/FindSystemd.cmake b/CMakeModules/FindSystemd.cmake new file mode 100644 index 00000000..09d60115 --- /dev/null +++ b/CMakeModules/FindSystemd.cmake @@ -0,0 +1,40 @@ +#.rst: +# FindSystemd +# ------- +# +# Find Systemd library +# +# Try to find Systemd library on UNIX systems. The following values are defined +# +# :: +# +# SYSTEMD_FOUND - True if Systemd is available +# SYSTEMD_INCLUDE_DIRS - Include directories for Systemd +# SYSTEMD_LIBRARIES - List of libraries for Systemd +# SYSTEMD_DEFINITIONS - List of definitions for Systemd +# +#============================================================================= +# Copyright (c) 2015 Jari Vetoniemi +# +# Distributed under the OSI-approved BSD License (the "License"); +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +include(FeatureSummary) +set_package_properties(Systemd PROPERTIES + URL "http://freedesktop.org/wiki/Software/systemd/" + DESCRIPTION "System and Service Manager") + +find_package(PkgConfig) +pkg_check_modules(PC_SYSTEMD QUIET libsystemd) +find_library(SYSTEMD_LIBRARIES NAMES systemd ${PC_SYSTEMD_LIBRARY_DIRS}) +find_path(SYSTEMD_INCLUDE_DIRS systemd/sd-login.h HINTS ${PC_SYSTEMD_INCLUDE_DIRS}) + +set(SYSTEMD_DEFINITIONS ${PC_SYSTEMD_CFLAGS_OTHER}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(SYSTEMD DEFAULT_MSG SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES) +mark_as_advanced(SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES SYSTEMD_DEFINITIONS) diff --git a/debian/changelog b/debian/changelog index 223dd68e..3f7e0c14 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,7 +10,7 @@ libonion (0.8.0) stable; urgency=low * Rework on request parser to allow OCS_YIELD (David Moreno). * Overall API improvements (David Moreno) * Use of custom low level functions: onion_malloc, onion_free... (Basile Starynkevitch) - * Bohem GC support (Basile Starynkevitch) + * Boehm GC support (Basile Starynkevitch) * Man pages for the tools. (David Moreno) * Semantic Versioning. * Many small fixes and improvements. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index da6a2854..5a8949e5 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,24 +1,26 @@ -if (PAM_ENABLED) - if (OPACK) - add_subdirectory(otop) - endif(OPACK) - add_subdirectory(basic) - add_subdirectory(fileserver) -else (PAM_ENABLED) - if (OPACK) - message(WARNING "Oterm without authentication support! May be very unsecure.") - else(OPACK) - message(WARNING "Oterm not compiled as there is no opack.") - endif (OPACK) +if (ONION_USE_PAM) + if (PAM_ENABLED) + if (OPACK) + add_subdirectory(otop) + endif(OPACK) + add_subdirectory(basic) + add_subdirectory(fileserver) + else (PAM_ENABLED) + if (OPACK) + message(WARNING "Oterm without authentication support! May be very unsecure.") + else(OPACK) + message(WARNING "Oterm not compiled as there is no opack.") + endif (OPACK) - message(WARNING "Some examples are disabled as you dont have PAM: otop, basic, fileserver.") -endif (PAM_ENABLED) + message(WARNING "Some examples are disabled as you dont have PAM: otop, basic, fileserver.") + endif (PAM_ENABLED) -if (OPACK) - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - add_subdirectory(oterm) - endif (CMAKE_SYSTEM_NAME STREQUAL "Linux") -endif (OPACK) + if (OPACK) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + add_subdirectory(oterm) + endif (CMAKE_SYSTEM_NAME STREQUAL "Linux") + endif (OPACK) +endif (ONION_USE_PAM) add_subdirectory(post) @@ -42,8 +44,6 @@ endif(OTEMPLATE) if (${CAIRO_ENABLED}) add_subdirectory(cairo) -else (${CAIRO_ENABLED}) - message(WARNING "Some examples are disabled as you dont have cairo: cairo") endif (${CAIRO_ENABLED}) diff --git a/examples/boehm-gc/boehm-gc.c b/examples/boehm-gc/boehm-gc.c index 81495e84..9c168ef7 100644 --- a/examples/boehm-gc/boehm-gc.c +++ b/examples/boehm-gc/boehm-gc.c @@ -1,5 +1,5 @@ /** Licensed under AGPL 3.0. (C) 2010 David Moreno Montero. http://coralbits.com */ -#define GC_THREADS 1 +#define GC_THREADS #include @@ -48,8 +48,8 @@ int main(int argc, char **argv){ memory_allocation_error); onion_low_initialize_threads( GC_pthread_create, GC_pthread_join, - GC_pthread_cancel, GC_pthread_detach, - GC_pthread_exit, GC_pthread_sigmask); + pthread_cancel, GC_pthread_detach, + pthread_exit, pthread_sigmask); signal(SIGINT,shutdown_server); signal(SIGTERM,shutdown_server); diff --git a/examples/cairo/CMakeLists.txt b/examples/cairo/CMakeLists.txt index e34ae8ac..cfe1e1c9 100644 --- a/examples/cairo/CMakeLists.txt +++ b/examples/cairo/CMakeLists.txt @@ -1,7 +1,7 @@ include_directories (${PROJECT_SOURCE_DIR}/src/) add_executable(cairo_example cairo.c) -target_link_libraries(cairo_example onion onion_extras cairo m) +target_link_libraries(cairo_example onion onion_extras ${CAIRO_LIBRARIES} m) set_target_properties(cairo_example PROPERTIES OUTPUT_NAME "onion-cairo_example") install(TARGETS cairo_example DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/examples/ofileserver/CMakeLists.txt b/examples/ofileserver/CMakeLists.txt index 5bf364f2..509593df 100644 --- a/examples/ofileserver/CMakeLists.txt +++ b/examples/ofileserver/CMakeLists.txt @@ -1,5 +1,5 @@ -include_directories (${PROJECT_SOURCE_DIR}/src/) -include_directories (${CMAKE_CURRENT_BINARY_DIR}) +include_directories (${PROJECT_SOURCE_DIR}/src/) +include_directories (${CMAKE_CURRENT_BINARY_DIR}) find_program(HAVE_MSGFMT msgfmt) add_custom_command( @@ -13,28 +13,28 @@ if(HAVE_MSGFMT) add_custom_target( fo_zh ALL COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/locale/LC_MESSAGES/ - COMMAND msgfmt ${CMAKE_CURRENT_SOURCE_DIR}/zh.po + COMMAND msgfmt ${CMAKE_CURRENT_SOURCE_DIR}/zh.po -o ${CMAKE_CURRENT_BINARY_DIR}/locale/LC_MESSAGES/zh.mo DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/zh.po ) add_custom_target( fo_es ALL COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/locale/LC_MESSAGES/ - COMMAND msgfmt ${CMAKE_CURRENT_SOURCE_DIR}/es.po + COMMAND msgfmt ${CMAKE_CURRENT_SOURCE_DIR}/es.po -o ${CMAKE_CURRENT_BINARY_DIR}/locale/LC_MESSAGES/es.mo DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/es.po ) add_custom_target( fo_fr ALL COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/locale/LC_MESSAGES/ - COMMAND msgfmt ${CMAKE_CURRENT_SOURCE_DIR}/fr.po + COMMAND msgfmt ${CMAKE_CURRENT_SOURCE_DIR}/fr.po -o ${CMAKE_CURRENT_BINARY_DIR}/locale/LC_MESSAGES/fr.mo DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/fr.po ) add_custom_target( fo_pl ALL COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/locale/LC_MESSAGES/ - COMMAND msgfmt ${CMAKE_CURRENT_SOURCE_DIR}/pl.po + COMMAND msgfmt ${CMAKE_CURRENT_SOURCE_DIR}/pl.po -o ${CMAKE_CURRENT_BINARY_DIR}/locale/LC_MESSAGES/pl.mo DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/pl.po ) @@ -42,11 +42,18 @@ endif(HAVE_MSGFMT) add_executable(ofileserver fileserver.c fileserver_html.c) -target_link_libraries(ofileserver onion_static m ) -if (${Z_LIB}) - target_link_libraries(ofileserver ${Z_LIB}) -endif(${Z_LIB}) +target_link_libraries(ofileserver onion_static m) + +if (GETTEXT_ENABLED) + if (INTL_LIBRARIES) + target_link_libraries(ofileserver ${INTL_LIBRARIES}) + endif (INTL_LIBRARIES) +endif (GETTEXT_ENABLED) + +find_package(ZLIB) +if (${ZLIB_FOUND}) + target_link_libraries(ofileserver ${ZLIB_LIBRARIES}) +endif(${ZLIB_FOUND}) set_target_properties(ofileserver PROPERTIES OUTPUT_NAME "onion-ofileserver") install(TARGETS ofileserver DESTINATION ${CMAKE_INSTALL_BINDIR}) - diff --git a/examples/ofileserver/fileserver.c b/examples/ofileserver/fileserver.c index 735b769e..140b7cef 100644 --- a/examples/ofileserver/fileserver.c +++ b/examples/ofileserver/fileserver.c @@ -27,7 +27,7 @@ #include #include #include -#ifdef GETTEXT_ENABLED +#ifdef HAVE_GETTEXT # include #endif #include @@ -102,7 +102,7 @@ int main(int argc, char **argv){ onion_handler_add(root, onion_handler_export_local_new(dirname)); // This is the root directory where the translations are. -#ifdef GETTEXT_ENABLED +#ifdef HAVE_GETTEXT #define W "." setenv("LANGUAGE","locale",1); // Remove LANGUAGE env var, set it to the locale name, setlocale(LC_ALL,""); diff --git a/examples/otop/CMakeLists.txt b/examples/otop/CMakeLists.txt index 3c6b5f4c..7712a926 100644 --- a/examples/otop/CMakeLists.txt +++ b/examples/otop/CMakeLists.txt @@ -10,7 +10,7 @@ add_executable(otop otop.c otop_data.c) target_link_libraries(otop onion ) if(${ONION_POLLER} STREQUAL "libev") - target_link_libraries(otop -lev) + target_link_libraries(otop ${LIBEV_LIBRARIES}) endif() install(TARGETS otop DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/install-dependencies.sh b/install-dependencies.sh new file mode 100644 index 00000000..107556c5 --- /dev/null +++ b/install-dependencies.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +if [[ $TRAVIS_OS_NAME == 'osx' ]]; then + + # Install some custom requirements on OS X + # e.g. brew install pyenv-virtualenv + + brew update; + brew tap homebrew/versions; + brew install gnutls; + brew install libgcrypt; + brew install hiredis; + brew install bdw-gc; + brew install libev; + brew install gettext; + + #FIXME: temporary hack for mac as gettext is not detected otherwise + ln -s /usr/local/Cellar/gettext/*/lib/libintl.dylib /usr/local/lib/; + ln -s /usr/local/Cellar/gettext/*/include/libintl.h /usr/local/include; + + if [[ $CXX == 'g++' ]]; then brew install gcc5 --enable-cxx; fi + if [[ $CXX == 'clang++' ]]; then brew install llvm37 --enable-cxx; fi +fi \ No newline at end of file diff --git a/src/bindings/cpp/CMakeLists.txt b/src/bindings/cpp/CMakeLists.txt index 2b379a3a..df927824 100644 --- a/src/bindings/cpp/CMakeLists.txt +++ b/src/bindings/cpp/CMakeLists.txt @@ -6,7 +6,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++0x") SET(INCLUDES_ONIONCPP onion.hpp dict.hpp request.hpp response.hpp url.hpp handler.hpp extrahandlers.hpp shortcuts.hpp exceptions.hpp listen_point.hpp http.hpp https.hpp mime.hpp) target_link_libraries(onioncpp onion) -target_link_libraries(onioncpp_static onioncpp_static) +target_link_libraries(onioncpp_static onion) MESSAGE(STATUS "Found include files ${INCLUDES_ONIONCPP}") diff --git a/src/onion/CMakeLists.txt b/src/onion/CMakeLists.txt index 9229ee1f..2f762248 100644 --- a/src/onion/CMakeLists.txt +++ b/src/onion/CMakeLists.txt @@ -20,6 +20,21 @@ endif (LIBRT_FOUND) ## optional add sources and libraries depeding on features +# Poller can be a bit more complex, but basically the same. +if (${ONION_POLLER} STREQUAL libevent) + find_package(Libevent COMPONENTS core pthreads REQUIRED) + LIST(APPEND SOURCES poller_libevent.c) + include_directories(${LIBEVENT_INCLUDE_DIRS}) +endif (${ONION_POLLER} STREQUAL libevent) +if (${ONION_POLLER} STREQUAL libev) + find_package(LibEv REQUIRED) + LIST(APPEND SOURCES poller_libev.c) + include_directories(${LIBEV_INCLUDE_DIR}) +endif (${ONION_POLLER} STREQUAL libev) +if (${ONION_POLLER} STREQUAL epoll) + LIST(APPEND SOURCES poller.c) +endif (${ONION_POLLER} STREQUAL epoll) + # library dependencies if (${SQLITE3_ENABLED}) LIST(APPEND SOURCES sessions_sqlite3.c) @@ -37,57 +52,36 @@ else(${GNUTLS_ENABLED}) endif(${GNUTLS_ENABLED}) if (${XML2_ENABLED}) MESSAGE(STATUS "Compiling WebDAV support") - include_directories(${XML2_HEADERS}) + include_directories(${LIBXML2_INCLUDE_DIR}) LIST(APPEND SOURCES handlers/webdav.c) - LIST(APPEND LIBRARIES ${XML2_LIB}) + LIST(APPEND LIBRARIES ${LIBXML2_LIBRARIES}) endif (${XML2_ENABLED}) if (${PAM_ENABLED}) LIST(APPEND SOURCES handlers/auth_pam.c) - LIST(APPEND LIBRARIES pam pam_misc) + LIST(APPEND LIBRARIES ${PAM_LIBRARY}) endif (${PAM_ENABLED}) if (GNUTLS_ENABLED) - LIST(APPEND LIBRARIES gcrypt gnutls) + LIST(APPEND LIBRARIES ${GCRYPT_LIBRARIES} ${GNUTLS_LIBRARIES}) endif(GNUTLS_ENABLED) if (PTHREADS) LIST(APPEND LIBRARIES pthread) endif(PTHREADS) if (SQLITE3_ENABLED) - LIST(APPEND LIBRARIES ${SQLITE3_LIB}) + LIST(APPEND LIBRARIES ${SQLITE3_LIBRARIES}) endif(SQLITE3_ENABLED) if (REDIS_ENABLED) - LIST(APPEND LIBRARIES ${REDIS_LIB}) + LIST(APPEND LIBRARIES ${HIREDIS_LIBRARIES}) endif(REDIS_ENABLED) if (${ONION_POLLER} STREQUAL libevent) - LIST(APPEND LIBRARIES event_core event_pthreads) + LIST(APPEND LIBRARIES ${LIBEVENT_LIBRARIES}) endif (${ONION_POLLER} STREQUAL libevent) if (${ONION_POLLER} STREQUAL libev) - LIST(APPEND LIBRARIES ${LIBEV_LIB}) + LIST(APPEND LIBRARIES ${LIBEV_LIBRARIES}) endif (${ONION_POLLER} STREQUAL libev) if (SYSTEMD_ENABLED) - LIST(APPEND LIBRARIES ${SD_DAEMON_LIB}) + LIST(APPEND LIBRARIES ${SYSTEMD_LIBRARIES}) endif(SYSTEMD_ENABLED) - -# Poller can be a bit more complex, but basically the same. -if (${ONION_POLLER} STREQUAL libevent) - LIST(APPEND SOURCES poller_libevent.c) -endif (${ONION_POLLER} STREQUAL libevent) -if (${ONION_POLLER} STREQUAL libev) - LIST(APPEND SOURCES poller_libev.c) - find_path(LIBEV_HEADER ev.h ${CMAKE_INCLUDE_PATH} /usr/local/include/) - find_library(LIBEV_LIB NAMES ev PATH /usr/local/lib/) - if (LIBEV_LIB) - message(STATUS "libev found at ${LIBEV_LIB}") - else (LIBEV_LIB) - message(FATAL_ERROR "libev not found. Cant compile. ${LIBEV_HEADER} ${LIBEV_LIB}") - endif (LIBEV_LIB) - include_directories(${LIBEV_HEADER}) -endif (${ONION_POLLER} STREQUAL libev) -if (${ONION_POLLER} STREQUAL epoll) - LIST(APPEND SOURCES poller.c) -endif (${ONION_POLLER} STREQUAL epoll) - - IF (${CMAKE_BUILD_TYPE} MATCHES "Fast") add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/all-onion.c diff --git a/src/onion/extras/CMakeLists.txt b/src/onion/extras/CMakeLists.txt index 0dfb4447..87dfb600 100644 --- a/src/onion/extras/CMakeLists.txt +++ b/src/onion/extras/CMakeLists.txt @@ -17,14 +17,14 @@ endif (${JPEG_ENABLED}) add_library(onion_extras STATIC ${PNG} ${JPEG}) if (${PNG_ENABLED}) -target_link_libraries(onion_extras ${PNG_LIB}) +target_link_libraries(onion_extras ${PNG_LIBRARIES}) endif (${PNG_ENABLED}) if (${JPEG_ENABLED}) -target_link_libraries(onion_extras ${JPEG_LIB}) +target_link_libraries(onion_extras ${JPEG_LIBRARIES}) endif (${JPEG_ENABLED}) -SET(INCLUDES_EXTRAS ${PNG_HEADER} ${JPEG_HEADER}) +SET(INCLUDES_EXTRAS png.h jpeg.h) MESSAGE(STATUS "Found include files ${INCLUDES_EXTRAS}") diff --git a/src/onion/handlers/auth_pam.c b/src/onion/handlers/auth_pam.c index ba367532..97477e67 100644 --- a/src/onion/handlers/auth_pam.c +++ b/src/onion/handlers/auth_pam.c @@ -26,7 +26,6 @@ #include #include -#include #include #include diff --git a/src/onion/low.c b/src/onion/low.c index 88696e8d..84ba1720 100644 --- a/src/onion/low.c +++ b/src/onion/low.c @@ -41,7 +41,7 @@ #include "low.h" #include "log.h" -/// @defgroup low Low level OS functions. Encapsulates some low level functions to allow other OS implementations (Bohem GC) +/// @defgroup low Low level OS functions. Encapsulates some low level functions to allow other OS implementations (Boehm GC) /* the pointers to user provided routines for memory management & memory failure */ diff --git a/tests/01-internal/03-response.c b/tests/01-internal/03-response.c index def24b1f..7d6cba3b 100644 --- a/tests/01-internal/03-response.c +++ b/tests/01-internal/03-response.c @@ -182,6 +182,7 @@ void t05_printf(){ onion_add_listen_point(server,NULL,NULL,onion_buffer_listen_point_new()); onion_request *request; char buffer[4096]; + char expected_result[4096]; memset(buffer,0,sizeof(buffer)); request=onion_request_new(server->listen_points[0]); @@ -196,7 +197,8 @@ void t05_printf(){ onion_request_free(request); onion_free(server); - FAIL_IF_NOT_STRSTR(buffer, "Hello world 123 (nil)"); + sprintf(expected_result, "%s %d %p", "Hello world", 123, NULL); + FAIL_IF_NOT_STRSTR(buffer, expected_result); END_LOCAL(); } diff --git a/tests/01-internal/06-onion.c b/tests/01-internal/06-onion.c index 5acdbaf3..e4682e50 100755 --- a/tests/01-internal/06-onion.c +++ b/tests/01-internal/06-onion.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include #include diff --git a/tests/01-internal/14-websockets.c b/tests/01-internal/14-websockets.c index 25645c8c..c5b8b606 100644 --- a/tests/01-internal/14-websockets.c +++ b/tests/01-internal/14-websockets.c @@ -187,7 +187,7 @@ void t02_websocket_server_w_ws(){ void t03_websocket_server_receive_small_packet(){ INIT_LOCAL(); int length = 0; - char *buffer = NULL, buffer2[114]; + char *buffer = NULL, buffer2[115]; memset(&ws_status,0,sizeof(ws_status)); onion *o=websocket_server_new(); onion_request *req=websocket_start_handshake(o); @@ -201,7 +201,7 @@ void t03_websocket_server_receive_small_packet(){ onion_websocket_read(ws, (char *)&buffer2, 120); - buffer2[113] = '\0'; + buffer2[114] = '\0'; FAIL_IF_NOT_EQUAL_STR(buffer2, "Some UTF-8-encoded chars which will be cut at the 117th char so I write some gap-filling text with no meaning unti"); onion_websocket_free(ws); diff --git a/tests/01-internal/CMakeLists.txt b/tests/01-internal/CMakeLists.txt index cdfb89bf..4f0c22bc 100644 --- a/tests/01-internal/CMakeLists.txt +++ b/tests/01-internal/CMakeLists.txt @@ -20,15 +20,19 @@ add_test(internal-server 05-server) if (GNUTLS_ENABLED) IF (CURL) -message(STATUS "Looking for certool") -FIND_PROGRAM(CERTTOOL certtool) -IF (CERTTOOL) -message(STATUS "Found certool compiling all tests") +message(STATUS "Looking for gnutls-certtool") +if (APPLE) + find_program(GNUTLS_CERTTOOL gnutls-certtool) +else (APPLE) + find_program(GNUTLS_CERTTOOL certtool) +endif (APPLE) +IF (GNUTLS_CERTTOOL) +message(STATUS "Found gnutls-certtool compiling all tests") add_custom_command( OUTPUT mycert.pem COMMAND - ${CERTTOOL} --generate-privkey --outfile mycert.key && - ${CERTTOOL} --generate-self-signed --load-privkey mycert.key --outfile mycert.crt --template ${CMAKE_CURRENT_SOURCE_DIR}/mycert.cfg && + ${GNUTLS_CERTTOOL} --generate-privkey --outfile mycert.key && + ${GNUTLS_CERTTOOL} --generate-self-signed --load-privkey mycert.key --outfile mycert.crt --template ${CMAKE_CURRENT_SOURCE_DIR}/mycert.cfg && cat mycert.crt mycert.key > mycert.pem DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/mycert.cfg ) @@ -36,13 +40,13 @@ add_custom_command( if(PTHREADS) add_executable(06-onion 06-onion.c utils.c mycert.pem) - target_link_libraries(06-onion onion curl) + target_link_libraries(06-onion onion ${CURL_LIBRARIES}) add_test(internal-onion 06-onion) endif(PTHREADS) -ELSE(CERTTOOL) -message(STATUS "Not found certool not compiling 06-server") -ENDIF (CERTTOOL) +ELSE(GNUTLS_CERTTOOL) +message(STATUS "Not found gnutls-certool not compiling 06-server") +ENDIF (GNUTLS_CERTTOOL) ENDIF (CURL) endif(GNUTLS_ENABLED) @@ -68,7 +72,7 @@ add_test(internal-sessions 11-sessions) IF (CURL) add_executable(12-cloexec 12-cloexec.c) -target_link_libraries(12-cloexec onion curl) +target_link_libraries(12-cloexec onion ${CURL_LIBRARIES}) add_test(internal-cloexec 12-cloexec) ENDIF (CURL) @@ -87,6 +91,11 @@ add_custom_command( DEPENDS ${OTEMPLATE} ${CMAKE_CURRENT_SOURCE_DIR}/../../AGPL.txt ) target_link_libraries(13-otemplates onion) +if (GETTEXT_ENABLED) + if (INTL_LIBRARIES) + target_link_libraries(13-otemplates ${INTL_LIBRARIES}) + endif (INTL_LIBRARIES) +endif (GETTEXT_ENABLED) add_test(internal-otemplates 13-otemplates) endif (OTEMPLATE) diff --git a/tests/01-internal/utils.c b/tests/01-internal/utils.c index a0fbe136..34524a1a 100644 --- a/tests/01-internal/utils.c +++ b/tests/01-internal/utils.c @@ -15,17 +15,20 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ - #include "utils.h" #include #include #include #include +#include #include #include #include +#ifndef SOCK_CLOEXEC +#define SOCK_CLOEXEC 0 +#endif int connect_to(const char *addr, const char *port){ struct addrinfo hints; diff --git a/tests/07-tools/CMakeLists.txt b/tests/07-tools/CMakeLists.txt index b874869e..e4c95d59 100644 --- a/tests/07-tools/CMakeLists.txt +++ b/tests/07-tools/CMakeLists.txt @@ -1,5 +1,5 @@ -include_directories (${PROJECT_SOURCE_DIR}/src/) +include_directories (${PROJECT_SOURCE_DIR}/src/) add_custom_command( OUTPUT test_html.c @@ -32,6 +32,12 @@ add_custom_command( add_executable(01-otemplate 01-otemplate.c test_html.c external_html.c extended_html.c base_html.c) target_link_libraries(01-otemplate onion_static) +if (GETTEXT_ENABLED) + if (INTL_LIBRARIES) + target_link_libraries(01-otemplate ${INTL_LIBRARIES}) + endif (INTL_LIBRARIES) +endif (GETTEXT_ENABLED) + # add_executable(02-test 02-test.cpp test_html.c external_html.c extended_html.c base_html.c) # target_link_libraries(02-test onion_static onion_handlers onioncpp) diff --git a/tools/common/updateassets.c b/tools/common/updateassets.c index f6425fb4..8d9c104e 100644 --- a/tools/common/updateassets.c +++ b/tools/common/updateassets.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "updateassets.h" diff --git a/tools/opack/CMakeLists.txt b/tools/opack/CMakeLists.txt index f595881b..8cc37e50 100644 --- a/tools/opack/CMakeLists.txt +++ b/tools/opack/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable(opack opack.c ../common/updateassets.c ../../src/onion/log.c ../. target_link_libraries(opack ${PTHREADS_LIB}) if(GNUTLS_ENABLED) - target_link_libraries(opack ${GNUTLS_LIB}) + target_link_libraries(opack ${GNUTLS_LIBRARIES}) endif(GNUTLS_ENABLED) install(TARGETS opack DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/tools/opack/opack.c b/tools/opack/opack.c index 2b4a7af3..b5c92bed 100644 --- a/tools/opack/opack.c +++ b/tools/opack/opack.c @@ -187,7 +187,9 @@ void parse_directory(const char *prefix, const char *dirname, FILE *outfd, onion if (de->d_name[0]=='.' || de->d_name[strlen(de->d_name)-1]=='~') continue; snprintf(fullname, sizeof(fullname), "%s/%s", dirname, de->d_name); - if (de->d_type==DT_DIR){ + struct stat s; + stat(de->d_name, &s); + if (S_ISDIR(s.st_mode)){ char prefix2[256]; snprintf(prefix2, sizeof(prefix2), "%s/%s", prefix, de->d_name); parse_directory(prefix2, fullname, outfd, assets); @@ -209,7 +211,9 @@ void parse_directory(const char *prefix, const char *dirname, FILE *outfd, onion if (de->d_name[0]=='.' || de->d_name[strlen(de->d_name)-1]=='~') continue; char *fname=funcname(prefix, de->d_name); - if (de->d_type==DT_DIR){ + struct stat s; + stat(de->d_name, &s); + if (S_ISDIR(s.st_mode)){ int l=strlen(de->d_name); fprintf(outfd, " if (strncmp(\"%s/\", path, %d)==0){\n", de->d_name, l+1); fprintf(outfd, " onion_request_advance_path(req, %d);\n", l+1); diff --git a/tools/otemplate/load.c b/tools/otemplate/load.c index 9acebb72..333b23bf 100644 --- a/tools/otemplate/load.c +++ b/tools/otemplate/load.c @@ -16,6 +16,8 @@ along with this program. If not, see . */ +#define _DARWIN_C_SOURCE + #include #include #include diff --git a/tools/otemplate/otemplate.c b/tools/otemplate/otemplate.c index 9e51ac0c..dda844b1 100644 --- a/tools/otemplate/otemplate.c +++ b/tools/otemplate/otemplate.c @@ -152,7 +152,7 @@ void help(const char *msg){ " error reporting refers to the C file, not the template.\n" " --asset-file|-a Write function definitions to an asset file. Defaults to assets.h\n" " Input filename or '-' to use stdin.\n" -" Output filename or '-' to use stdin.\n" +" Output filename or '-' to use stdout.\n" "\n" "Templatetags plugins are search in this order, always libPLUGIN.so, where PLUGIN is the plugin name:\n" " 1. Set by command line with --templatetagsdir or -t\n" @@ -237,7 +237,7 @@ int work(const char *infilename, const char *outfilename, onion_assets_file *ass fprintf(status.out, "/** Autogenerated by otemplate v. 0.2.0 */\n" "\n" -#ifdef GETTEXT_ENABLED +#ifdef HAVE_GETTEXT "#include \n" #endif "#include \n\n"