diff --git a/.bzrignore b/.bzrignore index f5e8d596f..45e3f5276 100644 --- a/.bzrignore +++ b/.bzrignore @@ -7,3 +7,5 @@ autom4te.cache objdir* Win32 x64 +docs/webpage_docs-1.1.0 +docs/log4cplus-1.1.0/docs diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 000000000..ef507e566 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,14 @@ +;;; Directory Local Variables +;;; See Info node `(emacs) Directory Variables' for more information. + +((nil . + ((fill-column . 79) + (indent-tabs-mode) + (show-trailing-whitespace . t) + (whitespace-style face trailing lines-tail space-before-tab indentation empty) + (whitespace-newline . t))) + (c++-mode . + ((tab-width . 4) + (whitespace-action warn-read-only auto-cleanup))) + (cmake-mode . + ((whitespace-action warn-read-only auto-cleanup)))) diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..7cc0be609 --- /dev/null +++ b/.gitignore @@ -0,0 +1,58 @@ +*.user +*.ncb +*.suo +*.sdf +*.opensdf +.#* +*~ +*.bak +ipch/ +autom4te.cache/ +objdir*/ +Win32/ +x64/ + +.idea + +# LaTeX/PDF produciton byproducts +*.aux +*.log +*.tex +*.toc +*.xwm +*.pdf +*.ref_rename_step + +# Compiler produced temporaries +*.s +*.ii + +# Patches +*.patch +*.diff + +# +# From Github's C++.gitignore: +# + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..ed037bea7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,61 @@ +language: cpp +compiler: + - gcc +env: + - PARAM_THREADS="--enable-threads --with-working-c-locale" + CXXFLAGS="" + - PARAM_THREADS="--enable-threads --with-working-locale" + CXXFLAGS="" + - PARAM_THREADS="--enable-threads --with-working-c-locale" + CXXFLAGS="-DUNICODE" + - PARAM_THREADS="--enable-threads --with-working-locale" + CXXFLAGS="-DUNICODE" + - PARAM_THREADS="--disable-threads --with-working-locale" + CXXFLAGS="" + - PARAM_THREADS="--disable-threads --with-working-locale" + CXXFLAGS="-DUNICODE" + - PARAM_THREADS="--enable-threads --with-iconv" + CXXFLAGS="" + - PARAM_THREADS="--enable-threads --with-iconv" + CXXFLAGS="-DUNICODE" + - PARAM_THREADS="--disable-threads --with-iconv" + CXXFLAGS="" + - PARAM_THREADS="--disable-threads --with-iconv" + CXXFLAGS="-DUNICODE" +before_install: + - wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add - + - sudo add-apt-repository --yes + 'deb http://ppa.launchpad.net/canonical-x/x-staging/ubuntu precise main' + - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test + - sudo apt-get update -qq + - sudo apt-get install -q + gcc-4.8 + g++-4.8 + libstdc++-4.8-dev + llvm-3.4 + clang-3.4 + swig + python + - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 + --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 + - sudo update-alternatives --config gcc +before_script: + - sh ./scripts/fix-timestamps.sh + - mkdir objdir + - cd objdir +script: ../configure $PARAM_THREADS + CXXFLAGS="$CXXFLAGS" + SWIG_FLAGS="$SWIG_FLAGS" + && make +after_failure: + - cat config.log + - cat tests/testsuite.log +branches: + only: + - 1.1.x +notifications: + recipients: + - vhaisman@gmail.com + email: + on_success: always + on_failure: always diff --git a/AUTHORS b/AUTHORS index e75e4e034..7651e8ebe 100644 --- a/AUTHORS +++ b/AUTHORS @@ -17,3 +17,12 @@ Andreas Bießmann Jens Rehsack Siva Chandran P Chernyshev Vyacheslav +Chris Steenwyk +Jukka Lantto +Konstantin Baumann +Yaqian Shen +Sergey Nikulov +Ray Logel +Maxym +Zhang Shengfa +Oskari Timperi diff --git a/CMakeLists.txt b/CMakeLists.txt index 7396d8065..00c1a9a9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,37 @@ +# This block needs to stay before the project (log4cplus) line so that +# the output files placed into Android's libs directory. +if (CMAKE_TOOLCHAIN_FILE) + get_filename_component(TOOL_CHAIN_FILE_NAME "${CMAKE_TOOLCHAIN_FILE}" NAME_WE) + if("${TOOL_CHAIN_FILE_NAME}" MATCHES "android.toolchain") + # Android: set output folder to ${CMAKE_BINARY_DIR} + set (LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH + "root for library output, set this to change where Android libs are compiled to") + endif() +endif () +# Remove when CMake >= 2.8.4 is required +set (CMAKE_LEGACY_CYGWIN_WIN32 0) + project (log4cplus) -cmake_minimum_required (VERSION 2.8.0) +cmake_minimum_required (VERSION 2.8.4) -set (log4cplus_version_major 1) -set (log4cplus_version_minor 1) -set (log4cplus_version_patch 0) -set (log4cplus_soversion 0) +enable_language (CXX) +include(GNUInstallDirs) + +include (Log4CPlusUtils.cmake) +log4cplus_get_version ("${PROJECT_SOURCE_DIR}/include" + log4cplus_version_major log4cplus_version_minor log4cplus_version_patch) +message("-- Generating build for Log4cplus version ${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}") +set (log4cplus_soversion 11) set (log4cplus_postfix "") option(LOG4CPLUS_BUILD_TESTING "Build the test suite." ON) -find_package (Threads) -message (STATUS "Threads: ${CMAKE_THREAD_LIBS_INIT}") +option(LOG4CPLUS_BUILD_LOGGINGSERVER "Build the logging server." ON) + +if(NOT LOG4CPLUS_SINGLE_THREADED) + find_package (Threads) + message (STATUS "Threads: ${CMAKE_THREAD_LIBS_INIT}") +endif(NOT LOG4CPLUS_SINGLE_THREADED) set(BUILD_SHARED_LIBS TRUE CACHE BOOL "If TRUE, log4cplus is built as a shared library, otherwise as a static library") @@ -40,33 +61,72 @@ option(UNICODE "Build with tchar = wchar_t" ${UNICODE_DEFAULT}) option(WITH_ICONV "Use iconv() for char->wchar_t conversion." OFF) -if (UNICODE) - set (log4cplus_postfix "${log4cplus_postfix}U") -endif (UNICODE) +option(ENABLE_SYMBOLS_VISIBILITY + "Enable compiler and platform specific options for symbols visibility" + ON) + +set(_WIN32_WINNT 0x0501 CACHE STRING "Define Windows API version to use.") +set(NTDDI_VERSION 0x05010200 CACHE STRING "Define Windows API version for NTDDI_VERSION") + +option(LOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME + "Turns on resulting file name decoration for static and UNICODE builds." ON) +if (LOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME) + if (NOT ${BUILD_SHARED_LIBS}) + # set S-prefix for static build + set (log4cplus_postfix "${log4cplus_postfix}S") + endif () + + if (UNICODE) + set (log4cplus_postfix "${log4cplus_postfix}U") + endif (UNICODE) +endif (LOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME) + +set (log4cplus "log4cplus${log4cplus_postfix}") if (WITH_ICONV) set(LOG4CPLUS_WITH_ICONV 1) endif () -set (log4cplus "log4cplus${log4cplus_postfix}") +if(LOG4CPLUS_CONFIGURE_CHECKS_PATH) + get_filename_component(LOG4CPLUS_CONFIGURE_CHECKS_PATH "${LOG4CPLUS_CONFIGURE_CHECKS_PATH}" ABSOLUTE) +endif() + +if(LOG4CPLUS_CONFIGURE_CHECKS_PATH AND EXISTS ${LOG4CPLUS_CONFIGURE_CHECKS_PATH}) + message(STATUS "Custom ConfigureChecks script found: ${LOG4CPLUS_CONFIGURE_CHECKS_PATH}") +else() + set(LOG4CPLUS_CONFIGURE_CHECKS_PATH "ConfigureChecks.cmake") +endif() + +include(${LOG4CPLUS_CONFIGURE_CHECKS_PATH}) -include(ConfigureChecks.cmake) +# Prepare defines.hxx.cmake from defines.hxx.in by doing a bit of +# string manipulation. +file(READ include/log4cplus/config/defines.hxx.in FILE_BUFFER) +string(REGEX REPLACE "#undef[^a-zA-Z0-9_]+([a-zA-Z0-9_]+)" + "#cmakedefine \\1 @\\1@" FILE_BUFFER "${FILE_BUFFER}") +set(DEFINES_HXX_CMAKE + ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx.cmake) +set(DEFINES_HXX ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx) +file(WRITE ${DEFINES_HXX_CMAKE} ${FILE_BUFFER}) -configure_file(include/log4cplus/config.h.cmake.in - ${log4cplus_BINARY_DIR}/include/log4cplus/config.h @ONLY) -configure_file(include/log4cplus/config/defines.hxx.cmake.in - ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx @ONLY) +configure_file(${DEFINES_HXX_CMAKE} ${DEFINES_HXX} @ONLY) include_directories (${log4cplus_SOURCE_DIR}/include ${log4cplus_BINARY_DIR}/include ) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) + if (LOG4CPLUS_BUILD_TESTING) enable_testing() endif (LOG4CPLUS_BUILD_TESTING) add_subdirectory (src) -add_subdirectory (loggingserver) + +if (LOG4CPLUS_BUILD_LOGGINGSERVER) + add_subdirectory (loggingserver) +endif (LOG4CPLUS_BUILD_LOGGINGSERVER) + if (LOG4CPLUS_BUILD_TESTING) add_subdirectory (tests) endif (LOG4CPLUS_BUILD_TESTING) diff --git a/ChangeLog b/ChangeLog index dc83dbacb..d786545e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,293 @@ +log4cplus 1.1.3-RC8 + +- Fixed GitHub issue #195. Check if queue thread pointer is not NULL and if + it is running before trying to join it. + +- Fixed GitHub issue #205. Fixed NULL pointer dereference of queue in + `AsyncAppender` code. + +- Fixed SF#333. `AsyncAppender`'s appenders need to be closed so that + accumulated logs get flushed onto disk. + +- Updated `android.toolchain.cmake` from OpenCV. + +- Fixed GitHub issue #215. Mark `~HierarchyLocker()` with `noexcept(false)` + to avoid unlikely but possible `terminate()` call and a warning message + during compilation. + +- Disabled TLS support for iOS. + +- Do not use language level thread-local storage on Cygwin. (GCC PR64697). + +- Allow filters cofiguration in `AsyncAppender`. (suggested in SF#297 by + Markus von Arx) + +- Handle `SocketBuffer` overflow by throwing exception. + + +log4cplus 1.1.3-RC7 + +- Fixed SF#322. -- C++11 construct that should not be present. + +- Fixed FreeAddrInfoA and FreeAddrInfoW not found. -- This required bump to + minimal version to Windows XP SP2. + +- Fixed missing thread's alternative name. -- GitHub bug #137. + +- Fixed GitHub bug #155. -- Process shutdown issues. + +- Fix GitHub bug #136. -- Adjust weekly, daily and twice daily rollover time + for `DailyRollingFileAppender` by time zone offset so that the rollover + happens at midnight, etc., of local time instead of UTC time. + +- Fix CMake/Visual Studio 2010 compilation. -- GitHub issue #188. + + +log4cplus 1.1.3-RC6 + +- Fixed GitHub issue #112 - sockets and memory leak in loggingserver. + + +log4cplus 1.1.3-RC5 + +- Fixed "most vexing parse" issue when using LOG4CPLUS_C_STR_TO_TSTRING(). + +- Fixed AcceptOnMatch property function in filters default to true value. + +- Fixed GitHub bug #92. DailyRollingFileAppender rollover time was drifting. + +- Added LOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME option to CMake builds to + produce log4cplus library without Unicode and/or static library decoration. + + +log4cplus 1.1.3-RC4 + +- Allow negative maximal length in pattern specifier to make trimming of end + instead of beginning possible. E.g., allow %.-1p to get initial letters of + log level. + +- Visual Studio DLL builds now have a resource with basic information about + the library. (Oskari Timperi) + +- LOG4CPLUS_*_FMT() macros can now be invoked with just formatting string, + without additional arguments. (Zhang Shengfa) + +- Added setCurrentThreadName() and setCurrentThreadName2() to allow setting + current thread name to custom string instead of the default stringified + thread ID. (Zhang Shengfa) + + +log4cplus 1.1.3-RC3 + +- Fixed bug #298. -- int to pointer cast error on Xcode 5.1. + +- Documented a work-around for Android's emutls issue. + +- Stopped using SOVERSION and VERSION properties in Android CMake builds. + + +log4cplus 1.1.3-RC2 + +- Fixed bug #295 - infinite loop when underlying *printf() function returned + EILSEQ. + +- Use PROJECT_SOURCE_DIR variable instead of CMAKE_SOURCE_DIR to allow using + log4cplus as sub-project of another CMake project. + + +log4cplus 1.1.3-RC1 + +- Added --enable-symbols-visibility-options to configure script to allow + turning off use of compiler and platform specific symbols visibility + options. + +- Added ENABLE_SYMBOLS_VISIBILITY setting for CMake build system to the same + effect as above. + +- Disabled LOG4CPLUS_INLINES_ARE_EXPORTED to fix linking issues on MinGW GCC + 4.8.x. + +- Added LOG4CPLUS_BUILD_LOGGINGSERVER setting for CMake build system to allow + disabling loggingserver. (Maxym) + +- Allow users overriding LOG4CPLUS_MACRO_FUNCTION. + +- Improved Android platform detection in CMake build system. (Maxym) + +- Allow overriding ConfigureChecks.cmake with user supplied file to help with + issues on iOS platform. + +- Updated android.toolchain.cmake from OpenCV project. + +- Added iOS support to CMake build system. (Maxym) + +- Fixed compilation issue of single-threaded builds on Windows. + +- Improved CMake build system's default installation directories for GNU + platforms by using GNUInstallDirs module. + + +log4cplus 1.1.2 + +- Added AbstractSocket::shutdown(). + +- Added missing documentation of MDC pattern layout converter. + +- Fixed bug #278 - TLS key leak. + +- Implemented %E{ENVVAR} pattern layout formatter for expansion of environment + variables. (Ray Logel) + + +log4cplus 1.1.2-RC3 + +- Fixed build issues on HP-UX with aCC. + +- Fixed build issues on Haiku. + +- Added mingw-log4cplus.spec to allow cross-compilation from + Fedora. (John Smits) + +- Fixed build issues on AIX with XLC. + +- Fixed build issues related to Microsoft's foo_s() functions with + some version of MinGW tool-chain. + +- Tiny speedup of getFormattedTime(). + +- Imported newer android/android.toolchain.cmake from OpenCV + repository. + + +log4cplus 1.1.2-RC2 + +- Fixed crash of DLL builds on Windows when _WIN32_WINNT>=0x0600. + +- Roll log file both before and after append to avoid logging into + stale file when the log file has already been rolled by another + logging process. + +- Known issue: Logging into a single log file from multiple processes + on Windows breaks the rolling of the log files because open files + cannot be renamed. + +- Fixed bug #166 - Close appender only once even when it is used by + multiple loggers. + + +log4cplus 1.1.2-RC1 + +- Fixed bug #163 - Initialization issue. + +- Added --enable-so-version and --enable-release-version configure + script options to allow production of undecorated binaries. + + +log4cplus 1.1.1 + +- FileAppender - Accept also std::ios_base::ate as "append to a log + file" specification. + + +log4cplus 1.1.1-RC4 + +- Fixed bug #156 - Messages are truncated when produced using the + LOG4CPLUS_*_FMT() macros. + +- Fixed bug #157 - Fedora package build failure. + +- Improved log4cplus initialization: + + - Use APC to initialize log4cplus outside loader lock. + + - Use Microsoft C runtime library TLS callbacks to initialize + log4cplus as static library. + + - Warn during compilation that automatic initialization is not + possible when log4cplus is being compiled with static Microsoft C + runtime library. + + - Provide log4cplus::initialize() function to allow users to + initialize log4cplus in situations where automatic initialization + is not possible. + +- Several improvements to CMake build: + + - Fixed OpenBSD + CMake builds. + + - Fixed issues with Visual Studio 2005 CMake builds. + + - Added support for CMake builds on Android with NDK. (Sergey + Nikulov) + + - The defines.hxx.cmake file is now generated out of defines.hxx.in. + + - Library version is parsed out of version.h. (Sergey Nikulov) + +- MDC formatter for PatternLayout ("%X") now expands into list of key + value pairs if no specific key is given. (Yaqian Shen) + +- Avoid clock_nanosleep() on Android. + +- ServerSocket::accept() can now be interrupted from another thread + using new function ServerSocket::interruptAccept(). + + +log4cplus 1.1.1-RC3 + +- Fixed another MinGW related build failure. + +- Fixed mismatched #if/#endif in Windows builds. + + +log4cplus 1.1.1-RC2 + +- Allow to disable TLS usage in macros through + LOG4CPLUS_MACRO_DISABLE_TLS preprocessor symbol. + +- Fixed compilation with Clang on Cygwin. + +- Fixed SIGSEGV when built with some MinGW distributions. + +- Fixed build failure when using -march=i386. + +- Implemented thread callback to initialize log4cplus for Visual + Studio builds of static library. + +- Fixed bug #154 - getHostname() failure because of uninitialized + WinSock. + +- Fixed detection of C++11 thread_local keyword. + +- Fixed builds using DevKit-tdm-32-4.5.2-20111229-1559. + + +log4cplus 1.1.1-RC1 + +- Improved documentation for various classes. + +- Cherry-picked various small improvements from trunk. + +- Fixed Unicode builds on *NIX. + +- Fixed static library builds from Visual Studio project. + +- Suppressed warning C4127 from MSVC. (Chris Steenwyk) + +- Improved MinGW32 and MinGW64 toolchains compatiblity. + +- Fixed encoding handling in Properties class. + +- Added include directive for properties files. (Jukka Lantto) + +- Added colored output for Win32ConsoleAppender. (Konstantin Baumann) + +- (Re)Introduced support for C++Builder (XE3) + +- Reimplemented acceptSocket() using select() on Windows to allow + interrupting the accept() call from different thread. + + log4cplus 1.1.0 - Fixed MacOS X support - Reimplemented semaphores using named ones diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index d62cd4c02..2090bd6bf 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -12,16 +12,16 @@ check_include_files(errno.h LOG4CPLUS_HAVE_ERRNO_H ) check_include_files(iconv.h LOG4CPLUS_HAVE_ICONV_H ) check_include_files(limits.h LOG4CPLUS_HAVE_LIMITS_H ) check_include_files(sys/types.h LOG4CPLUS_HAVE_SYS_TYPES_H ) -check_include_files(sys/socket.h LOG4CPLUS_HAVE_SYS_SOCKET_H ) +check_include_files("sys/types.h;sys/socket.h" LOG4CPLUS_HAVE_SYS_SOCKET_H ) check_include_files(sys/syscall.h LOG4CPLUS_HAVE_SYS_SYSCALL_H ) -check_include_files(sys/time.h LOG4CPLUS_HAVE_SYS_TIME_H ) -check_include_files(sys/timeb.h LOG4CPLUS_HAVE_SYS_TIMEB_H ) -check_include_files(sys/stat.h LOG4CPLUS_HAVE_SYS_STAT_H ) +check_include_files("sys/types.h;sys/time.h" LOG4CPLUS_HAVE_SYS_TIME_H ) +check_include_files("sys/types.h;sys/timeb.h" LOG4CPLUS_HAVE_SYS_TIMEB_H ) +check_include_files("sys/types.h;sys/stat.h" LOG4CPLUS_HAVE_SYS_STAT_H ) check_include_files(sys/file.h LOG4CPLUS_HAVE_SYS_FILE_H ) check_include_files(syslog.h LOG4CPLUS_HAVE_SYSLOG_H ) check_include_files(arpa/inet.h LOG4CPLUS_HAVE_ARPA_INET_H ) check_include_files(netinet/in.h LOG4CPLUS_HAVE_NETINET_IN_H ) -check_include_files(netinet/tcp.h LOG4CPLUS_HAVE_NETINET_TCP_H ) +check_include_files("sys/types.h;netinet/tcp.h" LOG4CPLUS_HAVE_NETINET_TCP_H ) check_include_files(netdb.h LOG4CPLUS_HAVE_NETDB_H ) check_include_files(unistd.h LOG4CPLUS_HAVE_UNISTD_H ) check_include_files(fcntl.h LOG4CPLUS_HAVE_FCNTL_H ) @@ -30,6 +30,7 @@ check_include_files(stdarg.h LOG4CPLUS_HAVE_STDARG_H ) check_include_files(stdlib.h LOG4CPLUS_HAVE_STDLIB_H ) check_include_files(time.h LOG4CPLUS_HAVE_TIME_H ) check_include_files(wchar.h LOG4CPLUS_HAVE_WCHAR_H ) +check_include_files(poll.h LOG4CPLUS_HAVE_POLL_H ) check_include_files(inttypes.h HAVE_INTTYPES_H ) @@ -55,6 +56,9 @@ check_function_exists(gmtime_r LOG4CPLUS_HAVE_GMTIME_R ) check_function_exists(localtime_r LOG4CPLUS_HAVE_LOCALTIME_R ) check_function_exists(gettimeofday LOG4CPLUS_HAVE_GETTIMEOFDAY ) check_function_exists(getpid LOG4CPLUS_HAVE_GETPID ) +check_function_exists(poll LOG4CPLUS_HAVE_POLL ) +check_function_exists(pipe LOG4CPLUS_HAVE_PIPE ) +check_function_exists(pipe2 LOG4CPLUS_HAVE_PIPE2 ) check_function_exists(ftime LOG4CPLUS_HAVE_FTIME ) check_function_exists(stat LOG4CPLUS_HAVE_STAT ) check_function_exists(lstat LOG4CPLUS_HAVE_LSTAT ) @@ -65,6 +69,7 @@ check_function_exists(htons LOG4CPLUS_HAVE_HTONS ) check_function_exists(ntohs LOG4CPLUS_HAVE_NTOHS ) check_function_exists(htonl LOG4CPLUS_HAVE_HTONL ) check_function_exists(ntohl LOG4CPLUS_HAVE_NTOHL ) +check_function_exists(shutdown LOG4CPLUS_HAVE_SHUTDOWN ) check_function_exists(vsnprintf LOG4CPLUS_HAVE_VSNPRINTF ) check_function_exists(_vsnprintf LOG4CPLUS_HAVE__VSNPRINTF ) check_function_exists(vsprintf_s LOG4CPLUS_HAVE_VSPRINTF_S ) @@ -192,7 +197,7 @@ if(NOT DEFINED LOG4CPLUS_DECLSPEC_EXPORT) endif() endif() -if(NOT DEFINED LOG4CPLUS_DECLSPEC_EXPORT) +if(NOT DEFINED LOG4CPLUS_DECLSPEC_EXPORT OR NOT ENABLE_SYMBOLS_VISIBILITY) set(LOG4CPLUS_DECLSPEC_EXPORT "") set(LOG4CPLUS_DECLSPEC_IMPORT "") set(LOG4CPLUS_DECLSPEC_PRIVATE "") diff --git a/Log4CPlusCPack.cmake b/Log4CPlusCPack.cmake index 495b7ef02..5986f62cf 100644 --- a/Log4CPlusCPack.cmake +++ b/Log4CPlusCPack.cmake @@ -1,6 +1,5 @@ set(CPACK_PACKAGE_NAME log4cplus) set(CPACK_PACKAGE_VERSION "${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "log4cplus is a log4j-inspired logging library for C++") - +set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE) include(CPack) - diff --git a/Log4CPlusUtils.cmake b/Log4CPlusUtils.cmake new file mode 100644 index 000000000..f63ea9d9b --- /dev/null +++ b/Log4CPlusUtils.cmake @@ -0,0 +1,17 @@ +# +# Utility macros for Log4Cplus project +# + +# Get Log4cplus version macro +# first param - path to include folder, we will rip version from version.h +macro(log4cplus_get_version _include_PATH vmajor vminor vpatch) + file(STRINGS "${_include_PATH}/log4cplus/version.h" _log4cplus_VER_STRING_AUX REGEX ".*#define[ ]+LOG4CPLUS_VERSION[ ]+") + string(REGEX MATCHALL "[0-9]+" _log4clpus_VER_LIST "${_log4cplus_VER_STRING_AUX}") + list(LENGTH _log4clpus_VER_LIST _log4cplus_VER_LIST_LEN) +# we also count '4' from the name... + if(_log4cplus_VER_LIST_LEN EQUAL 5) + list(GET _log4clpus_VER_LIST 2 ${vmajor}) + list(GET _log4clpus_VER_LIST 3 ${vminor}) + list(GET _log4clpus_VER_LIST 4 ${vpatch}) + endif() +endmacro() diff --git a/Makefile.in b/Makefile.in index 54773692a..c74f2b027 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -80,7 +80,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ @@ -225,6 +228,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/README b/README index e6c5a16a0..8fc5b0b45 100644 --- a/README +++ b/README @@ -1,3 +1,5 @@ +% log4cplus README + Short Description ================= @@ -10,17 +12,17 @@ Latest Project Information ========================== The latest up-to-date information for this project can be found at -http://log4cplus.sourceforge.net. Please submit bugs, patches, -feature requests, etc. there. +[log4cplus.sourceforge.net](http://log4cplus.sourceforge.net). Please +submit bugs, patches, feature requests, etc., there. Tested on the following platforms ================================= -- Linux/AMD64 with GCC 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) +- Linux/AMD64 with GCC 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1) - Linux/AMD64 with Sun C++ 5.12 Linux_i386 2011/11/16 -- Linux/AMD64 with Clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) - (based on LLVM 3.0) +- Linux/AMD64 with Clang version 3.2-1~exp9ubuntu1 + (tags/RELEASE_32/final) (based on LLVM 3.2) - Linux/AMD64 with Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.1 Build 20120410 - FreeBSD/AMD64 with GCC 3.4.6, 4.2.1 and 4.3.3 @@ -31,37 +33,62 @@ Tested on the following platforms - NetBSD 5.0.2/AMD64 with GCC 4.1.3 20080704 prerelease (NetBSD nb2 20081120) - OpenBSD 5.0/AMD64 with GCC 4.2.1 20070719 +- Haiku R1 Alpha 4.1 with GCC 4.6.3 Configure script options ======================== ---enable-debugging ------------------- +`--enable-debugging` +-------------------- This option is disabled by default. This option mainly affects GCC -builds but it also has some limitted effect on non-GCC builds. It -turns on debugging information generation, undefines NDEBUG symbol, -adds '-fkeep-inline-functions' and '-fstack-check' (GCC). +builds but it also has some limited effect on non-GCC builds. It +turns on debugging information generation, undefines `NDEBUG` symbol +and adds `-fstack-check` (GCC). ---enable-warnings ------------------ +`--enable-warnings` +------------------- This option is enabled by default. It adds platform / compiler dependent warning options to compiler command line. ---enable-profiling ------------------- +`--enable-so-version` +--------------------- + +This option is enabled by default. It enables SO version decoration +on resulting library file, e.g., the `.2.0.0` in +`liblog4cplus-1.2.so.2.0.0`. + + +`--enable-release-version` +-------------------------- + +This option is enabled by default. It enables release version +decoration on the resulting library file, e.g., the `-1.2` in +`liblog4cplus-1.2.so.2.0.0`. + + +`--enable-symbols-visibility-options` +------------------------------------- + +This option is enabled by default. It enables use of compiler and +platform specific option for symbols visibility. See also the +[Visibility](http://gcc.gnu.org/wiki/Visibility) page on GCC Wiki. + + +`--enable-profiling` +-------------------- This option is disabled by default. This option adds profiling -information generation compiler option -pg to GCC and Sun CC / Solaris -Studio builds. +information generation compiler option `-pg` to GCC and Sun CC / +Solaris Studio builds. ---enable-threads ----------------- +`--enable-threads` +------------------ This option is enabled by default. It turns on detection of necessary compiler and linker flags that enable POSIX threading support. @@ -72,50 +99,51 @@ script. One of the know deficiencies is Solaris Studio on Linux. See one of the later note for details. ---with-working-locale ---------------------- +`--with-working-locale` +----------------------- -This is one of three locale and wchar_t <-> char conversion related -options. It is disabled by default. +This is one of three locale and `wchar_t` <-> `char` conversion +related options. It is disabled by default. It is know to work well with GCC on Linux. Other platforms generally have lesser locale support in their implementations of the C++ -standard library. It is known not to work well on any *BSD. +standard library. It is known not to work well on any BSDs. See also docs/unicode.txt. ---with-working-c-locale ------------------------ +`--with-working-c-locale` +------------------------- -This is second of wchar_t <-> char conversion related options. It is -disabled by default. +This is second of `wchar_t` <-> `char` conversion related options. It +is disabled by default. -It is known to work well on most *NIX platforms, including recent Cygwin. +It is known to work well on most Unix--like platforms, including +recent Cygwin. ---with-iconv ------------- +`--with-iconv` +-------------- -This is third of wchar_t <-> char conversion related options. It is +This is third of `wchar_t` <-> `char` conversion related options. It is disabled by default. -The conversion using iconv() function always uses "UTF-8" and -"WCHAR_T" as source/target encodings. It is known to work well on -platforms with GNU iconv. Different implementations of iconv() might -not support "WCHAR_T" encoding selector. +The conversion using iconv() function always uses `"UTF-8"` and +`"WCHAR_T"` as source/target encoding. It is known to work well on +platforms with GNU iconv. Different implementations of `iconv()` +might not support `"WCHAR_T"` encoding selector. -Either system provided iconv() or library provided libiconv() are -detected and accepted. Also both SUSv3 and GNU iconv() function +Either system provided `iconv()` or library provided `libiconv()` are +detected and accepted. Also both SUSv3 and GNU `iconv()` function signatures are accepted. ---with-qt ---------- +`--with-qt` +----------- This option is disabled by default. It enables compilation of a separate shared library (liblog4cplusqt4debugappender) that implements -Qt4DebugAppender. It requires Qt4 and pkg-config to be installed. +`Qt4DebugAppender`. It requires Qt4 and pkg-config to be installed. Notes @@ -125,11 +153,28 @@ Cygwin/MinGW ------------ Some version of GCC (3.4.x and probably some of 4.x series too) on -Windows (both Mingw and Cygwin) produces lots of warnings of the form -"warning: inline function 'void foo()' is declared as dllimport: -attribute ignored." This can be worked around by adding --Wno-attributes option to GCC command. Unfortunatelly, not all -affected version of GCC have this option. +Windows (both Mingw and Cygwin) produces lots of warnings of the form: + +> warning: inline function 'void foo()' is declared as dllimport: + attribute ignored + +This can be worked around by adding `-Wno-attributes` option to GCC +command. Unfortunately, not all affected version of GCC have this +option. + + +MinGW and MSVCRT version +------------------------ + +log4cplus can use functions like `_vsnprintf_s()` (Microsoft's secure +version of `vsnprintf()`). MinGW tool--chains (by default) link to the +system MSVCRT.DLL. Unfortunately, older systems, like Windows XP, ship +with MSVCRT.DLL that lacks these functions. It is possible to compile +log4cplus with MinGW tool--chains but _without_ using the Microsoft's +secure functions by defining `__MSVCRT_VERSION__` to value less than +`0x900` and vice versa. + + $ ../configure CPPFLAGS="-D__MSVCRT_VERSION__=0x700" Windows and TLS @@ -137,28 +182,46 @@ Windows and TLS log4cplus uses thread-local storage (TLS) for NDC, MDC and to optimize use of some temporary objects. On Windows there are two ways to get -TLS: (1) using TlsAlloc() etc. functions, and (2) using -__declspec(thread). While method (2) generates faster code, it has -some limitations prior to Windows Vista. If log4cplus.dll is loaded -at run time using LoadLibrary() (or as a dependency of such loaded -library), then accessing __declspec(thread) variables can cause -general protection fault (GPF) errors. This is because Windows prior -to Windows Vista do not extend the TLS for libraries loaded at run -time using LoadLibrary(). To allow using the best available method, -log4cplus enables the method (2) by checking _WIN32_WINNT >= 0x0600 -condition, when compiling log4cplus targetted to Windows Vista or -later. +TLS: + +(1) using `TlsAlloc()`, etc., functions +(2) using `__declspec(thread)` + +While method (2) generates faster code, it has some limitations prior +to Windows Vista. If log4cplus.dll is loaded at run time using +`LoadLibrary()` (or as a dependency of such loaded library), then +accessing `__declspec(thread)` variables can cause general protection +fault (GPF) errors. This is because Windows prior to Windows Vista do +not extend the TLS for libraries loaded at run time using +LoadLibrary(). To allow using the best available method, log4cplus +enables the method (2) by checking `_WIN32_WINNT >= 0x0600` condition, +when compiling log4cplus targeted to Windows Vista or later. + + +Android, TLS and CMake +---------------------- + +[log4cplus] uses thread--local storage (TLS, see "Windows and TLS" for +details). On the Android platform, when [log4cplus] is being compiled using +the `android/android.toolchain.cmake`, you might get errors featuring the +`__emutls` symbol: + + + global-init.cxx:268:46: error: log4cplus::internal::__emutls_t._ZN9log4cplus8internal3ptdE causes a section type conflict with log4cplus::internal::ptd + +To work around this issue, invoke CMake with +`-DANDROID_FUNCTION_LEVEL_LINKING:BOOL=OFF` option. Threads and signals ------------------- -log4cplus is not safe to be used from async signals' handlers. This -is a property of most threaded programmes in general. If you are +log4cplus is not safe to be used from asynchronous signals' handlers. +This is a property of most threaded programmes in general. If you are going to use log4cplus in threaded application and if you want to use log4cplus from signal handlers then your only option is to block signals in all threads but one that will handle all signals. On POSIX -platforms, this is possible using the sigwait() call. log4cplus +platforms, this is possible using the `sigwait()` call. log4cplus enables this approach by blocking all signals in any threads created through its threads helpers. @@ -166,44 +229,44 @@ through its threads helpers. IBM's XL C/C++ compiler ----------------------- -IBM's XL C/C++ compiler executable has many variants ([1]). To -compile log4cplus with threading support specify one of the compiler -variants that support threading using the CXX variable on configure -script command line. E.g.: +IBM's XL C/C++ compiler executable has [many variants][1]. To compile +log4cplus with threading support specify one of the compiler variants +that support threading using the `CXX` variable on configure script +command line. E.g.: -$ ../configure --enable-threads CXX=xlC_r + $ ../configure --enable-threads CXX=xlC_r -[1] +[1]: http://pic.dhe.ibm.com/infocenter/comphelp/v121v141/index.jsp?topic=%2Fcom.ibm.xlcpp121.aix.doc%2Fcompiler_ref%2Ftucmpinv.html AIX reentrancy problem ---------------------- There appears to be a reentracy problem with AIX 5.3 and xlC 8 which -can result into a deadlock condition in some curcumstances. It is +can result into a deadlock condition in some circumstances. It is unknown whether the problem manifests with other versions of either the OS or the compiler, too. The problem was initially reported in a -bug report #3056687 ([1]). +bug report [#103][2]. The core of the problem is that IBM's/xlC's standard C++ IOStreams implementation uses global non recursive lock to protect some of its state. The application in the bug report was trying to do logging -using log4cplus from inside overflow() member function of a class -derived from std::streambuf class. log4cplus itself uses -std::ostringstream. This resulted into an attempt to recursivly lock -the global non recursive lock and a deadlock. +using log4cplus from inside `overflow()` member function of a class +derived from `std::streambuf` class. log4cplus itself uses +`std::ostringstream`. This resulted into an attempt to recursively +lock the global non recursive lock and a deadlock. -[1] +[2]: http://sourceforge.net/p/log4cplus/bugs/103/ Solaris / SunOS --------------- Some older version of this operating system might have problems -linking log4cplus due to missing __tls_get_addr ([1]) in their +linking log4cplus due to [missing `__tls_get_addr`][3] in their unpatched state. -[1] +[3]: https://groups.google.com/d/msg/comp.unix.solaris/AAMqkK0QZ6U/zlkVKA1L_QcJ Solaris Studio @@ -211,16 +274,17 @@ Solaris Studio Solaris Studio compilers' default standard C++ library is very non-standard. It seems that it is not conforming enough in, e.g., Sun -C++ 5.12 Linux_i386 2011/11/16 (missing std::time_t, etc.), but it +C++ 5.12 Linux_i386 2011/11/16 (missing `std::time_t`, etc.), but it works well enough on Solaris with Sun C++ 5.8 2005/10/13. Thus -log4cplus adds -library=stlport4 to the CXXFLAGS environment variable, -unless a switch matching -library=(stlport4|stdcxx4|Cstd) is already -present there. If you want to override the default supplied by -log4cplus, just set it into CXXFLAGS on configure script command line. +log4cplus adds `-library=stlport4` to the `CXXFLAGS` environment +variable, unless a switch matching `-library=(stlport4|stdcxx4|Cstd)` +is already present there. If you want to override the default +supplied by log4cplus, just set it into `CXXFLAGS` on configure script +command line. -Solaris Studio supports the __func__ symbol which can be used by +Solaris Studio supports the `__func__` symbol which can be used by log4cplus to record function name in logged events. To enable this -feature, add '-features=extensions' switch to CXXFLAGS for configure +feature, add `-features=extensions` switch to `CXXFLAGS` for configure script. Subsequently, you will have to add this switch to your application's build flags as well. @@ -228,67 +292,113 @@ application's build flags as well. Solaris Studio on GNU/Linux --------------------------- -The autotools and our configure.in combo does not handle Solaris +The autotools and our configure.ac combo does not handle Solaris Studio compiler on Linux well enough and needs a little help with configuration of POSIX threads: -$ COMMON_FLAGS="-L/lib/x86_64-linux-gnu/ -L/usr/lib/x86_64-linux-gnu/ \ --mt=yes -O" + $ COMMON_FLAGS="-L/lib/x86_64-linux-gnu/ \ + -L/usr/lib/x86_64-linux-gnu/ -mt=yes -O" + + $ ../configure --enable-threads=yes \ + CC=/opt/solarisstudio12.3/bin/cc \ + CXX=/opt/solarisstudio12.3/bin/CC \ + CFLAGS="$COMMON_FLAGS" \ + CXXFLAGS="$COMMON_FLAGS" \ + LDFLAGS="-lpthread" + + +HP-UX with aCC +-------------- + +It is necessary to turn on C++98 mode of aCC by providing the `-AA` flag: -$ ../configure --enable-threads=yes CC=/opt/solarisstudio12.3/bin/cc \ -CXX=/opt/solarisstudio12.3/bin/CC CFLAGS="$COMMON_FLAGS" \ -CXXFLAGS="$COMMON_FLAGS" LDFLAGS="-lpthread" + $ ../configure --enable-threads=yes CXXFLAGS="-AA" -Qt / Win32 / MSVC ------------------ +HP-UX with `aCC` on IA64 +------------------------ -In order to use log4cplus in Qt programs it is necessary to set -following option: +There is a problem on I64 HP-UX with `aCC` (HP C/aC++ B3910B +A.06.20). The problem manifests as +[unsatisfied symbols during linking of `loggingserver`][9]: -Treat WChar_t As Built in Type: No (/Zc:wchar_t-) + ld: Unsatisfied symbol "virtual table of loggingserver::ClientThread" in file loggingserver.o -Set this option for log4cplus project and Qt4DebugAppender project in -MS Visual Studio. Remember to use Unicode versions of log4cplus +The problem appears to be a deficiency in `aCC` and its support of +`__declspec(dllexport)`. To work around this issue, add +`--disable-symbols-visibility-options` to `configure` script command +line: + + $ ../configure --disable-symbols-visibility-options \ + --enable-threads=yes CXXFLAGS="-AA" + +[9]: http://h30499.www3.hp.com/t5/Languages-and-Scripting/Building-Log4cplus-fails-with-quot-ld-Unsatisfied-symbol-virtual/td-p/6261411#.UoHtgPmet8G + + +Haiku +----- + +Haiku is supported with GCC 4+. The default GCC version in Haiku is +set to version 2 (based on GCC 2.95.x). To change the default GCC +version to version 4, please run `setgcc gcc4` command. This is to +avoid linking errors like this: + +~~~~ +main.cpp:(.text.startup+0x54a): undefined reference to `_Unwind_Resume' +~~~~ + +Running the command switches the _current_ GCC version to version 4. +This change is permanent and global. See also Haiku ticket +[#8368](http://dev.haiku-os.org/ticket/8368). + + +Qt4 / Win32 / MSVC +------------------ + +In order to use log4cplus in Qt4 programs it is necessary to set +following option: `Treat WChar_t As Built in Type: No (/Zc:wchar_t-)` + +Set this option for log4cplus project and `Qt4DebugAppender` project +in MS Visual Studio. Remember to use Unicode versions of log4cplus libraries with Qt. It is also necessary to make clear distinction between debug and release builds of Qt project and log4cplus. Do not use log4cplus release library with debug version of Qt program or vice versa. -For registering Qt4DebugAppender library at run-time call this method: - -log4cplus::Qt4DebugAppender::registerAppender() ; +For registering Qt4DebugAppender library at runtime, call this +function: `log4cplus::Qt4DebugAppender::registerAppender()` Add these lines to qmake project file for using log4cplus and -Qt4DebugAppender: - -INCLUDEPATH += C:\log4cplus\include -win32 { - CONFIG(debug, debug|release) { - LIBS += -LC:\log4cplus\msvc10\Win32\bin.Debug_Unicode -llog4cplusUD - LIBS += -LC:\log4cplus\msvc10\Win32\bin.Debug_Unicode -llog4cplus-Qt4DebugAppender - } else { - LIBS += -LC:\log4cplus\msvc10\Win32\bin.Release_Unicode -llog4cplusU - LIBS += -LC:\log4cplus\msvc10\Win32\bin.Release_Unicode -llog4cplus-Qt4DebugAppender +`Qt4DebugAppender`: + + INCLUDEPATH += C:\log4cplus\include + win32 { + CONFIG(debug, debug|release) { + LIBS += -LC:\log4cplus\msvc10\Win32\bin.Debug_Unicode -llog4cplusUD + LIBS += -LC:\log4cplus\msvc10\Win32\bin.Debug_Unicode -llog4cplus-Qt4DebugAppender + } else { + LIBS += -LC:\log4cplus\msvc10\Win32\bin.Release_Unicode -llog4cplusU + LIBS += -LC:\log4cplus\msvc10\Win32\bin.Release_Unicode -llog4cplus-Qt4DebugAppender + } } -} -LOG4CPLUS_*_FMT() and UNICODE ------------------------------ +`LOG4CPLUS_*_FMT()` and UNICODE +------------------------------- -Beware, the %s specifier does not work the same way on *NIX as it does -on Windows with Visual Studio. With Visual Studio the %s specifier -changes its meaning conveniently by printing wchar_t string when used -with wprintf() and char strings when used with wprintf(). On the -other hand, *NIX keeps the meaning of printing char strings when used -with both wprintf() and printf(). It is necessary to use %ls (C99) -specifier or %S (SUSv2) specifier to print wchar_t strings on *NIX. +Beware, the `%s` specifier does not work the same way on Unix--like +platforms as it does on Windows with Visual Studio. With Visual Studio +the `%s` specifier changes its meaning conveniently by printing +`wchar_t` string when used with `wprintf()` and `char` strings when +used with `printf()`. On the other hand, Unix--like platforms keeps +the meaning of printing `char` strings when used with both `wprintf()` +and `printf()`. It is necessary to use `%ls` (C99) specifier or `%S` +(SUSv2) specifier to print `wchar_t` strings on Unix--like platforms. -The common ground for both platforms appears to be use of %ls and -wchar_t string to print strings with unmodified formatting string -argument on both *NIX and Windows. The conversion of wchar_t back to -char then depends on C locale. +The common ground for both platforms appears to be use of `%ls` and +`wchar_t` string to print strings with unmodified formatting string +argument on both Unix--like platforms and Windows. The conversion of +`wchar_t` back to `char` then depends on C locale. C++11 support @@ -308,7 +418,7 @@ log4cplus does not support too old or broken C++ compilers: - Visual C++ prior to 7.1 - GCC prior to 3.2 -- All Borland/CodeGear/Embarcadero C++ compilers +- Older versions of Borland/CodeGear/Embarcadero C++ compilers Unsupported platforms @@ -318,7 +428,7 @@ log4cplus requires some minimal set of C and/or C++ library functions. Some systems/platforms fail to provide these functions and thus log4cplus cannot be supported there: -- Windows CE - missing implementations of functions +- Windows CE - missing implementations of `` functions License diff --git a/TODO b/TODO index 6b73ca694..6cce370dd 100644 --- a/TODO +++ b/TODO @@ -32,3 +32,9 @@ order: - ConsoleAppender or specialized appender with colored output per log level. + +- Make ServerSocket::accept() interruptible. + +- Graylog2/GELF appender. See + . + diff --git a/acinclude.m4 b/acinclude.m4 index 6a3ca19ab..73a09d7b4 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -16,3 +16,5 @@ m4_include([m4/ax_gethostbyname_r.m4]) m4_include([m4/ax_getaddrinfo.m4]) m4_include([m4/ax_log4cplus_wrappers.m4]) m4_include([m4/pkg.m4]) +m4_include([m4/ax_gcc_func_attribute.m4]) +m4_include([m4/ax_gcc_var_attribute.m4]) diff --git a/aclocal.m4 b/aclocal.m4 index b44d7314d..4494e858f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.12.3 -*- Autoconf -*- +# generated automatically by aclocal 1.12.6 -*- Autoconf -*- # Copyright (C) 1996-2012 Free Software Foundation, Inc. @@ -34,7 +34,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.12' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.12.3], [], +m4_if([$1], [1.12.6], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -50,7 +50,7 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.12.3])dnl +[AM_AUTOMAKE_VERSION([1.12.6])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) diff --git a/android/android.toolchain.cmake b/android/android.toolchain.cmake new file mode 100644 index 000000000..1d69b7504 --- /dev/null +++ b/android/android.toolchain.cmake @@ -0,0 +1,1734 @@ +# Copyright (c) 2010-2011, Ethan Rublee +# Copyright (c) 2011-2014, Andrey Kamaev +# All rights reserved. +# +# 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. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# 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 HOLDER 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. + +# ------------------------------------------------------------------------------ +# Android CMake toolchain file, for use with the Android NDK r5-r10d +# Requires cmake 2.6.3 or newer (2.8.9 or newer is recommended). +# See home page: https://github.com/taka-no-me/android-cmake +# +# Usage Linux: +# $ export ANDROID_NDK=/absolute/path/to/the/android-ndk +# $ mkdir build && cd build +# $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake .. +# $ make -j8 +# +# Usage Windows: +# You need native port of make to build your project. +# Android NDK r7 (and newer) already has make.exe on board. +# For older NDK you have to install it separately. +# For example, this one: http://gnuwin32.sourceforge.net/packages/make.htm +# +# $ SET ANDROID_NDK=C:\absolute\path\to\the\android-ndk +# $ mkdir build && cd build +# $ cmake.exe -G"MinGW Makefiles" +# -DCMAKE_TOOLCHAIN_FILE=path\to\the\android.toolchain.cmake +# -DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%\prebuilt\windows\bin\make.exe" .. +# $ cmake.exe --build . +# +# +# Options (can be set as cmake parameters: -D=): +# ANDROID_NDK=/opt/android-ndk - path to the NDK root. +# Can be set as environment variable. Can be set only at first cmake run. +# +# ANDROID_ABI=armeabi-v7a - specifies the target Application Binary +# Interface (ABI). This option nearly matches to the APP_ABI variable +# used by ndk-build tool from Android NDK. +# +# Possible targets are: +# "armeabi" - ARMv5TE based CPU with software floating point operations +# "armeabi-v7a" - ARMv7 based devices with hardware FPU instructions +# this ABI target is used by default +# "armeabi-v7a-hard with NEON" - ARMv7 based devices with hardware FPU instructions and hardfp +# "armeabi-v7a with NEON" - same as armeabi-v7a, but +# sets NEON as floating-point unit +# "armeabi-v7a with VFPV3" - same as armeabi-v7a, but +# sets VFPV3 as floating-point unit (has 32 registers instead of 16) +# "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP +# "x86" - IA-32 instruction set +# "mips" - MIPS32 instruction set +# +# 64-bit ABIs for NDK r10 and newer: +# "arm64-v8a" - ARMv8 AArch64 instruction set +# "x86_64" - Intel64 instruction set (r1) +# "mips64" - MIPS64 instruction set (r6) +# +# ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for. +# Option is read-only when standalone toolchain is used. +# Note: building for "android-L" requires explicit configuration. +# +# ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 - the name of compiler +# toolchain to be used. The list of possible values depends on the NDK +# version. For NDK r10c the possible values are: +# +# * aarch64-linux-android-4.9 +# * aarch64-linux-android-clang3.4 +# * aarch64-linux-android-clang3.5 +# * arm-linux-androideabi-4.6 +# * arm-linux-androideabi-4.8 +# * arm-linux-androideabi-4.9 (default) +# * arm-linux-androideabi-clang3.4 +# * arm-linux-androideabi-clang3.5 +# * mips64el-linux-android-4.9 +# * mips64el-linux-android-clang3.4 +# * mips64el-linux-android-clang3.5 +# * mipsel-linux-android-4.6 +# * mipsel-linux-android-4.8 +# * mipsel-linux-android-4.9 +# * mipsel-linux-android-clang3.4 +# * mipsel-linux-android-clang3.5 +# * x86-4.6 +# * x86-4.8 +# * x86-4.9 +# * x86-clang3.4 +# * x86-clang3.5 +# * x86_64-4.9 +# * x86_64-clang3.4 +# * x86_64-clang3.5 +# +# ANDROID_FORCE_ARM_BUILD=OFF - set ON to generate 32-bit ARM instructions +# instead of Thumb. Is not available for "armeabi-v6 with VFP" +# (is forced to be ON) ABI. +# +# ANDROID_NO_UNDEFINED=ON - set ON to show all undefined symbols as linker +# errors even if they are not used. +# +# ANDROID_SO_UNDEFINED=OFF - set ON to allow undefined symbols in shared +# libraries. Automatically turned for NDK r5x and r6x due to GLESv2 +# problems. +# +# ANDROID_STL=gnustl_static - specify the runtime to use. +# +# Possible values are: +# none -> Do not configure the runtime. +# system -> Use the default minimal system C++ runtime library. +# Implies -fno-rtti -fno-exceptions. +# Is not available for standalone toolchain. +# system_re -> Use the default minimal system C++ runtime library. +# Implies -frtti -fexceptions. +# Is not available for standalone toolchain. +# gabi++_static -> Use the GAbi++ runtime as a static library. +# Implies -frtti -fno-exceptions. +# Available for NDK r7 and newer. +# Is not available for standalone toolchain. +# gabi++_shared -> Use the GAbi++ runtime as a shared library. +# Implies -frtti -fno-exceptions. +# Available for NDK r7 and newer. +# Is not available for standalone toolchain. +# stlport_static -> Use the STLport runtime as a static library. +# Implies -fno-rtti -fno-exceptions for NDK before r7. +# Implies -frtti -fno-exceptions for NDK r7 and newer. +# Is not available for standalone toolchain. +# stlport_shared -> Use the STLport runtime as a shared library. +# Implies -fno-rtti -fno-exceptions for NDK before r7. +# Implies -frtti -fno-exceptions for NDK r7 and newer. +# Is not available for standalone toolchain. +# gnustl_static -> Use the GNU STL as a static library. +# Implies -frtti -fexceptions. +# gnustl_shared -> Use the GNU STL as a shared library. +# Implies -frtti -fno-exceptions. +# Available for NDK r7b and newer. +# Silently degrades to gnustl_static if not available. +# c++_static -> Use the LLVM libc++ runtime as a static library. +# Implies -frtti -fexceptions. +# c++_shared -> Use the LLVM libc++ runtime as a static library. +# Implies -frtti -fno-exceptions. +# +# ANDROID_STL_FORCE_FEATURES=ON - turn rtti and exceptions support based on +# chosen runtime. If disabled, then the user is responsible for settings +# these options. +# +# What?: +# android-cmake toolchain searches for NDK/toolchain in the following order: +# ANDROID_NDK - cmake parameter +# ANDROID_NDK - environment variable +# ANDROID_STANDALONE_TOOLCHAIN - cmake parameter +# ANDROID_STANDALONE_TOOLCHAIN - environment variable +# ANDROID_NDK - default locations +# ANDROID_STANDALONE_TOOLCHAIN - default locations +# +# Make sure to do the following in your scripts: +# SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}" ) +# SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}" ) +# The flags will be prepopulated with critical flags, so don't loose them. +# Also be aware that toolchain also sets configuration-specific compiler +# flags and linker flags. +# +# ANDROID and BUILD_ANDROID will be set to true, you may test any of these +# variables to make necessary Android-specific configuration changes. +# +# Also ARMEABI or ARMEABI_V7A or ARMEABI_V7A_HARD or X86 or MIPS or ARM64_V8A or X86_64 or MIPS64 +# will be set true, mutually exclusive. NEON option will be set true +# if VFP is set to NEON. +# +# ------------------------------------------------------------------------------ + +cmake_minimum_required( VERSION 2.6.3 ) + +if( DEFINED CMAKE_CROSSCOMPILING ) + # subsequent toolchain loading is not really needed + return() +endif() + +if( CMAKE_TOOLCHAIN_FILE ) + # touch toolchain variable to suppress "unused variable" warning +endif() + +# inherit settings in recursive loads +get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE ) +if( _CMAKE_IN_TRY_COMPILE ) + include( "${CMAKE_CURRENT_SOURCE_DIR}/../android.toolchain.config.cmake" OPTIONAL ) +endif() + +# this one is important +if( CMAKE_VERSION VERSION_GREATER "3.0.99" ) + set( CMAKE_SYSTEM_NAME Android ) +else() + set( CMAKE_SYSTEM_NAME Linux ) +endif() + +# this one not so much +set( CMAKE_SYSTEM_VERSION 1 ) + +# rpath makes low sense for Android +set( CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "" ) +set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." ) + +# NDK search paths +set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r10d -r10c -r10b -r10 -r9d -r9c -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) +if( NOT DEFINED ANDROID_NDK_SEARCH_PATHS ) + if( CMAKE_HOST_WIN32 ) + file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS ) + set( ANDROID_NDK_SEARCH_PATHS "${ANDROID_NDK_SEARCH_PATHS}" "$ENV{SystemDrive}/NVPACK" ) + else() + file( TO_CMAKE_PATH "$ENV{HOME}" ANDROID_NDK_SEARCH_PATHS ) + set( ANDROID_NDK_SEARCH_PATHS /opt "${ANDROID_NDK_SEARCH_PATHS}/NVPACK" ) + endif() +endif() +if( NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH ) + set( ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH /opt/android-toolchain ) +endif() + +# known ABIs +set( ANDROID_SUPPORTED_ABIS_arm "armeabi-v7a;armeabi;armeabi-v7a with NEON;armeabi-v7a-hard with NEON;armeabi-v7a with VFPV3;armeabi-v6 with VFP" ) +set( ANDROID_SUPPORTED_ABIS_arm64 "arm64-v8a" ) +set( ANDROID_SUPPORTED_ABIS_x86 "x86" ) +set( ANDROID_SUPPORTED_ABIS_x86_64 "x86_64" ) +set( ANDROID_SUPPORTED_ABIS_mips "mips" ) +set( ANDROID_SUPPORTED_ABIS_mips64 "mips64" ) + +# API level defaults +set( ANDROID_DEFAULT_NDK_API_LEVEL 9 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_arm64 21 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_x86 9 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_x86_64 21 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_mips 9 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_mips64 21 ) + + +macro( __LIST_FILTER listvar regex ) + if( ${listvar} ) + foreach( __val ${${listvar}} ) + if( __val MATCHES "${regex}" ) + list( REMOVE_ITEM ${listvar} "${__val}" ) + endif() + endforeach() + endif() +endmacro() + +macro( __INIT_VARIABLE var_name ) + set( __test_path 0 ) + foreach( __var ${ARGN} ) + if( __var STREQUAL "PATH" ) + set( __test_path 1 ) + break() + endif() + endforeach() + + if( __test_path AND NOT EXISTS "${${var_name}}" ) + unset( ${var_name} CACHE ) + endif() + + if( " ${${var_name}}" STREQUAL " " ) + set( __values 0 ) + foreach( __var ${ARGN} ) + if( __var STREQUAL "VALUES" ) + set( __values 1 ) + elseif( NOT __var STREQUAL "PATH" ) + if( __var MATCHES "^ENV_.*$" ) + string( REPLACE "ENV_" "" __var "${__var}" ) + set( __value "$ENV{${__var}}" ) + elseif( DEFINED ${__var} ) + set( __value "${${__var}}" ) + elseif( __values ) + set( __value "${__var}" ) + else() + set( __value "" ) + endif() + + if( NOT " ${__value}" STREQUAL " " AND (NOT __test_path OR EXISTS "${__value}") ) + set( ${var_name} "${__value}" ) + break() + endif() + endif() + endforeach() + unset( __value ) + unset( __values ) + endif() + + if( __test_path ) + file( TO_CMAKE_PATH "${${var_name}}" ${var_name} ) + endif() + unset( __test_path ) +endmacro() + +macro( __DETECT_NATIVE_API_LEVEL _var _path ) + set( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*.*$" ) + file( STRINGS ${_path} __apiFileContent REGEX "${__ndkApiLevelRegex}" ) + if( NOT __apiFileContent ) + message( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." ) + endif() + string( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${_var} "${__apiFileContent}" ) + unset( __apiFileContent ) + unset( __ndkApiLevelRegex ) +endmacro() + +macro( __DETECT_TOOLCHAIN_MACHINE_NAME _var _root ) + if( EXISTS "${_root}" ) + file( GLOB __gccExePath RELATIVE "${_root}/bin/" "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" ) + __LIST_FILTER( __gccExePath "^[.].*" ) + list( LENGTH __gccExePath __gccExePathsCount ) + if( NOT __gccExePathsCount EQUAL 1 AND NOT _CMAKE_IN_TRY_COMPILE ) + message( WARNING "Could not determine machine name for compiler from ${_root}" ) + set( ${_var} "" ) + else() + get_filename_component( __gccExeName "${__gccExePath}" NAME_WE ) + string( REPLACE "-gcc" "" ${_var} "${__gccExeName}" ) + endif() + unset( __gccExePath ) + unset( __gccExePathsCount ) + unset( __gccExeName ) + else() + set( ${_var} "" ) + endif() +endmacro() + + +# fight against cygwin +set( ANDROID_FORBID_SYGWIN TRUE CACHE BOOL "Prevent cmake from working under cygwin and using cygwin tools") +mark_as_advanced( ANDROID_FORBID_SYGWIN ) +if( ANDROID_FORBID_SYGWIN ) + if( CYGWIN ) + message( FATAL_ERROR "Android NDK and android-cmake toolchain are not welcome Cygwin. It is unlikely that this cmake toolchain will work under cygwin. But if you want to try then you can set cmake variable ANDROID_FORBID_SYGWIN to FALSE and rerun cmake." ) + endif() + + if( CMAKE_HOST_WIN32 ) + # remove cygwin from PATH + set( __new_path "$ENV{PATH}") + __LIST_FILTER( __new_path "cygwin" ) + set(ENV{PATH} "${__new_path}") + unset(__new_path) + endif() +endif() + + +# detect current host platform +if( NOT DEFINED ANDROID_NDK_HOST_X64 AND (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64" OR CMAKE_HOST_APPLE) ) + set( ANDROID_NDK_HOST_X64 1 CACHE BOOL "Try to use 64-bit compiler toolchain" ) + mark_as_advanced( ANDROID_NDK_HOST_X64 ) +endif() + +set( TOOL_OS_SUFFIX "" ) +if( CMAKE_HOST_APPLE ) + set( ANDROID_NDK_HOST_SYSTEM_NAME "darwin-x86_64" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME2 "darwin-x86" ) +elseif( CMAKE_HOST_WIN32 ) + set( ANDROID_NDK_HOST_SYSTEM_NAME "windows-x86_64" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME2 "windows" ) + set( TOOL_OS_SUFFIX ".exe" ) +elseif( CMAKE_HOST_UNIX ) + set( ANDROID_NDK_HOST_SYSTEM_NAME "linux-x86_64" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME2 "linux-x86" ) +else() + message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" ) +endif() + +if( NOT ANDROID_NDK_HOST_X64 ) + set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) +endif() + +# see if we have path to Android NDK +if( NOT ANDROID_NDK AND NOT ANDROID_STANDALONE_TOOLCHAIN ) + __INIT_VARIABLE( ANDROID_NDK PATH ENV_ANDROID_NDK ) +endif() +if( NOT ANDROID_NDK ) + # see if we have path to Android standalone toolchain + __INIT_VARIABLE( ANDROID_STANDALONE_TOOLCHAIN PATH ENV_ANDROID_STANDALONE_TOOLCHAIN ) + + if( NOT ANDROID_STANDALONE_TOOLCHAIN ) + #try to find Android NDK in one of the the default locations + set( __ndkSearchPaths ) + foreach( __ndkSearchPath ${ANDROID_NDK_SEARCH_PATHS} ) + foreach( suffix ${ANDROID_SUPPORTED_NDK_VERSIONS} ) + list( APPEND __ndkSearchPaths "${__ndkSearchPath}/android-ndk${suffix}" ) + endforeach() + endforeach() + __INIT_VARIABLE( ANDROID_NDK PATH VALUES ${__ndkSearchPaths} ) + unset( __ndkSearchPaths ) + + if( ANDROID_NDK ) + message( STATUS "Using default path for Android NDK: ${ANDROID_NDK}" ) + message( STATUS " If you prefer to use a different location, please define a cmake or environment variable: ANDROID_NDK" ) + else() + #try to find Android standalone toolchain in one of the the default locations + __INIT_VARIABLE( ANDROID_STANDALONE_TOOLCHAIN PATH ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH ) + + if( ANDROID_STANDALONE_TOOLCHAIN ) + message( STATUS "Using default path for standalone toolchain ${ANDROID_STANDALONE_TOOLCHAIN}" ) + message( STATUS " If you prefer to use a different location, please define the variable: ANDROID_STANDALONE_TOOLCHAIN" ) + endif( ANDROID_STANDALONE_TOOLCHAIN ) + endif( ANDROID_NDK ) + endif( NOT ANDROID_STANDALONE_TOOLCHAIN ) +endif( NOT ANDROID_NDK ) + +# remember found paths +if( ANDROID_NDK ) + get_filename_component( ANDROID_NDK "${ANDROID_NDK}" ABSOLUTE ) + set( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" FORCE ) + set( BUILD_WITH_ANDROID_NDK True ) + if( EXISTS "${ANDROID_NDK}/RELEASE.TXT" ) + file( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE_FULL LIMIT_COUNT 1 REGEX "r[0-9]+[a-z]?" ) + string( REGEX MATCH "r([0-9]+)([a-z]?)" ANDROID_NDK_RELEASE "${ANDROID_NDK_RELEASE_FULL}" ) + else() + set( ANDROID_NDK_RELEASE "r1x" ) + set( ANDROID_NDK_RELEASE_FULL "unreleased" ) + endif() + string( REGEX REPLACE "r([0-9]+)([a-z]?)" "\\1*1000" ANDROID_NDK_RELEASE_NUM "${ANDROID_NDK_RELEASE}" ) + string( FIND " abcdefghijklmnopqastuvwxyz" "${CMAKE_MATCH_2}" __ndkReleaseLetterNum ) + math( EXPR ANDROID_NDK_RELEASE_NUM "${ANDROID_NDK_RELEASE_NUM}+${__ndkReleaseLetterNum}" ) +elseif( ANDROID_STANDALONE_TOOLCHAIN ) + get_filename_component( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE ) + # try to detect change + if( CMAKE_AR ) + string( LENGTH "${ANDROID_STANDALONE_TOOLCHAIN}" __length ) + string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidStandaloneToolchainPreviousPath ) + if( NOT __androidStandaloneToolchainPreviousPath STREQUAL ANDROID_STANDALONE_TOOLCHAIN ) + message( FATAL_ERROR "It is not possible to change path to the Android standalone toolchain on subsequent run." ) + endif() + unset( __androidStandaloneToolchainPreviousPath ) + unset( __length ) + endif() + set( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" CACHE INTERNAL "Path of the Android standalone toolchain" FORCE ) + set( BUILD_WITH_STANDALONE_TOOLCHAIN True ) +else() + list(GET ANDROID_NDK_SEARCH_PATHS 0 ANDROID_NDK_SEARCH_PATH) + message( FATAL_ERROR "Could not find neither Android NDK nor Android standalone toolchain. + You should either set an environment variable: + export ANDROID_NDK=~/my-android-ndk + or + export ANDROID_STANDALONE_TOOLCHAIN=~/my-android-toolchain + or put the toolchain or NDK in the default path: + sudo ln -s ~/my-android-ndk ${ANDROID_NDK_SEARCH_PATH}/android-ndk + sudo ln -s ~/my-android-toolchain ${ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH}" ) +endif() + +# android NDK layout +if( BUILD_WITH_ANDROID_NDK ) + if( NOT DEFINED ANDROID_NDK_LAYOUT ) + # try to automatically detect the layout + if( EXISTS "${ANDROID_NDK}/RELEASE.TXT") + set( ANDROID_NDK_LAYOUT "RELEASE" ) + elseif( EXISTS "${ANDROID_NDK}/../../linux-x86/toolchain/" ) + set( ANDROID_NDK_LAYOUT "LINARO" ) + elseif( EXISTS "${ANDROID_NDK}/../../gcc/" ) + set( ANDROID_NDK_LAYOUT "ANDROID" ) + endif() + endif() + set( ANDROID_NDK_LAYOUT "${ANDROID_NDK_LAYOUT}" CACHE STRING "The inner layout of NDK" ) + mark_as_advanced( ANDROID_NDK_LAYOUT ) + if( ANDROID_NDK_LAYOUT STREQUAL "LINARO" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) # only 32-bit at the moment + set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/../../${ANDROID_NDK_HOST_SYSTEM_NAME}/toolchain" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH "" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "" ) + elseif( ANDROID_NDK_LAYOUT STREQUAL "ANDROID" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) # only 32-bit at the moment + set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/../../gcc/${ANDROID_NDK_HOST_SYSTEM_NAME}/arm" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH "" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "" ) + else() # ANDROID_NDK_LAYOUT STREQUAL "RELEASE" + set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/toolchains" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH "/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME2}" ) + endif() + get_filename_component( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK_TOOLCHAINS_PATH}" ABSOLUTE ) + + # try to detect change of NDK + if( CMAKE_AR ) + string( LENGTH "${ANDROID_NDK_TOOLCHAINS_PATH}" __length ) + string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidNdkPreviousPath ) + if( NOT __androidNdkPreviousPath STREQUAL ANDROID_NDK_TOOLCHAINS_PATH ) + message( FATAL_ERROR "It is not possible to change the path to the NDK on subsequent CMake run. You must remove all generated files from your build folder first. + " ) + endif() + unset( __androidNdkPreviousPath ) + unset( __length ) + endif() +endif() + + +# get all the details about standalone toolchain +if( BUILD_WITH_STANDALONE_TOOLCHAIN ) + __DETECT_NATIVE_API_LEVEL( ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h" ) + set( ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) + set( __availableToolchains "standalone" ) + __DETECT_TOOLCHAIN_MACHINE_NAME( __availableToolchainMachines "${ANDROID_STANDALONE_TOOLCHAIN}" ) + if( NOT __availableToolchainMachines ) + message( FATAL_ERROR "Could not determine machine name of your toolchain. Probably your Android standalone toolchain is broken." ) + endif() + if( __availableToolchainMachines MATCHES x86_64 ) + set( __availableToolchainArchs "x86_64" ) + elseif( __availableToolchainMachines MATCHES i686 ) + set( __availableToolchainArchs "x86" ) + elseif( __availableToolchainMachines MATCHES aarch64 ) + set( __availableToolchainArchs "arm64" ) + elseif( __availableToolchainMachines MATCHES arm ) + set( __availableToolchainArchs "arm" ) + elseif( __availableToolchainMachines MATCHES mips64el ) + set( __availableToolchainArchs "mips64" ) + elseif( __availableToolchainMachines MATCHES mipsel ) + set( __availableToolchainArchs "mips" ) + endif() + execute_process( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" -dumpversion + OUTPUT_VARIABLE __availableToolchainCompilerVersions OUTPUT_STRIP_TRAILING_WHITESPACE ) + string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?" __availableToolchainCompilerVersions "${__availableToolchainCompilerVersions}" ) + if( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/bin/clang${TOOL_OS_SUFFIX}" ) + list( APPEND __availableToolchains "standalone-clang" ) + list( APPEND __availableToolchainMachines ${__availableToolchainMachines} ) + list( APPEND __availableToolchainArchs ${__availableToolchainArchs} ) + list( APPEND __availableToolchainCompilerVersions ${__availableToolchainCompilerVersions} ) + endif() +endif() + +macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst __toolchain_subpath ) + foreach( __toolchain ${${__availableToolchainsLst}} ) + if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}${__toolchain_subpath}" ) + SET( __toolchainVersionRegex "^TOOLCHAIN_VERSION[\t ]+:=[\t ]+(.*)$" ) + FILE( STRINGS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}/setup.mk" __toolchainVersionStr REGEX "${__toolchainVersionRegex}" ) + if( __toolchainVersionStr ) + string( REGEX REPLACE "${__toolchainVersionRegex}" "\\1" __toolchainVersionStr "${__toolchainVersionStr}" ) + string( REGEX REPLACE "-clang3[.][0-9]$" "-${__toolchainVersionStr}" __gcc_toolchain "${__toolchain}" ) + else() + string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" ) + endif() + unset( __toolchainVersionStr ) + unset( __toolchainVersionRegex ) + else() + set( __gcc_toolchain "${__toolchain}" ) + endif() + __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK_TOOLCHAINS_PATH}/${__gcc_toolchain}${__toolchain_subpath}" ) + if( __machine ) + string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9x]+)?$" __version "${__gcc_toolchain}" ) + if( __machine MATCHES x86_64 ) + set( __arch "x86_64" ) + elseif( __machine MATCHES i686 ) + set( __arch "x86" ) + elseif( __machine MATCHES aarch64 ) + set( __arch "arm64" ) + elseif( __machine MATCHES arm ) + set( __arch "arm" ) + elseif( __machine MATCHES mips64el ) + set( __arch "mips64" ) + elseif( __machine MATCHES mipsel ) + set( __arch "mips" ) + else() + set( __arch "" ) + endif() + #message("machine: !${__machine}!\narch: !${__arch}!\nversion: !${__version}!\ntoolchain: !${__toolchain}!\n") + if (__arch) + list( APPEND __availableToolchainMachines "${__machine}" ) + list( APPEND __availableToolchainArchs "${__arch}" ) + list( APPEND __availableToolchainCompilerVersions "${__version}" ) + list( APPEND ${__availableToolchainsVar} "${__toolchain}" ) + endif() + endif() + unset( __gcc_toolchain ) + endforeach() +endmacro() + +# get all the details about NDK +if( BUILD_WITH_ANDROID_NDK ) + file( GLOB ANDROID_SUPPORTED_NATIVE_API_LEVELS RELATIVE "${ANDROID_NDK}/platforms" "${ANDROID_NDK}/platforms/android-*" ) + string( REPLACE "android-" "" ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_SUPPORTED_NATIVE_API_LEVELS}" ) + set( __availableToolchains "" ) + set( __availableToolchainMachines "" ) + set( __availableToolchainArchs "" ) + set( __availableToolchainCompilerVersions "" ) + if( ANDROID_TOOLCHAIN_NAME AND EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_TOOLCHAIN_NAME}/" ) + # do not go through all toolchains if we know the name + set( __availableToolchainsLst "${ANDROID_TOOLCHAIN_NAME}" ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) + if( NOT __availableToolchains AND NOT ANDROID_NDK_TOOLCHAINS_SUBPATH STREQUAL ANDROID_NDK_TOOLCHAINS_SUBPATH2 ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH2}" ) + if( __availableToolchains ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH ${ANDROID_NDK_TOOLCHAINS_SUBPATH2} ) + endif() + endif() + endif() + if( NOT __availableToolchains ) + file( GLOB __availableToolchainsLst RELATIVE "${ANDROID_NDK_TOOLCHAINS_PATH}" "${ANDROID_NDK_TOOLCHAINS_PATH}/*" ) + if( __availableToolchainsLst ) + list(SORT __availableToolchainsLst) # we need clang to go after gcc + endif() + __LIST_FILTER( __availableToolchainsLst "^[.]" ) + __LIST_FILTER( __availableToolchainsLst "llvm" ) + __LIST_FILTER( __availableToolchainsLst "renderscript" ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) + if( NOT __availableToolchains AND NOT ANDROID_NDK_TOOLCHAINS_SUBPATH STREQUAL ANDROID_NDK_TOOLCHAINS_SUBPATH2 ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH2}" ) + if( __availableToolchains ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH ${ANDROID_NDK_TOOLCHAINS_SUBPATH2} ) + endif() + endif() + endif() + if( NOT __availableToolchains ) + message( FATAL_ERROR "Could not find any working toolchain in the NDK. Probably your Android NDK is broken." ) + endif() +endif() + +# build list of available ABIs +set( ANDROID_SUPPORTED_ABIS "" ) +set( __uniqToolchainArchNames ${__availableToolchainArchs} ) +list( REMOVE_DUPLICATES __uniqToolchainArchNames ) +list( SORT __uniqToolchainArchNames ) +foreach( __arch ${__uniqToolchainArchNames} ) + list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} ) +endforeach() +unset( __uniqToolchainArchNames ) +if( NOT ANDROID_SUPPORTED_ABIS ) + message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." ) +endif() + +# choose target ABI +__INIT_VARIABLE( ANDROID_ABI VALUES ${ANDROID_SUPPORTED_ABIS} ) +# verify that target ABI is supported +list( FIND ANDROID_SUPPORTED_ABIS "${ANDROID_ABI}" __androidAbiIdx ) +if( __androidAbiIdx EQUAL -1 ) + string( REPLACE ";" "\", \"" PRINTABLE_ANDROID_SUPPORTED_ABIS "${ANDROID_SUPPORTED_ABIS}" ) + message( FATAL_ERROR "Specified ANDROID_ABI = \"${ANDROID_ABI}\" is not supported by this cmake toolchain or your NDK/toolchain. + Supported values are: \"${PRINTABLE_ANDROID_SUPPORTED_ABIS}\" + " ) +endif() +unset( __androidAbiIdx ) + +# set target ABI options +if( ANDROID_ABI STREQUAL "x86" ) + set( X86 true ) + set( ANDROID_NDK_ABI_NAME "x86" ) + set( ANDROID_ARCH_NAME "x86" ) + set( ANDROID_LLVM_TRIPLE "i686-none-linux-android" ) + set( CMAKE_SYSTEM_PROCESSOR "i686" ) +elseif( ANDROID_ABI STREQUAL "x86_64" ) + set( X86 true ) + set( X86_64 true ) + set( ANDROID_NDK_ABI_NAME "x86_64" ) + set( ANDROID_ARCH_NAME "x86_64" ) + set( CMAKE_SYSTEM_PROCESSOR "x86_64" ) + set( ANDROID_LLVM_TRIPLE "x86_64-none-linux-android" ) +elseif( ANDROID_ABI STREQUAL "mips64" ) + set( MIPS64 true ) + set( ANDROID_NDK_ABI_NAME "mips64" ) + set( ANDROID_ARCH_NAME "mips64" ) + set( ANDROID_LLVM_TRIPLE "mips64el-none-linux-android" ) + set( CMAKE_SYSTEM_PROCESSOR "mips64" ) +elseif( ANDROID_ABI STREQUAL "mips" ) + set( MIPS true ) + set( ANDROID_NDK_ABI_NAME "mips" ) + set( ANDROID_ARCH_NAME "mips" ) + set( ANDROID_LLVM_TRIPLE "mipsel-none-linux-android" ) + set( CMAKE_SYSTEM_PROCESSOR "mips" ) +elseif( ANDROID_ABI STREQUAL "arm64-v8a" ) + set( ARM64_V8A true ) + set( ANDROID_NDK_ABI_NAME "arm64-v8a" ) + set( ANDROID_ARCH_NAME "arm64" ) + set( ANDROID_LLVM_TRIPLE "aarch64-none-linux-android" ) + set( CMAKE_SYSTEM_PROCESSOR "aarch64" ) + set( VFPV3 true ) + set( NEON true ) +elseif( ANDROID_ABI STREQUAL "armeabi" ) + set( ARMEABI true ) + set( ANDROID_NDK_ABI_NAME "armeabi" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv5te" ) +elseif( ANDROID_ABI STREQUAL "armeabi-v6 with VFP" ) + set( ARMEABI_V6 true ) + set( ANDROID_NDK_ABI_NAME "armeabi" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv6" ) + # need always fallback to older platform + set( ARMEABI true ) +elseif( ANDROID_ABI STREQUAL "armeabi-v7a") + set( ARMEABI_V7A true ) + set( ANDROID_NDK_ABI_NAME "armeabi-v7a" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) +elseif( ANDROID_ABI STREQUAL "armeabi-v7a with VFPV3" ) + set( ARMEABI_V7A true ) + set( ANDROID_NDK_ABI_NAME "armeabi-v7a" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) + set( VFPV3 true ) +elseif( ANDROID_ABI STREQUAL "armeabi-v7a with NEON" ) + set( ARMEABI_V7A true ) + set( ANDROID_NDK_ABI_NAME "armeabi-v7a" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) + set( VFPV3 true ) + set( NEON true ) +elseif( ANDROID_ABI STREQUAL "armeabi-v7a-hard with NEON" ) + set( ARMEABI_V7A_HARD true ) + set( ANDROID_NDK_ABI_NAME "armeabi-v7a-hard" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) + set( VFPV3 true ) + set( NEON true ) +else() + message( SEND_ERROR "Unknown ANDROID_ABI=\"${ANDROID_ABI}\" is specified." ) +endif() + +if( CMAKE_BINARY_DIR AND EXISTS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" ) + # really dirty hack + # it is not possible to change CMAKE_SYSTEM_PROCESSOR after the first run... + file( APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" "SET(CMAKE_SYSTEM_PROCESSOR \"${CMAKE_SYSTEM_PROCESSOR}\")\n" ) +endif() + +if( ANDROID_ARCH_NAME STREQUAL "arm" AND NOT ARMEABI_V6 ) + __INIT_VARIABLE( ANDROID_FORCE_ARM_BUILD VALUES OFF ) + set( ANDROID_FORCE_ARM_BUILD ${ANDROID_FORCE_ARM_BUILD} CACHE BOOL "Use 32-bit ARM instructions instead of Thumb-1" FORCE ) + mark_as_advanced( ANDROID_FORCE_ARM_BUILD ) +else() + unset( ANDROID_FORCE_ARM_BUILD CACHE ) +endif() + +# choose toolchain +if( ANDROID_TOOLCHAIN_NAME ) + list( FIND __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" __toolchainIdx ) + if( __toolchainIdx EQUAL -1 ) + list( SORT __availableToolchains ) + string( REPLACE ";" "\n * " toolchains_list "${__availableToolchains}" ) + set( toolchains_list " * ${toolchains_list}") + message( FATAL_ERROR "Specified toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is missing in your NDK or broken. Please verify that your NDK is working or select another compiler toolchain. +To configure the toolchain set CMake variable ANDROID_TOOLCHAIN_NAME to one of the following values:\n${toolchains_list}\n" ) + endif() + list( GET __availableToolchainArchs ${__toolchainIdx} __toolchainArch ) + if( NOT __toolchainArch STREQUAL ANDROID_ARCH_NAME ) + message( SEND_ERROR "Selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform." ) + endif() +else() + set( __toolchainIdx -1 ) + set( __applicableToolchains "" ) + set( __toolchainMaxVersion "0.0.0" ) + list( LENGTH __availableToolchains __availableToolchainsCount ) + math( EXPR __availableToolchainsCount "${__availableToolchainsCount}-1" ) + foreach( __idx RANGE ${__availableToolchainsCount} ) + list( GET __availableToolchainArchs ${__idx} __toolchainArch ) + if( __toolchainArch STREQUAL ANDROID_ARCH_NAME ) + list( GET __availableToolchainCompilerVersions ${__idx} __toolchainVersion ) + string( REPLACE "x" "99" __toolchainVersion "${__toolchainVersion}") + if( __toolchainVersion VERSION_GREATER __toolchainMaxVersion ) + set( __toolchainMaxVersion "${__toolchainVersion}" ) + set( __toolchainIdx ${__idx} ) + endif() + endif() + endforeach() + unset( __availableToolchainsCount ) + unset( __toolchainMaxVersion ) + unset( __toolchainVersion ) +endif() +unset( __toolchainArch ) +if( __toolchainIdx EQUAL -1 ) + message( FATAL_ERROR "No one of available compiler toolchains is able to compile for ${ANDROID_ARCH_NAME} platform." ) +endif() +list( GET __availableToolchains ${__toolchainIdx} ANDROID_TOOLCHAIN_NAME ) +list( GET __availableToolchainMachines ${__toolchainIdx} ANDROID_TOOLCHAIN_MACHINE_NAME ) +list( GET __availableToolchainCompilerVersions ${__toolchainIdx} ANDROID_COMPILER_VERSION ) + +unset( __toolchainIdx ) +unset( __availableToolchains ) +unset( __availableToolchainMachines ) +unset( __availableToolchainArchs ) +unset( __availableToolchainCompilerVersions ) + +# choose native API level +__INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_API_LEVEL ) +string( REPLACE "android-" "" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" ) +string( STRIP "${ANDROID_NATIVE_API_LEVEL}" ANDROID_NATIVE_API_LEVEL ) +# adjust API level +set( __real_api_level ${ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME}} ) +foreach( __level ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) + if( (__level LESS ANDROID_NATIVE_API_LEVEL OR __level STREQUAL ANDROID_NATIVE_API_LEVEL) AND NOT __level LESS __real_api_level ) + set( __real_api_level ${__level} ) + endif() +endforeach() +if( __real_api_level AND NOT ANDROID_NATIVE_API_LEVEL STREQUAL __real_api_level ) + message( STATUS "Adjusting Android API level 'android-${ANDROID_NATIVE_API_LEVEL}' to 'android-${__real_api_level}'") + set( ANDROID_NATIVE_API_LEVEL ${__real_api_level} ) +endif() +unset(__real_api_level) +# validate +list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx ) +if( __levelIdx EQUAL -1 ) + message( SEND_ERROR "Specified Android native API level 'android-${ANDROID_NATIVE_API_LEVEL}' is not supported by your NDK/toolchain." ) +else() + if( BUILD_WITH_ANDROID_NDK ) + __DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" ) + if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL AND NOT __realApiLevel GREATER 9000 ) + message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." ) + endif() + unset( __realApiLevel ) + endif() + set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE ) + set( CMAKE_ANDROID_API ${ANDROID_NATIVE_API_LEVEL} ) + if( CMAKE_VERSION VERSION_GREATER "2.8" ) + list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS ) + set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) + endif() +endif() +unset( __levelIdx ) + + +# remember target ABI +set( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE ) +if( CMAKE_VERSION VERSION_GREATER "2.8" ) + list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME} ) + set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME}} ) +endif() + + +# runtime choice (STL, rtti, exceptions) +if( NOT ANDROID_STL ) + set( ANDROID_STL gnustl_static ) +endif() +set( ANDROID_STL "${ANDROID_STL}" CACHE STRING "C++ runtime" ) +set( ANDROID_STL_FORCE_FEATURES ON CACHE BOOL "automatically configure rtti and exceptions support based on C++ runtime" ) +mark_as_advanced( ANDROID_STL ANDROID_STL_FORCE_FEATURES ) + +if( BUILD_WITH_ANDROID_NDK ) + if( NOT "${ANDROID_STL}" MATCHES "^(none|system|system_re|gabi\\+\\+_static|gabi\\+\\+_shared|stlport_static|stlport_shared|gnustl_static|gnustl_shared|c\\+\\+_static|c\\+\\+_shared)$") + message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\". +The possible values are: + none -> Do not configure the runtime. + system -> Use the default minimal system C++ runtime library. + system_re -> Same as system but with rtti and exceptions. + gabi++_static -> Use the GAbi++ runtime as a static library. + gabi++_shared -> Use the GAbi++ runtime as a shared library. + stlport_static -> Use the STLport runtime as a static library. + stlport_shared -> Use the STLport runtime as a shared library. + gnustl_static -> (default) Use the GNU STL as a static library. + gnustl_shared -> Use the GNU STL as a shared library. + c++_shared -> Use the LLVM libc++ runtime as a shared library. + c++_static -> Use the LLVM libc++ runtime as a static library. +" ) + endif() +elseif( BUILD_WITH_STANDALONE_TOOLCHAIN ) + if( NOT "${ANDROID_STL}" MATCHES "^(none|gnustl_static|gnustl_shared|c\\+\\+_static|c\\+\\+_shared)$") + message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\". +The possible values are: + none -> Do not configure the runtime. + gnustl_static -> (default) Use the GNU STL as a static library. + gnustl_shared -> Use the GNU STL as a shared library. + c++_shared -> Use the LLVM libc++ runtime as a shared library. + c++_static -> Use the LLVM libc++ runtime as a static library. +" ) + endif() +endif() + +unset( ANDROID_RTTI ) +unset( ANDROID_EXCEPTIONS ) +unset( ANDROID_STL_INCLUDE_DIRS ) +unset( __libstl ) +unset( __libsupcxx ) + +if( NOT _CMAKE_IN_TRY_COMPILE AND ANDROID_NDK_RELEASE STREQUAL "r7b" AND ARMEABI_V7A AND NOT VFPV3 AND ANDROID_STL MATCHES "gnustl" ) + message( WARNING "The GNU STL armeabi-v7a binaries from NDK r7b can crash non-NEON devices. The files provided with NDK r7b were not configured properly, resulting in crashes on Tegra2-based devices and others when trying to use certain floating-point functions (e.g., cosf, sinf, expf). +You are strongly recommended to switch to another NDK release. +" ) +endif() + +if( NOT _CMAKE_IN_TRY_COMPILE AND X86 AND ANDROID_STL MATCHES "gnustl" AND ANDROID_NDK_RELEASE STREQUAL "r6" ) + message( WARNING "The x86 system header file from NDK r6 has incorrect definition for ptrdiff_t. You are recommended to upgrade to a newer NDK release or manually patch the header: +See https://android.googlesource.com/platform/development.git f907f4f9d4e56ccc8093df6fee54454b8bcab6c2 + diff --git a/ndk/platforms/android-9/arch-x86/include/machine/_types.h b/ndk/platforms/android-9/arch-x86/include/machine/_types.h + index 5e28c64..65892a1 100644 + --- a/ndk/platforms/android-9/arch-x86/include/machine/_types.h + +++ b/ndk/platforms/android-9/arch-x86/include/machine/_types.h + @@ -51,7 +51,11 @@ typedef long int ssize_t; + #endif + #ifndef _PTRDIFF_T + #define _PTRDIFF_T + -typedef long ptrdiff_t; + +# ifdef __ANDROID__ + + typedef int ptrdiff_t; + +# else + + typedef long ptrdiff_t; + +# endif + #endif +" ) +endif() + + +# setup paths and STL for standalone toolchain +if( BUILD_WITH_STANDALONE_TOOLCHAIN ) + set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" ) + set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" ) + set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" ) + + if( NOT ANDROID_STL STREQUAL "none" ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/include/c++/${ANDROID_COMPILER_VERSION}" ) + if( NOT EXISTS "${ANDROID_STL_INCLUDE_DIRS}" ) + # old location ( pre r8c ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" ) + endif() + if( (ARMEABI_V7A OR ARMEABI_V7A_HARD) AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" ) + list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" ) + elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" ) + list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" ) + else() + list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" ) + endif() + # always search static GNU STL to get the location of libsupc++.a + if( (ARMEABI_V7A OR ARMEABI_V7A_HARD) AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb" ) + elseif( (ARMEABI_V7A OR ARMEABI_V7A_HARD) AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}" ) + elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libstdc++.a" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb" ) + elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libstdc++.a" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib" ) + endif() + if( __libstl ) + set( __libsupcxx "${__libstl}/libsupc++.a" ) + set( __libstl "${__libstl}/libstdc++.a" ) + endif() + if( NOT EXISTS "${__libsupcxx}" ) + message( FATAL_ERROR "The required libstdsupc++.a is missing in your standalone toolchain. + Usually it happens because of bug in make-standalone-toolchain.sh script from NDK r7, r7b and r7c. + You need to either upgrade to newer NDK or manually copy + $ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a + to + ${__libsupcxx} + " ) + endif() + if( ANDROID_STL STREQUAL "gnustl_shared" ) + if( (ARMEABI_V7A OR ARMEABI_V7A_HARD) AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" ) + elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" ) + elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" ) + endif() + endif() + endif() +endif() + +# clang +if( "${ANDROID_TOOLCHAIN_NAME}" STREQUAL "standalone-clang" ) + set( ANDROID_COMPILER_IS_CLANG 1 ) + execute_process( COMMAND "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/clang${TOOL_OS_SUFFIX}" --version OUTPUT_VARIABLE ANDROID_CLANG_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ) + string( REGEX MATCH "[0-9]+[.][0-9]+" ANDROID_CLANG_VERSION "${ANDROID_CLANG_VERSION}") +elseif( "${ANDROID_TOOLCHAIN_NAME}" MATCHES "-clang3[.][0-9]?$" ) + string( REGEX MATCH "3[.][0-9]$" ANDROID_CLANG_VERSION "${ANDROID_TOOLCHAIN_NAME}") + string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-${ANDROID_COMPILER_VERSION}" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" ) + if( NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}/bin/clang${TOOL_OS_SUFFIX}" ) + message( FATAL_ERROR "Could not find the Clang compiler driver" ) + endif() + set( ANDROID_COMPILER_IS_CLANG 1 ) + set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) +else() + set( ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" ) + unset( ANDROID_COMPILER_IS_CLANG CACHE ) +endif() + +string( REPLACE "." "" _clang_name "clang${ANDROID_CLANG_VERSION}" ) +if( NOT EXISTS "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" ) + set( _clang_name "clang" ) +endif() + + +# setup paths and STL for NDK +if( BUILD_WITH_ANDROID_NDK ) + set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) + set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" ) + + if( ANDROID_STL STREQUAL "none" ) + # do nothing + elseif( ANDROID_STL STREQUAL "system" ) + set( ANDROID_RTTI OFF ) + set( ANDROID_EXCEPTIONS OFF ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" ) + elseif( ANDROID_STL STREQUAL "system_re" ) + set( ANDROID_RTTI ON ) + set( ANDROID_EXCEPTIONS ON ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" ) + elseif( ANDROID_STL MATCHES "gabi" ) + if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7 + message( FATAL_ERROR "gabi++ is not available in your NDK. You have to upgrade to NDK r7 or newer to use gabi++.") + endif() + set( ANDROID_RTTI ON ) + set( ANDROID_EXCEPTIONS OFF ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/gabi++/include" ) + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gabi++/libs/${ANDROID_NDK_ABI_NAME}/libgabi++_static.a" ) + elseif( ANDROID_STL MATCHES "stlport" ) + if( NOT ANDROID_NDK_RELEASE_NUM LESS 8004 ) # before r8d + set( ANDROID_EXCEPTIONS ON ) + else() + set( ANDROID_EXCEPTIONS OFF ) + endif() + if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7 + set( ANDROID_RTTI OFF ) + else() + set( ANDROID_RTTI ON ) + endif() + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/stlport/stlport" ) + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/stlport/libs/${ANDROID_NDK_ABI_NAME}/libstlport_static.a" ) + elseif( ANDROID_STL MATCHES "gnustl" ) + set( ANDROID_EXCEPTIONS ON ) + set( ANDROID_RTTI ON ) + if( EXISTS "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" ) + if( ARMEABI_V7A AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.7" AND ANDROID_NDK_RELEASE STREQUAL "r8d" ) + # gnustl binary for 4.7 compiler is buggy :( + # TODO: look for right fix + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.6" ) + else() + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" ) + endif() + else() + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++" ) + endif() + set( ANDROID_STL_INCLUDE_DIRS "${__libstl}/include" "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/include" "${__libstl}/include/backward" ) + if( EXISTS "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" ) + set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" ) + else() + set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) + endif() + elseif( ANDROID_STL MATCHES "c\\+\\+" ) + set( ANDROID_EXCEPTIONS ON ) + set( ANDROID_RTTI ON ) + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/llvm-libc++" ) + set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libc++_static.a" ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/android/support/include" "${ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libcxx/include" "${ANDROID_NDK}/sources/cxx-stl/llvm-libc++abi/libcxxabi/include" ) + else() + message( FATAL_ERROR "Unknown runtime: ${ANDROID_STL}" ) + endif() + + # find libsupc++.a - rtti & exceptions + if( ANDROID_STL STREQUAL "system_re" OR ANDROID_STL MATCHES "gnustl" ) + set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r8b or newer + if( NOT EXISTS "${__libsupcxx}" ) + set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r7-r8 + endif() + if( NOT EXISTS "${__libsupcxx}" ) # before r7 + if( ARMEABI_V7A ) + if( ANDROID_FORCE_ARM_BUILD ) + set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" ) + else() + set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" ) + endif() + elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD ) + set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" ) + else() + set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" ) + endif() + endif() + if( NOT EXISTS "${__libsupcxx}") + message( ERROR "Could not find libsupc++.a for a chosen platform. Either your NDK is not supported or is broken.") + endif() + endif() +endif() + + +# case of shared STL linkage +if( ANDROID_STL MATCHES "shared" AND DEFINED __libstl ) + string( REPLACE "_static.a" "_shared.so" __libstl "${__libstl}" ) + if( NOT EXISTS "${__libstl}" ) + message( FATAL_ERROR "Unable to find shared library ${__libstl}" ) + endif() +endif() + + +# ccache support +__INIT_VARIABLE( _ndk_ccache NDK_CCACHE ENV_NDK_CCACHE ) +if( _ndk_ccache ) + if( DEFINED NDK_CCACHE AND NOT EXISTS NDK_CCACHE ) + unset( NDK_CCACHE CACHE ) + endif() + find_program( NDK_CCACHE "${_ndk_ccache}" DOC "The path to ccache binary") +else() + unset( NDK_CCACHE CACHE ) +endif() +unset( _ndk_ccache ) + + +# setup the cross-compiler +if( NOT CMAKE_C_COMPILER ) + if( NDK_CCACHE AND NOT ANDROID_SYSROOT MATCHES "[ ;\"]" ) + set( CMAKE_C_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C compiler" ) + set( CMAKE_CXX_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C++ compiler" ) + if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_C_COMPILER_ARG1 "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" CACHE PATH "C compiler") + set( CMAKE_CXX_COMPILER_ARG1 "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler") + else() + set( CMAKE_C_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "C compiler") + set( CMAKE_CXX_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler") + endif() + else() + if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_C_COMPILER "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" CACHE PATH "C compiler") + set( CMAKE_CXX_COMPILER "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler") + else() + set( CMAKE_C_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "C compiler" ) + set( CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler" ) + endif() + endif() + set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "assembler" ) + set( CMAKE_STRIP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip" ) + if( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc-ar${TOOL_OS_SUFFIX}" ) + # Use gcc-ar if we have it for better LTO support. + set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" ) + else() + set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" ) + endif() + set( CMAKE_LINKER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker" ) + set( CMAKE_NM "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-nm${TOOL_OS_SUFFIX}" CACHE PATH "nm" ) + set( CMAKE_OBJCOPY "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" ) + set( CMAKE_OBJDUMP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objdump${TOOL_OS_SUFFIX}" CACHE PATH "objdump" ) + set( CMAKE_RANLIB "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ranlib${TOOL_OS_SUFFIX}" CACHE PATH "ranlib" ) +endif() + +set( _CMAKE_TOOLCHAIN_PREFIX "${ANDROID_TOOLCHAIN_MACHINE_NAME}-" ) +if( CMAKE_VERSION VERSION_LESS 2.8.5 ) + set( CMAKE_ASM_COMPILER_ARG1 "-c" ) +endif() +if( APPLE ) + find_program( CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool ) + if( NOT CMAKE_INSTALL_NAME_TOOL ) + message( FATAL_ERROR "Could not find install_name_tool, please check your installation." ) + endif() + mark_as_advanced( CMAKE_INSTALL_NAME_TOOL ) +endif() + +# Force set compilers because standard identification works badly for us +include( CMakeForceCompiler ) +CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU ) +if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_C_COMPILER_ID Clang ) +endif() +set( CMAKE_C_PLATFORM_ID Linux ) +if( X86_64 OR MIPS64 OR ARM64_V8A ) + set( CMAKE_C_SIZEOF_DATA_PTR 8 ) +else() + set( CMAKE_C_SIZEOF_DATA_PTR 4 ) +endif() +set( CMAKE_C_HAS_ISYSROOT 1 ) +set( CMAKE_C_COMPILER_ABI ELF ) +CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU ) +if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_CXX_COMPILER_ID Clang) +endif() +set( CMAKE_CXX_PLATFORM_ID Linux ) +set( CMAKE_CXX_SIZEOF_DATA_PTR ${CMAKE_C_SIZEOF_DATA_PTR} ) +set( CMAKE_CXX_HAS_ISYSROOT 1 ) +set( CMAKE_CXX_COMPILER_ABI ELF ) +set( CMAKE_CXX_SOURCE_FILE_EXTENSIONS cc cp cxx cpp CPP c++ C ) +# force ASM compiler (required for CMake < 2.8.5) +set( CMAKE_ASM_COMPILER_ID_RUN TRUE ) +set( CMAKE_ASM_COMPILER_ID GNU ) +set( CMAKE_ASM_COMPILER_WORKS TRUE ) +set( CMAKE_ASM_COMPILER_FORCED TRUE ) +set( CMAKE_COMPILER_IS_GNUASM 1) +set( CMAKE_ASM_SOURCE_FILE_EXTENSIONS s S asm ) + +foreach( lang C CXX ASM ) + if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_${lang}_COMPILER_VERSION ${ANDROID_CLANG_VERSION} ) + else() + set( CMAKE_${lang}_COMPILER_VERSION ${ANDROID_COMPILER_VERSION} ) + endif() +endforeach() + +# flags and definitions +remove_definitions( -DANDROID ) +add_definitions( -DANDROID ) + +if( ANDROID_SYSROOT MATCHES "[ ;\"]" ) + if( CMAKE_HOST_WIN32 ) + # try to convert path to 8.3 form + file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cvt83.cmd" "@echo %~s1" ) + execute_process( COMMAND "$ENV{ComSpec}" /c "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cvt83.cmd" "${ANDROID_SYSROOT}" + OUTPUT_VARIABLE __path OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE __result ERROR_QUIET ) + if( __result EQUAL 0 ) + file( TO_CMAKE_PATH "${__path}" ANDROID_SYSROOT ) + set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" ) + else() + set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" ) + endif() + else() + set( ANDROID_CXX_FLAGS "'--sysroot=${ANDROID_SYSROOT}'" ) + endif() + if( NOT _CMAKE_IN_TRY_COMPILE ) + # quotes can break try_compile and compiler identification + message(WARNING "Path to your Android NDK (or toolchain) has non-alphanumeric symbols.\nThe build might be broken.\n") + endif() +else() + set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" ) +endif() + +# NDK flags +if (ARM64_V8A ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" ) + set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -funswitch-loops -finline-limit=300" ) + endif() +elseif( ARMEABI OR ARMEABI_V7A OR ARMEABI_V7A_HARD) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" ) + if( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 ) + set( ANDROID_CXX_FLAGS_RELEASE "-mthumb -fomit-frame-pointer -fno-strict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-marm -fno-omit-frame-pointer -fno-strict-aliasing" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -finline-limit=64" ) + endif() + else() + # always compile ARMEABI_V6 in arm mode; otherwise there is no difference from ARMEABI + set( ANDROID_CXX_FLAGS_RELEASE "-marm -fomit-frame-pointer -fstrict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-marm -fno-omit-frame-pointer -fno-strict-aliasing" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" ) + endif() + endif() +elseif( X86 OR X86_64 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" ) + endif() + set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" ) +elseif( MIPS OR MIPS64 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fno-strict-aliasing -finline-functions -funwind-tables -fmessage-length=0" ) + set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer" ) + set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers" ) + set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -funswitch-loops -finline-limit=300" ) + endif() +elseif() + set( ANDROID_CXX_FLAGS_RELEASE "" ) + set( ANDROID_CXX_FLAGS_DEBUG "" ) +endif() + +set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" ) # good/necessary when porting desktop libraries + +if( NOT X86 AND NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "-Wno-psabi ${ANDROID_CXX_FLAGS}" ) +endif() + +if( NOT ANDROID_COMPILER_VERSION VERSION_LESS "4.6" ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -no-canonical-prefixes" ) # see https://android-review.googlesource.com/#/c/47564/ +endif() + +# ABI-specific flags +if( ARMEABI_V7A_HARD ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a -mfloat-abi=hard -mhard-float -D_NDK_MATH_NO_SOFTFP=1" ) + if( NEON ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=neon" ) + elseif( VFPV3 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3" ) + else() + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3-d16" ) + endif() +elseif( ARMEABI_V7A ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a -mfloat-abi=softfp" ) + if( NEON ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=neon" ) + elseif( VFPV3 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3" ) + else() + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3-d16" ) + endif() + +elseif( ARMEABI_V6 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" ) # vfp == vfpv2 +elseif( ARMEABI ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" ) +endif() + +if( ANDROID_STL MATCHES "gnustl" AND (EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}") ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY " -o " ) + set( CMAKE_CXX_CREATE_SHARED_MODULE " -o " ) + set( CMAKE_CXX_LINK_EXECUTABLE " -o " ) +else() + set( CMAKE_CXX_CREATE_SHARED_LIBRARY " -o " ) + set( CMAKE_CXX_CREATE_SHARED_MODULE " -o " ) + set( CMAKE_CXX_LINK_EXECUTABLE " -o " ) +endif() + +# STL +if( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" ) + if( EXISTS "${__libstl}" ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libstl}\"" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libstl}\"" ) + set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \"${__libstl}\"" ) + endif() + if( EXISTS "${__libsupcxx}" ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libsupcxx}\"" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libsupcxx}\"" ) + set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \"${__libsupcxx}\"" ) + # C objects: + set( CMAKE_C_CREATE_SHARED_LIBRARY " -o " ) + set( CMAKE_C_CREATE_SHARED_MODULE " -o " ) + set( CMAKE_C_LINK_EXECUTABLE " -o " ) + set( CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY} \"${__libsupcxx}\"" ) + set( CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_C_CREATE_SHARED_MODULE} \"${__libsupcxx}\"" ) + set( CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} \"${__libsupcxx}\"" ) + endif() + if( ANDROID_STL MATCHES "gnustl" ) + if( NOT EXISTS "${ANDROID_LIBM_PATH}" ) + set( ANDROID_LIBM_PATH -lm ) + endif() + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} ${ANDROID_LIBM_PATH}" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} ${ANDROID_LIBM_PATH}" ) + set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${ANDROID_LIBM_PATH}" ) + endif() +endif() + +# variables controlling optional build flags +if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7 + # libGLESv2.so in NDK's prior to r7 refers to missing external symbols. + # So this flag option is required for all projects using OpenGL from native. + __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES ON ) +else() + __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES OFF ) +endif() +__INIT_VARIABLE( ANDROID_NO_UNDEFINED VALUES ON ) +__INIT_VARIABLE( ANDROID_FUNCTION_LEVEL_LINKING VALUES ON ) +__INIT_VARIABLE( ANDROID_GOLD_LINKER VALUES ON ) +__INIT_VARIABLE( ANDROID_NOEXECSTACK VALUES ON ) +__INIT_VARIABLE( ANDROID_RELRO VALUES ON ) + +set( ANDROID_NO_UNDEFINED ${ANDROID_NO_UNDEFINED} CACHE BOOL "Show all undefined symbols as linker errors" ) +set( ANDROID_SO_UNDEFINED ${ANDROID_SO_UNDEFINED} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" ) +set( ANDROID_FUNCTION_LEVEL_LINKING ${ANDROID_FUNCTION_LEVEL_LINKING} CACHE BOOL "Put each function in separate section and enable garbage collection of unused input sections at link time" ) +set( ANDROID_GOLD_LINKER ${ANDROID_GOLD_LINKER} CACHE BOOL "Enables gold linker" ) +set( ANDROID_NOEXECSTACK ${ANDROID_NOEXECSTACK} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" ) +set( ANDROID_RELRO ${ANDROID_RELRO} CACHE BOOL "Enables RELRO - a memory corruption mitigation technique" ) +mark_as_advanced( ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_FUNCTION_LEVEL_LINKING ANDROID_GOLD_LINKER ANDROID_NOEXECSTACK ANDROID_RELRO ) + +# linker flags +set( ANDROID_LINKER_FLAGS "" ) + +if( ARMEABI_V7A ) + # this is *required* to use the following linker flags that routes around + # a CPU bug in some Cortex-A8 implementations: + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--fix-cortex-a8" ) +endif() + +if( ARMEABI_V7A_HARD ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-warn-mismatch -lm_hard" ) +endif() + +if( ANDROID_NO_UNDEFINED ) + if( MIPS ) + # there is some sysroot-related problem in mips linker... + if( NOT ANDROID_SYSROOT MATCHES "[ ;\"]" ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined -Wl,-rpath-link,${ANDROID_SYSROOT}/usr/lib" ) + endif() + else() + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined" ) + endif() +endif() + +if( ANDROID_SO_UNDEFINED ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-allow-shlib-undefined" ) +endif() + +if( ANDROID_FUNCTION_LEVEL_LINKING ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--gc-sections" ) +endif() + +if( ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" ) + if( ANDROID_GOLD_LINKER AND (CMAKE_HOST_UNIX OR ANDROID_NDK_RELEASE_NUM GREATER 8002) AND (ARMEABI OR ARMEABI_V7A OR ARMEABI_V7A_HARD OR X86) ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" ) + elseif( ANDROID_NDK_RELEASE_NUM GREATER 8002 ) # after r8b + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=bfd" ) + elseif( ANDROID_NDK_RELEASE STREQUAL "r8b" AND ARMEABI AND NOT _CMAKE_IN_TRY_COMPILE ) + message( WARNING "The default bfd linker from arm GCC 4.6 toolchain can fail with 'unresolvable R_ARM_THM_CALL relocation' error message. See https://code.google.com/p/android/issues/detail?id=35342 + On Linux and OS X host platform you can workaround this problem using gold linker (default). + Rerun cmake with -DANDROID_GOLD_LINKER=ON option in case of problems. +" ) + endif() +endif() # version 4.6 + +if( ANDROID_NOEXECSTACK ) + if( ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -Xclang -mnoexecstack" ) + else() + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -Wa,--noexecstack" ) + endif() + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,noexecstack" ) +endif() + +if( ANDROID_RELRO ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,relro -Wl,-z,now" ) +endif() + +if( ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} -Qunused-arguments ${ANDROID_CXX_FLAGS}" ) + if( BUILD_WITH_ANDROID_NDK ) + set( ANDROID_CXX_FLAGS "-gcc-toolchain ${ANDROID_TOOLCHAIN_ROOT} ${ANDROID_CXX_FLAGS}" ) + endif() +endif() + +# cache flags +set( CMAKE_CXX_FLAGS "" CACHE STRING "c++ flags" ) +set( CMAKE_C_FLAGS "" CACHE STRING "c flags" ) +set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "c++ Release flags" ) +set( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "c Release flags" ) +set( CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "c++ Debug flags" ) +set( CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "c Debug flags" ) +set( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "shared linker flags" ) +set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "module linker flags" ) +set( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "executable linker flags" ) + +# put flags to cache (for debug purpose only) +set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" CACHE INTERNAL "Android specific c/c++ flags" ) +set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE}" CACHE INTERNAL "Android specific c/c++ Release flags" ) +set( ANDROID_CXX_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG}" CACHE INTERNAL "Android specific c/c++ Debug flags" ) +set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS}" CACHE INTERNAL "Android specific c/c++ linker flags" ) + +# finish flags +set( CMAKE_CXX_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" ) +set( CMAKE_C_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" ) +set( CMAKE_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELEASE}" ) +set( CMAKE_C_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} ${CMAKE_C_FLAGS_RELEASE}" ) +set( CMAKE_CXX_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_DEBUG}" ) +set( CMAKE_C_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} ${CMAKE_C_FLAGS_DEBUG}" ) +set( CMAKE_SHARED_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" ) +set( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" ) +set( CMAKE_EXE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" ) + +if( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK_RELEASE STREQUAL "r8" ) + set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" ) + set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" ) + set( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" ) +endif() + +# pie/pic +if( NOT (ANDROID_NATIVE_API_LEVEL LESS 16) AND (NOT DEFINED ANDROID_APP_PIE OR ANDROID_APP_PIE) AND (CMAKE_VERSION VERSION_GREATER 2.8.8) ) + set( CMAKE_POSITION_INDEPENDENT_CODE TRUE ) + set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie") +else() + set( CMAKE_POSITION_INDEPENDENT_CODE FALSE ) + set( CMAKE_CXX_FLAGS "-fpic ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_C_FLAGS "-fpic ${CMAKE_C_FLAGS}" ) +endif() + +# configure rtti +if( DEFINED ANDROID_RTTI AND ANDROID_STL_FORCE_FEATURES ) + if( ANDROID_RTTI ) + set( CMAKE_CXX_FLAGS "-frtti ${CMAKE_CXX_FLAGS}" ) + else() + set( CMAKE_CXX_FLAGS "-fno-rtti ${CMAKE_CXX_FLAGS}" ) + endif() +endif() + +# configure exceptios +if( DEFINED ANDROID_EXCEPTIONS AND ANDROID_STL_FORCE_FEATURES ) + if( ANDROID_EXCEPTIONS ) + set( CMAKE_CXX_FLAGS "-fexceptions ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_C_FLAGS "-fexceptions ${CMAKE_C_FLAGS}" ) + else() + set( CMAKE_CXX_FLAGS "-fno-exceptions ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_C_FLAGS "-fno-exceptions ${CMAKE_C_FLAGS}" ) + endif() +endif() + +# global includes and link directories +include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_STL_INCLUDE_DIRS} ) +get_filename_component(__android_install_path "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ABSOLUTE) # avoid CMP0015 policy warning +link_directories( "${__android_install_path}" ) + +# detect if need link crtbegin_so.o explicitly +if( NOT DEFINED ANDROID_EXPLICIT_CRT_LINK ) + set( __cmd "${CMAKE_CXX_CREATE_SHARED_LIBRARY}" ) + string( REPLACE "" "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" __cmd "${__cmd}" ) + string( REPLACE "" "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}" __cmd "${__cmd}" ) + string( REPLACE "" "${CMAKE_CXX_FLAGS}" __cmd "${__cmd}" ) + string( REPLACE "" "" __cmd "${__cmd}" ) + string( REPLACE "" "${CMAKE_SHARED_LINKER_FLAGS}" __cmd "${__cmd}" ) + string( REPLACE "" "-shared" __cmd "${__cmd}" ) + string( REPLACE "" "" __cmd "${__cmd}" ) + string( REPLACE "" "" __cmd "${__cmd}" ) + string( REPLACE "" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toolchain_crtlink_test.so" __cmd "${__cmd}" ) + string( REPLACE "" "\"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" __cmd "${__cmd}" ) + string( REPLACE "" "" __cmd "${__cmd}" ) + separate_arguments( __cmd ) + foreach( __var ANDROID_NDK ANDROID_NDK_TOOLCHAINS_PATH ANDROID_STANDALONE_TOOLCHAIN ) + if( ${__var} ) + set( __tmp "${${__var}}" ) + separate_arguments( __tmp ) + string( REPLACE "${__tmp}" "${${__var}}" __cmd "${__cmd}") + endif() + endforeach() + string( REPLACE "'" "" __cmd "${__cmd}" ) + string( REPLACE "\"" "" __cmd "${__cmd}" ) + execute_process( COMMAND ${__cmd} RESULT_VARIABLE __cmd_result OUTPUT_QUIET ERROR_QUIET ) + if( __cmd_result EQUAL 0 ) + set( ANDROID_EXPLICIT_CRT_LINK ON ) + else() + set( ANDROID_EXPLICIT_CRT_LINK OFF ) + endif() +endif() + +if( ANDROID_EXPLICIT_CRT_LINK ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" ) +endif() + +# setup output directories +set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" ) + +if( DEFINED LIBRARY_OUTPUT_PATH_ROOT + OR EXISTS "${CMAKE_SOURCE_DIR}/AndroidManifest.xml" + OR (EXISTS "${CMAKE_SOURCE_DIR}/../AndroidManifest.xml" AND EXISTS "${CMAKE_SOURCE_DIR}/../jni/") ) + set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "Root for binaries output, set this to change where Android libs are installed to" ) + if( NOT _CMAKE_IN_TRY_COMPILE ) + if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" ) + set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" ) + else() + set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" ) + endif() + set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for Android libs" ) + endif() +endif() + +# copy shaed stl library to build directory +if( NOT _CMAKE_IN_TRY_COMPILE AND __libstl MATCHES "[.]so$" AND DEFINED LIBRARY_OUTPUT_PATH ) + get_filename_component( __libstlname "${__libstl}" NAME ) + execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__libstl}" "${LIBRARY_OUTPUT_PATH}/${__libstlname}" RESULT_VARIABLE __fileCopyProcess ) + if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${LIBRARY_OUTPUT_PATH}/${__libstlname}") + message( SEND_ERROR "Failed copying of ${__libstl} to the ${LIBRARY_OUTPUT_PATH}/${__libstlname}" ) + endif() + unset( __fileCopyProcess ) + unset( __libstlname ) +endif() + + +# set these global flags for cmake client scripts to change behavior +set( ANDROID True ) +set( BUILD_ANDROID True ) + +# where is the target environment +set( CMAKE_FIND_ROOT_PATH "${ANDROID_TOOLCHAIN_ROOT}/bin" "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" "${ANDROID_SYSROOT}" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share" ) + +# only search for libraries and includes in the ndk toolchain +set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) +set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) +set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) + + +# macro to find packages on the host OS +macro( find_host_package ) + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) + if( CMAKE_HOST_WIN32 ) + SET( WIN32 1 ) + SET( UNIX ) + elseif( CMAKE_HOST_APPLE ) + SET( APPLE 1 ) + SET( UNIX ) + endif() + find_package( ${ARGN} ) + SET( WIN32 ) + SET( APPLE ) + SET( UNIX 1 ) + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) +endmacro() + + +# macro to find programs on the host OS +macro( find_host_program ) + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) + if( CMAKE_HOST_WIN32 ) + SET( WIN32 1 ) + SET( UNIX ) + elseif( CMAKE_HOST_APPLE ) + SET( APPLE 1 ) + SET( UNIX ) + endif() + find_program( ${ARGN} ) + SET( WIN32 ) + SET( APPLE ) + SET( UNIX 1 ) + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) +endmacro() + + +# export toolchain settings for the try_compile() command +if( NOT _CMAKE_IN_TRY_COMPILE ) + set( __toolchain_config "") + foreach( __var NDK_CCACHE LIBRARY_OUTPUT_PATH_ROOT ANDROID_FORBID_SYGWIN + ANDROID_NDK_HOST_X64 + ANDROID_NDK + ANDROID_NDK_LAYOUT + ANDROID_STANDALONE_TOOLCHAIN + ANDROID_TOOLCHAIN_NAME + ANDROID_ABI + ANDROID_NATIVE_API_LEVEL + ANDROID_STL + ANDROID_STL_FORCE_FEATURES + ANDROID_FORCE_ARM_BUILD + ANDROID_NO_UNDEFINED + ANDROID_SO_UNDEFINED + ANDROID_FUNCTION_LEVEL_LINKING + ANDROID_GOLD_LINKER + ANDROID_NOEXECSTACK + ANDROID_RELRO + ANDROID_LIBM_PATH + ANDROID_EXPLICIT_CRT_LINK + ANDROID_APP_PIE + ) + if( DEFINED ${__var} ) + if( ${__var} MATCHES " ") + set( __toolchain_config "${__toolchain_config}set( ${__var} \"${${__var}}\" CACHE INTERNAL \"\" )\n" ) + else() + set( __toolchain_config "${__toolchain_config}set( ${__var} ${${__var}} CACHE INTERNAL \"\" )\n" ) + endif() + endif() + endforeach() + file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/android.toolchain.config.cmake" "${__toolchain_config}" ) + unset( __toolchain_config ) +endif() + + +# force cmake to produce / instead of \ in build commands for Ninja generator +if( CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_HOST_WIN32 ) + # it is a bad hack after all + # CMake generates Ninja makefiles with UNIX paths only if it thinks that we are going to build with MinGW + set( CMAKE_COMPILER_IS_MINGW TRUE ) # tell CMake that we are MinGW + set( CMAKE_CROSSCOMPILING TRUE ) # stop recursion + enable_language( C ) + enable_language( CXX ) + # unset( CMAKE_COMPILER_IS_MINGW ) # can't unset because CMake does not convert back-slashes in response files without it + unset( MINGW ) +endif() + + +# Variables controlling behavior or set by cmake toolchain: +# ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a-hard with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips", "arm64-v8a", "x86_64", "mips64" +# ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14,15,16,17,18,19,21 (depends on NDK version) +# ANDROID_STL : gnustl_static/gnustl_shared/stlport_static/stlport_shared/gabi++_static/gabi++_shared/system_re/system/none +# ANDROID_FORBID_SYGWIN : ON/OFF +# ANDROID_NO_UNDEFINED : ON/OFF +# ANDROID_SO_UNDEFINED : OFF/ON (default depends on NDK version) +# ANDROID_FUNCTION_LEVEL_LINKING : ON/OFF +# ANDROID_GOLD_LINKER : ON/OFF +# ANDROID_NOEXECSTACK : ON/OFF +# ANDROID_RELRO : ON/OFF +# ANDROID_FORCE_ARM_BUILD : ON/OFF +# ANDROID_STL_FORCE_FEATURES : ON/OFF +# ANDROID_LIBM_PATH : path to libm.so (set to something like $(TOP)/out/target/product//obj/lib/libm.so) to workaround unresolved `sincos` +# Can be set only at the first run: +# ANDROID_NDK : path to your NDK install +# NDK_CCACHE : path to your ccache executable +# ANDROID_TOOLCHAIN_NAME : the NDK name of compiler toolchain +# ANDROID_NDK_HOST_X64 : try to use x86_64 toolchain (default for x64 host systems) +# ANDROID_NDK_LAYOUT : the inner NDK structure (RELEASE, LINARO, ANDROID) +# LIBRARY_OUTPUT_PATH_ROOT : +# ANDROID_STANDALONE_TOOLCHAIN +# +# Primary read-only variables: +# ANDROID : always TRUE +# ARMEABI : TRUE for arm v6 and older devices +# ARMEABI_V6 : TRUE for arm v6 +# ARMEABI_V7A : TRUE for arm v7a +# ARMEABI_V7A_HARD : TRUE for arm v7a with hardfp +# ARM64_V8A : TRUE for arm64-v8a +# NEON : TRUE if NEON unit is enabled +# VFPV3 : TRUE if VFP version 3 is enabled +# X86 : TRUE if configured for x86 +# X86_64 : TRUE if configured for x86_64 +# MIPS : TRUE if configured for mips +# MIPS64 : TRUE if configured for mips64 +# BUILD_WITH_ANDROID_NDK : TRUE if NDK is used +# BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used +# ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform +# ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a", "armeabi-v7a-hard", "x86", "mips", "arm64-v8a", "x86_64", "mips64" depending on ANDROID_ABI +# ANDROID_NDK_RELEASE : from r5 to r10d; set only for NDK +# ANDROID_NDK_RELEASE_NUM : numeric ANDROID_NDK_RELEASE version (1000*major+minor) +# ANDROID_ARCH_NAME : "arm", "x86", "mips", "arm64", "x86_64", "mips64" depending on ANDROID_ABI +# ANDROID_SYSROOT : path to the compiler sysroot +# TOOL_OS_SUFFIX : "" or ".exe" depending on host platform +# ANDROID_COMPILER_IS_CLANG : TRUE if clang compiler is used +# +# Secondary (less stable) read-only variables: +# ANDROID_COMPILER_VERSION : GCC version used (not Clang version) +# ANDROID_CLANG_VERSION : version of clang compiler if clang is used +# ANDROID_CXX_FLAGS : C/C++ compiler flags required by Android platform +# ANDROID_SUPPORTED_ABIS : list of currently allowed values for ANDROID_ABI +# ANDROID_TOOLCHAIN_MACHINE_NAME : "arm-linux-androideabi", "arm-eabi" or "i686-android-linux" +# ANDROID_TOOLCHAIN_ROOT : path to the top level of toolchain (standalone or placed inside NDK) +# ANDROID_CLANG_TOOLCHAIN_ROOT : path to clang tools +# ANDROID_SUPPORTED_NATIVE_API_LEVELS : list of native API levels found inside NDK +# ANDROID_STL_INCLUDE_DIRS : stl include paths +# ANDROID_RTTI : if rtti is enabled by the runtime +# ANDROID_EXCEPTIONS : if exceptions are enabled by the runtime +# ANDROID_GCC_TOOLCHAIN_NAME : read-only, differs from ANDROID_TOOLCHAIN_NAME only if clang is used +# +# Defaults: +# ANDROID_DEFAULT_NDK_API_LEVEL +# ANDROID_DEFAULT_NDK_API_LEVEL_${ARCH} +# ANDROID_NDK_SEARCH_PATHS +# ANDROID_SUPPORTED_ABIS_${ARCH} +# ANDROID_SUPPORTED_NDK_VERSIONS diff --git a/android/scripts/cmake_android.sh b/android/scripts/cmake_android.sh new file mode 100755 index 000000000..539e4f18b --- /dev/null +++ b/android/scripts/cmake_android.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cd `dirname $0`/.. + +mkdir -p build +cd build + +cmake -DANDROID_NATIVE_API_LEVEL=android-9 -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. + diff --git a/android/scripts/cmake_android_armeabi.sh b/android/scripts/cmake_android_armeabi.sh new file mode 100755 index 000000000..c740010f1 --- /dev/null +++ b/android/scripts/cmake_android_armeabi.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cd `dirname $0`/.. + +mkdir -p build_armeabi +cd build_armeabi + +cmake -DANDROID_NATIVE_API_LEVEL=android-9 -DANDROID_ABI=armeabi -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. + diff --git a/android/scripts/cmake_android_mips.sh b/android/scripts/cmake_android_mips.sh new file mode 100755 index 000000000..0e85eef8a --- /dev/null +++ b/android/scripts/cmake_android_mips.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cd `dirname $0`/.. + +mkdir -p build_mips +cd build_mips + +cmake -DANDROID_NATIVE_API_LEVEL=android-9 -DANDROID_ABI=mips -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. + diff --git a/android/scripts/cmake_android_neon.sh b/android/scripts/cmake_android_neon.sh new file mode 100755 index 000000000..b4bcd76fb --- /dev/null +++ b/android/scripts/cmake_android_neon.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cd `dirname $0`/.. + +mkdir -p build_neon +cd build_neon + +cmake -DANDROID_NATIVE_API_LEVEL=android-9 -DANDROID_ABI="armeabi-v7a with NEON" -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. + diff --git a/android/scripts/cmake_android_x86.sh b/android/scripts/cmake_android_x86.sh new file mode 100755 index 000000000..2260fd886 --- /dev/null +++ b/android/scripts/cmake_android_x86.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +cd `dirname $0`/.. + +mkdir -p build_x86 +cd build_x86 + +cmake -DANDROID_NATIVE_API_LEVEL=android-9 -DANDROID_ABI=x86 -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. + diff --git a/config.guess b/config.guess index d622a44e5..872b96a16 100755 --- a/config.guess +++ b/config.guess @@ -4,7 +4,7 @@ # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. -timestamp='2012-02-10' +timestamp='2012-09-25' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -200,6 +200,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} @@ -302,7 +306,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) + arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) @@ -801,6 +805,9 @@ EOF i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; @@ -1201,6 +1208,9 @@ EOF BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; @@ -1256,7 +1266,7 @@ EOF NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; - NSE-?:NONSTOP_KERNEL:*:*) + NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) @@ -1330,9 +1340,6 @@ EOF exit ;; esac -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - eval $set_cc_for_build cat >$dummy.c <config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by log4cplus $as_me 1.1.0, which was +It was created by log4cplus $as_me 1.1.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3024,7 +3039,7 @@ fi # Define the identity of the package. PACKAGE='log4cplus' - VERSION='1.1.0' + VERSION='1.1.3' # Some tools Automake needs. @@ -4210,7 +4225,7 @@ esac # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=5:0:0 +LT_VERSION=11:5:2 LT_RELEASE=1.1 @@ -4338,6 +4353,70 @@ fi +# Check whether --enable-so-version was given. +if test "${enable_so_version+set}" = set; then : + enableval=$enable_so_version; case "${enableval}" in #( + yes) : + ;; #( + no) : + ;; #( + *) : + as_fn_error $? "bad value ${enableval} for --enable-so-version" "$LINENO" 5 ;; +esac +else + enable_so_version=yes +fi + + if test "x$enable_so_version" = "xyes"; then + ENABLE_VERSION_INFO_OPTION_TRUE= + ENABLE_VERSION_INFO_OPTION_FALSE='#' +else + ENABLE_VERSION_INFO_OPTION_TRUE='#' + ENABLE_VERSION_INFO_OPTION_FALSE= +fi + + + +# Check whether --enable-release-version was given. +if test "${enable_release_version+set}" = set; then : + enableval=$enable_release_version; case "${enableval}" in #( + yes) : + ;; #( + no) : + ;; #( + *) : + as_fn_error $? "bad value ${enableval} for --enable-release-version" "$LINENO" 5 ;; +esac +else + enable_release_version=yes +fi + + if test "x$enable_release_version" = "xyes"; then + ENABLE_RELEASE_OPTION_TRUE= + ENABLE_RELEASE_OPTION_FALSE='#' +else + ENABLE_RELEASE_OPTION_TRUE='#' + ENABLE_RELEASE_OPTION_FALSE= +fi + + + +# Check whether --enable-symbols-visibility-options was given. +if test "${enable_symbols_visibility_options+set}" = set; then : + enableval=$enable_symbols_visibility_options; case "${enableval}" in #( + yes) : + ;; #( + no) : + ;; #( + *) : + as_fn_error $? "bad value ${enableval} for --enable-symbols-visibility-options" "$LINENO" 5 ;; +esac +else + enable_symbols_visibility_options=yes +fi + + + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -5107,6 +5186,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu esac fi +LOG4CPLUS_AIX_XLC_LDFLAGS= { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : @@ -5171,8 +5251,75 @@ $as_echo "$ac_cv_path_GREP" >&6; } case $ax_cv_cxx_compiler_vendor in #( + ibm) : + as_fn_append CXXFLAGS " -qroconst" + as_fn_append LOG4CPLUS_AIX_XLC_LDFLAGS " -qmkshrobj=-300" ;; #( gnu|clang) : - if test "x$enable_warnings" = "xyes"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fdiagnostics-show-caret" >&5 +$as_echo_n "checking CXXFLAGS for gcc -fdiagnostics-show-caret... " >&6; } +if ${ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret+:} false; then : + $as_echo_n "(cached) " >&6 +else + ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret="no, unknown" + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + ac_save_CXXFLAGS="$CXXFLAGS" +for ac_arg in "-pedantic -Werror % -fdiagnostics-show-caret" "-pedantic % -fdiagnostics-show-caret %% no, obsolete" # +do CXXFLAGS="$ac_save_CXXFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret=`echo $ac_arg | sed -e 's,.*% *,,'`; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done + CXXFLAGS="$ac_save_CXXFLAGS" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret" >&5 +$as_echo "$ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret" >&6; } +var=$ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret +case ".$var" in + .ok|.ok,*) ;; + .|.no|.no,*) ;; + *) + if echo " $CXXFLAGS " | grep " $var " 2>&1 >/dev/null + then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS does contain \$var"; } >&5 + (: CXXFLAGS does contain $var) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS=\"\$CXXFLAGS \$var\""; } >&5 + (: CXXFLAGS="$CXXFLAGS $var") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + CXXFLAGS="$CXXFLAGS $var" + fi + ;; +esac + + if test "x$enable_warnings" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -Wextra" >&5 $as_echo_n "checking CXXFLAGS for gcc -Wextra... " >&6; } if ${ax_cv_cxxflags_gcc_option__Wextra+:} false; then : @@ -6141,12 +6288,16 @@ case ".$var" in ;; esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fkeep-inline-functions" >&5 -$as_echo_n "checking CXXFLAGS for gcc -fkeep-inline-functions... " >&6; } -if ${ax_cv_cxxflags_gcc_option__fkeep_inline_functions+:} false; then : + case "$target_os" in #( + mingw32) : + ;; #( + *) : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fstack-check" >&5 +$as_echo_n "checking CXXFLAGS for gcc -fstack-check... " >&6; } +if ${ax_cv_cxxflags_gcc_option__fstack_check+:} false; then : $as_echo_n "(cached) " >&6 else - ax_cv_cxxflags_gcc_option__fkeep_inline_functions="no, unknown" + ax_cv_cxxflags_gcc_option__fstack_check="no, unknown" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -6155,7 +6306,7 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_save_CXXFLAGS="$CXXFLAGS" -for ac_arg in "-pedantic -Werror % -fkeep-inline-functions" "-pedantic % -fkeep-inline-functions %% no, obsolete" # +for ac_arg in "-pedantic -Werror % -fstack-check" "-pedantic % -fstack-check %% no, obsolete" # do CXXFLAGS="$ac_save_CXXFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6169,7 +6320,7 @@ return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : - ax_cv_cxxflags_gcc_option__fkeep_inline_functions=`echo $ac_arg | sed -e 's,.*% *,,'`; break + ax_cv_cxxflags_gcc_option__fstack_check=`echo $ac_arg | sed -e 's,.*% *,,'`; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done @@ -6182,9 +6333,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__fkeep_inline_functions" >&5 -$as_echo "$ax_cv_cxxflags_gcc_option__fkeep_inline_functions" >&6; } -var=$ax_cv_cxxflags_gcc_option__fkeep_inline_functions +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__fstack_check" >&5 +$as_echo "$ax_cv_cxxflags_gcc_option__fstack_check" >&6; } +var=$ax_cv_cxxflags_gcc_option__fstack_check case ".$var" in .ok|.ok,*) ;; .|.no|.no,*) ;; @@ -6205,12 +6356,12 @@ case ".$var" in ;; esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fstack-check" >&5 -$as_echo_n "checking CXXFLAGS for gcc -fstack-check... " >&6; } -if ${ax_cv_cxxflags_gcc_option__fstack_check+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fstack-protector" >&5 +$as_echo_n "checking CXXFLAGS for gcc -fstack-protector... " >&6; } +if ${ax_cv_cxxflags_gcc_option__fstack_protector+:} false; then : $as_echo_n "(cached) " >&6 else - ax_cv_cxxflags_gcc_option__fstack_check="no, unknown" + ax_cv_cxxflags_gcc_option__fstack_protector="no, unknown" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -6219,7 +6370,7 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_save_CXXFLAGS="$CXXFLAGS" -for ac_arg in "-pedantic -Werror % -fstack-check" "-pedantic % -fstack-check %% no, obsolete" # +for ac_arg in "-pedantic -Werror % -fstack-protector" "-pedantic % -fstack-protector %% no, obsolete" # do CXXFLAGS="$ac_save_CXXFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6233,7 +6384,7 @@ return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : - ax_cv_cxxflags_gcc_option__fstack_check=`echo $ac_arg | sed -e 's,.*% *,,'`; break + ax_cv_cxxflags_gcc_option__fstack_protector=`echo $ac_arg | sed -e 's,.*% *,,'`; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done @@ -6246,9 +6397,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__fstack_check" >&5 -$as_echo "$ax_cv_cxxflags_gcc_option__fstack_check" >&6; } -var=$ax_cv_cxxflags_gcc_option__fstack_check +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__fstack_protector" >&5 +$as_echo "$ax_cv_cxxflags_gcc_option__fstack_protector" >&6; } +var=$ax_cv_cxxflags_gcc_option__fstack_protector case ".$var" in .ok|.ok,*) ;; .|.no|.no,*) ;; @@ -6268,13 +6419,14 @@ case ".$var" in fi ;; esac - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fstack-protector" >&5 -$as_echo_n "checking CXXFLAGS for gcc -fstack-protector... " >&6; } -if ${ax_cv_cxxflags_gcc_option__fstack_protector+:} false; then : + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -ftrapv" >&5 +$as_echo_n "checking CXXFLAGS for gcc -ftrapv... " >&6; } +if ${ax_cv_cxxflags_gcc_option__ftrapv+:} false; then : $as_echo_n "(cached) " >&6 else - ax_cv_cxxflags_gcc_option__fstack_protector="no, unknown" + ax_cv_cxxflags_gcc_option__ftrapv="no, unknown" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -6283,7 +6435,7 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_save_CXXFLAGS="$CXXFLAGS" -for ac_arg in "-pedantic -Werror % -fstack-protector" "-pedantic % -fstack-protector %% no, obsolete" # +for ac_arg in "-pedantic -Werror % -ftrapv" "-pedantic % -ftrapv %% no, obsolete" # do CXXFLAGS="$ac_save_CXXFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6297,7 +6449,7 @@ return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : - ax_cv_cxxflags_gcc_option__fstack_protector=`echo $ac_arg | sed -e 's,.*% *,,'`; break + ax_cv_cxxflags_gcc_option__ftrapv=`echo $ac_arg | sed -e 's,.*% *,,'`; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done @@ -6310,9 +6462,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__fstack_protector" >&5 -$as_echo "$ax_cv_cxxflags_gcc_option__fstack_protector" >&6; } -var=$ax_cv_cxxflags_gcc_option__fstack_protector +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__ftrapv" >&5 +$as_echo "$ax_cv_cxxflags_gcc_option__ftrapv" >&6; } +var=$ax_cv_cxxflags_gcc_option__ftrapv case ".$var" in .ok|.ok,*) ;; .|.no|.no,*) ;; @@ -6333,12 +6485,12 @@ case ".$var" in ;; esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -ftrapv" >&5 -$as_echo_n "checking CXXFLAGS for gcc -ftrapv... " >&6; } -if ${ax_cv_cxxflags_gcc_option__ftrapv+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -ftrack-macro-expansion" >&5 +$as_echo_n "checking CXXFLAGS for gcc -ftrack-macro-expansion... " >&6; } +if ${ax_cv_cxxflags_gcc_option__ftrack_macro_expansion+:} false; then : $as_echo_n "(cached) " >&6 else - ax_cv_cxxflags_gcc_option__ftrapv="no, unknown" + ax_cv_cxxflags_gcc_option__ftrack_macro_expansion="no, unknown" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -6347,7 +6499,7 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_save_CXXFLAGS="$CXXFLAGS" -for ac_arg in "-pedantic -Werror % -ftrapv" "-pedantic % -ftrapv %% no, obsolete" # +for ac_arg in "-pedantic -Werror % -ftrack-macro-expansion" "-pedantic % -ftrack-macro-expansion %% no, obsolete" # do CXXFLAGS="$ac_save_CXXFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6361,7 +6513,7 @@ return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : - ax_cv_cxxflags_gcc_option__ftrapv=`echo $ac_arg | sed -e 's,.*% *,,'`; break + ax_cv_cxxflags_gcc_option__ftrack_macro_expansion=`echo $ac_arg | sed -e 's,.*% *,,'`; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done @@ -6374,9 +6526,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__ftrapv" >&5 -$as_echo "$ax_cv_cxxflags_gcc_option__ftrapv" >&6; } -var=$ax_cv_cxxflags_gcc_option__ftrapv +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__ftrack_macro_expansion" >&5 +$as_echo "$ax_cv_cxxflags_gcc_option__ftrack_macro_expansion" >&6; } +var=$ax_cv_cxxflags_gcc_option__ftrack_macro_expansion case ".$var" in .ok|.ok,*) ;; .|.no|.no,*) ;; @@ -7059,6 +7211,8 @@ esac esac +if test "x$enable_symbols_visibility_options" = "xyes"; then : + @@ -7122,9 +7276,10 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#if defined (__clang__) +#if defined (__clang__) || defined (__HAIKU__) // Here the problem is that Clang only warns that it does not support -// __declspec(dllexport) but still compiles the executable. +// __declspec(dllexport) but still compiles the executable. GCC on Haiku OS +// suffers from the same problem. # error Please fail. And extra please fail. #else @@ -7232,7 +7387,7 @@ fi { continue_checks=; unset continue_checks;} -if test "x$ac_cv_declspec" = "xyes" || test "x$ac_cv__attribute__visibility" = "xyes" || test "x$ac_cv__global" = "xyes"; then : + if test "x$ac_cv_declspec" = "xyes" || test "x$ac_cv__attribute__visibility" = "xyes" || test "x$ac_cv__global" = "xyes"; then : case $ax_cv_cxx_compiler_vendor in #( gnu|clang) : { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fvisibility=hidden" >&5 @@ -7299,7 +7454,8 @@ case ".$var" in ;; esac ;; #( - sun) : + + sun) : { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for sun/cc -xldscope=hidden" >&5 $as_echo_n "checking CXXFLAGS for sun/cc -xldscope=hidden... " >&6; } if ${ax_cv_cxxflags_sun_option__xldscope_hidden+:} false; then : @@ -7368,6 +7524,7 @@ esac ;; esac fi +fi @@ -7385,6 +7542,7 @@ else #include #include +#include int main () @@ -7437,6 +7595,7 @@ else #include #include +#include int main () @@ -7596,6 +7755,176 @@ fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((constructor_priority))" >&5 +$as_echo_n "checking for __attribute__((constructor_priority))... " >&6; } +if ${ax_cv_have_func_attribute_constructor_priority+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + + int foo( void ) __attribute__((__constructor__(65535/2))); + +int +main () +{ + + ; + return 0; +} + +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + if test -s conftest.err; then : + ax_cv_have_func_attribute_constructor_priority=no +else + ax_cv_have_func_attribute_constructor_priority=yes +fi +else + ax_cv_have_func_attribute_constructor_priority=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have_func_attribute_constructor_priority" >&5 +$as_echo "$ax_cv_have_func_attribute_constructor_priority" >&6; } + + if test yes = $ax_cv_have_func_attribute_constructor_priority; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY 1 +_ACEOF + +fi + + + + +if test "x$ax_cv_have_func_attribute_constructor_priority" = "xyes"; then : + $as_echo "#define LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY 1" >>confdefs.h + +fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((constructor))" >&5 +$as_echo_n "checking for __attribute__((constructor))... " >&6; } +if ${ax_cv_have_func_attribute_constructor+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + + int foo( void ) __attribute__((constructor)); + +int +main () +{ + + ; + return 0; +} + +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + if test -s conftest.err; then : + ax_cv_have_func_attribute_constructor=no +else + ax_cv_have_func_attribute_constructor=yes +fi +else + ax_cv_have_func_attribute_constructor=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have_func_attribute_constructor" >&5 +$as_echo "$ax_cv_have_func_attribute_constructor" >&6; } + + if test yes = $ax_cv_have_func_attribute_constructor; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR 1 +_ACEOF + +fi + + + + +if test "x$ax_cv_have_func_attribute_constructor" = "xyes"; then : + $as_echo "#define LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR 1" >>confdefs.h + +fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((init_priority))" >&5 +$as_echo_n "checking for __attribute__((init_priority))... " >&6; } +if ${ax_cv_have_var_attribute_init_priority+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + + struct bar { bar() {} ~bar() {} }; + bar b __attribute__((init_priority(65535/2))); + +int +main () +{ + + + + ; + return 0; +} + +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + if test -s conftest.err; then : + ax_cv_have_var_attribute_init_priority=no +else + ax_cv_have_var_attribute_init_priority=yes +fi +else + ax_cv_have_var_attribute_init_priority=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have_var_attribute_init_priority" >&5 +$as_echo "$ax_cv_have_var_attribute_init_priority" >&6; } + + if test yes = $ax_cv_have_var_attribute_init_priority; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_VAR_ATTRIBUTE_INIT_PRIORITY 1 +_ACEOF + +fi + + + + +if test "x$ax_cv_have_var_attribute_init_priority" = "xyes"; then : + $as_echo "#define LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY 1" >>confdefs.h + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5 $as_echo_n "checking for library containing strerror... " >&6; } if ${ac_cv_search_strerror+:} false; then : @@ -7844,7 +8173,7 @@ return gethostbyname (); return 0; } _ACEOF -for ac_lib in '' nsl; do +for ac_lib in '' nsl network net; do if test -z "$ac_lib"; then ac_res="none required" else @@ -7900,7 +8229,7 @@ return setsockopt (); return 0; } _ACEOF -for ac_lib in '' socket; do +for ac_lib in '' socket network net; do if test -z "$ac_lib"; then ac_res="none required" else @@ -8549,6 +8878,14 @@ if test "x$ac_cv_header_limits_h" = xyes; then : fi + + ac_fn_cxx_check_header_mongrel "$LINENO" "poll.h" "ac_cv_header_poll_h" "$ac_includes_default" +if test "x$ac_cv_header_poll_h" = xyes; then : + $as_echo "#define LOG4CPLUS_HAVE_POLL_H 1" >>confdefs.h + +fi + + if test "x$with_iconv" = "xyes"; then : ac_fn_cxx_check_header_mongrel "$LINENO" "iconv.h" "ac_cv_header_iconv_h" "$ac_includes_default" @@ -9337,6 +9674,8 @@ fi fi + if test \( "$target_os" != "darwin" -o "$target_cpu" != "arm" \) \ + -a "$target_os" != "cygwin"; then : @@ -9352,6 +9691,11 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ + // check that pointers to classes work as well + struct S { S () { } void foo () { } int member; }; + extern thread_local S * p_s; + thread_local S * p_s = 0; + extern thread_local int x; thread_local int * ptr = 0; int foo () { ptr = &x; return x; } @@ -9362,12 +9706,13 @@ main () { x = 2; foo (); + p_s = new S; ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv__thread_local=yes + ac_cv_thread_local=yes ax_tls_support=yes else ac_cv_thread_local=no @@ -9403,6 +9748,11 @@ else #endif #endif + // check that pointers to classes work as well + struct S { S () { } void foo () { } int member; }; + extern __thread S * p_s; + __thread S * p_s = 0; + extern __thread int x; __thread int * ptr = 0; int foo () { ptr = &x; return x; } @@ -9413,6 +9763,7 @@ main () { x = 2; foo (); + p_s = new S; ; return 0; @@ -9455,6 +9806,11 @@ else # error Please fail. And extra please fail. #else + // check that pointers to classes work as well + struct S { S () { } void foo () { } int member; }; + extern __declspec(thread) S * p_s; + __declspec(thread) S * p_s = 0; + extern __declspec(thread) int x; __declspec(thread) int * ptr = 0; int foo () { ptr = &x; return x; } @@ -9466,6 +9822,7 @@ main () { x = 2; foo (); + p_s = new S; ; return 0; } @@ -9491,19 +9848,28 @@ fi fi +fi + + + + if test "x$ac_cv_thread_local" = "xyes"; then : + $as_echo "#define LOG4CPLUS_HAVE_TLS_SUPPORT 1" >>confdefs.h + $as_echo "#define LOG4CPLUS_THREAD_LOCAL_VAR thread_local" >>confdefs.h - if test "x$ac_cv_declspec_thread" = "xyes"; then : +else + if test "x$ac_cv_declspec_thread" = "xyes"; then : $as_echo "#define LOG4CPLUS_HAVE_TLS_SUPPORT 1" >>confdefs.h - $as_echo "#define LOG4CPLUS_THREAD_LOCAL_VAR __declspec(thread)" >>confdefs.h + $as_echo "#define LOG4CPLUS_THREAD_LOCAL_VAR __declspec(thread)" >>confdefs.h else if test "x$ac_cv__thread_keyword" = "xyes"; then : $as_echo "#define LOG4CPLUS_HAVE_TLS_SUPPORT 1" >>confdefs.h - $as_echo "#define LOG4CPLUS_THREAD_LOCAL_VAR __thread" >>confdefs.h + $as_echo "#define LOG4CPLUS_THREAD_LOCAL_VAR __thread" >>confdefs.h +fi fi fi else @@ -9617,6 +9983,45 @@ fi done + for ac_func in poll +do : + ac_fn_cxx_check_func "$LINENO" "poll" "ac_cv_func_poll" +if test "x$ac_cv_func_poll" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_POLL 1 +_ACEOF + $as_echo "#define LOG4CPLUS_HAVE_POLL 1" >>confdefs.h + +fi +done + + + for ac_func in pipe +do : + ac_fn_cxx_check_func "$LINENO" "pipe" "ac_cv_func_pipe" +if test "x$ac_cv_func_pipe" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_PIPE 1 +_ACEOF + $as_echo "#define LOG4CPLUS_HAVE_PIPE 1" >>confdefs.h + +fi +done + + + for ac_func in pipe2 +do : + ac_fn_cxx_check_func "$LINENO" "pipe2" "ac_cv_func_pipe2" +if test "x$ac_cv_func_pipe2" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_PIPE2 1 +_ACEOF + $as_echo "#define LOG4CPLUS_HAVE_PIPE2 1" >>confdefs.h + +fi +done + + for ac_func in ftime do : ac_fn_cxx_check_func "$LINENO" "ftime" "ac_cv_func_ftime" @@ -9747,6 +10152,19 @@ fi done + for ac_func in shutdown +do : + ac_fn_cxx_check_func "$LINENO" "shutdown" "ac_cv_func_shutdown" +if test "x$ac_cv_func_shutdown" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SHUTDOWN 1 +_ACEOF + $as_echo "#define LOG4CPLUS_HAVE_SHUTDOWN 1" >>confdefs.h + +fi +done + + for ac_func in mbstowcs do : ac_fn_cxx_check_func "$LINENO" "mbstowcs" "ac_cv_func_mbstowcs" @@ -9868,14 +10286,27 @@ fi done - for ac_func in _vsnprintf + for ac_func in vsnwprintf do : - ac_fn_cxx_check_func "$LINENO" "_vsnprintf" "ac_cv_func__vsnprintf" -if test "x$ac_cv_func__vsnprintf" = xyes; then : + ac_fn_cxx_check_func "$LINENO" "vsnwprintf" "ac_cv_func_vsnwprintf" +if test "x$ac_cv_func_vsnwprintf" = xyes; then : cat >>confdefs.h <<_ACEOF -#define HAVE__VSNPRINTF 1 +#define HAVE_VSNWPRINTF 1 _ACEOF - $as_echo "#define LOG4CPLUS_HAVE__VSNPRINTF 1" >>confdefs.h + $as_echo "#define LOG4CPLUS_HAVE_VSNWPRINTF 1" >>confdefs.h + +fi +done + + + for ac_func in _vsnwprintf +do : + ac_fn_cxx_check_func "$LINENO" "_vsnwprintf" "ac_cv_func__vsnwprintf" +if test "x$ac_cv_func__vsnwprintf" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE__VSNWPRINTF 1 +_ACEOF + $as_echo "#define LOG4CPLUS_HAVE__VSNWPRINTF 1" >>confdefs.h fi done @@ -21129,6 +21560,14 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${ENABLE_VERSION_INFO_OPTION_TRUE}" && test -z "${ENABLE_VERSION_INFO_OPTION_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_VERSION_INFO_OPTION\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${ENABLE_RELEASE_OPTION_TRUE}" && test -z "${ENABLE_RELEASE_OPTION_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_RELEASE_OPTION\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -21538,7 +21977,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by log4cplus $as_me 1.1.0, which was +This file was extended by log4cplus $as_me 1.1.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21604,7 +22043,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -log4cplus config.status 1.1.0 +log4cplus config.status 1.1.3 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 3fd7c1c2c..b22ec6149 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ dnl Process this file with autoconf to produce a configure script. dnl This version of log4cplus requires the follwing autotools versions: dnl autoconf-2.69 -dnl automake-1.12 +dnl automake-1.12.6 dnl libtool-2.4.2 -AC_INIT([log4cplus],[1.1.0]) +AC_INIT([log4cplus],[1.1.3]) AC_CANONICAL_TARGET AC_CONFIG_SRCDIR([src/logger.cxx]) AC_CONFIG_MACRO_DIR([m4]) @@ -18,7 +18,7 @@ AM_PROG_AR # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=5:0:0 +LT_VERSION=11:5:2 LT_RELEASE=1.1 AC_SUBST([LT_VERSION]) AC_SUBST([LT_RELEASE]) @@ -75,7 +75,7 @@ dnl Debugging or release build? AC_ARG_ENABLE([debugging], [AS_HELP_STRING([--enable-debugging], [Turns off optimization and adds switches that generate debugging - information.])], + information. [default=no]])], [LOG4CPLUS_CHECK_YESNO([${enableval}], [--enable-debugging])], [enable_debugging=no]) @@ -99,10 +99,40 @@ dnl Turn warnings on/off? AC_ARG_ENABLE([warnings], [AC_HELP_STRING([--enable-warnings], - [Use compiler warnings option, e.g. -Wall. Enabled by default.])], + [Use compiler warnings option, e.g. -Wall. [default=yes]])], [LOG4CPLUS_CHECK_YESNO([${enableval}], [--enable-warnings])], [enable_warnings=yes]) +dnl Enable SO version. + +AC_ARG_ENABLE([so-version], + [AC_HELP_STRING([--enable-so-version], + [Use libtool -version-info option. [default=yes]])], + [LOG4CPLUS_CHECK_YESNO([${enableval}], [--enable-so-version])], + [enable_so_version=yes]) +AM_CONDITIONAL([ENABLE_VERSION_INFO_OPTION], + [test "x$enable_so_version" = "xyes"]) + +dnl Enable release version. + +AC_ARG_ENABLE([release-version], + [AC_HELP_STRING([--enable-release-version], + [Use libtool -release option. [default=yes]])], + [LOG4CPLUS_CHECK_YESNO([${enableval}], [--enable-release-version])], + [enable_release_version=yes]) +AM_CONDITIONAL([ENABLE_RELEASE_OPTION], + [test "x$enable_release_version" = "xyes"]) + +dnl Enable use of symbol visibility options. + +AC_ARG_ENABLE([symbols-visibility-options], + [AC_HELP_STRING([--enable-symbols-visibility-options], + [Use platform and compiler specific symbols visibility options, + where they are available. [default=yes]])], + [LOG4CPLUS_CHECK_YESNO([${enableval}], + [--enable-symbols-visibility-options])], + [enable_symbols_visibility_options=yes]) + dnl Check for c/c++ compilers. AC_PROG_CXX @@ -146,9 +176,14 @@ AS_IF([test "x$enable_warnings" = "xyes"], [sun], [], [AX_CXXFLAGS_WARN_ALL])]) +LOG4CPLUS_AIX_XLC_LDFLAGS= AS_CASE([$ax_cv_cxx_compiler_vendor], + [ibm], + [AS_VAR_APPEND([CXXFLAGS], [" -qroconst"]) + AS_VAR_APPEND([LOG4CPLUS_AIX_XLC_LDFLAGS], [" -qmkshrobj=-300"])], [gnu|clang], - [AS_IF([test "x$enable_warnings" = "xyes"], + [AX_CXXFLAGS_GCC_OPTION([-fdiagnostics-show-caret]) + AS_IF([test "x$enable_warnings" = "xyes"], [AX_CXXFLAGS_GCC_OPTION([-Wextra]) dnl The -ansi switch sets __STRICT_ANSI__ which disables some dnl useful function declarations in MinGW and Cygwin headers. @@ -178,12 +213,17 @@ AS_CASE([$ax_cv_cxx_compiler_vendor], AS_IF([test "x$enable_debugging" = "xyes"], [AX_CXXFLAGS_GCC_OPTION([-g3]) - AX_CXXFLAGS_GCC_OPTION([-fkeep-inline-functions]) - AX_CXXFLAGS_GCC_OPTION([-fstack-check]) - AX_CXXFLAGS_GCC_OPTION([-fstack-protector]) + dnl AX_CXXFLAGS_GCC_OPTION([-fkeep-inline-functions]) + AS_CASE(["$target_os"], + dnl Disable these for MinGW32 as it seems to generate DLLs that + dnl segfault in DllMain(). + [mingw32], [], + [AX_CXXFLAGS_GCC_OPTION([-fstack-check]) + AX_CXXFLAGS_GCC_OPTION([-fstack-protector])]) dnl -Wstack-protector results into not too interesting warnings. dnl AX_CXXFLAGS_GCC_OPTION([-Wstack-protector]) - AX_CXXFLAGS_GCC_OPTION([-ftrapv])], + AX_CXXFLAGS_GCC_OPTION([-ftrapv]) + AX_CXXFLAGS_GCC_OPTION([-ftrack-macro-expansion])], [AC_REQUIRE([AC_PROG_GREP]) AS_IF([AS_ECHO_N(["$CXXFLAGS"]) dnl | $GREP -e ['\(^\|[[:space:]]\)-O\([^[:space:]]*\([[:space:]]\|$\)\)'] >/dev/null], @@ -247,17 +287,24 @@ AS_CASE([$ax_cv_cxx_compiler_vendor], dnl Adding -library=Crun is always necessary. AX_CXXFLAGS_SUN_OPTION([-library=Crun])]) +AC_SUBST([LOG4CPLUS_AIX_XLC_LDFLAGS]) -AX_DECLSPEC([LOG4CPLUS_DECLSPEC]) -AS_IF([test "x$ac_cv_declspec" = "xyes" dnl - || test "x$ac_cv__attribute__visibility" = "xyes" dnl - || test "x$ac_cv__global" = "xyes"], - [AS_CASE([$ax_cv_cxx_compiler_vendor], - [gnu|clang], - [AX_CXXFLAGS_GCC_OPTION([-fvisibility=hidden])], +AS_IF([test "x$enable_symbols_visibility_options" = "xyes"], + [AX_DECLSPEC([LOG4CPLUS_DECLSPEC]) + AS_IF([test "x$ac_cv_declspec" = "xyes" dnl + || test "x$ac_cv__attribute__visibility" = "xyes" dnl + || test "x$ac_cv__global" = "xyes"], + [AS_CASE([$ax_cv_cxx_compiler_vendor], + [gnu|clang], + [AX_CXXFLAGS_GCC_OPTION([-fvisibility=hidden])], + + dnl Adding -Bhidden or -Bhidden_def to CXXFLAGS causes configure + dnl tests to fail because main() becomes hidden. + dnl[hp], + dnl[AS_VAR_APPEND([CXXFLAGS], [" -Bhidden -Wl,-a"])], - [sun], - [AX_CXXFLAGS_SUN_OPTION([-xldscope=hidden])])]) + [sun], + [AX_CXXFLAGS_SUN_OPTION([-xldscope=hidden])])])]) AX_C99_VARIADIC_MACROS AH_TEMPLATE([LOG4CPLUS_HAVE_C99_VARIADIC_MACROS]) @@ -284,6 +331,20 @@ AH_TEMPLATE([LOG4CPLUS_HAVE_FUNC_SYMBOL]) AS_IF([test "x$ac_cv_have___func___symbol" = "xyes"], [AC_DEFINE([LOG4CPLUS_HAVE_FUNC_SYMBOL])]) +AX_GCC_FUNC_ATTRIBUTE([constructor_priority]) +AH_TEMPLATE([LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY]) +AS_IF([test "x$ax_cv_have_func_attribute_constructor_priority" = "xyes"], + [AC_DEFINE([LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY])]) + +AX_GCC_FUNC_ATTRIBUTE([constructor]) +AH_TEMPLATE([LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR]) +AS_IF([test "x$ax_cv_have_func_attribute_constructor" = "xyes"], + [AC_DEFINE([LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR])]) + +AX_GCC_VAR_ATTRIBUTE([init_priority]) +AH_TEMPLATE([LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY]) +AS_IF([test "x$ax_cv_have_var_attribute_init_priority" = "xyes"], + [AC_DEFINE([LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY])]) dnl Checks for libraries. @@ -294,8 +355,8 @@ AC_SEARCH_LIBS([clock_gettime], [rt posix4]) dnl On some systems libcompat exists only as a static library which dnl breaks compilation of shared library log4cplus. dnl AC_SEARCH_LIBS([ftime], [compat]) -AC_SEARCH_LIBS([gethostbyname], [nsl]) -AC_SEARCH_LIBS([setsockopt], [socket]) +AC_SEARCH_LIBS([gethostbyname], [nsl network net]) +AC_SEARCH_LIBS([setsockopt], [socket network net]) AS_IF([test "x$with_iconv" = "xyes"], [AC_SEARCH_LIBS([iconv_open], [iconv], [], [AC_SEARCH_LIBS([libiconv_open], [iconv])])]) @@ -333,6 +394,7 @@ LOG4CPLUS_CHECK_HEADER([wchar.h], [LOG4CPLUS_HAVE_WCHAR_H]) LOG4CPLUS_CHECK_HEADER([time.h], [LOG4CPLUS_HAVE_TIME_H]) LOG4CPLUS_CHECK_HEADER([errno.h], [LOG4CPLUS_HAVE_ERRNO_H]) LOG4CPLUS_CHECK_HEADER([limits.h], [LOG4CPLUS_HAVE_LIMITS_H]) +LOG4CPLUS_CHECK_HEADER([poll.h], [LOG4CPLUS_HAVE_POLL_H]) AS_IF([test "x$with_iconv" = "xyes"], [LOG4CPLUS_CHECK_HEADER([iconv.h], [LOG4CPLUS_HAVE_ICONV_H])]) @@ -389,15 +451,25 @@ dnl Multi threaded library. AS_IF([test "x$ac_cv_cxx11_atomics" = "xyes"], [AC_DEFINE([LOG4CPLUS_HAVE_CXX11_ATOMICS])]) - AX_TLS_SUPPORT + dnl Check if TLS is supported, but only if it isn't iOS target, because it + dnl is forbidden by Apple Store to use __tlv_* functions. Also, Cygwin + dnl passes the compilation and link test here but fails during linking of + dnl the real code, so we want to avoid it too. See GCC PR64697. + AS_IF([test \( "$target_os" != "darwin" -o "$target_cpu" != "arm" \) \ + -a "$target_os" != "cygwin"], + [AX_TLS_SUPPORT]) + AH_TEMPLATE([LOG4CPLUS_HAVE_TLS_SUPPORT]) AH_TEMPLATE([LOG4CPLUS_THREAD_LOCAL_VAR]) - AS_IF([test "x$ac_cv_declspec_thread" = "xyes"], + AS_IF([test "x$ac_cv_thread_local" = "xyes"], [AC_DEFINE([LOG4CPLUS_HAVE_TLS_SUPPORT]) - AC_DEFINE([LOG4CPLUS_THREAD_LOCAL_VAR], [__declspec(thread)])], - [AS_IF([test "x$ac_cv__thread_keyword" = "xyes"], - [AC_DEFINE([LOG4CPLUS_HAVE_TLS_SUPPORT]) - AC_DEFINE([LOG4CPLUS_THREAD_LOCAL_VAR], [__thread])])])], + AC_DEFINE([LOG4CPLUS_THREAD_LOCAL_VAR], [thread_local])], + [AS_IF([test "x$ac_cv_declspec_thread" = "xyes"], + [AC_DEFINE([LOG4CPLUS_HAVE_TLS_SUPPORT]) + AC_DEFINE([LOG4CPLUS_THREAD_LOCAL_VAR], [__declspec(thread)])], + [AS_IF([test "x$ac_cv__thread_keyword" = "xyes"], + [AC_DEFINE([LOG4CPLUS_HAVE_TLS_SUPPORT]) + AC_DEFINE([LOG4CPLUS_THREAD_LOCAL_VAR], [__thread])])])])], dnl Single threaded library. [AC_MSG_NOTICE([Creating a single-threaded library]) @@ -418,6 +490,9 @@ LOG4CPLUS_CHECK_FUNCS([nanosleep], [LOG4CPLUS_HAVE_NANOSLEEP]) LOG4CPLUS_CHECK_FUNCS([clock_nanosleep], [LOG4CPLUS_HAVE_CLOCK_NANOSLEEP]) LOG4CPLUS_CHECK_FUNCS([clock_gettime], [LOG4CPLUS_HAVE_CLOCK_GETTIME]) LOG4CPLUS_CHECK_FUNCS([getpid], [LOG4CPLUS_HAVE_GETPID]) +LOG4CPLUS_CHECK_FUNCS([poll], [LOG4CPLUS_HAVE_POLL]) +LOG4CPLUS_CHECK_FUNCS([pipe], [LOG4CPLUS_HAVE_PIPE]) +LOG4CPLUS_CHECK_FUNCS([pipe2], [LOG4CPLUS_HAVE_PIPE2]) LOG4CPLUS_CHECK_FUNCS([ftime], [LOG4CPLUS_HAVE_FTIME]) LOG4CPLUS_CHECK_FUNCS([stat], [LOG4CPLUS_HAVE_STAT]) LOG4CPLUS_CHECK_FUNCS([lstat], [LOG4CPLUS_HAVE_LSTAT]) @@ -428,6 +503,7 @@ LOG4CPLUS_CHECK_FUNCS([htons], [LOG4CPLUS_HAVE_HTONS]) LOG4CPLUS_CHECK_FUNCS([ntohs], [LOG4CPLUS_HAVE_NTOHS]) LOG4CPLUS_CHECK_FUNCS([htonl], [LOG4CPLUS_HAVE_HTONL]) LOG4CPLUS_CHECK_FUNCS([ntohl], [LOG4CPLUS_HAVE_NTOHL]) +LOG4CPLUS_CHECK_FUNCS([shutdown], [LOG4CPLUS_HAVE_SHUTDOWN]) LOG4CPLUS_CHECK_FUNCS([mbstowcs], [LOG4CPLUS_HAVE_MBSTOWCS]) LOG4CPLUS_CHECK_FUNCS([wcstombs], [LOG4CPLUS_HAVE_WCSTOMBS]) AS_IF([test "x$with_iconv" = "xyes"], @@ -441,7 +517,8 @@ AS_IF([test "x$with_iconv" = "xyes"], dnl Various functions used by snprintf.cxx. LOG4CPLUS_CHECK_FUNCS([vsnprintf], [LOG4CPLUS_HAVE_VSNPRINTF]) -LOG4CPLUS_CHECK_FUNCS([_vsnprintf], [LOG4CPLUS_HAVE__VSNPRINTF]) +LOG4CPLUS_CHECK_FUNCS([vsnwprintf], [LOG4CPLUS_HAVE_VSNWPRINTF]) +LOG4CPLUS_CHECK_FUNCS([_vsnwprintf], [LOG4CPLUS_HAVE__VSNWPRINTF]) LOG4CPLUS_CHECK_FUNCS([vsprintf_s], [LOG4CPLUS_HAVE_VSPRINTF_S]) LOG4CPLUS_CHECK_FUNCS([vswprintf_s], [LOG4CPLUS_HAVE_VSWPRINTF_S]) LOG4CPLUS_CHECK_FUNCS([vfprintf_s], [LOG4CPLUS_HAVE_VFPRINTF_S]) diff --git a/cygport/log4cplus-1.1.0-rc8-1.cygport b/cygport/log4cplus.cygport similarity index 74% rename from cygport/log4cplus-1.1.0-rc8-1.cygport rename to cygport/log4cplus.cygport index 3ae5aa275..4d70fab05 100644 --- a/cygport/log4cplus-1.1.0-rc8-1.cygport +++ b/cygport/log4cplus.cygport @@ -1,3 +1,6 @@ +NAME=log4cplus +VERSION=1.1.3-rc1 +RELEASE=1 CATEGORY="Libs" SUMMARY="C++ logging library" DESCRIPTION="log4cplus is a simple to use C++ logging API providing thread-safe, @@ -9,12 +12,12 @@ SRC_URI="mirror://sourceforge/log4cplus/log4cplus-stable/${PV%-rc*}/${P}.tar.xz" PATCH_URI="configure.ac-relax-libtool-version.patch configure.ac-disable-__thread-keyword.patch" -PKG_NAMES="lib${PN}1.1_4 lib${PN}qt4debugappender1.1_4 +PKG_NAMES="lib${PN}1.1_9 lib${PN}qt4debugappender1.1_9 lib${PN}-devel lib${PN}qt4debugappender-devel" -liblog4cplus1_1_4_SUMMARY="${SUMMARY} (runtime)" -liblog4cplus1_1_4_CONTENTS="usr/bin/cyglog4cplus-1-1-4.dll" -liblog4cplusqt4debugappender1_1_4_SUMMARY="${SUMMARY} (Qt4 runtime)" -liblog4cplusqt4debugappender1_1_4_CONTENTS="usr/bin/cyglog4cplusqt4*-1-1-4.dll" +liblog4cplus1_1_9_SUMMARY="${SUMMARY} (runtime)" +liblog4cplus1_1_9_CONTENTS="usr/bin/cyglog4cplus-1-1-9.dll" +liblog4cplusqt4debugappender1_1_9_SUMMARY="${SUMMARY} (Qt4 runtime)" +liblog4cplusqt4debugappender1_1_9_CONTENTS="usr/bin/cyglog4cplusqt4*-1-1-9.dll" liblog4cplus_devel_SUMMARY="${SUMMARY} (development)" liblog4cplus_devel_CONTENTS="--exclude=*qt4* usr/include/ usr/lib/ usr/share/doc/" liblog4cplusqt4debugappender_devel_SUMMARY="${SUMMARY} (Qt4 development)" diff --git a/depcomp b/depcomp index debb6ffa3..e1f51f482 100755 --- a/depcomp +++ b/depcomp @@ -1,7 +1,7 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2012-03-27.16; # UTC +scriptversion=2012-07-12.20; # UTC # Copyright (C) 1999-2012 Free Software Foundation, Inc. @@ -74,6 +74,9 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" +# Avoid interferences from the environment. +gccflag= dashmflag= + # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case @@ -108,7 +111,7 @@ if test "$depmode" = msvc7msys; then fi if test "$depmode" = xlc; then - # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations. + # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi @@ -142,13 +145,17 @@ gcc3) ;; gcc) +## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. +## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. +## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). +## -MM, not -M (despite what the docs say). Also, it might not be +## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then @@ -334,6 +341,79 @@ icc) rm -f "$tmpdepfile" ;; +## The order of this option in the case statement is important, since the +## shell code in configure will try each of these formats in the order +## listed in this file. A plain '-MD' option would be understood by many +## compilers, so we must ensure this comes after the gcc and icc options. +pgcc) + # Portland's C compiler understands '-MD'. + # Will always output deps to 'file.d' where file is the root name of the + # source file under compilation, even if file resides in a subdirectory. + # The object file name does not affect the name of the '.d' file. + # pgcc 10.2 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using '\' : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + # Use the source, not the object, to determine the base name, since + # that's sadly what pgcc will do too. + base=`echo "$source" | sed -e 's|^.*/||' -e 's/\.[-_a-zA-Z0-9]*$//'` + tmpdepfile="$base.d" + + # For projects that build the same source file twice into different object + # files, the pgcc approach of using the *source* file root name can cause + # problems in parallel builds. Use a locking strategy to avoid stomping on + # the same $tmpdepfile. + lockdir="$base.d-lock" + trap "echo '$0: caught signal, cleaning up...' >&2; rm -rf $lockdir" 1 2 13 15 + numtries=100 + i=$numtries + while test $i -gt 0 ; do + # mkdir is a portable test-and-set. + if mkdir $lockdir 2>/dev/null; then + # This process acquired the lock. + "$@" -MD + stat=$? + # Release the lock. + rm -rf $lockdir + break + else + ## the lock is being held by a different process, + ## wait until the winning process is done or we timeout + while test -d $lockdir && test $i -gt 0; do + sleep 1 + i=`expr $i - 1` + done + fi + i=`expr $i - 1` + done + trap - 1 2 13 15 + if test $i -le 0; then + echo "$0: failed to acquire lock after $numtries attempts" >&2 + echo "$0: check lockdir '$lockdir'" >&2 + exit 1 + fi + + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option diff --git a/docs/doxygen.config b/docs/doxygen.config index 7fb3753a9..b49512c51 100644 --- a/docs/doxygen.config +++ b/docs/doxygen.config @@ -32,7 +32,7 @@ PROJECT_NAME = log4cplus # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.1.0 +PROJECT_NUMBER = 1.1.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer @@ -52,7 +52,7 @@ PROJECT_LOGO = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = log4cplus-1.1.0/docs +OUTPUT_DIRECTORY = log4cplus-1.1.3/docs # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output diff --git a/docs/release.txt b/docs/release.txt index f186ba93a..a0c422fa4 100644 --- a/docs/release.txt +++ b/docs/release.txt @@ -4,7 +4,7 @@ This describes the release procedure: 2. Tag revision on branch. - 3. Run scripts/prepare_dist_from_bzr.sh to prepare tarballs. + 3. Run scripts/prepare_dist_from_git.sh to prepare tarballs. 4. Upload tarballs to SourceForge. @@ -14,4 +14,6 @@ This describes the release procedure: 6. Add news entry to log4cplus.sf.net web page. - 7. Add release entry to freecode.net. + 7. Post release information to G+ log4cplus group. + + 8. Add release entry to freecode.net. diff --git a/docs/webpage_doxygen.config b/docs/webpage_doxygen.config index 934784e8c..88ea32b2a 100644 --- a/docs/webpage_doxygen.config +++ b/docs/webpage_doxygen.config @@ -1,4 +1,4 @@ -# Doxyfile 1.7.6.1 +# Doxyfile 1.8.3.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -32,7 +32,7 @@ PROJECT_NAME = log4cplus # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.1.0 +PROJECT_NUMBER = 1.1.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer @@ -52,7 +52,7 @@ PROJECT_LOGO = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = webpage_docs-1.1.0 +OUTPUT_DIRECTORY = webpage_docs-1.1.3 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -126,7 +126,9 @@ FULL_PATH_NAMES = NO # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the -# path to strip. +# path to strip. Note that you specify absolute paths here, but also +# relative paths, which will be relative from the directory where doxygen is +# started. STRIP_FROM_PATH = @@ -229,17 +231,34 @@ OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions -# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, +# and language is one of the parsers supported by doxygen: IDL, Java, +# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, +# C++. For instance to make doxygen treat .inc files as Fortran files (default +# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note +# that for custom extensions you also need to set FILE_PATTERNS otherwise the +# files are not read by doxygen. EXTENSION_MAPPING = +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented classes, +# or namespaces to their corresponding documentation. Such a link can be +# prevented in individual cases by by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. + +AUTOLINK_SUPPORT = YES + # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and @@ -260,10 +279,10 @@ CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES (the +# default) will make doxygen replace the get and set methods by a property in +# the documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. @@ -353,6 +372,11 @@ EXTRACT_ALL = YES EXTRACT_PRIVATE = NO +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. @@ -520,7 +544,8 @@ GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. +# documentation sections, marked by \if section-label ... \endif +# and \cond section-label ... \endcond blocks. ENABLED_SECTIONS = @@ -540,12 +565,6 @@ MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. @@ -571,7 +590,7 @@ FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file +# output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. @@ -584,7 +603,8 @@ LAYOUT_FILE = # requires the bibtex tool to be installed. See also # http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. +# feature you need bibtex and perl available in the search path. Do not use +# file names with spaces, bibtex cannot handle them. CITE_BIB_FILES = @@ -766,6 +786,13 @@ FILTER_SOURCE_FILES = NO FILTER_SOURCE_PATTERNS = +# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page (index.html). +# This can be useful if you have a project on for instance GitHub and want reuse +# the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- @@ -784,7 +811,7 @@ INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. +# fragments. Normal C, C++ and Fortran comments will always remain visible. STRIP_CODE_COMMENTS = YES @@ -887,13 +914,23 @@ HTML_FOOTER = webpage_footer.html # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# style sheet in the HTML output directory as well, or it will be erased! +# fine-tune the look of the HTML output. If left blank doxygen will +# generate a default style sheet. Note that it is recommended to use +# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this +# tag will in the future become obsolete. HTML_STYLESHEET = doxygen.css +# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional +# user-defined cascading style sheet that is included after the standard +# style sheets created by doxygen. Using this option one can overrule +# certain style aspects. This is preferred over using HTML_STYLESHEET +# since it does not replace the standard style sheet and is therefor more +# robust against future updates. Doxygen will copy the style sheet file to +# the output directory. + +HTML_EXTRA_STYLESHEET = + # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the @@ -934,20 +971,23 @@ HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = YES -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). +# page has loaded. HTML_DYNAMIC_SECTIONS = NO +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). @@ -975,9 +1015,9 @@ DOCSET_FEEDNAME = "Doxygen generated docs" DOCSET_BUNDLE_ID = org.doxygen.Project -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely +# identify the documentation publisher. This should be a reverse domain-name +# style string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher @@ -1126,11 +1166,6 @@ GENERATE_TREEVIEW = NO ENUM_VALUES_PER_LINE = 4 -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. @@ -1162,19 +1197,27 @@ FORMULA_TRANSPARENT = YES # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you also need to install MathJax separately and +# output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO +# When MathJax is enabled you can set the default output format to be used for +# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and +# SVG. The default value is HTML-CSS, which is slower, but has the best +# compatibility. + +MATHJAX_FORMAT = HTML-CSS + # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the -# mathjax.org site, so you can quickly see the result without installing -# MathJax, but it is strongly recommended to install a local copy of MathJax -# before deployment. +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. +# However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. MATHJAX_RELPATH = http://www.mathjax.org/mathjax @@ -1194,15 +1237,55 @@ MATHJAX_EXTENSIONS = SEARCHENGINE = NO # When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup -# and does not have live searching capabilities. +# implemented using a web server instead of a web client using Javascript. +# There are two flavours of web server based search depending on the +# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for +# searching and an index file used by the script. When EXTERNAL_SEARCH is +# enabled the indexing and searching needs to be provided by external tools. +# See the manual for details. SERVER_BASED_SEARCH = NO +# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP +# script for searching. Instead the search results are written to an XML file +# which needs to be processed by an external indexer. Doxygen will invoke an +# external search engine pointed to by the SEARCHENGINE_URL option to obtain +# the search results. Doxygen ships with an example indexer (doxyindexer) and +# search engine (doxysearch.cgi) which are based on the open source search engine +# library Xapian. See the manual for configuration details. + +EXTERNAL_SEARCH = NO + +# The SEARCHENGINE_URL should point to a search engine hosted by a web server +# which will returned the search results when EXTERNAL_SEARCH is enabled. +# Doxygen ships with an example search engine (doxysearch) which is based on +# the open source search engine library Xapian. See the manual for configuration +# details. + +SEARCHENGINE_URL = + +# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed +# search data is written to a file for indexing by an external tool. With the +# SEARCHDATA_FILE tag the name of this file can be specified. + +SEARCHDATA_FILE = searchdata.xml + +# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the +# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is +# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple +# projects and redirect the results back to the right project. + +EXTERNAL_SEARCH_ID = + +# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen +# projects other than the one defined by this configuration file, but that are +# all added to the same external search index. Each project needs to have a +# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id +# of to a relative location where the documentation can be found. +# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... + +EXTRA_SEARCH_MAPPINGS = + #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- @@ -1524,22 +1607,18 @@ SKIP_FUNCTION_MACROS = YES # Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. TAGFILES = @@ -1652,6 +1731,15 @@ GROUP_GRAPHS = YES UML_LOOK = NO +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. @@ -1692,7 +1780,7 @@ CALLER_GRAPH = NO GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. diff --git a/iOS/ConfigureChecks.cmake b/iOS/ConfigureChecks.cmake new file mode 100644 index 000000000..196fff021 --- /dev/null +++ b/iOS/ConfigureChecks.cmake @@ -0,0 +1,160 @@ +include(CheckIncludeFiles) +include(CheckFunctionExists) +include(CheckLibraryExists) +include(CheckSymbolExists) +include(CheckTypeSize) +include(CheckCSourceCompiles) +include(CheckCXXSourceCompiles) + +#check_include_files(dlfcn.h HAVE_DLFCN_H ) + +set(LOG4CPLUS_HAVE_ERRNO_H 1) +set(LOG4CPLUS_HAVE_ICONV_H 1) +set(LOG4CPLUS_HAVE_LIMITS_H 1) +set(LOG4CPLUS_HAVE_SYS_TYPES_H 1) +set(LOG4CPLUS_HAVE_SYS_SOCKET_H 1) +set(LOG4CPLUS_HAVE_SYS_SYSCALL_H 1) +set(LOG4CPLUS_HAVE_SYS_TIME_H 1) +set(LOG4CPLUS_HAVE_SYS_TIMEB_H 1) +set(LOG4CPLUS_HAVE_SYS_STAT_H 1) +set(LOG4CPLUS_HAVE_SYS_FILE_H 1) +set(LOG4CPLUS_HAVE_SYSLOG_H 1) +set(LOG4CPLUS_HAVE_ARPA_INET_H 1) +set(LOG4CPLUS_HAVE_NETINET_IN_H 1) +set(LOG4CPLUS_HAVE_NETINET_TCP_H 1) +set(LOG4CPLUS_HAVE_NETDB_H 1) +set(LOG4CPLUS_HAVE_UNISTD_H 1) +set(LOG4CPLUS_HAVE_FCNTL_H 1) +set(LOG4CPLUS_HAVE_STDIO_H 1) +set(LOG4CPLUS_HAVE_STDARG_H 1) +set(LOG4CPLUS_HAVE_STDLIB_H 1) +set(LOG4CPLUS_HAVE_TIME_H 1) +set(LOG4CPLUS_HAVE_WCHAR_H 1) +set(LOG4CPLUS_HAVE_POLL_H 1) + + +# set(HAVE_INTTYPES_H 1) +# set(HAVE_MEMORY_H 1) +# set(HAVE_STDINT_H 1) +# set(HAVE_STRINGS_H 1) +# set(HAVE_STRING_H 1) + + +#check_include_files("stdlib.h;stdio.h;stdarg.h;string.h;float.h" STDC_HEADERS ) + +find_library(LIBADVAPI32 advapi32) +find_library(LIBKERNEL32 kernel32) +find_library(LIBNSL nsl) +find_library(LIBRT rt) +find_library(LIBICONV iconv) +find_library(LIBPOSIX4 posix4) +find_library(LIBCPOSIX cposix) +find_library(LIBSOCKET socket) +find_library(LIBWS2_32 ws2_32) + +set(LOG4CPLUS_HAVE_GMTIME_R 1) +set(LOG4CPLUS_HAVE_LOCALTIME_R 1) +set(LOG4CPLUS_HAVE_GETTIMEOFDAY 1) +set(LOG4CPLUS_HAVE_GETPID 1) +set(LOG4CPLUS_HAVE_POLL 1) +set(LOG4CPLUS_HAVE_PIPE 1) +#set(LOG4CPLUS_HAVE_PIPE2 ) +set(LOG4CPLUS_HAVE_FTIME 1) +set(LOG4CPLUS_HAVE_STAT 1) +set(LOG4CPLUS_HAVE_LSTAT 1) +set(LOG4CPLUS_HAVE_FCNTL 1) +set(LOG4CPLUS_HAVE_FLOCK 1) +set(LOG4CPLUS_HAVE_LOCKF 1) +set(LOG4CPLUS_HAVE_HTONS 1) +set(LOG4CPLUS_HAVE_NTOHS 1) +set(LOG4CPLUS_HAVE_HTONL 1) +set(LOG4CPLUS_HAVE_NTOHL 1) +set(LOG4CPLUS_HAVE_SHUTDOWN 1) +set(LOG4CPLUS_HAVE_VSNPRINTF 1) +#set(LOG4CPLUS_HAVE__VSNPRINTF ) +#set(LOG4CPLUS_HAVE_VSPRINTF_S ) +#set(LOG4CPLUS_HAVE_VSWPRINTF_S ) +#set(LOG4CPLUS_HAVE_VFPRINTF_S ) +#set(LOG4CPLUS_HAVE_VFWPRINTF_S ) +#set(LOG4CPLUS_HAVE__VSNPRINTF_S ) +#set(LOG4CPLUS_HAVE__VSNWPRINTF_S ) +set(LOG4CPLUS_HAVE_MBSTOWCS 1) +set(LOG4CPLUS_HAVE_WCSTOMBS 1) + + +set(LOG4CPLUS_HAVE_ENAMETOOLONG 1) +set(LOG4CPLUS_HAVE_GETTID 1) +set(LOG4CPLUS_HAVE_FUNCTION_MACRO 1) +set(LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO 1) +set(LOG4CPLUS_HAVE_FUNC_SYMBOL 1) + +set(LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH 1) +set(LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH 1) + +set(LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS 1) +set(LOG4CPLUS_HAVE_C99_VARIADIC_MACROS 1) + +#set(LOG4CPLUS_HAVE_CLOCK_GETTIME ) +#set(LOG4CPLUS_HAVE_CLOCK_NANOSLEEP ) +set(LOG4CPLUS_HAVE_NANOSLEEP 1) + +#set(LOG4CPLUS_HAVE_ICONV_OPEN ) +#set(LOG4CPLUS_HAVE_ICONV_CLOSE ) +#set(LOG4CPLUS_HAVE_ICONV ) + +#set(LOG4CPLUS_HAVE_GETHOSTBYNAME_R) +set(LOG4CPLUS_HAVE_GETADDRINFO 1) + + +set(LOG4CPLUS_DECLSPEC_EXPORT "__attribute__ ((visibility(\"default\")))" ) +set(LOG4CPLUS_DECLSPEC_IMPORT "__attribute__ ((visibility(\"default\")))" ) +set(LOG4CPLUS_DECLSPEC_PRIVATE "__attribute__ ((visibility(\"hidden\")))" ) + +set(LOG4CPLUS_HAVE_TLS_SUPPORT 1) +set(LOG4CPLUS_THREAD_LOCAL_VAR "__thread") + +#set(LOG4CPLUS_HAVE_CXX11_ATOMICS ) + +#set(socklen_t) + +set(HAVE_STDLIB_H ${LOG4CPLUS_HAVE_STDLIB_H} ) +set(HAVE_SYS_STAT_H ${LOG4CPLUS_HAVE_SYS_STAT_H} ) +set(HAVE_SYS_TYPES_H ${LOG4CPLUS_HAVE_SYS_TYPES_H} ) +set(HAVE_SYS_FILE_H ${LOG4CPLUS_HAVE_SYS_FILE_H} ) +set(HAVE_UNISTD_H ${LOG4CPLUS_HAVE_UNISTD_H} ) + + +set(HAVE_FTIME ${LOG4CPLUS_HAVE_FTIME} ) +set(HAVE_GETPID ${LOG4CPLUS_HAVE_GETPID} ) +set(HAVE_GETTIMEOFDAY ${LOG4CPLUS_HAVE_GETTIMEOFDAY} ) +set(HAVE_GETADDRINFO ${LOG4CPLUS_HAVE_GETADDRINFO} ) +set(HAVE_GETHOSTBYNAME_R ${LOG4CPLUS_HAVE_GETHOSTBYNAME_R} ) +set(HAVE_GMTIME_R ${LOG4CPLUS_HAVE_GMTIME_R} ) +set(HAVE_HTONL ${LOG4CPLUS_HAVE_HTONL} ) +set(HAVE_HTONS ${LOG4CPLUS_HAVE_HTONS} ) +set(HAVE_ICONV_OPEN ${LOG4CPLUS_HAVE_ICONV_OPEN} ) +set(HAVE_ICONV_CLOSE ${LOG4CPLUS_HAVE_ICONV_CLOSE} ) +set(HAVE_ICONV ${LOG4CPLUS_HAVE_ICONV} ) +set(HAVE_LSTAT ${LOG4CPLUS_HAVE_LSTAT} ) +set(HAVE_FCNTL ${LOG4CPLUS_HAVE_FCNTL} ) +set(HAVE_LOCKF ${LOG4CPLUS_HAVE_LOCKF} ) +set(HAVE_FLOCK ${LOG4CPLUS_HAVE_FLOCK} ) +set(HAVE_LOCALTIME_R ${LOG4CPLUS_HAVE_LOCALTIME_R} ) +set(HAVE_NTOHL ${LOG4CPLUS_HAVE_NTOHL} ) +set(HAVE_NTOHS ${LOG4CPLUS_HAVE_NTOHS} ) +set(HAVE_STAT ${LOG4CPLUS_HAVE_STAT} ) + +set(HAVE_VFPRINTF_S ${LOG4CPLUS_HAVE_VFPRINTF_S} ) +set(HAVE_VFWPRINTF_S ${LOG4CPLUS_HAVE_VFWPRINTF_S} ) +set(HAVE_VSNPRINTF ${LOG4CPLUS_HAVE_VSNPRINTF} ) +set(HAVE_VSPRINTF_S ${LOG4CPLUS_HAVE_VSPRINTF_S} ) +set(HAVE_VSWPRINTF_S ${LOG4CPLUS_HAVE_VSWPRINTF_S} ) +set(HAVE__VSNPRINTF ${LOG4CPLUS_HAVE__VSNPRINTF} ) +set(HAVE__VSNPRINTF_S ${LOG4CPLUS_HAVE__VSNPRINTF_S} ) +set(HAVE__VSNWPRINTF_S ${LOG4CPLUS_HAVE__VSNWPRINTF_S} ) + +set(HAVE_FUNCTION_MACRO ${LOG4CPLUS_HAVE_FUNCTION_MACRO} ) +set(HAVE_PRETTY_FUNCTION_MACRO ${LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO} ) + +set(HAVE___SYNC_ADD_AND_FETCH ${LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH} ) +set(HAVE___SYNC_SUB_AND_FETCH ${LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH} ) diff --git a/iOS/README.txt b/iOS/README.txt new file mode 100644 index 000000000..528b9b74e --- /dev/null +++ b/iOS/README.txt @@ -0,0 +1,13 @@ +NOTE: log4cplus build for iOS is based on iOS.cmake toolchain file, + orininally taken from https://code.google.com/p/ios-cmake/ + +To build the library for iOS, being in current folder, perform the steps below: +For armv7 architecture: +$ ./scripts/cmake_ios_armv7.sh +$ cmake --build ./build_armv7 --config "Release" +$ cmake --build ./build_armv7 --config "Debug" + +For i386 architecture: +$ ./scripts/cmake_ios_i386.sh +$ cmake --build ./build_i386 --config "Release" +$ cmake --build ./build_i386 --config "Debug" diff --git a/iOS/iOS.cmake b/iOS/iOS.cmake new file mode 100644 index 000000000..df2e3faca --- /dev/null +++ b/iOS/iOS.cmake @@ -0,0 +1,193 @@ +# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake +# files which are included with CMake 2.8.4 +# It has been altered for iOS development + +# Options: +# +# IOS_PLATFORM = OS (default) or SIMULATOR +# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders +# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch. +# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch. +# +# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder +# By default this location is automatcially chosen based on the IOS_PLATFORM value above. +# If set manually, it will override the default location and force the user of a particular Developer Platform +# +# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder +# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value. +# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path. +# If set manually, this will force the use of a specific SDK version + +# Macros: +# +# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE) +# A convenience macro for setting xcode specific properties on targets +# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1") +# +# find_host_package (PROGRAM ARGS) +# A macro used to find executable programs on the host system, not within the iOS environment. +# Thanks to the android-cmake project for providing the command + +# Standard settings +set (CMAKE_SYSTEM_NAME Darwin) +set (CMAKE_SYSTEM_VERSION 1) +set (UNIX True) +set (APPLE True) +set (IOS True) + +# Required as of cmake 2.8.10 +set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE) + +# Determine the cmake host system version so we know where to find the iOS SDKs +find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin) +if (CMAKE_UNAME) + exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) + string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}") +endif (CMAKE_UNAME) + +# Force the compilers to gcc for iOS +include (CMakeForceCompiler) +CMAKE_FORCE_C_COMPILER (/usr/bin/clang Apple) +CMAKE_FORCE_CXX_COMPILER (/usr/bin/clang++ Apple) +set(CMAKE_AR ar CACHE FILEPATH "" FORCE) + +# Skip the platform compiler checks for cross compiling +set (CMAKE_CXX_COMPILER_WORKS TRUE) +set (CMAKE_C_COMPILER_WORKS TRUE) + +# All iOS/Darwin specific settings - some may be redundant +set (CMAKE_SHARED_LIBRARY_PREFIX "lib") +set (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") +set (CMAKE_SHARED_MODULE_PREFIX "lib") +set (CMAKE_SHARED_MODULE_SUFFIX ".so") +set (CMAKE_MODULE_EXISTS 1) +set (CMAKE_DL_LIBS "") + +set (CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") +set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") +set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") +set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") + +# Hidden visibilty is required for cxx on iOS +set (CMAKE_C_FLAGS_INIT "") +set (CMAKE_CXX_FLAGS_INIT "-fvisibility=hidden -fvisibility-inlines-hidden -isysroot ${CMAKE_OSX_SYSROOT}") + +set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") +set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}") + +set (CMAKE_PLATFORM_HAS_INSTALLNAME 1) +set (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names") +set (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names") +set (CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") +set (CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") +set (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a") + +# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree +# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache +# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun) +# hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex +if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL) + find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool) +endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL) + +# Setup iOS platform unless specified manually with IOS_PLATFORM +if (NOT DEFINED IOS_PLATFORM) + set (IOS_PLATFORM "OS") +endif (NOT DEFINED IOS_PLATFORM) +set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform") + +# Check the platform selection and setup for developer root +if (${IOS_PLATFORM} STREQUAL "OS") + set (IOS_PLATFORM_LOCATION "iPhoneOS.platform") + + # This causes the installers to properly locate the output libraries + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos") +elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR") + set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform") + + # This causes the installers to properly locate the output libraries + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator") +else (${IOS_PLATFORM} STREQUAL "OS") + message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR") +endif (${IOS_PLATFORM} STREQUAL "OS") + +# Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT +# Note Xcode 4.3 changed the installation location, choose the most recent one available +set (XCODE_POST_43_ROOT "/Applications/Xcode.app/Contents/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer") +set (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer") +if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) + if (EXISTS ${XCODE_POST_43_ROOT}) + set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT}) + elseif(EXISTS ${XCODE_PRE_43_ROOT}) + set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT}) + endif (EXISTS ${XCODE_POST_43_ROOT}) +endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) +set (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform") + +# Find and use the most recent iOS sdk unless specified manually with CMAKE_IOS_SDK_ROOT +if (NOT DEFINED CMAKE_IOS_SDK_ROOT) + file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*") + if (_CMAKE_IOS_SDKS) + list (SORT _CMAKE_IOS_SDKS) + list (REVERSE _CMAKE_IOS_SDKS) + list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT) + else (_CMAKE_IOS_SDKS) + message (FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.") + endif (_CMAKE_IOS_SDKS) + message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}") +endif (NOT DEFINED CMAKE_IOS_SDK_ROOT) +set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK") + +# Set the sysroot default to the most recent SDK +set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support") + +# set the architecture for iOS +# NOTE: Currently both ARCHS_STANDARD_32_BIT and ARCHS_UNIVERSAL_IPHONE_OS set armv7 only, so set both manually +if (${IOS_PLATFORM} STREQUAL "OS") + set (IOS_ARCH armv6 armv7) +else (${IOS_PLATFORM} STREQUAL "OS") + set (IOS_ARCH i386) +endif (${IOS_PLATFORM} STREQUAL "OS") + +set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string "Build architecture for iOS") + +# Set the find root to the iOS developer roots and to user defined paths +set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root") + +# default to searching for frameworks first +set (CMAKE_FIND_FRAMEWORK FIRST) + +# set up the default search directories for frameworks +set (CMAKE_SYSTEM_FRAMEWORK_PATH + ${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks + ${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks + ${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks +) + +# only search the iOS sdks, not the remainder of the host filesystem +set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + + +# This little macro lets you set any XCode specific property +macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) + set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE}) +endmacro (set_xcode_property) + + +# This macro lets you find executable programs on the host system +macro (find_host_package) + set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) + set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) + set (IOS FALSE) + + find_package(${ARGN}) + + set (IOS TRUE) + set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) + set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endmacro (find_host_package) + diff --git a/iOS/scripts/cmake_ios_armv7.sh b/iOS/scripts/cmake_ios_armv7.sh new file mode 100755 index 000000000..0bee3392e --- /dev/null +++ b/iOS/scripts/cmake_ios_armv7.sh @@ -0,0 +1,18 @@ +#!/bin/sh +scripts_dir=`cd $(dirname $0);pwd` +cd $scripts_dir/.. + +mkdir -p build_armv7 +cd build_armv7 + +cmake -G "Xcode" -DBUILD_SHARED_LIBS="FALSE" \ + -DCMAKE_TOOLCHAIN_FILE=$scripts_dir/../iOS.cmake \ + -DLOG4CPLUS_SINGLE_THREADED="TRUE" \ + -DLOG4CPLUS_BUILD_TESTING="OFF" \ + -DLOG4CPLUS_QT4="OFF" \ + -DLOG4CPLUS_BUILD_LOGGINGSERVER="OFF" \ + -DLOG4CPLUS_CONFIGURE_CHECKS_PATH=$scripts_dir/../ConfigureChecks.cmake \ + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=$scripts_dir/../build_armv7/Binaries \ + $@ \ + $scripts_dir/../.. + diff --git a/iOS/scripts/cmake_ios_i386.sh b/iOS/scripts/cmake_ios_i386.sh new file mode 100755 index 000000000..31fee0197 --- /dev/null +++ b/iOS/scripts/cmake_ios_i386.sh @@ -0,0 +1,19 @@ +#!/bin/sh +scripts_dir=`cd $(dirname $0);pwd` +cd $scripts_dir/.. + +mkdir -p build_i386 +cd build_i386 + +cmake -G "Xcode" -DBUILD_SHARED_LIBS="FALSE" \ + -DIOS_PLATFORM="SIMULATOR" \ + -DCMAKE_TOOLCHAIN_FILE=$scripts_dir/../iOS.cmake \ + -DLOG4CPLUS_SINGLE_THREADED="TRUE" \ + -DLOG4CPLUS_BUILD_TESTING="OFF" \ + -DLOG4CPLUS_QT4="OFF" \ + -DLOG4CPLUS_BUILD_LOGGINGSERVER="OFF" \ + -DLOG4CPLUS_CONFIGURE_CHECKS_PATH=$scripts_dir/../ConfigureChecks.cmake \ + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=$scripts_dir/../build_i386/Binaries \ + $@ \ + $scripts_dir/../.. + diff --git a/include/Makefile.in b/include/Makefile.in index 460e75823..a78f1554c 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -74,7 +74,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -162,6 +165,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/include/log4cplus/appender.h b/include/log4cplus/appender.h index 5c8041653..5eca94c77 100644 --- a/include/log4cplus/appender.h +++ b/include/log4cplus/appender.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -86,6 +86,25 @@ namespace log4cplus { * *

Properties

*
+ * + *
layout
+ *
This property specifies message layout used by + * Appender. + * \sa Layout + *
+ * + *
filters
+ *
This property specifies possibly multiple filters used by + * Appender. Each of multple filters and its properties is under a + * numbered subkey of filters key. E.g.: + * filters.1=log4cplus::spi::LogLevelMatchFilter. Filter + * subkey numbers must be consecutive.
+ * + *
Threshold
+ *
This property specifies log level threshold. Events with + * lower log level than the threshold will not be logged by + * appender.
+ * *
UseLockFile
*
Set this property to true if you want your output * through this appender to be synchronized between multiple @@ -118,6 +137,14 @@ namespace log4cplus { // Dtor virtual ~Appender(); + /** + * This function is for derived appenders to call from their + * destructors. All classes derived from `Appender` class + * _must_ call this function from their destructors. It + * ensures that appenders will get properly closed during + * shutdown by call to `close()` function before they are + * destroyed. + */ void destructorImpl(); // Methods @@ -129,6 +156,11 @@ namespace log4cplus { */ virtual void close() = 0; + /** + * Check if this appender is in closed state. + */ + bool isClosed() const; + /** * This method performs threshold checks and invokes filters before * delegating actual logging to the subclasses specific {@link diff --git a/include/log4cplus/asyncappender.h b/include/log4cplus/asyncappender.h index 641f98843..af9d5e536 100644 --- a/include/log4cplus/asyncappender.h +++ b/include/log4cplus/asyncappender.h @@ -5,7 +5,7 @@ // Author: Vaclav Haisman // // -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/boost/deviceappender.hxx b/include/log4cplus/boost/deviceappender.hxx index b1caba742..e31fc7902 100644 --- a/include/log4cplus/boost/deviceappender.hxx +++ b/include/log4cplus/boost/deviceappender.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/clfsappender.h b/include/log4cplus/clfsappender.h index 29c1d8fa5..ca46b69c2 100644 --- a/include/log4cplus/clfsappender.h +++ b/include/log4cplus/clfsappender.h @@ -5,7 +5,7 @@ // Author: Vaclav Zeman // // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/clogger.h b/include/log4cplus/clogger.h index aa2eb88d1..a340d1bec 100644 --- a/include/log4cplus/clogger.h +++ b/include/log4cplus/clogger.h @@ -6,7 +6,7 @@ * Author: Jens Rehsack * * - * Copyright 2011 Jens Rehsack & Tad E. Smith + * Copyright 2011-2013 Jens Rehsack & Tad E. Smith * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/log4cplus/config.h.in b/include/log4cplus/config.h.in index 8a703c5fe..f2d8819f0 100644 --- a/include/log4cplus/config.h.in +++ b/include/log4cplus/config.h.in @@ -33,6 +33,13 @@ /* Define to 1 if you have the `ftime' function. */ #undef HAVE_FTIME +/* Define to 1 if the system has the `constructor' function attribute */ +#undef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR + +/* Define to 1 if the system has the `constructor_priority' function attribute + */ +#undef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY + /* */ #undef HAVE_GETADDRINFO @@ -108,12 +115,24 @@ /* Define to 1 if you have the `ntohs' function. */ #undef HAVE_NTOHS +/* Define to 1 if you have the `pipe' function. */ +#undef HAVE_PIPE + +/* Define to 1 if you have the `pipe2' function. */ +#undef HAVE_PIPE2 + +/* Define to 1 if you have the `poll' function. */ +#undef HAVE_POLL + /* Define if you have POSIX threads libraries and header files. */ #undef HAVE_PTHREAD /* Have PTHREAD_PRIO_INHERIT. */ #undef HAVE_PTHREAD_PRIO_INHERIT +/* Define to 1 if you have the `shutdown' function. */ +#undef HAVE_SHUTDOWN + /* Define to 1 if you have the `stat' function. */ #undef HAVE_STAT @@ -142,6 +161,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if the system has the `init_priority' variable attribute */ +#undef HAVE_VAR_ATTRIBUTE_INIT_PRIORITY + /* Define to 1 if you have the `vfprintf_s' function. */ #undef HAVE_VFPRINTF_S @@ -151,6 +173,9 @@ /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF +/* Define to 1 if you have the `vsnwprintf' function. */ +#undef HAVE_VSNWPRINTF + /* Define to 1 if you have the `vsprintf_s' function. */ #undef HAVE_VSPRINTF_S @@ -160,12 +185,12 @@ /* Define to 1 if you have the `wcstombs' function. */ #undef HAVE_WCSTOMBS -/* Define to 1 if you have the `_vsnprintf' function. */ -#undef HAVE__VSNPRINTF - /* Define to 1 if you have the `_vsnprintf_s' function. */ #undef HAVE__VSNPRINTF_S +/* Define to 1 if you have the `_vsnwprintf' function. */ +#undef HAVE__VSNWPRINTF + /* Define to 1 if you have the `_vsnwprintf_s' function. */ #undef HAVE__VSNWPRINTF_S @@ -235,6 +260,12 @@ /* */ #undef LOG4CPLUS_HAVE_FUNCTION_MACRO +/* */ +#undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR + +/* */ +#undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY + /* */ #undef LOG4CPLUS_HAVE_FUNC_SYMBOL @@ -310,9 +341,24 @@ /* */ #undef LOG4CPLUS_HAVE_NTOHS +/* */ +#undef LOG4CPLUS_HAVE_PIPE + +/* */ +#undef LOG4CPLUS_HAVE_PIPE2 + +/* */ +#undef LOG4CPLUS_HAVE_POLL + +/* */ +#undef LOG4CPLUS_HAVE_POLL_H + /* */ #undef LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO +/* */ +#undef LOG4CPLUS_HAVE_SHUTDOWN + /* */ #undef LOG4CPLUS_HAVE_STAT @@ -358,6 +404,9 @@ /* */ #undef LOG4CPLUS_HAVE_UNISTD_H +/* */ +#undef LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY + /* */ #undef LOG4CPLUS_HAVE_VFPRINTF_S @@ -367,6 +416,9 @@ /* */ #undef LOG4CPLUS_HAVE_VSNPRINTF +/* */ +#undef LOG4CPLUS_HAVE_VSNWPRINTF + /* */ #undef LOG4CPLUS_HAVE_VSPRINTF_S @@ -380,10 +432,10 @@ #undef LOG4CPLUS_HAVE_WCSTOMBS /* */ -#undef LOG4CPLUS_HAVE__VSNPRINTF +#undef LOG4CPLUS_HAVE__VSNPRINTF_S /* */ -#undef LOG4CPLUS_HAVE__VSNPRINTF_S +#undef LOG4CPLUS_HAVE__VSNWPRINTF /* */ #undef LOG4CPLUS_HAVE__VSNWPRINTF_S diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index fb5a30f33..c1331c8bd 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -99,7 +99,8 @@ #endif #if (defined (_MSC_VER) && _MSC_VER >= 1600) \ - || defined (__GXX_EXPERIMENTAL_CXX0X__) + || defined (__GXX_EXPERIMENTAL_CXX0X__) \ + || __cplusplus >= 201103L # define LOG4CPLUS_HAVE_CXX11_SUPPORT #endif @@ -108,6 +109,14 @@ # define LOG4CPLUS_HAVE_RVALUE_REFS #endif +#if defined (LOG4CPLUS_HAVE_CXX11_SUPPORT) \ + && (__has_feature(cxx_noexcept) \ + || (defined (_MSC_VER) && _MSC_VER >= 1900)) +# define LOG4CPLUS_NOEXCEPT_FALSE noexcept(false) +#else +# define LOG4CPLUS_NOEXCEPT_FALSE /* empty */ +#endif + #if ! defined (UNICODE) && defined (__GNUC__) && __GNUC__ >= 3 # define LOG4CPLUS_FORMAT_ATTRIBUTE(archetype, format_index, first_arg_index) \ __attribute__ ((format (archetype, format_index, first_arg_index))) @@ -119,10 +128,14 @@ #if defined (__GNUC__) && __GNUC__ >= 3 # define LOG4CPLUS_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) # define LOG4CPLUS_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# define LOG4CPLUS_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) __builtin_expect ((exp), (c)) #else -# define LOG4CPLUS_ATTRIBUTE_NORETURN /* empty */ +# if ! defined (LOG4CPLUS_ATTRIBUTE_NORETURN) +# define LOG4CPLUS_ATTRIBUTE_NORETURN /* empty */ +# endif # define LOG4CPLUS_ATTRIBUTE_PURE /* empty */ +# define LOG4CPLUS_ATTRIBUTE_DEPRECATED /* empty */ # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) (exp) #endif @@ -130,6 +143,7 @@ #define LOG4CPLUS_UNLIKELY(cond) LOG4CPLUS_BUILTIN_EXPECT(!! (cond), 0) #if defined (_MSC_VER) \ + || (defined (__BORLANDC__) && __BORLANDC__ >= 0x0650) \ || (defined (__COMO__) && __COMO_VERSION__ >= 400) /* ??? */ \ || (defined (__DMC__) && __DMC__ >= 0x700) /* ??? */ \ || (defined (__clang__) && __clang_major__ >= 3) \ @@ -139,6 +153,25 @@ # pragma once #endif +#if defined (LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY) +# define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) \ + __attribute__ ((__constructor__ ((prio)))) +#elif defined (LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR) +# define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) \ + __attribute__ ((__constructor__)) +#else +# define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) /* empty */ +#endif + +#if defined (LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY) +# define LOG4CPLUS_INIT_PRIORITY(prio) \ + __attribute__ ((__init_priority__ ((prio)))) +#else +# define LOG4CPLUS_INIT_PRIORITY(prio) /* empty */ +#endif + +#define LOG4CPLUS_INIT_PRIORITY_BASE (65535 / 2) + #include #if defined(__cplusplus) @@ -152,6 +185,9 @@ namespace log4cplus //! automatically by other means. LOG4CPLUS_EXPORT void threadCleanup (); +//! Initializes log4cplus. +LOG4CPLUS_EXPORT void initialize (); + } // namespace log4cplus #endif diff --git a/include/log4cplus/config/defines.hxx.cmake.in b/include/log4cplus/config/defines.hxx.cmake.in deleted file mode 100644 index 697ac33dd..000000000 --- a/include/log4cplus/config/defines.hxx.cmake.in +++ /dev/null @@ -1,236 +0,0 @@ -#ifndef LOG4CPLUS_CONFIG_DEFINES_HXX -#define LOG4CPLUS_CONFIG_DEFINES_HXX - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYSLOG_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_ARPA_INET_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_NETINET_IN_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_NETINET_TCP_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_TIMEB_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_TIME_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_TYPES_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_STAT_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_SYSCALL_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_FILE_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_TIME_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_SOCKET_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_NETDB_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_UNISTD_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_FCNTL_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_STDARG_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_STDIO_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_STDLIB_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_ERRNO_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_WCHAR_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_ICONV_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_LIMITS_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_FTIME 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_GETADDRINFO 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_GETHOSTBYNAME_R 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_GETPID 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_GETTIMEOFDAY 1 - -/* Define to 1 if you have the `clock_gettime' function. */ -#cmakedefine LOG4CPLUS_HAVE_CLOCK_GETTIME 1 - -/* Define to 1 if you have the `nanosleep' function. */ -#cmakedefine LOG4CPLUS_HAVE_NANOSLEEP 1 - -/* Define to 1 if you have the `clock_nanosleep' function. */ -#cmakedefine LOG4CPLUS_HAVE_CLOCK_NANOSLEEP 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_GMTIME_R 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_HTONL 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_HTONS 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_LOCALTIME_R 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_LSTAT 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_FCNTL 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_LOCKF 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_FLOCK 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_NTOHL 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_NTOHS 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_STAT 1 - -/* Define if this is a single-threaded library. */ -#undef LOG4CPLUS_SINGLE_THREADED - -/* */ -#undef LOG4CPLUS_USE_PTHREADS - -/* Define for compilers/standard libraries that support more than just the "C" - locale. */ -#cmakedefine LOG4CPLUS_WORKING_LOCALE 1 - -/* Define for C99 compilers/standard libraries that support more than just the - "C" locale. */ -#cmakedefine LOG4CPLUS_WORKING_C_LOCALE 1 - -/* Define to int if undefined. */ -#cmakedefine socklen_t int - -/* Defined for --enable-debugging builds. */ -/* this is not used anywhere #undef LOG4CPLUS_DEBUGGING */ - -/* Defined if the compiler understands __declspec(export) or __attribute__((export)) construct. */ -#cmakedefine LOG4CPLUS_DECLSPEC_EXPORT @LOG4CPLUS_DECLSPEC_EXPORT@ - -/* Defined if the compiler understands __declspec(import) or __attribute__((import)) construct. */ -#cmakedefine LOG4CPLUS_DECLSPEC_IMPORT @LOG4CPLUS_DECLSPEC_IMPORT@ /**/ - -/* Defined if the compiler understands - __attribute__((visibility("hidden"))) construct. */ -#cmakedefine LOG4CPLUS_DECLSPEC_PRIVATE @LOG4CPLUS_DECLSPEC_PRIVATE@ - -/* */ -#cmakedefine LOG4CPLUS_HAVE_TLS_SUPPORT 1 - -/* */ -#cmakedefine LOG4CPLUS_THREAD_LOCAL_VAR @LOG4CPLUS_THREAD_LOCAL_VAR@ - -/* Defined if the host OS provides ENAMETOOLONG errno value. */ -#cmakedefine LOG4CPLUS_HAVE_ENAMETOOLONG 1 - -/* Defined if the compiler provides __sync_add_and_fetch(). */ -#cmakedefine LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH 1 - -/* Defined if the compiler provides __sync_sub_and_fetch(). */ -#cmakedefine LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH 1 - -/* Defined if the compiler provides C++11 header and increment, - decrement operations. */ -#cmakedefine LOG4CPLUS_HAVE_CXX11_ATOMICS 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_C99_VARIADIC_MACROS 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_VSNPRINTF 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE__VSNPRINTF 1 - -/* Define to 1 if you have the `vfprintf_s' function. */ -#cmakedefine LOG4CPLUS_HAVE_VFPRINTF_S 1 - -/* Define to 1 if you have the `vfwprintf_s' function. */ -#cmakedefine LOG4CPLUS_HAVE_VFWPRINTF_S 1 - -/* Define to 1 if you have the `vsprintf_s' function. */ -#cmakedefine LOG4CPLUS_HAVE_VSPRINTF_S 1 - -/* Define to 1 if you have the `vswprintf_s' function. */ -#cmakedefine LOG4CPLUS_HAVE_VSWPRINTF_S 1 - -/* Define to 1 if you have the `_vsnprintf_s' function. */ -#cmakedefine LOG4CPLUS_HAVE__VSNPRINTF_S 1 - -/* Define to 1 if you have the `_vsnwprintf_s' function. */ -#cmakedefine LOG4CPLUS_HAVE__VSNWPRINTF_S 1 - -/* Defined if the compiler supports __FUNCTION__ macro. */ -#cmakedefine LOG4CPLUS_HAVE_FUNCTION_MACRO 1 - -/* Defined if the compiler supports __PRETTY_FUNCTION__ macro. */ -#cmakedefine LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO 1 - -/* Defined if the compiler supports __func__ symbol. */ -#cmakedefine LOG4CPLUS_HAVE_FUNC_SYMBOL 1 - -/* Define to 1 if you have the `mbstowcs' function. */ -#cmakedefine LOG4CPLUS_HAVE_MBSTOWCS 1 - -/* Define to 1 if you have the `wcstombs' function. */ -#cmakedefine LOG4CPLUS_HAVE_WCSTOMBS 1 - -/* Define to 1 if you have Linux style syscall(SYS_gettid). */ -#cmakedefine LOG4CPLUS_HAVE_GETTID 1 - -/* Define when iconv() is available. */ -#cmakedefine LOG4CPLUS_WITH_ICONV 1 - -/* Define to 1 if you have the `iconv' function. */ -#cmakedefine LOG4CPLUS_HAVE_ICONV 1 - -/* Define to 1 if you have the `iconv_close' function. */ -#cmakedefine LOG4CPLUS_HAVE_ICONV_CLOSE 1 - -/* Define to 1 if you have the `iconv_open' function. */ -#cmakedefine LOG4CPLUS_HAVE_ICONV_OPEN 1 - -#endif // LOG4CPLUS_CONFIG_DEFINES_HXX diff --git a/include/log4cplus/config/defines.hxx.in b/include/log4cplus/config/defines.hxx.in index 53142895a..b87b4a484 100644 --- a/include/log4cplus/config/defines.hxx.in +++ b/include/log4cplus/config/defines.hxx.in @@ -121,6 +121,21 @@ /* */ #undef LOG4CPLUS_HAVE_NTOHS +/* Define to 1 if you have the `shutdown' function. */ +#undef LOG4CPLUS_HAVE_SHUTDOWN + +/* */ +#undef LOG4CPLUS_HAVE_PIPE + +/* */ +#undef LOG4CPLUS_HAVE_PIPE2 + +/* */ +#undef LOG4CPLUS_HAVE_POLL + +/* */ +#undef LOG4CPLUS_HAVE_POLL_H + /* */ #undef LOG4CPLUS_HAVE_STAT @@ -184,6 +199,12 @@ /* */ #undef LOG4CPLUS_HAVE_VSNPRINTF +/* Define to 1 if you have the `vsnwprintf' function. */ +#undef LOG4CPLUS_HAVE_VSNWPRINTF + +/* Define to 1 if you have the `_vsnwprintf' function. */ +#undef LOG4CPLUS_HAVE__VSNWPRINTF + /* */ #undef LOG4CPLUS_HAVE__VSNPRINTF @@ -235,4 +256,14 @@ /* Define to 1 if you have the `iconv_open' function. */ #undef LOG4CPLUS_HAVE_ICONV_OPEN +/* Define to 1 if the system has the `constructor' function attribute + with priority */ +#undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY + +/* Define to 1 if the system has the `constructor' function attribute */ +#undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR + +/* Define to 1 if the system has the `init_priority' variable attribute */ +#undef LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY + #endif // LOG4CPLUS_CONFIG_DEFINES_HXX diff --git a/include/log4cplus/config/macosx.h b/include/log4cplus/config/macosx.h index 2e3065cdc..448090c71 100644 --- a/include/log4cplus/config/macosx.h +++ b/include/log4cplus/config/macosx.h @@ -5,7 +5,7 @@ // Author: Christopher R. Bailey // // -// Copyright 2003-2010 Christopher R. Bailey +// Copyright 2003-2013 Christopher R. Bailey // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index a9c65ee29..2ade3b914 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -28,9 +28,14 @@ #pragma once #endif +#if defined (__MINGW32__) || defined (__MINGW64__) +# include <_mingw.h> +#endif + #ifdef _WIN32 -#if (defined (_MSC_VER) && _MSC_VER >= 1400) || defined (__MINGW32__) +#if (defined (_MSC_VER) && _MSC_VER > 1400) \ + || (defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 3) # define LOG4CPLUS_HAVE_INTRIN_H #endif @@ -67,8 +72,14 @@ // MSVC has both and so does MinGW. #define LOG4CPLUS_HAVE_VSNPRINTF #define LOG4CPLUS_HAVE__VSNPRINTF - -#if defined (_MSC_VER) || defined (__MINGW32__) +#define LOG4CPLUS_HAVE__VSNWPRINTF + +// Limit the use of foo_s() functions to builds using Visual Studio +// 2005 and its run time library. In MinGW land, limit the foo_s() +// functions to MinGw-w64 toolchain and __MSVCRT_VERSION__ >= 0x0900. +#if (defined (_MSC_VER) && _MSC_VER >= 1400) \ + || (defined (__MSVCRT_VERSION__) && __MSVCRT_VERSION__ >= 0x0900 \ + && defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 2) // MS secure versions of vprintf(). # define LOG4CPLUS_HAVE_VSPRINTF_S # define LOG4CPLUS_HAVE_VSWPRINTF_S @@ -81,8 +92,17 @@ # define LOG4CPLUS_HAVE_VSNPRINTF_S # define LOG4CPLUS_HAVE__VSNPRINTF_S # define LOG4CPLUS_HAVE__VSNWPRINTF_S + +// MS printf-like functions supporting positional parameters. +# define LOG4CPLUS_HAVE__VSPRINTF_P +# define LOG4CPLUS_HAVE__VSWPRINTF_P + +// MS secure version of _tsopen(). +# define LOG4CPLUS_HAVE__TSOPEN_S #endif +#define LOG4CPLUS_HAVE__TSOPEN + #define LOG4CPLUS_DLLMAIN_HINSTANCE HINSTANCE #define LOG4CPLUS_HAVE_NT_EVENT_LOG @@ -135,27 +155,56 @@ # define LOG4CPLUS_HAVE_FUNCTION_MACRO # define LOG4CPLUS_HAVE_FUNCSIG_MACRO # define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS +# define LOG4CPLUS_ATTRIBUTE_NORETURN __declspec(noreturn) +# endif +# if _MSC_VER >= 1700 +# define LOG4CPLUS_HAVE_CXX11_ATOMICS # endif #endif #if defined (__GNUC__) # undef LOG4CPLUS_INLINES_ARE_EXPORTED +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +# define LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO +# define LOG4CPLUS_HAVE_FUNC_SYMBOL +# endif # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) -# define LOG4CPLUS_INLINES_ARE_EXPORTED -# define LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH -# define LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH +# if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) +# define LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH +# define LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH +# endif +# endif +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) +# if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) +# define LOG4CPLUS_HAVE___ATOMIC_ADD_FETCH +# define LOG4CPLUS_HAVE___ATOMIC_SUB_FETCH +# endif +// This has worked for some versions of MinGW with GCC 4.7+ but it +// appears to be broken again in 4.8.x. Thus, we disable this for GCC +// completely forever. +// +//# define LOG4CPLUS_INLINES_ARE_EXPORTED # endif # define LOG4CPLUS_HAVE_FUNCTION_MACRO # define LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS # define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS -# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# define LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO -# endif # if defined (__MINGW32__) # define LOG4CPLUS_WORKING_C_LOCALE # endif #endif +#if defined (__BORLANDC__) && __BORLANDC__ >= 0x0650 +# define LOG4CPLUS_HAVE_FUNCTION_MACRO +# define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS +#endif // __BORLANDC__ + +#if ! defined (LOG4CPLUS_DISABLE_DLL_RUNTIME_WARNING) +# if defined (LOG4CPLUS_STATIC) && defined (_MSC_VER) && ! defined (_DLL) +# pragma message("You are not using DLL C run time library. " \ + "You must call log4cplus::initialize() once before " \ + "you use any other log4cplus API.") +# endif +#endif #endif // _WIN32 #endif // LOG4CPLUS_CONFIG_WIN32_HEADER_ diff --git a/include/log4cplus/config/windowsh-inc.h b/include/log4cplus/config/windowsh-inc.h index 86dc8647d..b71a8e105 100644 --- a/include/log4cplus/config/windowsh-inc.h +++ b/include/log4cplus/config/windowsh-inc.h @@ -5,7 +5,7 @@ // Author: Vaclav Zeman // // -// Copyright (C) 2010-2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/configurator.h b/include/log4cplus/configurator.h index 20f4ccb6c..5cbb96f11 100644 --- a/include/log4cplus/configurator.h +++ b/include/log4cplus/configurator.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -46,18 +46,23 @@ namespace log4cplus /** * Provides configuration from an external file. See configure() for * the expected format. - * + * * All option values admit variable substitution. For * example, if userhome environment property is set to * /home/xyz and the File option is set to the string * ${userhome}/test.log, then File option will be * interpreted as the string /home/xyz/test.log. - * + * * The syntax of variable substitution is similar to that of UNIX * shells. The string between an opening "${" and * closing "}" is interpreted as a key. Its value is * searched in the environment properties. The corresponding value replaces * the ${variableName} sequence. + * + * Configuration files also recognize include + * file.properties directive that allow composing + * configuration from multiple files. There is no cyclic includes + * detection mechanism to stop unbound recursion. */ class LOG4CPLUS_EXPORT PropertyConfigurator { diff --git a/include/log4cplus/consoleappender.h b/include/log4cplus/consoleappender.h index 404512b43..e31bdad5b 100644 --- a/include/log4cplus/consoleappender.h +++ b/include/log4cplus/consoleappender.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2009 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/fileappender.h b/include/log4cplus/fileappender.h index b1a7e209b..787b92ea8 100644 --- a/include/log4cplus/fileappender.h +++ b/include/log4cplus/fileappender.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/fstreams.h b/include/log4cplus/fstreams.h index 99e3a6602..d0c0831d5 100644 --- a/include/log4cplus/fstreams.h +++ b/include/log4cplus/fstreams.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2011 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/appenderattachableimpl.h b/include/log4cplus/helpers/appenderattachableimpl.h index 1f13ea831..4cfaf3f21 100644 --- a/include/log4cplus/helpers/appenderattachableimpl.h +++ b/include/log4cplus/helpers/appenderattachableimpl.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/fileinfo.h b/include/log4cplus/helpers/fileinfo.h index 7daa25d55..725c940d8 100644 --- a/include/log4cplus/helpers/fileinfo.h +++ b/include/log4cplus/helpers/fileinfo.h @@ -1,6 +1,6 @@ // -*- C++ -*- // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/helpers/lockfile.h b/include/log4cplus/helpers/lockfile.h index c2775e909..f451ff82b 100644 --- a/include/log4cplus/helpers/lockfile.h +++ b/include/log4cplus/helpers/lockfile.h @@ -1,6 +1,6 @@ // -*- C++ -*- // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/helpers/loglog.h b/include/log4cplus/helpers/loglog.h index 3c7a7bc75..336f18fda 100644 --- a/include/log4cplus/helpers/loglog.h +++ b/include/log4cplus/helpers/loglog.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/logloguser.h b/include/log4cplus/helpers/logloguser.h index e8a3ddbf8..11b3f5ed0 100644 --- a/include/log4cplus/helpers/logloguser.h +++ b/include/log4cplus/helpers/logloguser.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/pointer.h b/include/log4cplus/helpers/pointer.h index 20d44d424..0b1b6febb 100644 --- a/include/log4cplus/helpers/pointer.h +++ b/include/log4cplus/helpers/pointer.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/property.h b/include/log4cplus/helpers/property.h index d418801c9..e97c6d4c5 100644 --- a/include/log4cplus/helpers/property.h +++ b/include/log4cplus/helpers/property.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2002-2010 Tad E. Smith +// Copyright 2002-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ namespace log4cplus { namespace helpers { + //! \sa log4cplus::PropertyConfigurator class LOG4CPLUS_EXPORT Properties { public: enum PFlags @@ -141,6 +142,7 @@ namespace log4cplus { // Data StringMap data; + unsigned flags; private: template diff --git a/include/log4cplus/helpers/queue.h b/include/log4cplus/helpers/queue.h index 2ebd13c3e..eefaf2f0e 100644 --- a/include/log4cplus/helpers/queue.h +++ b/include/log4cplus/helpers/queue.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/helpers/sleep.h b/include/log4cplus/helpers/sleep.h index 36d45592c..f3c56363e 100644 --- a/include/log4cplus/helpers/sleep.h +++ b/include/log4cplus/helpers/sleep.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/snprintf.h b/include/log4cplus/helpers/snprintf.h index be8bd8159..f0dc9490c 100644 --- a/include/log4cplus/helpers/snprintf.h +++ b/include/log4cplus/helpers/snprintf.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010-2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -46,8 +46,9 @@ class LOG4CPLUS_EXPORT snprintf_buf tchar const * print (tchar const * fmt, ...) LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 2, 3); - tchar const * print_va_list (tchar const * fmt, std::va_list) - LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 2, 0); + + int print_va_list (tchar const * & str, tchar const * fmt, std::va_list) + LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 0); private: std::vector buf; diff --git a/include/log4cplus/helpers/socket.h b/include/log4cplus/helpers/socket.h index e0bc9b4f4..b73c7e016 100644 --- a/include/log4cplus/helpers/socket.h +++ b/include/log4cplus/helpers/socket.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -41,9 +41,10 @@ namespace log4cplus { not_opened, bad_address, connection_failed, - broken_pipe, + broken_pipe, invalid_access_mode, - message_truncated + message_truncated, + accept_interrupted }; typedef std::ptrdiff_t SOCKET_TYPE; @@ -62,7 +63,7 @@ namespace log4cplus { /// Close socket virtual void close(); virtual bool isOpen() const; - + virtual void shutdown(); AbstractSocket& operator=(const AbstractSocket& rhs); protected: @@ -110,6 +111,10 @@ namespace log4cplus { virtual ~ServerSocket(); Socket accept(); + void interruptAccept (); + + protected: + std::ptrdiff_t interruptHandles[2]; }; @@ -119,6 +124,7 @@ namespace log4cplus { SocketState& state); LOG4CPLUS_EXPORT SOCKET_TYPE acceptSocket(SOCKET_TYPE sock, SocketState& state); LOG4CPLUS_EXPORT int closeSocket(SOCKET_TYPE sock); + LOG4CPLUS_EXPORT int shutdownSocket(SOCKET_TYPE sock); LOG4CPLUS_EXPORT long read(SOCKET_TYPE sock, SocketBuffer& buffer); LOG4CPLUS_EXPORT long write(SOCKET_TYPE sock, diff --git a/include/log4cplus/helpers/socketbuffer.h b/include/log4cplus/helpers/socketbuffer.h index b1bd0f381..f8b961326 100644 --- a/include/log4cplus/helpers/socketbuffer.h +++ b/include/log4cplus/helpers/socketbuffer.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/stringhelper.h b/include/log4cplus/helpers/stringhelper.h index 0feea1024..56d150c92 100644 --- a/include/log4cplus/helpers/stringhelper.h +++ b/include/log4cplus/helpers/stringhelper.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -116,7 +116,7 @@ namespace log4cplus { intType const mod = -(a + value); value = -r; - *(it - 1) = LOG4CPLUS_TEXT('0') + static_cast(mod); + *(it - 1) = static_cast(LOG4CPLUS_TEXT('0') + mod); --it; } else @@ -159,10 +159,12 @@ namespace log4cplus { typedef std::numeric_limits intTypeLimits; typedef ConvertIntegerToStringHelper HelperType; + + tchar buffer[intTypeLimits::digits10 + 2]; + // We define buffer_size from buffer using sizeof operator + // to appease HP aCC compiler. + const std::size_t buffer_size = sizeof (buffer) / sizeof (tchar); - const std::size_t buffer_size - = intTypeLimits::digits10 + 2; - tchar buffer[buffer_size]; tchar * it = &buffer[buffer_size]; tchar const * const buf_end = it; @@ -180,7 +182,7 @@ namespace log4cplus { { intType mod = value % 10; value = value / 10; - *(it - 1) = LOG4CPLUS_TEXT('0') + static_cast(mod); + *(it - 1) = static_cast(LOG4CPLUS_TEXT('0') + mod); } if (negative) diff --git a/include/log4cplus/helpers/thread-config.h b/include/log4cplus/helpers/thread-config.h index e9917b98d..4f9e06367 100644 --- a/include/log4cplus/helpers/thread-config.h +++ b/include/log4cplus/helpers/thread-config.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/timehelper.h b/include/log4cplus/helpers/timehelper.h index cbac5786d..06b3281b7 100644 --- a/include/log4cplus/helpers/timehelper.h +++ b/include/log4cplus/helpers/timehelper.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/hierarchy.h b/include/log4cplus/hierarchy.h index 8f473c4d1..2c023a961 100644 --- a/include/log4cplus/hierarchy.h +++ b/include/log4cplus/hierarchy.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/hierarchylocker.h b/include/log4cplus/hierarchylocker.h index 1bad2d150..9f18aacb5 100644 --- a/include/log4cplus/hierarchylocker.h +++ b/include/log4cplus/hierarchylocker.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -48,25 +48,25 @@ namespace log4cplus public: // ctor & dtor HierarchyLocker(Hierarchy& h); - ~HierarchyLocker(); - + ~HierarchyLocker() LOG4CPLUS_NOEXCEPT_FALSE; + /** * Calls the resetConfiguration() method on the locked Hierarchy. */ - void resetConfiguration(); - + void resetConfiguration(); + /** * Calls the getInstance() method on the locked Hierarchy. */ Logger getInstance(const log4cplus::tstring& name); - + /** * Calls the getInstance() method on the locked Hierarchy. */ Logger getInstance(const log4cplus::tstring& name, spi::LoggerFactory& factory); - + void addAppender(Logger &logger, log4cplus::SharedAppenderPtr& appender); - + private: // Data Hierarchy& h; @@ -77,4 +77,3 @@ namespace log4cplus } // end namespace log4cplus #endif // LOG4CPLUS_HIERARCHY_LOCKER_HEADER_ - diff --git a/include/log4cplus/internal/cygwin-win32.h b/include/log4cplus/internal/cygwin-win32.h index 4e9b57b1d..ab5a74404 100644 --- a/include/log4cplus/internal/cygwin-win32.h +++ b/include/log4cplus/internal/cygwin-win32.h @@ -4,7 +4,7 @@ // Created: 7/2011 // Author: Vaclav Zeman // -// Copyright (C) 2011, Vaclav Zeman. All rights reserved. +// Copyright (C) 2011-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/internal/env.h b/include/log4cplus/internal/env.h index 08b3e4a17..8c9a36445 100644 --- a/include/log4cplus/internal/env.h +++ b/include/log4cplus/internal/env.h @@ -5,7 +5,7 @@ // Author: Vaclav Haisman // // -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/internal/internal.h b/include/log4cplus/internal/internal.h index 80de4817c..3b467ef73 100644 --- a/include/log4cplus/internal/internal.h +++ b/include/log4cplus/internal/internal.h @@ -5,7 +5,7 @@ // Author: Vaclav Haisman // // -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -150,17 +150,9 @@ set_ptd (per_thread_data * p) } -//! The default value of the \param alloc is false for Win32 DLL builds -//! since per thread data are already initialized by DllMain(). inline per_thread_data * -get_ptd (bool alloc -#if defined (_WIN32) && defined (LOG4CPLUS_BUILD_DLL) - = false -#else - = true -#endif - ) +get_ptd (bool alloc = true) { if (LOG4CPLUS_UNLIKELY (! ptd && alloc)) return alloc_ptd (); diff --git a/include/log4cplus/internal/socket.h b/include/log4cplus/internal/socket.h index 6ac7dc6c4..988c1a1b9 100644 --- a/include/log4cplus/internal/socket.h +++ b/include/log4cplus/internal/socket.h @@ -5,18 +5,18 @@ // Author: Vaclav Haisman // // -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. -// +// Copyright (C) 2010-2015, Vaclav Haisman. All rights reserved. +// // Redistribution and use in source and binary forms, with or without modifica- // tion, 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 ``AS IS'' AND ANY EXPRESSED 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 @@ -28,7 +28,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/** @file +/** @file * This header contains declaration internal to log4cplus. They must never be * visible from user accesible headers or exported in DLL/shared libray. */ @@ -57,25 +57,129 @@ #include #endif +#ifdef LOG4CPLUS_HAVE_UNISTD_H +#include +#endif + +#if defined (LOG4CPLUS_HAVE_NETDB_H) +#include +#endif + namespace log4cplus { namespace helpers { - #if defined(_WIN32) typedef SOCKET os_socket_type; +os_socket_type const INVALID_OS_SOCKET_VALUE = INVALID_SOCKET; + +struct ADDRINFOT_deleter +{ + void + operator () (ADDRINFOA * ptr) const + { + FreeAddrInfoA(ptr); + } + + void + operator () (ADDRINFOW * ptr) const + { + FreeAddrInfoW(ptr); + } +}; + + +struct socket_closer +{ + void + operator () (SOCKET s) + { + if (s && s != INVALID_OS_SOCKET_VALUE) + { + DWORD const eno = WSAGetLastError(); + ::closesocket(s); + WSASetLastError(eno); + } + } +}; + + #else typedef int os_socket_type; +os_socket_type const INVALID_OS_SOCKET_VALUE = -1; + + +struct addrinfo_deleter +{ + void + operator () (struct addrinfo * ptr) const + { + freeaddrinfo(ptr); + } +}; + + +struct socket_closer +{ + void + operator () (os_socket_type s) + { + if (s >= 0) + { + int const eno = errno; + close(s); + errno = eno; + } + } +}; + #endif -os_socket_type const INVALID_OS_SOCKET_VALUE -#if defined(_WIN32) - = INVALID_SOCKET; -#else - = -1; +struct socket_holder +{ + os_socket_type sock; + + socket_holder() + : sock(INVALID_OS_SOCKET_VALUE) + { } + + socket_holder(os_socket_type s) + : sock(s) + { } + + ~socket_holder() + { + socket_closer()(sock); + } + + void + reset(os_socket_type s = INVALID_OS_SOCKET_VALUE) + { + if (sock != INVALID_OS_SOCKET_VALUE) + socket_closer()(sock); + + sock = s; + } + + os_socket_type + detach() + { + os_socket_type s = sock; + sock = INVALID_OS_SOCKET_VALUE; + return s; + } + +private: + socket_holder (socket_holder const &); + socket_holder operator = (socket_holder const &); + +#if defined (LOG4CPLUS_HAVE_CXX11_SUPPORT) + socket_holder (socket_holder &&); + socket_holder operator = (socket_holder &&); #endif +}; static inline @@ -112,7 +216,7 @@ get_last_socket_error () } // namespace helpers { -} // namespace log4cplus { +} // namespace log4cplus { #endif // LOG4CPLUS_INTERNAL_SOCKET_H_ diff --git a/include/log4cplus/layout.h b/include/log4cplus/layout.h index 56964c1a6..16a6d31de 100644 --- a/include/log4cplus/layout.h +++ b/include/log4cplus/layout.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -223,10 +223,9 @@ namespace log4cplus { * character. In the example above the conversion specifier * "%-5p" means the LogLevel of the logging event should be left * justified to a width of five characters. - * + * * The recognized conversion characters are * - * * * * @@ -312,6 +311,18 @@ namespace log4cplus { * * * + * + * + * + * + * + * * * * * * + * + * + * + * + * + * * * @@ -554,6 +576,18 @@ namespace log4cplus { * The above text is largely inspired from Peter A. Darnell and * Philip E. Margolis' highly recommended book "C -- a Software * Engineering Approach", ISBN 0-387-97389-3. + * + *

Properties

+ * + *
+ *
NDCMaxDepth
+ *
This property limits how many deepest NDC components will + * be printed by %%x specifier.
+ * + *
ConversionPattern
+ *
This property specifies conversion pattern.
+ *
+ * */ class LOG4CPLUS_EXPORT PatternLayout : public Layout diff --git a/include/log4cplus/log4judpappender.h b/include/log4cplus/log4judpappender.h index 5aaabb39d..51302c723 100644 --- a/include/log4cplus/log4judpappender.h +++ b/include/log4cplus/log4judpappender.h @@ -5,7 +5,7 @@ // Author: Siva Chandran P // // -// Copyright 2012 Siva Chandran P +// Copyright 2012-2013 Siva Chandran P // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -36,14 +36,11 @@ namespace log4cplus { * The Log4jUdpAppender has the following properties: * *
    - * *
  • Remote logging is non-intrusive as far as the log event * is concerned. In other words, the event will be logged with * the same time stamp, NDC, location info as if it were logged * locally by the client.
  • * - *
  • Log4jUdpAppender do not use a layout.
  • - * *
  • Remote logging uses the UDP protocol.
  • *
* diff --git a/include/log4cplus/logger.h b/include/log4cplus/logger.h index 524912e71..d0397612b 100644 --- a/include/log4cplus/logger.h +++ b/include/log4cplus/logger.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/loggingmacros.h b/include/log4cplus/loggingmacros.h index 2efc456be..4e108b85d 100644 --- a/include/log4cplus/loggingmacros.h +++ b/include/log4cplus/loggingmacros.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -39,6 +39,25 @@ #include +#if defined(_MSC_VER) +#define LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ + __pragma (warning (push)) \ + __pragma (warning (disable:4127)) + +#define LOG4CPLUS_RESTORE_DOWHILE_WARNING() \ + __pragma (warning (pop)) + +#else +#define LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() /* empty */ +#define LOG4CPLUS_RESTORE_DOWHILE_WARNING() /* empty */ + +#endif + +#define LOG4CPLUS_DOWHILE_NOTHING() \ + LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ + do { } while (0) \ + LOG4CPLUS_RESTORE_DOWHILE_WARNING() + #if defined(LOG4CPLUS_DISABLE_FATAL) && !defined(LOG4CPLUS_DISABLE_ERROR) #define LOG4CPLUS_DISABLE_ERROR #endif @@ -121,24 +140,22 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, } // namespace log4cplus -#undef LOG4CPLUS_MACRO_FUNCTION -#define LOG4CPLUS_MACRO_FUNCTION() 0 -#if ! defined (LOG4CPLUS_DISABLE_FUNCTION_MACRO) +#if ! defined (LOG4CPLUS_DISABLE_FUNCTION_MACRO) \ + && ! defined (LOG4CPLUS_MACRO_FUNCTION) # if defined (LOG4CPLUS_HAVE_FUNCSIG_MACRO) -# undef LOG4CPLUS_MACRO_FUNCTION # define LOG4CPLUS_MACRO_FUNCTION() __FUNCSIG__ # elif defined (LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO) -# undef LOG4CPLUS_MACRO_FUNCTION # define LOG4CPLUS_MACRO_FUNCTION() __PRETTY_FUNCTION__ # elif defined (LOG4CPLUS_HAVE_FUNCTION_MACRO) -# undef LOG4CPLUS_MACRO_FUNCTION # define LOG4CPLUS_MACRO_FUNCTION() __FUNCTION__ # elif defined (LOG4CPLUS_HAVE_FUNC_SYMBOL) -# undef LOG4CPLUS_MACRO_FUNCTION # define LOG4CPLUS_MACRO_FUNCTION() __func__ # endif #endif +#if ! defined (LOG4CPLUS_MACRO_FUNCTION) +# define LOG4CPLUS_MACRO_FUNCTION() 0 +#endif // Make TRACE and DEBUG log level unlikely and INFO, WARN, ERROR and // FATAL log level likely. @@ -161,23 +178,46 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_ ## logLevel (pred) +// Either use temporary instances of ostringstream +// and snprintf_buf, or use thread-local instances. +#if defined (LOG4CPLUS_MACRO_DISABLE_TLS) +# define LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM(var) \ + log4cplus::tostringstream var + +# define LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF(var) \ + log4cplus::helpers::snprintf_buf var + +#else +# define LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM(var) \ + log4cplus::tostringstream & var \ + = log4cplus::detail::get_macro_body_oss () + +# define LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF(var) \ + log4cplus::helpers::snprintf_buf & var \ + = log4cplus::detail::get_macro_body_snprintf_buf () + +#endif + + #define LOG4CPLUS_MACRO_BODY(logger, logEvent, logLevel) \ + LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ do { \ log4cplus::Logger const & _l \ = log4cplus::detail::macros_get_logger (logger); \ if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( \ _l.isEnabledFor (log4cplus::logLevel), logLevel)) { \ - log4cplus::tostringstream & _log4cplus_buf \ - = log4cplus::detail::get_macro_body_oss (); \ + LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM (_log4cplus_buf); \ _log4cplus_buf << logEvent; \ log4cplus::detail::macro_forced_log (_l, \ log4cplus::logLevel, _log4cplus_buf.str(), \ __FILE__, __LINE__, LOG4CPLUS_MACRO_FUNCTION ()); \ } \ - } while (0) + } while (0) \ + LOG4CPLUS_RESTORE_DOWHILE_WARNING() #define LOG4CPLUS_MACRO_STR_BODY(logger, logEvent, logLevel) \ + LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ do { \ log4cplus::Logger const & _l \ = log4cplus::detail::macros_get_logger (logger); \ @@ -187,41 +227,44 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, log4cplus::logLevel, logEvent, \ __FILE__, __LINE__, LOG4CPLUS_MACRO_FUNCTION ()); \ } \ - } while(0) + } while(0) \ + LOG4CPLUS_RESTORE_DOWHILE_WARNING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel, logFmt, ...) \ +#define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel, ...) \ + LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ do { \ log4cplus::Logger const & _l \ = log4cplus::detail::macros_get_logger (logger); \ if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( \ _l.isEnabledFor (log4cplus::logLevel), logLevel)) { \ - log4cplus::helpers::snprintf_buf & _snpbuf \ - = log4cplus::detail::get_macro_body_snprintf_buf (); \ + LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF (_snpbuf); \ log4cplus::tchar const * _logEvent \ - = _snpbuf.print (logFmt, __VA_ARGS__); \ + = _snpbuf.print (__VA_ARGS__); \ log4cplus::detail::macro_forced_log (_l, \ log4cplus::logLevel, _logEvent, \ __FILE__, __LINE__, LOG4CPLUS_MACRO_FUNCTION ()); \ - } \ - } while(0) + } \ + } while(0) \ + LOG4CPLUS_RESTORE_DOWHILE_WARNING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel, logFmt, logArgs...) \ +#define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel, logArgs...) \ + LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ do { \ log4cplus::Logger const & _l \ = log4cplus::detail::macros_get_logger (logger); \ if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( \ _l.isEnabledFor (log4cplus::logLevel), logLevel)) { \ - log4cplus::helpers::snprintf_buf & _snpbuf \ - = log4cplus::detail::get_macro_body_snprintf_buf (); \ + LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF (_snpbuf); \ log4cplus::tchar const * _logEvent \ - = _snpbuf.print (logFmt, logArgs); \ + = _snpbuf.print (logArgs); \ log4cplus::detail::macro_forced_log (_l, \ log4cplus::logLevel, _logEvent, \ __FILE__, __LINE__, LOG4CPLUS_MACRO_FUNCTION ()); \ } \ - } while(0) + } while(0) \ + LOG4CPLUS_RESTORE_DOWHILE_WARNING() #endif @@ -242,21 +285,21 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, TRACE_LOG_LEVEL) #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_TRACE_FMT(logger, logFmt, ...) \ - LOG4CPLUS_MACRO_FMT_BODY (logger, TRACE_LOG_LEVEL, logFmt, __VA_ARGS__) +#define LOG4CPLUS_TRACE_FMT(logger, ...) \ + LOG4CPLUS_MACRO_FMT_BODY (logger, TRACE_LOG_LEVEL, __VA_ARGS__) #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_TRACE_FMT(logger, logFmt, logArgs...) \ - LOG4CPLUS_MACRO_FMT_BODY(logger, TRACE_LOG_LEVEL, logFmt, logArgs) +#define LOG4CPLUS_TRACE_FMT(logger, logArgs...) \ + LOG4CPLUS_MACRO_FMT_BODY(logger, TRACE_LOG_LEVEL, logArgs) #endif #else -#define LOG4CPLUS_TRACE_METHOD(logger, logEvent) do { } while (0) -#define LOG4CPLUS_TRACE(logger, logEvent) do { } while (0) -#define LOG4CPLUS_TRACE_STR(logger, logEvent) do { } while (0) +#define LOG4CPLUS_TRACE_METHOD(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_TRACE(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_TRACE_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_TRACE_FMT(logger, logFmt, ...) do { } while (0) +#define LOG4CPLUS_TRACE_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_TRACE_FMT(logger, logFmt, logArgs...) do { } while (0) +#define LOG4CPLUS_TRACE_FMT(logger, logFmt, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -273,20 +316,20 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, DEBUG_LOG_LEVEL) #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_DEBUG_FMT(logger, logFmt, ...) \ - LOG4CPLUS_MACRO_FMT_BODY (logger, DEBUG_LOG_LEVEL, logFmt, __VA_ARGS__) +#define LOG4CPLUS_DEBUG_FMT(logger, ...) \ + LOG4CPLUS_MACRO_FMT_BODY (logger, DEBUG_LOG_LEVEL, __VA_ARGS__) #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_DEBUG_FMT(logger, logFmt, logArgs...) \ - LOG4CPLUS_MACRO_FMT_BODY(logger, DEBUG_LOG_LEVEL, logFmt, logArgs) +#define LOG4CPLUS_DEBUG_FMT(logger, logArgs...) \ + LOG4CPLUS_MACRO_FMT_BODY(logger, DEBUG_LOG_LEVEL, logArgs) #endif #else -#define LOG4CPLUS_DEBUG(logger, logEvent) do { } while (0) -#define LOG4CPLUS_DEBUG_STR(logger, logEvent) do { } while (0) +#define LOG4CPLUS_DEBUG(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_DEBUG_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_DEBUG_FMT(logger, logFmt, ...) do { } while (0) +#define LOG4CPLUS_DEBUG_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_DEBUG_FMT(logger, logFmt, logArgs...) do { } while (0) +#define LOG4CPLUS_DEBUG_FMT(logger, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -303,20 +346,20 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, INFO_LOG_LEVEL) #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_INFO_FMT(logger, logFmt, ...) \ - LOG4CPLUS_MACRO_FMT_BODY (logger, INFO_LOG_LEVEL, logFmt, __VA_ARGS__) +#define LOG4CPLUS_INFO_FMT(logger, ...) \ + LOG4CPLUS_MACRO_FMT_BODY (logger, INFO_LOG_LEVEL, __VA_ARGS__) #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_INFO_FMT(logger, logFmt, logArgs...) \ - LOG4CPLUS_MACRO_FMT_BODY(logger, INFO_LOG_LEVEL, logFmt, logArgs) +#define LOG4CPLUS_INFO_FMT(logger, logArgs...) \ + LOG4CPLUS_MACRO_FMT_BODY(logger, INFO_LOG_LEVEL, logArgs) #endif #else -#define LOG4CPLUS_INFO(logger, logEvent) do { } while (0) -#define LOG4CPLUS_INFO_STR(logger, logEvent) do { } while (0) +#define LOG4CPLUS_INFO(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_INFO_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_INFO_FMT(logger, logFmt, ...) do { } while (0) +#define LOG4CPLUS_INFO_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_INFO_FMT(logger, logFmt, logArgs...) do { } while (0) +#define LOG4CPLUS_INFO_FMT(logger, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -333,20 +376,20 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, WARN_LOG_LEVEL) #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_WARN_FMT(logger, logFmt, ...) \ - LOG4CPLUS_MACRO_FMT_BODY (logger, WARN_LOG_LEVEL, logFmt, __VA_ARGS__) +#define LOG4CPLUS_WARN_FMT(logger, ...) \ + LOG4CPLUS_MACRO_FMT_BODY (logger, WARN_LOG_LEVEL, __VA_ARGS__) #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_WARN_FMT(logger, logFmt, logArgs...) \ - LOG4CPLUS_MACRO_FMT_BODY(logger, WARN_LOG_LEVEL, logFmt, logArgs) +#define LOG4CPLUS_WARN_FMT(logger, logArgs...) \ + LOG4CPLUS_MACRO_FMT_BODY(logger, WARN_LOG_LEVEL, logArgs) #endif #else -#define LOG4CPLUS_WARN(logger, logEvent) do { } while (0) -#define LOG4CPLUS_WARN_STR(logger, logEvent) do { } while (0) +#define LOG4CPLUS_WARN(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_WARN_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_WARN_FMT(logger, logFmt, ...) do { } while (0) +#define LOG4CPLUS_WARN_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_WARN_FMT(logger, logFmt, logArgs...) do { } while (0) +#define LOG4CPLUS_WARN_FMT(logger, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -363,20 +406,20 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, ERROR_LOG_LEVEL) #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_ERROR_FMT(logger, logFmt, ...) \ - LOG4CPLUS_MACRO_FMT_BODY (logger, ERROR_LOG_LEVEL, logFmt, __VA_ARGS__) +#define LOG4CPLUS_ERROR_FMT(logger, ...) \ + LOG4CPLUS_MACRO_FMT_BODY (logger, ERROR_LOG_LEVEL, __VA_ARGS__) #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_ERROR_FMT(logger, logFmt, logArgs...) \ - LOG4CPLUS_MACRO_FMT_BODY(logger, ERROR_LOG_LEVEL, logFmt, logArgs) +#define LOG4CPLUS_ERROR_FMT(logger, logArgs...) \ + LOG4CPLUS_MACRO_FMT_BODY(logger, ERROR_LOG_LEVEL, logArgs) #endif #else -#define LOG4CPLUS_ERROR(logger, logEvent) do { } while (0) -#define LOG4CPLUS_ERROR_STR(logger, logEvent) do { } while (0) +#define LOG4CPLUS_ERROR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_ERROR_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_ERROR_FMT(logger, logFmt, ...) do { } while (0) +#define LOG4CPLUS_ERROR_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_ERROR_FMT(logger, logFmt, logArgs...) do { } while (0) +#define LOG4CPLUS_ERROR_FMT(logger, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -393,20 +436,20 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, FATAL_LOG_LEVEL) #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_FATAL_FMT(logger, logFmt, ...) \ - LOG4CPLUS_MACRO_FMT_BODY (logger, FATAL_LOG_LEVEL, logFmt, __VA_ARGS__) +#define LOG4CPLUS_FATAL_FMT(logger, ...) \ + LOG4CPLUS_MACRO_FMT_BODY (logger, FATAL_LOG_LEVEL, __VA_ARGS__) #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_FATAL_FMT(logger, logFmt, logArgs...) \ - LOG4CPLUS_MACRO_FMT_BODY(logger, FATAL_LOG_LEVEL, logFmt, logArgs) +#define LOG4CPLUS_FATAL_FMT(logger, logArgs...) \ + LOG4CPLUS_MACRO_FMT_BODY(logger, FATAL_LOG_LEVEL, logArgs) #endif #else -#define LOG4CPLUS_FATAL(logger, logEvent) do { } while (0) -#define LOG4CPLUS_FATAL_STR(logger, logEvent) do { } while (0) +#define LOG4CPLUS_FATAL(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_FATAL_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_FATAL_FMT(logger, logFmt, ...) do { } while (0) +#define LOG4CPLUS_FATAL_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_FATAL_FMT(logger, logFmt, logArgs...) do { } while (0) +#define LOG4CPLUS_FATAL_FMT(logger, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif diff --git a/include/log4cplus/loglevel.h b/include/log4cplus/loglevel.h index 7d7d83b7a..d7e0db2cb 100644 --- a/include/log4cplus/loglevel.h +++ b/include/log4cplus/loglevel.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/mdc.h b/include/log4cplus/mdc.h index f4b009ea6..ff23774d5 100644 --- a/include/log4cplus/mdc.h +++ b/include/log4cplus/mdc.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/ndc.h b/include/log4cplus/ndc.h index 8acf49d09..26e1b5918 100644 --- a/include/log4cplus/ndc.h +++ b/include/log4cplus/ndc.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/nteventlogappender.h b/include/log4cplus/nteventlogappender.h index 99635ff4e..9ea3a8974 100644 --- a/include/log4cplus/nteventlogappender.h +++ b/include/log4cplus/nteventlogappender.h @@ -4,7 +4,7 @@ // Created: 4/2003 // Author: Michael CATANZARITI // -// Copyright 2003-2010 Michael CATANZARITI +// Copyright 2003-2013 Michael CATANZARITI // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/nullappender.h b/include/log4cplus/nullappender.h index 84598527d..15456fc4b 100644 --- a/include/log4cplus/nullappender.h +++ b/include/log4cplus/nullappender.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/qt4debugappender.h b/include/log4cplus/qt4debugappender.h index ddb8d2b6c..8908a6ed9 100644 --- a/include/log4cplus/qt4debugappender.h +++ b/include/log4cplus/qt4debugappender.h @@ -5,7 +5,7 @@ // Author: Vaclav Zeman // // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/socketappender.h b/include/log4cplus/socketappender.h index aa75c84dd..a288c512a 100644 --- a/include/log4cplus/socketappender.h +++ b/include/log4cplus/socketappender.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/appenderattachable.h b/include/log4cplus/spi/appenderattachable.h index 0f527ed26..986bf9b4d 100644 --- a/include/log4cplus/spi/appenderattachable.h +++ b/include/log4cplus/spi/appenderattachable.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/factory.h b/include/log4cplus/spi/factory.h index c449ee9d7..709edf55e 100644 --- a/include/log4cplus/spi/factory.h +++ b/include/log4cplus/spi/factory.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2002-2010 Tad E. Smith +// Copyright 2002-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/filter.h b/include/log4cplus/spi/filter.h index 6e38a8090..1febd23fb 100644 --- a/include/log4cplus/spi/filter.h +++ b/include/log4cplus/spi/filter.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 1999-2010 Tad E. Smith +// Copyright 1999-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/loggerfactory.h b/include/log4cplus/spi/loggerfactory.h index a417db64f..ad735f1d6 100644 --- a/include/log4cplus/spi/loggerfactory.h +++ b/include/log4cplus/spi/loggerfactory.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/loggerimpl.h b/include/log4cplus/spi/loggerimpl.h index d1f287bf6..c7e46337b 100644 --- a/include/log4cplus/spi/loggerimpl.h +++ b/include/log4cplus/spi/loggerimpl.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/loggingevent.h b/include/log4cplus/spi/loggingevent.h index 44043103a..c2d4596fc 100644 --- a/include/log4cplus/spi/loggingevent.h +++ b/include/log4cplus/spi/loggingevent.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -66,12 +66,23 @@ namespace log4cplus { LogLevel loglevel, const log4cplus::tstring& message, const char* filename, int line); + //! This constructor is deprecated in favor of the next one because + //! of the additional `thread2` parameter. InternalLoggingEvent(const log4cplus::tstring& logger, LogLevel loglevel, const log4cplus::tstring& ndc, MappedDiagnosticContextMap const & mdc, const log4cplus::tstring& message, const log4cplus::tstring& thread, log4cplus::helpers::Time time, const log4cplus::tstring& file, + int line) LOG4CPLUS_ATTRIBUTE_DEPRECATED; + + InternalLoggingEvent(const log4cplus::tstring& logger, + LogLevel loglevel, const log4cplus::tstring& ndc, + MappedDiagnosticContextMap const & mdc, + const log4cplus::tstring& message, + const log4cplus::tstring& thread, + const log4cplus::tstring& thread2, + log4cplus::helpers::Time time, const log4cplus::tstring& file, int line); InternalLoggingEvent (); diff --git a/include/log4cplus/spi/objectregistry.h b/include/log4cplus/spi/objectregistry.h index 5adfa031f..d05947422 100644 --- a/include/log4cplus/spi/objectregistry.h +++ b/include/log4cplus/spi/objectregistry.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/rootlogger.h b/include/log4cplus/spi/rootlogger.h index ac73326b1..6c466c261 100644 --- a/include/log4cplus/spi/rootlogger.h +++ b/include/log4cplus/spi/rootlogger.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/streams.h b/include/log4cplus/streams.h index cc5200805..df33c4d0d 100644 --- a/include/log4cplus/streams.h +++ b/include/log4cplus/streams.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/syslogappender.h b/include/log4cplus/syslogappender.h index f33bc7aec..60e06bd5c 100644 --- a/include/log4cplus/syslogappender.h +++ b/include/log4cplus/syslogappender.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/tchar.h b/include/log4cplus/tchar.h index f433b58f4..217fc76d8 100644 --- a/include/log4cplus/tchar.h +++ b/include/log4cplus/tchar.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/impl/syncprims-impl.h b/include/log4cplus/thread/impl/syncprims-impl.h index 5c4b8d140..6a2df916b 100644 --- a/include/log4cplus/thread/impl/syncprims-impl.h +++ b/include/log4cplus/thread/impl/syncprims-impl.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -65,8 +65,9 @@ namespace log4cplus { namespace thread { namespace impl { -LOG4CPLUS_EXPORT void syncprims_throw_exception (char const * const msg, - char const * const file, int line) LOG4CPLUS_ATTRIBUTE_NORETURN; +LOG4CPLUS_EXPORT void LOG4CPLUS_ATTRIBUTE_NORETURN + syncprims_throw_exception (char const * const msg, + char const * const file, int line); #define LOG4CPLUS_THROW_RTE(msg) \ diff --git a/include/log4cplus/thread/impl/syncprims-pmsm.h b/include/log4cplus/thread/impl/syncprims-pmsm.h index f5cd3ef71..34b315db5 100644 --- a/include/log4cplus/thread/impl/syncprims-pmsm.h +++ b/include/log4cplus/thread/impl/syncprims-pmsm.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/impl/syncprims-pthreads.h b/include/log4cplus/thread/impl/syncprims-pthreads.h index 851d7e0ed..ed559b086 100644 --- a/include/log4cplus/thread/impl/syncprims-pthreads.h +++ b/include/log4cplus/thread/impl/syncprims-pthreads.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -245,11 +245,17 @@ inline void Semaphore::lock () const { + int ret; + while (( #if defined (LOG4CPLUS_USE_NAMED_POSIX_SEMAPHORE) - int ret = sem_wait (sem); + ret = sem_wait (sem) #else - int ret = sem_wait (&sem); + ret = sem_wait (&sem) #endif + ) == -1 + && errno == EINTR) + { /* try again after signal */ } + if (ret != 0) LOG4CPLUS_THROW_RTE ("Semaphore::lock"); } diff --git a/include/log4cplus/thread/impl/syncprims-win32.h b/include/log4cplus/thread/impl/syncprims-win32.h index f16837bcc..35cc42303 100644 --- a/include/log4cplus/thread/impl/syncprims-win32.h +++ b/include/log4cplus/thread/impl/syncprims-win32.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/impl/threads-impl.h b/include/log4cplus/thread/impl/threads-impl.h index 3389e9414..88b40b24a 100644 --- a/include/log4cplus/thread/impl/threads-impl.h +++ b/include/log4cplus/thread/impl/threads-impl.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/thread/impl/tls.h b/include/log4cplus/thread/impl/tls.h index d471a56a2..5a390aeb7 100644 --- a/include/log4cplus/thread/impl/tls.h +++ b/include/log4cplus/thread/impl/tls.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/syncprims-pub-impl.h b/include/log4cplus/thread/syncprims-pub-impl.h index e82d64174..15e045cd9 100644 --- a/include/log4cplus/thread/syncprims-pub-impl.h +++ b/include/log4cplus/thread/syncprims-pub-impl.h @@ -1,16 +1,16 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. -// +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. +// // Redistribution and use in source and binary forms, with or without modifica- // tion, 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 ``AS IS'' AND ANY EXPRESSED 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 @@ -38,9 +38,11 @@ #if defined (LOG4CPLUS_SINGLE_THREADED) # define LOG4CPLUS_THREADED(x) +# define LOG4CPLUS_THREADED2(x, y) (y) #else # include # define LOG4CPLUS_THREADED(x) (x) +# define LOG4CPLUS_THREADED2(x, y) (x) #endif @@ -61,8 +63,9 @@ MutexImplBase::~MutexImplBase () // LOG4CPLUS_INLINE_EXPORT -Mutex::Mutex (Mutex::Type t) - : mtx (LOG4CPLUS_THREADED (new impl::Mutex (t)) + 0) +Mutex::Mutex (Mutex::Type LOG4CPLUS_THREADED (t)) + : mtx (LOG4CPLUS_THREADED2 (new impl::Mutex (t), + static_cast(0))) { } @@ -105,7 +108,8 @@ SemaphoreImplBase::~SemaphoreImplBase () LOG4CPLUS_INLINE_EXPORT Semaphore::Semaphore (unsigned LOG4CPLUS_THREADED (max), unsigned LOG4CPLUS_THREADED (initial)) - : sem (LOG4CPLUS_THREADED (new impl::Semaphore (max, initial)) + 0) + : sem (LOG4CPLUS_THREADED2 (new impl::Semaphore (max, initial), + static_cast(0))) { } @@ -147,7 +151,8 @@ FairMutexImplBase::~FairMutexImplBase () LOG4CPLUS_INLINE_EXPORT FairMutex::FairMutex () - : mtx (LOG4CPLUS_THREADED (new impl::FairMutex) + 0) + : mtx (LOG4CPLUS_THREADED2 (new impl::FairMutex, + static_cast(0))) { } @@ -189,7 +194,8 @@ ManualResetEventImplBase::~ManualResetEventImplBase () LOG4CPLUS_INLINE_EXPORT ManualResetEvent::ManualResetEvent (bool LOG4CPLUS_THREADED (sig)) - : ev (LOG4CPLUS_THREADED (new impl::ManualResetEvent (sig)) + 0) + : ev (LOG4CPLUS_THREADED2 (new impl::ManualResetEvent (sig), + static_cast(0))) { } @@ -251,7 +257,8 @@ SharedMutexImplBase::~SharedMutexImplBase () LOG4CPLUS_INLINE_EXPORT SharedMutex::SharedMutex () - : sm (LOG4CPLUS_THREADED (new impl::SharedMutex) + 0) + : sm (LOG4CPLUS_THREADED2 (new impl::SharedMutex, + static_cast(0))) { } @@ -292,7 +299,7 @@ SharedMutex::wrunlock () const } -} } // namespace log4cplus { namespace thread { +} } // namespace log4cplus { namespace thread { #endif // LOG4CPLUS_ENABLE_SYNCPRIMS_PUB_IMPL diff --git a/include/log4cplus/thread/syncprims.h b/include/log4cplus/thread/syncprims.h index 6e52dc206..d0438458b 100644 --- a/include/log4cplus/thread/syncprims.h +++ b/include/log4cplus/thread/syncprims.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/threads.h b/include/log4cplus/thread/threads.h index 42fa48687..82149c4b0 100644 --- a/include/log4cplus/thread/threads.h +++ b/include/log4cplus/thread/threads.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -39,6 +39,8 @@ namespace log4cplus { namespace thread { LOG4CPLUS_EXPORT log4cplus::tstring const & getCurrentThreadName(); LOG4CPLUS_EXPORT log4cplus::tstring const & getCurrentThreadName2(); +LOG4CPLUS_EXPORT void setCurrentThreadName(const log4cplus::tstring & name); +LOG4CPLUS_EXPORT void setCurrentThreadName2(const log4cplus::tstring & name); LOG4CPLUS_EXPORT void yield(); LOG4CPLUS_EXPORT void blockAllSignals(); diff --git a/include/log4cplus/tracelogger.h b/include/log4cplus/tracelogger.h index d0d5b4c1d..a056ccdc5 100644 --- a/include/log4cplus/tracelogger.h +++ b/include/log4cplus/tracelogger.h @@ -5,7 +5,7 @@ // Author: Vaclav Haisman // // -// Copyright 2009-2010 Tad E. Smith +// Copyright 2009-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/tstring.h b/include/log4cplus/tstring.h index 92832bb5d..7829b4e2f 100644 --- a/include/log4cplus/tstring.h +++ b/include/log4cplus/tstring.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -49,7 +49,6 @@ tostring (char const * str) return std::string (str); } - inline std::string tostring (std::string const & str) @@ -57,6 +56,23 @@ tostring (std::string const & str) return str; } +inline +std::string const & +tostring (std::string & str) +{ + return str; +} + +#ifdef LOG4CPLUS_HAVE_RVALUE_REFS +inline +std::string +tostring (std::string && str) +{ + return std::move (str); +} + +#endif + inline @@ -73,6 +89,23 @@ towstring (std::wstring const & str) return str; } +inline +std::wstring const & +towstring (std::wstring & str) +{ + return str; +} + +#ifdef LOG4CPLUS_HAVE_RVALUE_REFS +inline +std::wstring +towstring (std::wstring && str) +{ + return std::move (str); +} + +#endif + LOG4CPLUS_EXPORT std::string tostring(const std::wstring&); LOG4CPLUS_EXPORT std::string tostring(wchar_t const *); @@ -89,7 +122,7 @@ LOG4CPLUS_EXPORT std::wstring towstring(char const *); #else // UNICODE -#define LOG4CPLUS_C_STR_TO_TSTRING(STRING) std::string(STRING) +#define LOG4CPLUS_C_STR_TO_TSTRING(STRING) (std::string(STRING)) #define LOG4CPLUS_STRING_TO_TSTRING(STRING) STRING #define LOG4CPLUS_TSTRING_TO_STRING(STRING) STRING diff --git a/include/log4cplus/version.h b/include/log4cplus/version.h index 0f9b2296e..0481df955 100644 --- a/include/log4cplus/version.h +++ b/include/log4cplus/version.h @@ -1,16 +1,16 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. -// +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. +// // Redistribution and use in source and binary forms, with or without modifica- // tion, 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 ``AS IS'' AND ANY EXPRESSED 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 @@ -38,8 +38,8 @@ #define LOG4CPLUS_MAKE_VERSION_STR(major, minor, point) \ #major "." #minor "." #point -#define LOG4CPLUS_VERSION LOG4CPLUS_MAKE_VERSION(1, 1, 0) -#define LOG4CPLUS_VERSION_STR LOG4CPLUS_MAKE_VERSION_STR(1, 1, 0) +#define LOG4CPLUS_VERSION LOG4CPLUS_MAKE_VERSION(1, 1, 3) +#define LOG4CPLUS_VERSION_STR LOG4CPLUS_MAKE_VERSION_STR(1, 1, 3) namespace log4cplus diff --git a/include/log4cplus/win32consoleappender.h b/include/log4cplus/win32consoleappender.h index b2d0dc151..c98eb5553 100644 --- a/include/log4cplus/win32consoleappender.h +++ b/include/log4cplus/win32consoleappender.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -49,13 +49,23 @@ namespace log4cplus * will try to allocate new console using the * AllocConsole() Win32 function. * + *
logToStdErr
+ *
When it is set true, the output will be into + * STD_ERROR_HANDLE instead of STD_OUTPUT_HANDLE. + *
+ * + *
TextColor
+ *
See MSDN documentation for + * + * Character Attributes. * */ class LOG4CPLUS_EXPORT Win32ConsoleAppender : public Appender { public: - explicit Win32ConsoleAppender (bool allocConsole = true); + explicit Win32ConsoleAppender (bool allocConsole = true, + bool logToStdErr = false, unsigned int textColor = 0); Win32ConsoleAppender (helpers::Properties const & properties); virtual ~Win32ConsoleAppender (); @@ -68,6 +78,8 @@ namespace log4cplus void write_console (void *, tchar const *, std::size_t); bool alloc_console; + bool log_to_std_err; + unsigned int text_color; private: Win32ConsoleAppender (Win32ConsoleAppender const &); diff --git a/include/log4cplus/win32debugappender.h b/include/log4cplus/win32debugappender.h index ba6667abf..50059d475 100644 --- a/include/log4cplus/win32debugappender.h +++ b/include/log4cplus/win32debugappender.h @@ -5,7 +5,7 @@ // Author: Eduardo Francos, Odalio SARL // // -// Copyright 2003-2010 Odalio SARL +// Copyright 2003-2013 Odalio SARL // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/log4cplus.spec b/log4cplus.spec index 0267a2a81..2bc4eb3a4 100644 --- a/log4cplus.spec +++ b/log4cplus.spec @@ -1,5 +1,5 @@ Name: log4cplus -Version: 1.1.0 +Version: 1.1.3 Release: 1 Summary: log4cplus, C++ logging library @@ -47,6 +47,13 @@ cp -rp include/log4cplus $RPM_BUILD_ROOT%{prefix}/include/ rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/config/stamp-* rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/config/*.in rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/stamp-* +rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/config/macosx.h +rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/config/win32.h +rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/config/windowsh-inc.h +rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/internal/cygwin-win32.h +rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/thread/impl/syncprims-win32.h +find %{buildroot} -name .svn -type d -exec find '{}' -delete \; +find %{buildroot} -name "*.in" -delete %clean @@ -62,4 +69,12 @@ rm -rf $RPM_BUILD_ROOT %prefix/include/log4cplus/*.h %prefix/include/log4cplus/helpers/*.h %prefix/include/log4cplus/spi/*.h -%attr(644,root,root) %prefix/lib/*.a +%prefix/include/log4cplus/boost/*.hxx +%prefix/include/log4cplus/config.hxx +%prefix/include/log4cplus/config/defines.hxx +%prefix/include/log4cplus/internal/*.h +%prefix/include/log4cplus/thread/impl/*.h +%prefix/include/log4cplus/thread/*.h +%attr(644,root,root) +%prefix/lib/*.a +%prefix/lib/pkgconfig/log4cplus.pc diff --git a/loggingserver/CMakeLists.txt b/loggingserver/CMakeLists.txt index 3b0b0f7a8..e53512050 100644 --- a/loggingserver/CMakeLists.txt +++ b/loggingserver/CMakeLists.txt @@ -11,4 +11,4 @@ message (STATUS "Sources: ${loggingserver_sources}") add_executable (loggingserver ${loggingserver_sources}) target_link_libraries (loggingserver ${log4cplus}) -install(TARGETS loggingserver DESTINATION bin) +install(TARGETS loggingserver DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/loggingserver/Makefile.in b/loggingserver/Makefile.in index 656e3bc60..15bc33f22 100644 --- a/loggingserver/Makefile.in +++ b/loggingserver/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -75,7 +75,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -154,6 +157,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/loggingserver/loggingserver.cxx b/loggingserver/loggingserver.cxx index 8d8dc3c93..7bc1e6f9d 100644 --- a/loggingserver/loggingserver.cxx +++ b/loggingserver/loggingserver.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,22 +19,154 @@ // limitations under the License. #include +#include #include #include #include #include #include #include +#include +#include namespace loggingserver { -class ClientThread : public log4cplus::thread::AbstractThread + +typedef std::list ThreadQueueType; + + +class ReaperThread + : public log4cplus::thread::AbstractThread +{ +public: + ReaperThread (log4cplus::thread::Mutex & mtx_, + log4cplus::thread::ManualResetEvent & ev_, + ThreadQueueType & queue_) + : mtx (mtx_) + , ev (ev_) + , queue (queue_) + , stop (false) + { } + + virtual + ~ReaperThread () + { } + + virtual void run (); + + void signal_exit (); + +private: + log4cplus::thread::Mutex & mtx; + log4cplus::thread::ManualResetEvent & ev; + ThreadQueueType & queue; + bool stop; +}; + + +typedef log4cplus::helpers::SharedObjectPtr ReaperThreadPtr; + + +void +ReaperThread::signal_exit () +{ + log4cplus::thread::MutexGuard guard (mtx); + stop = true; + ev.signal (); +} + + +void +ReaperThread::run () +{ + ThreadQueueType q; + + while (true) + { + ev.timed_wait (30 * 1000); + + { + log4cplus::thread::MutexGuard guard (mtx); + + // Check exit condition as the very first thing. + if (stop) + { + std::cout << "Reaper thread is stopping..." << std::endl; + return; + } + + ev.reset (); + q.swap (queue); + } + + if (! q.empty ()) + { + std::cout << "Reaper thread is reaping " << q.size () << " threads." + << std::endl; + + for (ThreadQueueType::iterator it = q.begin (), end_it = q.end (); + it != end_it; ++it) + { + AbstractThread & t = **it; + t.join (); + } + + q.clear (); + } + } +} + + + +/** + This class wraps ReaperThread thread and its queue. + */ +class Reaper +{ +public: + Reaper () + { + reaper_thread = ReaperThreadPtr (new ReaperThread (mtx, ev, queue)); + reaper_thread->start (); + } + + ~Reaper () + { + reaper_thread->signal_exit (); + reaper_thread->join (); + } + + void visit (log4cplus::thread::AbstractThreadPtr const & thread_ptr); + +private: + log4cplus::thread::Mutex mtx; + log4cplus::thread::ManualResetEvent ev; + ThreadQueueType queue; + ReaperThreadPtr reaper_thread; +}; + + +void +Reaper::visit (log4cplus::thread::AbstractThreadPtr const & thread_ptr) +{ + log4cplus::thread::MutexGuard guard (mtx); + queue.push_back (thread_ptr); + ev.signal (); +} + + + + +class ClientThread + : public log4cplus::thread::AbstractThread { public: - ClientThread(log4cplus::helpers::Socket clientsock) - : clientsock(clientsock) + ClientThread(log4cplus::helpers::Socket clientsock_, Reaper & reaper_) + : self_reference (log4cplus::thread::AbstractThreadPtr (this)) + , clientsock(clientsock_) + , reaper (reaper_) { std::cout << "Received a client connection!!!!" << std::endl; } @@ -47,17 +179,59 @@ class ClientThread : public log4cplus::thread::AbstractThread virtual void run(); private: + log4cplus::thread::AbstractThreadPtr self_reference; log4cplus::helpers::Socket clientsock; + Reaper & reaper; }; -} +void +loggingserver::ClientThread::run() +{ + try + { + while (1) + { + if (!clientsock.isOpen()) + break; + + log4cplus::helpers::SocketBuffer msgSizeBuffer(sizeof(unsigned int)); + if (!clientsock.read(msgSizeBuffer)) + break; + + unsigned int msgSize = msgSizeBuffer.readInt(); + + log4cplus::helpers::SocketBuffer buffer(msgSize); + if (!clientsock.read(buffer)) + break; + + log4cplus::spi::InternalLoggingEvent event + = log4cplus::helpers::readFromBuffer(buffer); + log4cplus::Logger logger + = log4cplus::Logger::getInstance(event.getLoggerName()); + logger.callAppenders(event); + } + } + catch (...) + { + reaper.visit (self_reference); + self_reference = log4cplus::thread::AbstractThreadPtr (); + throw; + } + + reaper.visit (self_reference); + self_reference = log4cplus::thread::AbstractThreadPtr (); +} +} // namespace loggingserver + int main(int argc, char** argv) { + log4cplus::initialize (); + if(argc < 3) { std::cout << "Usage: port config_file" << std::endl; return 1; @@ -70,49 +244,21 @@ main(int argc, char** argv) log4cplus::helpers::ServerSocket serverSocket(port); if (!serverSocket.isOpen()) { - std::cout << "Could not open server socket, maybe port " + std::cerr << "Could not open server socket, maybe port " << port << " is already in use." << std::endl; return 2; } - while(1) { - loggingserver::ClientThread *thr = - new loggingserver::ClientThread(serverSocket.accept()); + loggingserver::Reaper reaper; + + for (;;) + { + loggingserver::ClientThread *thr = + new loggingserver::ClientThread(serverSocket.accept(), reaper); thr->start(); } - return 0; -} - - -//////////////////////////////////////////////////////////////////////////////// -// loggingserver::ClientThread implementation -//////////////////////////////////////////////////////////////////////////////// + log4cplus::Logger::shutdown(); - -void -loggingserver::ClientThread::run() -{ - while(1) { - if(!clientsock.isOpen()) { - return; - } - log4cplus::helpers::SocketBuffer msgSizeBuffer(sizeof(unsigned int)); - if(!clientsock.read(msgSizeBuffer)) { - return; - } - - unsigned int msgSize = msgSizeBuffer.readInt(); - - log4cplus::helpers::SocketBuffer buffer(msgSize); - if(!clientsock.read(buffer)) { - return; - } - - log4cplus::spi::InternalLoggingEvent event - = log4cplus::helpers::readFromBuffer(buffer); - log4cplus::Logger logger - = log4cplus::Logger::getInstance(event.getLoggerName()); - logger.callAppenders(event); - } + return 0; } diff --git a/m4/ax_declspec.m4 b/m4/ax_declspec.m4 index 19672d390..e0a395f2d 100644 --- a/m4/ax_declspec.m4 +++ b/m4/ax_declspec.m4 @@ -48,9 +48,10 @@ AC_CACHE_CHECK([for __declspec(dllexport) and __declspec(dllimport)], AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ -#if defined (__clang__) +#if defined (__clang__) || defined (__HAIKU__) // Here the problem is that Clang only warns that it does not support -// __declspec(dllexport) but still compiles the executable. +// __declspec(dllexport) but still compiles the executable. GCC on Haiku OS +// suffers from the same problem. # error Please fail. And extra please fail. #else diff --git a/m4/ax_gcc_func_attribute.m4 b/m4/ax_gcc_func_attribute.m4 new file mode 100644 index 000000000..5ffe071d1 --- /dev/null +++ b/m4/ax_gcc_func_attribute.m4 @@ -0,0 +1,223 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE) +# +# DESCRIPTION +# +# This macro checks if the compiler supports one of GCC's function +# attributes; many other compilers also provide function attributes with +# the same syntax. Compiler warnings are used to detect supported +# attributes as unsupported ones are ignored by default so quieting +# warnings when using this macro will yield false positives. +# +# The ATTRIBUTE parameter holds the name of the attribute to be checked. +# +# If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_. +# +# The macro caches its result in the ax_cv_have_func_attribute_ +# variable. +# +# The macro currently supports the following function attributes: +# +# alias +# aligned +# alloc_size +# always_inline +# artificial +# cold +# const +# constructor +# constructor_priority for constructor attribute with priority +# deprecated +# destructor +# dllexport +# dllimport +# error +# externally_visible +# flatten +# format +# format_arg +# gnu_inline +# hot +# ifunc +# leaf +# malloc +# noclone +# noinline +# nonnull +# noreturn +# nothrow +# optimize +# pure +# unused +# used +# visibility +# warning +# warn_unused_result +# weak +# weakref +# +# Unsuppored function attributes will be tested with a prototype returning +# an int and not accepting any arguments and the result of the check might +# be wrong or meaningless so use with care. +# +# LICENSE +# +# Copyright (c) 2013 Gabriele Svelto +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [ + AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1]) + + AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + m4_case([$1], + [alias], [ + int foo( void ) { return 0; } + int bar( void ) __attribute__(($1("foo"))); + ], + [aligned], [ + int foo( void ) __attribute__(($1(32))); + ], + [alloc_size], [ + void *foo(int a) __attribute__(($1(1))); + ], + [always_inline], [ + inline __attribute__(($1)) int foo( void ) { return 0; } + ], + [artificial], [ + inline __attribute__(($1)) int foo( void ) { return 0; } + ], + [cold], [ + int foo( void ) __attribute__(($1)); + ], + [const], [ + int foo( void ) __attribute__(($1)); + ], + [constructor_priority], [ + int foo( void ) __attribute__((__constructor__(65535/2))); + ], + [constructor], [ + int foo( void ) __attribute__(($1)); + ], + [deprecated], [ + int foo( void ) __attribute__(($1(""))); + ], + [destructor], [ + int foo( void ) __attribute__(($1)); + ], + [dllexport], [ + __attribute__(($1)) int foo( void ) { return 0; } + ], + [dllimport], [ + int foo( void ) __attribute__(($1)); + ], + [error], [ + int foo( void ) __attribute__(($1(""))); + ], + [externally_visible], [ + int foo( void ) __attribute__(($1)); + ], + [flatten], [ + int foo( void ) __attribute__(($1)); + ], + [format], [ + int foo(const char *p, ...) __attribute__(($1(printf, 1, 2))); + ], + [format_arg], [ + char *foo(const char *p) __attribute__(($1(1))); + ], + [gnu_inline], [ + inline __attribute__(($1)) int foo( void ) { return 0; } + ], + [hot], [ + int foo( void ) __attribute__(($1)); + ], + [ifunc], [ + int my_foo( void ) { return 0; } + static int (*resolve_foo(void))(void) { return my_foo; } + int foo( void ) __attribute__(($1("resolve_foo"))); + ], + [leaf], [ + __attribute__(($1)) int foo( void ) { return 0; } + ], + [malloc], [ + void *foo( void ) __attribute__(($1)); + ], + [noclone], [ + int foo( void ) __attribute__(($1)); + ], + [noinline], [ + __attribute__(($1)) int foo( void ) { return 0; } + ], + [nonnull], [ + int foo(char *p) __attribute__(($1(1))); + ], + [noreturn], [ + void foo( void ) __attribute__(($1)); + ], + [nothrow], [ + int foo( void ) __attribute__(($1)); + ], + [optimize], [ + __attribute__(($1(3))) int foo( void ) { return 0; } + ], + [pure], [ + int foo( void ) __attribute__(($1)); + ], + [unused], [ + int foo( void ) __attribute__(($1)); + ], + [used], [ + int foo( void ) __attribute__(($1)); + ], + [visibility], [ + int foo_def( void ) __attribute__(($1("default"))); + int foo_hid( void ) __attribute__(($1("hidden"))); + int foo_int( void ) __attribute__(($1("internal"))); + int foo_pro( void ) __attribute__(($1("protected"))); + ], + [warning], [ + int foo( void ) __attribute__(($1(""))); + ], + [warn_unused_result], [ + int foo( void ) __attribute__(($1)); + ], + [weak], [ + int foo( void ) __attribute__(($1)); + ], + [weakref], [ + static int foo( void ) { return 0; } + static int bar( void ) __attribute__(($1("foo"))); + ], + [ + m4_warn([syntax], [Unsupported attribute $1, the test may fail]) + int foo( void ) __attribute__(($1)); + ] + )], []) + ], + dnl GCC doesn't exit with an error if an unknown attribute is + dnl provided but only outputs a warning, so accept the attribute + dnl only if no warning were issued. + [AS_IF([test -s conftest.err], + [AS_VAR_SET([ac_var], [no])], + [AS_VAR_SET([ac_var], [yes])])], + [AS_VAR_SET([ac_var], [no])]) + ]) + + AS_IF([test yes = AS_VAR_GET([ac_var])], + [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1, + [Define to 1 if the system has the `$1' function attribute])], []) + + AS_VAR_POPDEF([ac_var]) +]) diff --git a/m4/ax_gcc_var_attribute.m4 b/m4/ax_gcc_var_attribute.m4 new file mode 100644 index 000000000..4f60f6da1 --- /dev/null +++ b/m4/ax_gcc_var_attribute.m4 @@ -0,0 +1,141 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_gcc_var_attribute.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_GCC_VAR_ATTRIBUTE(ATTRIBUTE) +# +# DESCRIPTION +# +# This macro checks if the compiler supports one of GCC's variable +# attributes; many other compilers also provide variable attributes with +# the same syntax. Compiler warnings are used to detect supported +# attributes as unsupported ones are ignored by default so quieting +# warnings when using this macro will yield false positives. +# +# The ATTRIBUTE parameter holds the name of the attribute to be checked. +# +# If ATTRIBUTE is supported define HAVE_VAR_ATTRIBUTE_. +# +# The macro caches its result in the ax_cv_have_var_attribute_ +# variable. +# +# The macro currently supports the following variable attributes: +# +# aligned +# cleanup +# common +# nocommon +# deprecated +# mode +# packed +# tls_model +# unused +# used +# vector_size +# weak +# dllimport +# dllexport +# init_priority +# +# Unsuppored variable attributes will be tested against a global integer +# variable and without any arguments given to the attribute itself; the +# result of this check might be wrong or meaningless so use with care. +# +# LICENSE +# +# Copyright (c) 2013 Gabriele Svelto +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AC_DEFUN([AX_GCC_VAR_ATTRIBUTE], [ + AS_VAR_PUSHDEF([ac_var], [ax_cv_have_var_attribute_$1]) + + AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + m4_case([$1], + [aligned], [ + int foo __attribute__(($1(32))); + ], + [cleanup], [ + int bar(int *t) { return *t; }; + ], + [common], [ + int foo __attribute__(($1)); + ], + [nocommon], [ + int foo __attribute__(($1)); + ], + [deprecated], [ + int foo __attribute__(($1)) = 0; + ], + [mode], [ + long foo __attribute__(($1(word))); + ], + [packed], [ + struct bar { + int baz __attribute__(($1)); + }; + ], + [tls_model], [ + __thread int bar1 __attribute__(($1("global-dynamic"))); + __thread int bar2 __attribute__(($1("local-dynamic"))); + __thread int bar3 __attribute__(($1("initial-exec"))); + __thread int bar4 __attribute__(($1("local-exec"))); + ], + [unused], [ + int foo __attribute__(($1)); + ], + [used], [ + int foo __attribute__(($1)); + ], + [vector_size], [ + int foo __attribute__(($1(16))); + ], + [weak], [ + int foo __attribute__(($1)); + ], + [dllimport], [ + int foo __attribute__(($1)); + ], + [dllexport], [ + int foo __attribute__(($1)); + ], + [init_priority], [ + struct bar { bar() {} ~bar() {} }; + bar b __attribute__(($1(65535/2))); + ], + [ + m4_warn([syntax], [Unsupported attribute $1, the test may fail]) + int foo __attribute__(($1)); + ] + )], [ + m4_case([$1], + [cleanup], [ + int foo __attribute__(($1(bar))) = 0; + foo = foo + 1; + ], + [] + )]) + ], + dnl GCC doesn't exit with an error if an unknown attribute is + dnl provided but only outputs a warning, so accept the attribute + dnl only if no warning were issued. + [AS_IF([test -s conftest.err], + [AS_VAR_SET([ac_var], [no])], + [AS_VAR_SET([ac_var], [yes])])], + [AS_VAR_SET([ac_var], [no])]) + ]) + + AS_IF([test yes = AS_VAR_GET([ac_var])], + [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_VAR_ATTRIBUTE_$1), 1, + [Define to 1 if the system has the `$1' variable attribute])], []) + + AS_VAR_POPDEF([ac_var]) +]) diff --git a/m4/ax_macro_va_args.m4 b/m4/ax_macro_va_args.m4 index bf1df41fe..1150e2d94 100644 --- a/m4/ax_macro_va_args.m4 +++ b/m4/ax_macro_va_args.m4 @@ -16,6 +16,7 @@ AC_CACHE_CHECK([for C99 variadic macros], [ac_cv_c99_variadic_macros], [[ #include #include +#include ]], [[ using namespace std; @@ -48,6 +49,7 @@ AC_CACHE_CHECK([for GNU style variadic macros], [ac_cv_gnu_variadic_macros], [[ #include #include +#include ]], [[ using namespace std; diff --git a/m4/ax_tls_support.m4 b/m4/ax_tls_support.m4 index b410488d7..95cdc50bc 100644 --- a/m4/ax_tls_support.m4 +++ b/m4/ax_tls_support.m4 @@ -15,14 +15,20 @@ AC_CACHE_CHECK([for thread_local], [ac_cv_thread_local], AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ + // check that pointers to classes work as well + struct S { S () { } void foo () { } int member; }; + extern thread_local S * p_s; + thread_local S * p_s = 0; + extern thread_local int x; thread_local int * ptr = 0; int foo () { ptr = &x; return x; } thread_local int x = 1; ]], [[x = 2; - foo ();]])], - [ac_cv__thread_local=yes + foo (); + p_s = new S;]])], + [ac_cv_thread_local=yes ax_tls_support=yes], [ac_cv_thread_local=no], [ac_cv_thread_local=no]) @@ -43,6 +49,11 @@ AC_CACHE_CHECK([for __thread], [ac_cv__thread_keyword], [ #endif #endif + // check that pointers to classes work as well + struct S { S () { } void foo () { } int member; }; + extern __thread S * p_s; + __thread S * p_s = 0; + extern __thread int x; __thread int * ptr = 0; int foo () { ptr = &x; return x; } @@ -50,6 +61,7 @@ AC_CACHE_CHECK([for __thread], [ac_cv__thread_keyword], [ ]], [[x = 2; foo (); + p_s = new S; ]])], [ac_cv__thread_keyword=yes ax_tls_support=yes], @@ -71,6 +83,11 @@ AC_CACHE_CHECK([for __declspec(thread)], [ac_cv_declspec_thread], [ # error Please fail. And extra please fail. #else + // check that pointers to classes work as well + struct S { S () { } void foo () { } int member; }; + extern __declspec(thread) S * p_s; + __declspec(thread) S * p_s = 0; + extern __declspec(thread) int x; __declspec(thread) int * ptr = 0; int foo () { ptr = &x; return x; } @@ -78,7 +95,8 @@ And extra please fail. #endif ]], [[x = 2; - foo ();]])], + foo (); + p_s = new S;]])], [ac_cv_declspec_thread=yes ax_tls_support=yes], [ac_cv_declspec_thread=no], diff --git a/mingw-log4cplus.spec b/mingw-log4cplus.spec new file mode 100755 index 000000000..b7d5e03aa --- /dev/null +++ b/mingw-log4cplus.spec @@ -0,0 +1,125 @@ +Name: log4cplus +Version: 1.1.3 +Release: 1%{?dist} +Summary: log4cplus, C++ logging library + +License: Apache +Group: Development/Libraries +URL: http://log4cplus.sourceforge.net/ +Source0: http://downloads.sourceforge.net/project/log4cplus/log4cplus-stable/1.1.3/log4cplus-1.1.3.tar.gz + +BuildArch: noarch + +BuildRequires: mingw32-filesystem >= 95 +BuildRequires: mingw32-gcc +BuildRequires: mingw32-binutils +BuildRequires: mingw32-gettext +BuildRequires: mingw32-win-iconv +BuildRequires: mingw32-zlib + +BuildRequires: mingw64-filesystem >= 95 +BuildRequires: mingw64-gcc +BuildRequires: mingw64-binutils +BuildRequires: mingw64-gettext +BuildRequires: mingw64-win-iconv +BuildRequires: mingw64-zlib + +%description +log4cplus is a simple to use C++ logging API providing thread-safe, +flexible, and arbitrarily granular control over log management and +configuration. It is modeled after the Java log4j API. + +# Strip removes essential information from the .dll.a file, so disable it +%define __strip /bin/true + +# Win32 +%package -n mingw32-log4cplus +Summary: MinGW compiled log4cplus library for the Win32 target + +%description -n mingw32-log4cplus +MinGW compiled log4cplus library for the Win32 target + +%package -n mingw32-log4cplus-devel +Summary: Headers for the MinGW compiled log4cplus library for the Win32 target + +%description -n mingw32-log4cplus-devel +Headers for the MinGW compiled log4cplus library for the Win32 target + +# Win64 +%package -n mingw64-log4cplus +Summary: MinGW compiled log4cplus library for the Win64 target + +%description -n mingw64-log4cplus +MinGW compiled log4cplus library for the Win64 target + +%package -n mingw64-log4cplus-devel +Summary: Headers for the MinGW compiled log4cplus library for the Win64 target + +%description -n mingw64-log4cplus-devel +Headers for the MinGW compiled log4cplus library for the Win64 target + +%prep +%setup -q -n log4cplus-%{version} + +%build +%mingw_configure +%mingw_make %{?_smp_mflags} + +%install +rm -rf $RPM_BUILD_ROOT +%mingw_make_install DESTDIR=$RPM_BUILD_ROOT +find $RPM_BUILD_ROOT -name "*.la" -delete +find $RPM_BUILD_ROOT -name "stamp-*" -delete +find $RPM_BUILD_ROOT -name "*.in" -delete +find $RPM_BUILD_ROOT -name macosx.h -delete +find $RPM_BUILD_ROOT -name windowsh-inc.h -delete +find $RPM_BUILD_ROOT -name cygwin-win32.h -delete +find $RPM_BUILD_ROOT -name syncprims-win32.h -delete +# find $RPM_BUILD_ROOT -name liblog4cplus.a -delete +find $RPM_BUILD_ROOT -name .svn -type d -exec find '{}' -delete \; + +# Win32 +%files -n mingw32-log4cplus +%{mingw32_bindir}/lib*.dll + +%files -n mingw32-log4cplus-devel +%defattr(-,root,root,755) +%{mingw32_includedir}/log4cplus/*.h +%{mingw32_includedir}/log4cplus/helpers/*.h +%{mingw32_includedir}/log4cplus/spi/*.h +%{mingw32_includedir}/log4cplus/boost/*.hxx +%{mingw32_includedir}/log4cplus/config.hxx +%{mingw32_includedir}/log4cplus/config/defines.hxx +%{mingw32_includedir}/log4cplus/config/win32.h +%{mingw32_includedir}/log4cplus/internal/*.h +%{mingw32_includedir}/log4cplus/thread/impl/*.h +%{mingw32_includedir}/log4cplus/thread/*.h +%attr(644,root,root) +%{mingw32_libdir}/*.dll.a +%{mingw32_libdir}/liblog4cplus.a +%{mingw32_libdir}/pkgconfig/log4cplus.pc + +# Win64 +%files -n mingw64-log4cplus +%{mingw64_bindir}/lib*.dll + +%files -n mingw64-log4cplus-devel +%defattr(-,root,root,755) +%{mingw64_includedir}/log4cplus/*.h +%{mingw64_includedir}/log4cplus/helpers/*.h +%{mingw64_includedir}/log4cplus/spi/*.h +%{mingw64_includedir}/log4cplus/boost/*.hxx +%{mingw64_includedir}/log4cplus/config.hxx +%{mingw64_includedir}/log4cplus/config/defines.hxx +%{mingw64_includedir}/log4cplus/config/win32.h +%{mingw64_includedir}/log4cplus/internal/*.h +%{mingw64_includedir}/log4cplus/thread/impl/*.h +%{mingw64_includedir}/log4cplus/thread/*.h +%attr(644,root,root) +%{mingw64_libdir}/*.dll.a +%{mingw64_libdir}/liblog4cplus.a +%{mingw64_libdir}/pkgconfig/log4cplus.pc + +%changelog +* Wed Aug 14 2013 John Smits - 1.1.1-1 +- Initial release diff --git a/msvc10/log4cplus.props b/msvc10/log4cplus.props index 5ca303bc3..1094604f3 100755 --- a/msvc10/log4cplus.props +++ b/msvc10/log4cplus.props @@ -9,7 +9,7 @@ ..\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;INSIDE_LOG4CPLUS;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;NTDDI_VERSION=0x05010200;INSIDE_LOG4CPLUS;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) true $(IntDir)$(ProjectName).pch $(IntDir) diff --git a/msvc10/log4cplus.sln b/msvc10/log4cplus.sln index 9f28fc29a..4d38577ca 100755 --- a/msvc10/log4cplus.sln +++ b/msvc10/log4cplus.sln @@ -49,6 +49,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CLFSAppender", "CLFSAppende EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Qt4DebugAppender", "Qt4DebugAppender.vcxproj", "{18B64AA1-A2F7-46BE-8D48-7882AA471FA9}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "propertyconfig_test", "tests\propertyconfig_test.vcxproj", "{44D4D0A3-FAFA-4134-9806-BCB830594E28}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug_Unicode|Win32 = Debug_Unicode|Win32 @@ -381,6 +383,22 @@ Global {18B64AA1-A2F7-46BE-8D48-7882AA471FA9}.Release|Win32.Build.0 = Release|Win32 {18B64AA1-A2F7-46BE-8D48-7882AA471FA9}.Release|x64.ActiveCfg = Release|x64 {18B64AA1-A2F7-46BE-8D48-7882AA471FA9}.Release|x64.Build.0 = Release|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug_Unicode|Win32.ActiveCfg = Debug_Unicode|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug_Unicode|Win32.Build.0 = Debug_Unicode|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug_Unicode|x64.ActiveCfg = Debug_Unicode|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug_Unicode|x64.Build.0 = Debug_Unicode|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug|Win32.ActiveCfg = Debug|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug|Win32.Build.0 = Debug|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug|x64.ActiveCfg = Debug|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug|x64.Build.0 = Debug|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release_Unicode|Win32.ActiveCfg = Release_Unicode|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release_Unicode|Win32.Build.0 = Release_Unicode|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release_Unicode|x64.ActiveCfg = Release_Unicode|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release_Unicode|x64.Build.0 = Release_Unicode|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release|Win32.ActiveCfg = Release|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release|Win32.Build.0 = Release|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release|x64.ActiveCfg = Release|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -401,5 +419,6 @@ Global {F83D31E0-B607-4D3E-AF53-BA2A19BE17ED} = {92DEA81D-81ED-4283-BBC7-41975647F69E} {7EFABA06-71CD-498F-BF10-C41A7D2DCF3B} = {92DEA81D-81ED-4283-BBC7-41975647F69E} {AE4CF05D-9770-4BF2-BB73-1DA37E2A1508} = {92DEA81D-81ED-4283-BBC7-41975647F69E} + {44D4D0A3-FAFA-4134-9806-BCB830594E28} = {92DEA81D-81ED-4283-BBC7-41975647F69E} EndGlobalSection EndGlobal diff --git a/msvc10/log4cplusS.vcxproj b/msvc10/log4cplusS.vcxproj index 5981bf5f3..0a0519dac 100755 --- a/msvc10/log4cplusS.vcxproj +++ b/msvc10/log4cplusS.vcxproj @@ -649,16 +649,7 @@ %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) - - true - true - true - true - true - true - true - true - + @@ -1016,16 +1007,7 @@ - - true - true - true - true - true - true - true - true - + diff --git a/msvc10/tests/propertyconfig_test.vcxproj b/msvc10/tests/propertyconfig_test.vcxproj new file mode 100755 index 000000000..283121de8 --- /dev/null +++ b/msvc10/tests/propertyconfig_test.vcxproj @@ -0,0 +1,463 @@ + + + + + Debug_Unicode + Win32 + + + Debug_Unicode + x64 + + + Debug + Win32 + + + Debug + x64 + + + Release_Unicode + Win32 + + + Release_Unicode + x64 + + + Release + Win32 + + + Release + x64 + + + + {44D4D0A3-FAFA-4134-9806-BCB830594E28} + + + + Application + false + Unicode + true + + + Application + false + Unicode + + + Application + false + MultiByte + + + Application + false + MultiByte + + + Application + false + Unicode + true + + + Application + false + Unicode + + + Application + false + MultiByte + + + Application + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + true + true + false + false + true + true + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + $(OutDir)propertyconfig_test.tlb + + + + + Disabled + %(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + $(IntDir)propertyconfig_test.pch + true + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplusd.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + true + $(OutDir)propertyconfig_test.pdb + Console + MachineX86 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + X64 + $(OutDir)propertyconfig_test.tlb + + + + + Disabled + %(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + $(IntDir)propertyconfig_test.pch + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplusd.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + true + $(OutDir)propertyconfig_test.pdb + Console + MachineX64 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + $(OutDir)propertyconfig_test.tlb + + + + + MaxSpeed + OnlyExplicitInline + %(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + $(IntDir)propertyconfig_test.pch + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplus.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + $(OutDir)propertyconfig_test.pdb + Console + MachineX86 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + X64 + $(OutDir)propertyconfig_test.tlb + + + + + MaxSpeed + OnlyExplicitInline + %(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + $(IntDir)propertyconfig_test.pch + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplus.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + $(OutDir)propertyconfig_test.pdb + Console + MachineX64 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + $(OutDir)propertyconfig_test.tlb + + + + + Disabled + %(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + $(IntDir)propertyconfig_test.pch + true + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplusud.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + true + $(OutDir)propertyconfig_test.pdb + Console + MachineX86 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + X64 + $(OutDir)propertyconfig_test.tlb + + + + + Disabled + %(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + $(IntDir)propertyconfig_test.pch + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplusud.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + true + $(OutDir)propertyconfig_test.pdb + Console + MachineX64 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + $(OutDir)propertyconfig_test.tlb + + + + + MaxSpeed + OnlyExplicitInline + %(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + $(IntDir)propertyconfig_test.pch + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplusu.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + $(OutDir)propertyconfig_test.pdb + Console + MachineX86 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + X64 + $(OutDir)propertyconfig_test.tlb + + + + + MaxSpeed + OnlyExplicitInline + %(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + $(IntDir)propertyconfig_test.pch + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplusu.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + $(OutDir)propertyconfig_test.pdb + Console + MachineX64 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + + + {917836a4-0ddc-47be-b930-1b3bfdf6c940} + false + + + + + + \ No newline at end of file diff --git a/msvc10/tests/propertyconfig_test.vcxproj.filters b/msvc10/tests/propertyconfig_test.vcxproj.filters new file mode 100755 index 000000000..67cef8e30 --- /dev/null +++ b/msvc10/tests/propertyconfig_test.vcxproj.filters @@ -0,0 +1,14 @@ + + + + + {34631475-FC1B-4856-9E3F-95323D5701B7} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + + + Source Files + + + \ No newline at end of file diff --git a/qt4debugappender/CMakeLists.txt b/qt4debugappender/CMakeLists.txt index 87e682c5f..17ad56902 100644 --- a/qt4debugappender/CMakeLists.txt +++ b/qt4debugappender/CMakeLists.txt @@ -26,9 +26,9 @@ if (WIN32) endif () install (TARGETS ${qt4debugappender} - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin) + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install (FILES ../include/log4cplus/qt4debugappender.h - DESTINATION include/log4cplus) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus) diff --git a/qt4debugappender/Makefile.am b/qt4debugappender/Makefile.am index 60fd62b2b..c2cae6d6a 100644 --- a/qt4debugappender/Makefile.am +++ b/qt4debugappender/Makefile.am @@ -16,10 +16,24 @@ INCLUDES_SRC = \ LIB_SRC = $(INCLUDES_SRC) \ qt4debugappender.cxx +if ENABLE_VERSION_INFO_OPTION +VERSION_INFO_OPTION=-version-info @LT_VERSION@ +else +VERSION_INFO_OPTION=-avoid-version +endif + +if ENABLE_RELEASE_OPTION +RELEASE_OPTION=-release @LT_RELEASE@ +else +RELEASE_OPTION= +endif + +LOG4CPLUS_VERSION_LT_FLAGS=$(VERSION_INFO_OPTION) $(RELEASE_OPTION) + liblog4cplusqt4debugappender_la_SOURCES = $(LIB_SRC) liblog4cplusqt4debugappender_la_LIBADD = $(top_builddir)/src/liblog4cplus.la liblog4cplusqt4debugappender_la_LDFLAGS = -no-undefined \ - -version-info @LT_VERSION@ -release @LT_RELEASE@ \ + $(LOG4CPLUS_VERSION_LT_FLAGS) \ @QT_LIBS@ diff --git a/qt4debugappender/Makefile.in b/qt4debugappender/Makefile.in index 89e5710d2..e16da01be 100644 --- a/qt4debugappender/Makefile.in +++ b/qt4debugappender/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -74,7 +74,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -195,6 +198,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ @@ -303,10 +307,15 @@ INCLUDES_SRC = \ LIB_SRC = $(INCLUDES_SRC) \ qt4debugappender.cxx +@ENABLE_VERSION_INFO_OPTION_FALSE@VERSION_INFO_OPTION = -avoid-version +@ENABLE_VERSION_INFO_OPTION_TRUE@VERSION_INFO_OPTION = -version-info @LT_VERSION@ +@ENABLE_RELEASE_OPTION_FALSE@RELEASE_OPTION = +@ENABLE_RELEASE_OPTION_TRUE@RELEASE_OPTION = -release @LT_RELEASE@ +LOG4CPLUS_VERSION_LT_FLAGS = $(VERSION_INFO_OPTION) $(RELEASE_OPTION) liblog4cplusqt4debugappender_la_SOURCES = $(LIB_SRC) liblog4cplusqt4debugappender_la_LIBADD = $(top_builddir)/src/liblog4cplus.la liblog4cplusqt4debugappender_la_LDFLAGS = -no-undefined \ - -version-info @LT_VERSION@ -release @LT_RELEASE@ \ + $(LOG4CPLUS_VERSION_LT_FLAGS) \ @QT_LIBS@ all: all-am diff --git a/qt4debugappender/qt4debugappender.cxx b/qt4debugappender/qt4debugappender.cxx index ac03f41e7..e9f6304af 100644 --- a/qt4debugappender/qt4debugappender.cxx +++ b/qt4debugappender/qt4debugappender.cxx @@ -4,7 +4,7 @@ // Author: Vaclav Zeman // // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/scripts/doautoreconf.sh b/scripts/doautoreconf.sh index 9063d6392..1523f65ea 100755 --- a/scripts/doautoreconf.sh +++ b/scripts/doautoreconf.sh @@ -1,6 +1,6 @@ #!/bin/sh -export AUTOMAKE_SUFFIX=-1.12.3 +export AUTOMAKE_SUFFIX=-1.12.6 export AUTOCONF_SUFFIX=-2.69 export LIBTOOL_SUFFIX=-2.4.2 diff --git a/scripts/prepare_dist_from_bzr.sh b/scripts/prepare_dist_from_git.sh similarity index 77% rename from scripts/prepare_dist_from_bzr.sh rename to scripts/prepare_dist_from_git.sh index 69f494ffe..1e3c6ebd7 100755 --- a/scripts/prepare_dist_from_bzr.sh +++ b/scripts/prepare_dist_from_git.sh @@ -6,7 +6,7 @@ THIS_SCRIPT=`basename "$0"` function usage { - echo "$THIS_SCRIPT []" + echo "$THIS_SCRIPT [] []" } function gpg_sign @@ -32,24 +32,26 @@ function find_archiver command_exists "$1" && echo "$1" || echo ':' } -BZR_URL="$1" -if [[ -z "$BZR_URL" ]] ; then +GIT_URL="$1" +if [[ -z "$GIT_URL" ]] ; then usage exit 1 fi -if [[ -z "$2" ]] ; then - BZR_URL=${BZR_URL%/} - BZR_BASE_URL=${BZR_URL%/*} - BZR_BRANCH_NAME=${BZR_URL#$BZR_BASE_URL} - BZR_BRANCH_NAME=${BZR_BRANCH_NAME#/} - SRC_DIR=$BZR_BRANCH_NAME +GIT_BRANCH="$2" +if [[ -z "$GIT_BRANCH" ]] ; then + usage + exit 1 +fi + +if [[ -z "$3" ]] ; then + SRC_DIR=$GIT_BRANCH else - SRC_DIR="$2" + SRC_DIR="$3" fi -if [[ ! -z "$3" ]] ; then - GPG_KEY="$3" +if [[ ! -z "$4" ]] ; then + GPG_KEY="$4" else GPG_KEY= fi @@ -71,11 +73,12 @@ BZIP2=${BZIP2:-$(find_archiver bzip2)} GZIP=${GZIP:-$(find_archiver gzip)} SEVENZA=${SEVENZA:-$(find_archiver 7za)} LRZIP=${LRZIP:-$(find_archiver lrzip)} -BZR=${BZR:-bzr} +GIT=${GIT:-git} GPG=${GPG:-gpg} -$BZR export --per-file-timestamps -v "$SRC_DIR" "$BZR_URL" -$BZR version-info "$BZR_URL" >"$SRC_DIR/REVISION" +$GIT clone -v --depth=1 "$GIT_URL" -b "$GIT_BRANCH" "$SRC_DIR" +(cd "$SRC_DIR" && $GIT rev-parse @ >REVISION) +rm -rf "$SRC_DIR/.git" pushd "$SRC_DIR" $SHELL ./scripts/fix-timestamps.sh @@ -85,7 +88,7 @@ $SEVENZA a -t7z "$DEST_DIR/$SRC_DIR".7z "$SRC_DIR" >/dev/null \ & $SEVENZA a -tzip "$DEST_DIR/$SRC_DIR".zip "$SRC_DIR" >/dev/null TAR_FILE="$SRC_DIR".tar -$TAR -cf "$TAR_FILE" "$SRC_DIR" +$TAR -c --format=posix -f "$TAR_FILE" "$SRC_DIR" $XZ -e -c "$TAR_FILE" >"$DEST_DIR/$TAR_FILE".xz \ & $BZIP2 -9 -c "$TAR_FILE" >"$DEST_DIR/$TAR_FILE".bz2 \ diff --git a/scripts/propagate-version.pl b/scripts/propagate-version.pl new file mode 100755 index 000000000..2a12d2374 --- /dev/null +++ b/scripts/propagate-version.pl @@ -0,0 +1,110 @@ +#!perl + +# Enable in-place editing +BEGIN +{ + $^I = '.bak'; +} + +use strict; +use feature 'unicode_strings'; + +# parse line from include/log4cplus/version.h + +open (my $fh, "<", "include/log4cplus/version.h") + or die $!; + +my ($major, $minor, $point, $version); +while (my $line = <$fh>) +{ + if ($line =~ m/\s* # \s* define \s+ LOG4CPLUS_VERSION \s+ + LOG4CPLUS_MAKE_VERSION \s* \( + \s* (\d+) \s* , \s* (\d+) \s* , \s* (\d+) \s* \)/x) + { + ($major, $minor, $point) = ($1, $2, $3); + $version = "$major.$minor.$point"; + print "version: ", $version, "\n"; + last; + } +} + +close $fh; + +# parse SO version from configure.ac + +open (my $fh2, "<", "configure.ac") + or die $!; + +my ($so_current, $so_revision, $so_age, $so_current_adjusted); +while (my $line = <$fh2>) +{ + if ($line =~ m/\s* LT_VERSION= \s* + (\d+) \s* : \s* (\d+) \s* : \s* (\d+) \s*/x) + { + ($so_current, $so_revision, $so_age) = ($1, $2, $3); + print +("SO version: ", $so_current, ".", $so_revision, ".", $so_age, + "\n"); + $so_current_adjusted = $so_current - $so_age; + print +("MingGW/Cygwin version: ", $major, "-", $minor, "-", + $so_current_adjusted, "\n"); + last; + } +} + +close $fh2; + +# edit configure.ac + +{ + local $^I = ".bak"; + local @ARGV = ("configure.ac"); + while (my $line = <>) + { + $line =~ s/(.*AC_INIT\(.*\[)(\d+(?:\.\d+(?:\.\d+)?)?)(\].*)/$1$version$3/x; + $line =~ s/(.*LT_RELEASE=)(.*)/$1$major.$minor/x; + print $line; + } + + local @ARGV = ("docs/doxygen.config"); + while (my $line = <>) + { + $line =~ s/(\s* PROJECT_NUMBER \s* = \s*)(.*)/$1$version/x; + $line =~ s/(\s* OUTPUT_DIRECTORY \s* = \s*)(.*)/$1log4cplus-$version\/docs/x; + print $line; + } + + local @ARGV = ("docs/webpage_doxygen.config"); + while (my $line = <>) + { + $line =~ s/(\s* PROJECT_NUMBER \s* = \s*)(.*)/$1$version/x; + $line =~ s/(\s* OUTPUT_DIRECTORY \s* = \s*)(.*)/$1webpage_docs-$version/x; + print $line; + } + + local @ARGV = ("log4cplus.spec", "mingw-log4cplus.spec"); + while (my $line = <>) + { + $line =~ s/(Version: \s*)(.*)/$1$version/x; + if ($line =~ /Source\d*:/x) + { + $line =~ s/(\d+\.\d+\.\d+)/$version/gx; + } + print $line; + } + + local @ARGV = ("cygport/log4cplus.cygport"); + while (my $line = <>) + { + $line =~ s/(\s* VERSION \s* = \s*)(\d+\.\d+\.\d+)(-.+)?/$1$version$3/x + || $line =~ s/\d+ ([._\-]) \d+ ([._\-]) \d+ + /$major$1$minor$2$so_current_adjusted/gx; + print $line; + } + + local @ARGV = ("CMakeLists.txt"); + while (my $line = <>) + { + $line =~ s/(set\s*\(log4cplus_soversion\s*)\d+(\))/$1$so_current$2/x; + print $line; + } +} diff --git a/scripts/update_copyrights.sh b/scripts/update_copyrights.sh new file mode 100755 index 000000000..aa0ac8145 --- /dev/null +++ b/scripts/update_copyrights.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +FILES=`find . \( \( -not -path './objdir*' \) -and \( -name '*.h' -o -name '*.hxx' -o -name '*.cxx' \) \)` +perl -wn -i.bak -e ' +use strict; + +my $YEAR = 2013; + +my $sep = qr/[\s,;]/; +if (/copyright/i) +{ + print STDERR; +} +if (/(copyright $sep+ (?:\(c\) $sep+)? (?:\d{4})) (\s* - \s*) (\d{4})/ixgp) +{ + #print STDERR "($1) ($2) ($3)\n"; + #print STDERR "${^PREMATCH}$1$2$YEAR${^POSTMATCH}"; + print "${^PREMATCH}$1$2$YEAR${^POSTMATCH}"; +} +elsif (/(copyright $sep+ (?:\(c\) $sep+)? (\d{4}))/ixgp) +{ + #print STDERR "($1)\n"; + #print STDERR "${^PREMATCH}$1-$YEAR${^POSTMATCH}"; + print "${^PREMATCH}$1-$YEAR${^POSTMATCH}"; +} +else +{ + print; +} +' $FILES diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3f70a05a6..43e034f88 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -68,6 +68,19 @@ endif () if (UNICODE) add_definitions (-DUNICODE -D_UNICODE -UMBCS -U_MBCS) endif (UNICODE) +if (WIN32) + add_definitions (-DMINGW_HAS_SECURE_API=1) + add_definitions (-D_WIN32_WINNT=${_WIN32_WINNT}) + add_definitions (-DNTDDI_VERSION=${NTDDI_VERSION}) + + if (BUILD_SHARED_LIBS) + set(log4cplus_build_shared 1) + else () + set(log4cplus_build_shared 0) + endif () + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/log4cplus.rc.in ${CMAKE_CURRENT_BINARY_DIR}/log4cplus.rc @ONLY) + list(APPEND log4cplus_sources ${CMAKE_CURRENT_BINARY_DIR}/log4cplus.rc) +endif (WIN32) add_library (${log4cplus} ${log4cplus_sources}) @@ -92,10 +105,16 @@ if (LOG4CPLUS_WITH_ICONV AND LIBICONV) endif () target_link_libraries (${log4cplus} ${log4cplus_LIBS}) -set_target_properties (${log4cplus} PROPERTIES - VERSION "${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}" - SOVERSION "${log4cplus_soversion}" - COMPILE_FLAGS "-DINSIDE_LOG4CPLUS") +if (ANDROID) + # Android does not seem to have SO version support. + set_target_properties (${log4cplus} PROPERTIES + COMPILE_FLAGS "-DINSIDE_LOG4CPLUS") +else () + set_target_properties (${log4cplus} PROPERTIES + VERSION "${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}" + SOVERSION "${log4cplus_soversion}" + COMPILE_FLAGS "-DINSIDE_LOG4CPLUS") +endif () if (WIN32) set_target_properties (${log4cplus} PROPERTIES @@ -103,9 +122,9 @@ if (WIN32) target_link_libraries (${log4cplus} ws2_32 advapi32) endif () -install(TARGETS ${log4cplus} LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin) +install(TARGETS ${log4cplus} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES ../include/log4cplus/appender.h ../include/log4cplus/asyncappender.h @@ -135,10 +154,10 @@ install(FILES ../include/log4cplus/appender.h ../include/log4cplus/version.h ../include/log4cplus/win32debugappender.h ../include/log4cplus/win32consoleappender.h - DESTINATION include/log4cplus ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus ) install(FILES ../include/log4cplus/boost/deviceappender.hxx - DESTINATION include/log4cplus/boost ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/boost ) install(FILES ../include/log4cplus/helpers/appenderattachableimpl.h @@ -156,12 +175,12 @@ install(FILES ../include/log4cplus/helpers/appenderattachableimpl.h ../include/log4cplus/helpers/stringhelper.h ../include/log4cplus/helpers/thread-config.h ../include/log4cplus/helpers/timehelper.h - DESTINATION include/log4cplus/helpers ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/helpers ) install(FILES ../include/log4cplus/internal/env.h ../include/log4cplus/internal/internal.h ../include/log4cplus/internal/socket.h - DESTINATION include/log4cplus/internal ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/internal ) install(FILES ../include/log4cplus/spi/appenderattachable.h ../include/log4cplus/spi/factory.h @@ -171,7 +190,7 @@ install(FILES ../include/log4cplus/spi/appenderattachable.h ../include/log4cplus/spi/loggingevent.h ../include/log4cplus/spi/objectregistry.h ../include/log4cplus/spi/rootlogger.h - DESTINATION include/log4cplus/spi ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/spi ) install(FILES ../include/log4cplus/thread/impl/syncprims-impl.h # ../include/log4cplus/thread/impl/syncprims-pmsm.h @@ -179,16 +198,15 @@ install(FILES ../include/log4cplus/thread/impl/syncprims-impl.h ../include/log4cplus/thread/impl/syncprims-win32.h ../include/log4cplus/thread/impl/threads-impl.h ../include/log4cplus/thread/impl/tls.h - DESTINATION include/log4cplus/thread/impl ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/thread/impl ) install(FILES ../include/log4cplus/thread/syncprims-pub-impl.h ../include/log4cplus/thread/syncprims.h ../include/log4cplus/thread/threads.h - DESTINATION include/log4cplus/thread ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/thread ) install(FILES ../include/log4cplus/config/macosx.h ../include/log4cplus/config/win32.h ../include/log4cplus/config/windowsh-inc.h ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx - DESTINATION include/log4cplus/config ) - + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/config ) diff --git a/src/Makefile.am b/src/Makefile.am index 9d8214263..6923779aa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -142,5 +142,21 @@ LIB_SRC = $(SINGLE_THREADED_SRC) liblog4cplus_la_SOURCES = $(LIB_SRC) +if ENABLE_VERSION_INFO_OPTION +VERSION_INFO_OPTION=-version-info @LT_VERSION@ +else +VERSION_INFO_OPTION=-avoid-version +endif + +if ENABLE_RELEASE_OPTION +RELEASE_OPTION=-release @LT_RELEASE@ +else +RELEASE_OPTION= +endif + +LOG4CPLUS_VERSION_LT_FLAGS=$(VERSION_INFO_OPTION) $(RELEASE_OPTION) + #liblog4cplus_a_LIBADD = @LIBOBJS@ @ALLOCA@ -liblog4cplus_la_LDFLAGS = -no-undefined -version-info @LT_VERSION@ -release @LT_RELEASE@ +liblog4cplus_la_LDFLAGS = -no-undefined \ + $(LOG4CPLUS_VERSION_LT_FLAGS) \ + $(LOG4CPLUS_AIX_XLC_LDFLAGS) diff --git a/src/Makefile.in b/src/Makefile.in index cb8e3eb1a..602785c76 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -74,7 +74,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -207,6 +210,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ @@ -439,9 +443,17 @@ SINGLE_THREADED_SRC = \ LIB_SRC = $(SINGLE_THREADED_SRC) liblog4cplus_la_SOURCES = $(LIB_SRC) +@ENABLE_VERSION_INFO_OPTION_FALSE@VERSION_INFO_OPTION = -avoid-version +@ENABLE_VERSION_INFO_OPTION_TRUE@VERSION_INFO_OPTION = -version-info @LT_VERSION@ +@ENABLE_RELEASE_OPTION_FALSE@RELEASE_OPTION = +@ENABLE_RELEASE_OPTION_TRUE@RELEASE_OPTION = -release @LT_RELEASE@ +LOG4CPLUS_VERSION_LT_FLAGS = $(VERSION_INFO_OPTION) $(RELEASE_OPTION) #liblog4cplus_a_LIBADD = @LIBOBJS@ @ALLOCA@ -liblog4cplus_la_LDFLAGS = -no-undefined -version-info @LT_VERSION@ -release @LT_RELEASE@ +liblog4cplus_la_LDFLAGS = -no-undefined \ + $(LOG4CPLUS_VERSION_LT_FLAGS) \ + $(LOG4CPLUS_AIX_XLC_LDFLAGS) + all: all-am .SUFFIXES: diff --git a/src/appender.cxx b/src/appender.cxx index 1c88f916c..56f6f9f02 100644 --- a/src/appender.cxx +++ b/src/appender.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -207,7 +207,16 @@ Appender::Appender(const log4cplus::helpers::Properties & properties) Appender::~Appender() -{ } +{ + helpers::LogLog & loglog = helpers::getLogLog (); + + loglog.debug(LOG4CPLUS_TEXT("Destroying appender named [") + name + + LOG4CPLUS_TEXT("].")); + + if (! closed) + loglog.error ( + LOG4CPLUS_TEXT ("Derived Appender did not call destructorImpl().")); +} @@ -218,13 +227,10 @@ Appender::~Appender() void Appender::destructorImpl() { - helpers::getLogLog().debug( LOG4CPLUS_TEXT("Destroying appender named [") - + name - + LOG4CPLUS_TEXT("].")); - - // An appender might be closed then destroyed. There is no - // point in closing twice. - if(closed) + // An appender might be closed then destroyed. There is no point + // in closing twice. It can actually be a wrong thing to do, e.g., + // files get rolled more than once. + if (closed) return; close(); @@ -232,6 +238,11 @@ Appender::destructorImpl() } +bool Appender::isClosed() const +{ + return closed; +} + void Appender::doAppend(const log4cplus::spi::InternalLoggingEvent& event) diff --git a/src/appenderattachableimpl.cxx b/src/appenderattachableimpl.cxx index 7eb6953a5..8ec908411 100644 --- a/src/appenderattachableimpl.cxx +++ b/src/appenderattachableimpl.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/asyncappender.cxx b/src/asyncappender.cxx index c30c5eb61..d0f239326 100644 --- a/src/asyncappender.cxx +++ b/src/asyncappender.cxx @@ -1,15 +1,15 @@ -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. -// +// Copyright (C) 2009-2016, Vaclav Haisman. All rights reserved. +// // Redistribution and use in source and binary forms, with or without modifica- // tion, 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 ``AS IS'' AND ANY EXPRESSED 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 @@ -100,6 +100,7 @@ AsyncAppender::AsyncAppender (SharedAppenderPtr const & app, AsyncAppender::AsyncAppender (helpers::Properties const & props) + : Appender (props) { tstring const & appender_name ( props.getProperty (LOG4CPLUS_TEXT ("Appender"))); @@ -155,11 +156,21 @@ AsyncAppender::init_queue_thread (unsigned queue_len) void AsyncAppender::close () { - unsigned ret = queue->signal_exit (); - if (ret & (thread::Queue::ERROR_BIT | thread::Queue::ERROR_AFTER)) - getErrorHandler ()->error ( - LOG4CPLUS_TEXT ("Error in AsyncAppender::close")); - queue_thread->join (); + if (queue) + { + unsigned ret = queue->signal_exit (); + if (ret & (thread::Queue::ERROR_BIT | thread::Queue::ERROR_AFTER)) + getErrorHandler ()->error ( + LOG4CPLUS_TEXT ("Error in AsyncAppender::close")); + } + + if (queue_thread && queue_thread->isRunning ()) + queue_thread->join (); + + removeAllAppenders(); + + queue_thread = 0; + queue = 0; } diff --git a/src/clfsappender.cxx b/src/clfsappender.cxx index 06a406263..a17c353c7 100644 --- a/src/clfsappender.cxx +++ b/src/clfsappender.cxx @@ -4,7 +4,7 @@ // Author: Vaclav Zeman // // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/clogger.cxx b/src/clogger.cxx index f8578ffad..6fe7e3838 100644 --- a/src/clogger.cxx +++ b/src/clogger.cxx @@ -4,7 +4,7 @@ // Author: Jens Rehsack // // -// Copyright 2011 Jens Rehsack & Tad E. Smith +// Copyright 2011-2013 Jens Rehsack & Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -145,11 +145,18 @@ log4cplus_logger_log(const log4cplus_char_t *name, loglevel_t ll, if( logger.isEnabledFor(ll) ) { - std::va_list ap; - va_start(ap, msgfmt); + const tchar * msg = 0; snprintf_buf buf; - const tchar * msg = buf.print_va_list(msgfmt, ap); - va_end(ap); + std::va_list ap; + + do + { + va_start(ap, msgfmt); + retval = buf.print_va_list(msg, msgfmt, ap); + va_end(ap); + } + while (retval == -1); + logger.forcedLog(ll, msg); } @@ -164,19 +171,26 @@ log4cplus_logger_log(const log4cplus_char_t *name, loglevel_t ll, } LOG4CPLUS_EXPORT int -log4cplus_logger_force_log(const log4cplus_char_t *name, loglevel_t ll, const log4cplus_char_t *msgfmt, ...) +log4cplus_logger_force_log(const log4cplus_char_t *name, loglevel_t ll, + const log4cplus_char_t *msgfmt, ...) { int retval = -1; try { Logger logger = name ? Logger::getInstance(name) : Logger::getRoot(); - - std::va_list ap; - va_start(ap, msgfmt); + const tchar * msg = 0; snprintf_buf buf; - const tchar * msg = buf.print_va_list(msgfmt, ap); - va_end(ap); + std::va_list ap; + + do + { + va_start(ap, msgfmt); + retval = buf.print_va_list(msg, msgfmt, ap); + va_end(ap); + } + while (retval == -1); + logger.forcedLog(ll, msg); retval = 0; diff --git a/src/configurator.cxx b/src/configurator.cxx index 5fbab28f3..dcaf74ad6 100644 --- a/src/configurator.cxx +++ b/src/configurator.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -289,8 +289,7 @@ PropertyConfigurator::configure() helpers::getLogLog ().setQuietMode (quiet_mode); bool disable_override = false; - if (properties.getBool (disable_override, - LOG4CPLUS_TEXT ("disableOverride"))) + properties.getBool (disable_override, LOG4CPLUS_TEXT ("disableOverride")); initializeLog4cplus(); configureAppenders(); diff --git a/src/consoleappender.cxx b/src/consoleappender.cxx index 021d3d984..ff8b01c3e 100644 --- a/src/consoleappender.cxx +++ b/src/consoleappender.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/cygwin-win32.cxx b/src/cygwin-win32.cxx index 0badce539..c961afe7c 100644 --- a/src/cygwin-win32.cxx +++ b/src/cygwin-win32.cxx @@ -3,7 +3,7 @@ // Created: 7/2011 // Author: Vaclav Zeman // -// Copyright (C) 2011, Vaclav Zeman. All rights reserved. +// Copyright (C) 2011-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -27,6 +27,12 @@ // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if defined (__CYGWIN__) + +// Work around missing _X86_ symbol with Clang on Cygwin. +#if ! defined (_X86_) && defined (__i386__) +# define _X86_ 1 +#endif + #include // This is intentionally included directly instead of through diff --git a/src/env.cxx b/src/env.cxx index 43186449c..89cda1822 100644 --- a/src/env.cxx +++ b/src/env.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/factory.cxx b/src/factory.cxx index dae83219a..b11b4670b 100644 --- a/src/factory.cxx +++ b/src/factory.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2002-2010 Tad E. Smith +// Copyright 2002-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/fileappender.cxx b/src/fileappender.cxx index b681dd008..8a454e6ec 100644 --- a/src/fileappender.cxx +++ b/src/fileappender.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ #include #include #include +#include #include #if defined (__BORLANDC__) @@ -187,7 +188,8 @@ rolloverFiles(const tstring& filename, unsigned int maxBackupIndex) static std::locale -get_locale_by_name (tstring const & locale_name) try +get_locale_by_name (tstring const & locale_name) +{try { spi::LocaleFactoryRegistry & reg = spi::getLocaleFactoryRegistry (); spi::LocaleFactory * fact = reg.get (locale_name); @@ -205,7 +207,7 @@ catch (std::runtime_error const &) helpers::getLogLog ().error ( LOG4CPLUS_TEXT ("Failed to create locale " + locale_name)); return std::locale (); -} +}} } // namespace @@ -234,7 +236,7 @@ FileAppender::FileAppender(const Properties& props, , bufferSize (0) , buffer (0) { - bool app = (mode_ == std::ios::app); + bool app = (mode_ & (std::ios_base::app | std::ios_base::ate)) != 0; tstring const & fn = props.getProperty( LOG4CPLUS_TEXT("File") ); if (fn.empty()) { @@ -395,8 +397,9 @@ FileAppender::reopen() { // Close the current file out.close(); - out.clear(); // reset flags since the C++ standard specified that all the - // flags should remain unchanged on a close + // reset flags since the C++ standard specified that all + // the flags should remain unchanged on a close + out.clear(); // Re-open the file. open(std::ios_base::out | std::ios_base::ate); @@ -445,7 +448,6 @@ RollingFileAppender::RollingFileAppender(const Properties& properties) && tmp.compare (len - 2, 2, LOG4CPLUS_TEXT("KB")) == 0) tmpMaxFileSize *= 1024; // convert to kilobytes } - tmpMaxFileSize = (std::max)(tmpMaxFileSize, MINIMUM_ROLLING_LOG_SIZE); } properties.getInt (tmpMaxBackupIndex, LOG4CPLUS_TEXT("MaxBackupIndex")); @@ -487,11 +489,20 @@ RollingFileAppender::~RollingFileAppender() void RollingFileAppender::append(const spi::InternalLoggingEvent& event) { + // Seek to the end of log file so that tellp() below returns the + // right size. + if (useLockFile) + out.seekp (0, std::ios_base::end); + + // Rotate log file if needed before appending to it. + if (out.tellp() > maxFileSize) + rollover(true); + FileAppender::append(event); - if(out.tellp() > maxFileSize) { + // Rotate log file if needed after appending to it. + if (out.tellp() > maxFileSize) rollover(true); - } } @@ -624,6 +635,59 @@ DailyRollingFileAppender::DailyRollingFileAppender( } +namespace +{ + + +static +Time +round_time (Time const & t, time_t seconds) +{ + return Time ( + t.getTime () + - static_cast(std::fmod ( + static_cast(t.getTime ()), + static_cast(seconds)))); +} + + +static +Time +round_time_and_add (Time const & t, Time const & seconds) +{ + return round_time (t, seconds.sec ()) + seconds; +} + + +static +long +local_time_offset (Time t) +{ + tm time_local, time_gmt; + + t.localtime (&time_local); + t.gmtime (&time_gmt); + + t.setTime (&time_local); + Time t2 = t; + + t.setTime (&time_gmt); + Time t3 = t; + + return t2.sec () - t3.sec (); +} + + +static +Time +adjust_for_time_zone (Time const & t, long tzoffset) +{ + return t - Time (tzoffset); +} + + +} // namespace + void DailyRollingFileAppender::init(DailyRollingFileSchedule sch) @@ -738,8 +802,9 @@ DailyRollingFileAppender::rollover(bool alreadyLocked) // Close the current file out.close(); - out.clear(); // reset flags since the C++ standard specified that all the - // flags should remain unchanged on a close + // reset flags since the C++ standard specified that all the flags + // should remain unchanged on a close + out.clear(); // If we've already rolled over this time period, we'll make sure that we // don't overwrite any of those previous files. @@ -802,7 +867,7 @@ DailyRollingFileAppender::calculateNextRolloverTime(const Time& t) const { switch(schedule) { - case MONTHLY: + case MONTHLY: { struct tm nextMonthTime; t.localtime(&nextMonthTime); @@ -815,14 +880,17 @@ DailyRollingFileAppender::calculateNextRolloverTime(const Time& t) const LOG4CPLUS_TEXT("DailyRollingFileAppender::calculateNextRolloverTime()-") LOG4CPLUS_TEXT(" setTime() returned error")); // Set next rollover to 31 days in future. - ret = (t + Time(2678400)); + ret = round_time (t, 24 * 60 * 60) + Time(2678400); } return ret; } case WEEKLY: - return (t + Time(7 * 24 * 60 * 60)); + { + Time next = round_time (t, 24 * 60 * 60) + Time (7 * 24 * 60 * 60); + return adjust_for_time_zone (next, local_time_offset (next)); + } default: helpers::getLogLog ().error ( @@ -831,16 +899,22 @@ DailyRollingFileAppender::calculateNextRolloverTime(const Time& t) const // Fall through. case DAILY: - return (t + Time(24 * 60 * 60)); + { + Time next = round_time_and_add (t, Time (24 * 60 * 60)); + return adjust_for_time_zone (next, local_time_offset (next)); + } case TWICE_DAILY: - return (t + Time(12 * 60 * 60)); + { + Time next = round_time_and_add (t, Time (12 * 60 * 60)); + return adjust_for_time_zone (next, local_time_offset (next)); + } case HOURLY: - return (t + Time(60 * 60)); + return round_time_and_add (t, Time (60 * 60)); case MINUTELY: - return (t + Time(60)); + return round_time_and_add (t, Time (60)); }; } diff --git a/src/fileinfo.cxx b/src/fileinfo.cxx index 5b0405ba8..36f57e23f 100644 --- a/src/fileinfo.cxx +++ b/src/fileinfo.cxx @@ -1,6 +1,6 @@ // -*- C++ -*- // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/filter.cxx b/src/filter.cxx index a2c23878f..2542f4802 100644 --- a/src/filter.cxx +++ b/src/filter.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -110,8 +110,7 @@ LogLevelMatchFilter::LogLevelMatchFilter(const helpers::Properties& properties) { init(); - properties.getBool (acceptOnMatch = false, - LOG4CPLUS_TEXT("AcceptOnMatch")); + properties.getBool (acceptOnMatch, LOG4CPLUS_TEXT("AcceptOnMatch")); tstring const & log_level_to_match = properties.getProperty( LOG4CPLUS_TEXT("LogLevelToMatch") ); @@ -135,7 +134,7 @@ LogLevelMatchFilter::decide(const InternalLoggingEvent& event) const } bool matchOccured = (logLevelToMatch == event.getLogLevel()); - + if(matchOccured) { return (acceptOnMatch ? ACCEPT : DENY); } @@ -161,8 +160,7 @@ LogLevelRangeFilter::LogLevelRangeFilter(const helpers::Properties& properties) { init(); - properties.getBool (acceptOnMatch = false, - LOG4CPLUS_TEXT("AcceptOnMatch")); + properties.getBool (acceptOnMatch, LOG4CPLUS_TEXT("AcceptOnMatch")); tstring const & log_level_min = properties.getProperty( LOG4CPLUS_TEXT("LogLevelMin") ); @@ -224,8 +222,7 @@ StringMatchFilter::StringMatchFilter(const helpers::Properties& properties) { init(); - properties.getBool (acceptOnMatch = false, - LOG4CPLUS_TEXT("AcceptOnMatch")); + properties.getBool (acceptOnMatch, LOG4CPLUS_TEXT("AcceptOnMatch")); stringToMatch = properties.getProperty( LOG4CPLUS_TEXT("StringToMatch") ); } diff --git a/src/global-init.cxx b/src/global-init.cxx index 10726b6a6..e74227b05 100644 --- a/src/global-init.cxx +++ b/src/global-init.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ LOG4CPLUS_EXPORT tostream & tcerr = std::cerr; #endif // UNICODE -namespace +namespace { @@ -72,7 +72,7 @@ struct DefaultContext enum DCState -{ +{ DC_UNINITIALIZED, DC_INITIALIZED, DC_DESTROYED @@ -82,7 +82,7 @@ enum DCState static DCState default_context_state; static DefaultContext * default_context; - + struct destroy_default_context { ~destroy_default_context () @@ -91,7 +91,8 @@ struct destroy_default_context default_context = 0; default_context_state = DC_DESTROYED; } -} static destroy_default_context_; +} static destroy_default_context_ +LOG4CPLUS_INIT_PRIORITY (LOG4CPLUS_INIT_PRIORITY_BASE + 1); static @@ -109,7 +110,7 @@ alloc_dc () throw std::logic_error ("alloc_dc() called in DC_INITIALIZED state."); default_context = new DefaultContext; - + if (default_context_state == DC_DESTROYED) default_context->loglog.error ( LOG4CPLUS_TEXT ("Re-initializing default context after it has") @@ -162,7 +163,7 @@ getTTCCLayoutTimeBase () LogLevelManager & -getLogLevelManager () +getLogLevelManager () { return get_dc ()->log_level_manager; } @@ -175,7 +176,7 @@ getDefaultHierarchy () } -NDC & +NDC & getNDC () { return get_dc ()->ndc; @@ -357,7 +358,8 @@ threadSetup () } -void initializeLog4cplus() +void +initializeLog4cplus() { static bool initialized = false; if (initialized) @@ -375,45 +377,94 @@ void initializeLog4cplus() } +void +initialize () +{ + initializeLog4cplus (); +} + + void threadCleanup () { - // Do thread-specific cleanup. - internal::per_thread_data * ptd = internal::get_ptd (false); - delete ptd; + // Here we check that we can get CRT's heap handle because if we do not + // then the following `delete` will fail with access violation in + // `RtlFreeHeap()`. + // + // How is it possible that the CRT heap handle is NULL? + // + // This function can be called from TLS initializer/terminator by loader + // when log4cplus is compiled and linked to as a static library. In case of + // other threads temination, it should do its job and free per-thread + // data. However, when the whole process is being terminated, it is called + // after the CRT has been uninitialized and the CRT heap is not available + // any more. In such case, instead of crashing, we just give up and leak + // the memory for the short while before the process terminates anyway. + // + // It is possible to work around this situation in user application by + // calling `threadCleanup()` manually before `main()` exits. +#if defined (_WIN32) + if (_get_heap_handle() != 0) + { +#endif + // Do thread-specific cleanup. + internal::per_thread_data * ptd = internal::get_ptd (false); + delete ptd; +#if defined (_WIN32) + } + else + { + OutputDebugString ( + LOG4CPLUS_TEXT ("log4cplus: ") + LOG4CPLUS_TEXT ("CRT heap is already gone in threadCleanup()\n")); + } +#endif internal::set_ptd (0); } -} // namespace log4cplus +#if defined (_WIN32) +static +VOID CALLBACK +initializeLog4cplusApcProc (ULONG_PTR /*dwParam*/) +{ + initializeLog4cplus (); + threadSetup (); +} -#if defined (_WIN32) && defined (LOG4CPLUS_BUILD_DLL) +static +void +queueLog4cplusInitializationThroughAPC () +{ + if (! QueueUserAPC (initializeLog4cplusApcProc, GetCurrentThread (), + 0)) + throw std::runtime_error ("QueueUserAPC() has failed"); +} + -extern "C" -BOOL -WINAPI -DllMain (LOG4CPLUS_DLLMAIN_HINSTANCE /*hinstDLL*/, DWORD fdwReason, - LPVOID /*lpReserved*/) +static +void NTAPI +thread_callback (LPVOID /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpReserved*/) { // Perform actions based on the reason for calling. - switch( fdwReason ) - { + switch (fdwReason) + { case DLL_PROCESS_ATTACH: { - log4cplus::initializeLog4cplus(); - - // Do thread-specific initialization for the main thread. - log4cplus::threadSetup (); - + // We cannot initialize log4cplus directly here. This is because + // DllMain() is called under loader lock. When we are using C++11 + // threads and synchronization primitives then there is a deadlock + // somewhere in internals of std::mutex::lock(). + queueLog4cplusInitializationThroughAPC (); break; } case DLL_THREAD_ATTACH: { - // Do thread-specific initialization. - log4cplus::threadSetup (); - + // We could call threadSetup() here but that imposes overhead + // on threads that do not use log4cplus. Thread local data will + // be initialized lazily instead. break; } @@ -438,29 +489,147 @@ DllMain (LOG4CPLUS_DLLMAIN_HINSTANCE /*hinstDLL*/, DWORD fdwReason, break; } - } + } // switch +} + + +static +void NTAPI +thread_callback_initializer(LPVOID hinstDLL, DWORD fdwReason, LPVOID lpReserved) +{ + if (fdwReason == DLL_PROCESS_ATTACH + || fdwReason == DLL_THREAD_ATTACH) + thread_callback(hinstDLL, fdwReason, lpReserved); +} + +static +void NTAPI +thread_callback_terminator(LPVOID hinstDLL, DWORD fdwReason, LPVOID lpReserved) +{ + if (fdwReason == DLL_THREAD_DETACH + || fdwReason == DLL_PROCESS_DETACH) + thread_callback(hinstDLL, fdwReason, lpReserved); +} + +#endif + + +} // namespace log4cplus + + +#if defined (_WIN32) && defined (LOG4CPLUS_BUILD_DLL) && defined (_DLL) +extern "C" +BOOL +WINAPI +DllMain (LOG4CPLUS_DLLMAIN_HINSTANCE hinstDLL, DWORD fdwReason, + LPVOID lpReserved) +{ + log4cplus::thread_callback (hinstDLL, fdwReason, lpReserved); return TRUE; // Successful DLL_PROCESS_ATTACH. } - + +#elif defined (_WIN32) \ + && defined (_MSC_VER) && _MSC_VER >= 1400 && defined (_DLL) +extern "C" +{ + +// This magic has been pieced together from several sources: +// - +// - +// - `internal_shared.h` in CRT source in Visual Studio 2015 + +#pragma data_seg (push, old_seg) +#ifdef _WIN64 +#pragma const_seg (".CRT$XLY") +extern const #else +#pragma data_seg (".CRT$XLY") +#endif +PIMAGE_TLS_CALLBACK log4cplus_p_thread_callback_initializer = log4cplus::thread_callback_initializer; +#pragma data_seg (pop, old_seg) + +#pragma data_seg (push, old_seg) +#ifdef _WIN64 +#pragma const_seg (".CRT$XLAA") +extern const +#else +#pragma data_seg (".CRT$XLAA") +#endif +PIMAGE_TLS_CALLBACK log4cplus_p_thread_callback_terminator = log4cplus::thread_callback_terminator; +#pragma data_seg (pop, old_seg) + +#ifdef _WIN64 +#pragma comment (linker, "/INCLUDE:_tls_used") +#pragma comment (linker, "/INCLUDE:log4cplus_p_thread_callback_initializer") +#pragma comment (linker, "/INCLUDE:log4cplus_p_thread_callback_terminator") +#else +#pragma comment (linker, "/INCLUDE:__tls_used") +#pragma comment (linker, "/INCLUDE:_log4cplus_p_thread_callback_initializer") +#pragma comment (linker, "/INCLUDE:_log4cplus_p_thread_callback_terminator") +#endif + +} // extern "C" +#elif defined (_WIN32) namespace { - struct _static_log4cplus_initializer +struct _static_log4cplus_initializer +{ + _static_log4cplus_initializer () + { + // It is not possible to reliably call initializeLog4cplus() here + // when we are using Visual Studio and C++11 threads + // and synchronization primitives. It would result into a deadlock + // on loader lock. +#if ! (defined (LOG4CPLUS_WITH_CXX11_THREADS) && defined (_MSC_VER)) + log4cplus::initializeLog4cplus (); +#endif + } + + ~_static_log4cplus_initializer () { - _static_log4cplus_initializer () - { - log4cplus::initializeLog4cplus(); - } - - ~_static_log4cplus_initializer () - { - // Last thread cleanup. - log4cplus::threadCleanup (); - } - } static initializer; + // Last thread cleanup. + log4cplus::threadCleanup (); +#if ! defined (LOG4CPLUS_THREAD_LOCAL_VAR) + log4cplus::thread::impl::tls_cleanup ( + log4cplus::internal::tls_storage_key); +#endif + } +} static initializer; + +} // namespace + +#else +namespace { + +static void +_log4cplus_initializer_func () + LOG4CPLUS_CONSTRUCTOR_FUNC (LOG4CPLUS_INIT_PRIORITY_BASE); +static void +_log4cplus_initializer_func () +{ + log4cplus::initializeLog4cplus(); } +struct _static_log4cplus_initializer +{ + _static_log4cplus_initializer () + { + log4cplus::initializeLog4cplus(); + } + + ~_static_log4cplus_initializer () + { + // Last thread cleanup. + log4cplus::threadCleanup (); + + log4cplus::thread::impl::tls_cleanup ( + log4cplus::internal::tls_storage_key); + } +} static initializer +LOG4CPLUS_INIT_PRIORITY (LOG4CPLUS_INIT_PRIORITY_BASE); + +} // namespace #endif diff --git a/src/hierarchy.cxx b/src/hierarchy.cxx index 07020ef73..538705ee3 100644 --- a/src/hierarchy.cxx +++ b/src/hierarchy.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/hierarchylocker.cxx b/src/hierarchylocker.cxx index df31794ce..3a8dfa472 100644 --- a/src/hierarchylocker.cxx +++ b/src/hierarchylocker.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ HierarchyLocker::HierarchyLocker(Hierarchy& _h) } -HierarchyLocker::~HierarchyLocker() +HierarchyLocker::~HierarchyLocker() LOG4CPLUS_NOEXCEPT_FALSE { try { for(LoggerList::iterator it=loggerList.begin(); it!=loggerList.end(); ++it) { diff --git a/src/layout.cxx b/src/layout.cxx index 61331e1b2..de801bd1b 100644 --- a/src/layout.cxx +++ b/src/layout.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/lockfile.cxx b/src/lockfile.cxx index 5d597868e..d7e63a934 100644 --- a/src/lockfile.cxx +++ b/src/lockfile.cxx @@ -1,6 +1,6 @@ // -*- C++ -*- // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -91,16 +91,22 @@ namespace log4cplus { namespace helpers { #if defined (_WIN32) +#if defined (__BORLANDC__) +int const OPEN_FLAGS = O_RDWR | O_CREAT | O_NOINHERIT; +int const OPEN_SHFLAGS = SH_DENYNO; +int const OPEN_MODE = S_IREAD | S_IWRITE; +#else int const OPEN_FLAGS = _O_RDWR | _O_CREAT /*| _O_TEMPORARY*/ | _O_NOINHERIT; int const OPEN_SHFLAGS = _SH_DENYNO; int const OPEN_MODE = _S_IREAD | _S_IWRITE; +#endif namespace { static HANDLE -get_os_HANDLE (int fd, helpers::LogLog & loglog) +get_os_HANDLE (int fd, helpers::LogLog & loglog = helpers::getLogLog ()) { HANDLE fh = reinterpret_cast(_get_osfhandle (fd)); if (fh == INVALID_HANDLE_VALUE) @@ -125,6 +131,52 @@ mode_t const OPEN_MODE = (S_IRWXU ^ S_IXUSR) #endif + +//! Helper function that sets FD_CLOEXEC on descriptor on platforms +//! that support it. +LOG4CPLUS_PRIVATE +bool +trySetCloseOnExec (int fd, helpers::LogLog & loglog = helpers::getLogLog ()) +{ +#if defined (WIN32) + int ret = SetHandleInformation (get_os_HANDLE (fd), HANDLE_FLAG_INHERIT, 0); + if (! ret) + { + DWORD eno = GetLastError (); + loglog.warn ( + tstring ( + LOG4CPLUS_TEXT ("could not unset HANDLE_FLAG_INHERIT on fd: ")) + + convertIntegerToString (fd) + + LOG4CPLUS_TEXT (", errno: ") + + convertIntegerToString (eno)); + return false; + } + +#elif defined (FD_CLOEXEC) + int ret = fcntl (fd, F_SETFD, FD_CLOEXEC); + if (ret == -1) + { + int eno = errno; + loglog.warn ( + tstring (LOG4CPLUS_TEXT ("could not set FD_CLOEXEC on fd: ")) + + convertIntegerToString (fd) + + LOG4CPLUS_TEXT (", errno: ") + + convertIntegerToString (eno)); + return false; + } +#else + return false; + +#endif + + return true; +} + + +// +// +// + struct LockFile::Impl { #if defined (LOG4CPLUS_USE_POSIX_LOCKING) \ @@ -166,9 +218,17 @@ LockFile::open (int open_flags) const LogLog & loglog = getLogLog (); #if defined (_WIN32) +# if defined (LOG4CPLUS_HAVE__TSOPEN_S) && defined (_tsopen_s) errno_t eno = _tsopen_s (&data->fd, lock_file_name.c_str (), open_flags, OPEN_SHFLAGS, OPEN_MODE); if (eno != 0) +# elif defined (LOG4CPLUS_HAVE__TSOPEN) && defined (_tsopen) + data->fd = _tsopen (lock_file_name.c_str (), open_flags, OPEN_SHFLAGS, + OPEN_MODE); + if (data->fd == -1) +# else +# error "Neither _tsopen_s() nor _tsopen() is available." +# endif loglog.error (tstring (LOG4CPLUS_TEXT("could not open or create file ")) + lock_file_name, true); @@ -180,9 +240,8 @@ LockFile::open (int open_flags) const tstring (LOG4CPLUS_TEXT ("could not open or create file ")) + lock_file_name, true); -#if ! defined (O_CLOEXEC) && defined (FD_CLOEXEC) - int ret = fcntl (data->fd, F_SETFD, FD_CLOEXEC); - if (ret == -1) +#if ! defined (O_CLOEXEC) + if (! trySetCloseOnExec (data->fd, loglog)) loglog.warn ( tstring (LOG4CPLUS_TEXT("could not set FD_CLOEXEC on file ")) + lock_file_name); diff --git a/src/log4cplus.rc.in b/src/log4cplus.rc.in new file mode 100644 index 000000000..542f71142 --- /dev/null +++ b/src/log4cplus.rc.in @@ -0,0 +1,43 @@ +#include + +#ifdef NDEBUG +#define VER_DEBUG 0 +#else +#define VER_DEBUG VS_FF_DEBUG +#endif + +#if @log4cplus_build_shared@ +#define VER_FILETYPE VFT_DLL +#else +#define VER_FILETYPE VFT_STATIC_LIB +#endif + +#define VER_BINARY @log4cplus_version_major@,@log4cplus_version_minor@,@log4cplus_version_patch@,0 +#define VER_STR "@log4cplus_version_major@.@log4cplus_version_minor@.@log4cplus_version_patch@" + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VER_BINARY +PRODUCTVERSION VER_BINARY +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS VER_DEBUG +FILEOS VOS_NT_WINDOWS32 +FILETYPE VER_FILETYPE +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "log4cplus" + VALUE "FileDescription", "log4cplus logging library" + VALUE "FileVersion", VER_STR + VALUE "InternalName", "@log4cplus@" + VALUE "ProductName", "@log4cplus@" + VALUE "ProductVersion", VER_STR + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1200 + END +END diff --git a/src/log4judpappender.cxx b/src/log4judpappender.cxx index f33a04b34..30b09cd17 100644 --- a/src/log4judpappender.cxx +++ b/src/log4judpappender.cxx @@ -4,7 +4,7 @@ // Author: Siva Chandran P // // -// Copyright 2012 Siva Chandran P +// Copyright 2012-2013 Siva Chandran P // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/logger.cxx b/src/logger.cxx index 2d490437c..a0502327f 100644 --- a/src/logger.cxx +++ b/src/logger.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/loggerimpl.cxx b/src/loggerimpl.cxx index 08ba0aaca..459831c03 100644 --- a/src/loggerimpl.cxx +++ b/src/loggerimpl.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -80,9 +80,12 @@ void LoggerImpl::closeNestedAppenders() { SharedAppenderPtrList appenders = getAllAppenders(); - for(SharedAppenderPtrList::iterator it=appenders.begin(); it!=appenders.end(); ++it) + for(SharedAppenderPtrList::iterator it=appenders.begin(); + it!=appenders.end(); ++it) { - (*it)->close(); + Appender & appender = **it; + if (! appender.isClosed()) + appender.close(); } } diff --git a/src/loggingevent.cxx b/src/loggingevent.cxx index f0c951bde..fb67a1df2 100644 --- a/src/loggingevent.cxx +++ b/src/loggingevent.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ InternalLoggingEvent::InternalLoggingEvent(const log4cplus::tstring& logger, , thread() , timestamp(log4cplus::helpers::Time::gettimeofday()) , file(filename - ? LOG4CPLUS_C_STR_TO_TSTRING(filename) + ? LOG4CPLUS_C_STR_TO_TSTRING(filename) : log4cplus::tstring()) , function () , line(line_) @@ -79,6 +79,30 @@ InternalLoggingEvent::InternalLoggingEvent(const log4cplus::tstring& logger, } +InternalLoggingEvent::InternalLoggingEvent(const log4cplus::tstring& logger, + LogLevel loglevel, const log4cplus::tstring& ndc_, + MappedDiagnosticContextMap const & mdc_, const log4cplus::tstring& message_, + const log4cplus::tstring& thread_, const log4cplus::tstring& thread2_, + log4cplus::helpers::Time time, const log4cplus::tstring& file_, int line_) + : message(message_) + , loggerName(logger) + , ll(loglevel) + , ndc(ndc_) + , mdc(mdc_) + , thread(thread_) + , thread2(thread2_) + , timestamp(time) + , file(file_) + , function () + , line(line_) + , threadCached(true) + , thread2Cached(true) + , ndcCached(true) + , mdcCached(true) +{ +} + + InternalLoggingEvent::InternalLoggingEvent () : ll (NOT_SET_LOG_LEVEL) , function () @@ -98,6 +122,7 @@ InternalLoggingEvent::InternalLoggingEvent( , ndc(rhs.getNDC()) , mdc(rhs.getMDCCopy()) , thread(rhs.getThread()) + , thread2(rhs.getThread2()) , timestamp(rhs.getTimestamp()) , file(rhs.getFile()) , function(rhs.getFunction()) @@ -174,7 +199,7 @@ InternalLoggingEvent::setFunction (log4cplus::tstring const & func) } -const log4cplus::tstring& +const log4cplus::tstring& InternalLoggingEvent::getMessage() const { return message; @@ -245,6 +270,7 @@ InternalLoggingEvent::swap (InternalLoggingEvent & other) swap (function, other.function); swap (line, other.line); swap (threadCached, other.threadCached); + swap (thread2Cached, other.thread2Cached); swap (ndcCached, other.ndcCached); } diff --git a/src/loggingmacros.cxx b/src/loggingmacros.cxx index 3005ed8d3..8025e516c 100644 --- a/src/loggingmacros.cxx +++ b/src/loggingmacros.cxx @@ -4,7 +4,7 @@ // Author: Vaclav Haisman // // -// Copyright 2010 Vaclav Haisman +// Copyright 2010-2013 Vaclav Haisman // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/loglevel.cxx b/src/loglevel.cxx index 4481f792a..87a8f344f 100644 --- a/src/loglevel.cxx +++ b/src/loglevel.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -44,29 +44,6 @@ static tstring const NOTSET_STRING (LOG4CPLUS_TEXT("NOTSET")); static tstring const UNKNOWN_STRING (LOG4CPLUS_TEXT("UNKNOWN")); -struct log_levels_table_rec -{ - LogLevel const ll; - tstring const * const str; -}; - - -#define DEF_LLTAB_REC(x) { x ## _LOG_LEVEL, &(x ## _STRING) } - -static log_levels_table_rec const log_levels_table[8] = { - DEF_LLTAB_REC (OFF), - DEF_LLTAB_REC (FATAL), - DEF_LLTAB_REC (ERROR), - DEF_LLTAB_REC (WARN), - DEF_LLTAB_REC (INFO), - DEF_LLTAB_REC (DEBUG), - DEF_LLTAB_REC (TRACE), - DEF_LLTAB_REC (ALL), -}; - -#undef DEF_LLTAB_REC - - static tstring const & defaultLogLevelToStringMethod(LogLevel ll) @@ -82,7 +59,7 @@ defaultLogLevelToStringMethod(LogLevel ll) //case ALL_LOG_LEVEL: return ALL_STRING; case NOT_SET_LOG_LEVEL: return NOTSET_STRING; }; - + return internal::empty_str; } @@ -91,28 +68,46 @@ static LogLevel defaultStringToLogLevelMethod(const tstring& s) { - std::size_t const tbl_size - = sizeof (log_levels_table) / sizeof (log_levels_table[0]); +#if __cplusplus < 201103L + if (s.empty ()) + return NOT_SET_LOG_LEVEL; - for (log_levels_table_rec const * it = log_levels_table; - it != log_levels_table + tbl_size; ++it) + // The above check is only necessary prior to C++11 standard. Since C++11, + // accessing str[0] is always safe as it returns '\0' for empty string. +#endif + + switch (s[0]) { - if (*it->str == s) - return it->ll; +#define DEF_LLMATCH(_chr, _logLevel) \ + case LOG4CPLUS_TEXT (_chr): \ + if (s == _logLevel ## _STRING) \ + return _logLevel ## _LOG_LEVEL; \ + else \ + break; + + DEF_LLMATCH ('O', OFF); + DEF_LLMATCH ('F', FATAL); + DEF_LLMATCH ('E', ERROR); + DEF_LLMATCH ('W', WARN); + DEF_LLMATCH ('I', INFO); + DEF_LLMATCH ('D', DEBUG); + DEF_LLMATCH ('T', TRACE); + DEF_LLMATCH ('A', ALL); + +#undef DEF_LLMATCH } - + return NOT_SET_LOG_LEVEL; } } // namespace - ////////////////////////////////////////////////////////////////////////////// // LogLevelManager ctors and dtor ////////////////////////////////////////////////////////////////////////////// -LogLevelManager::LogLevelManager() +LogLevelManager::LogLevelManager() { LogLevelToStringMethodRec rec; rec.func = defaultLogLevelToStringMethod; @@ -123,7 +118,7 @@ LogLevelManager::LogLevelManager() } -LogLevelManager::~LogLevelManager() +LogLevelManager::~LogLevelManager() { } @@ -159,7 +154,7 @@ LogLevelManager::toString(LogLevel ll) const } -LogLevel +LogLevel LogLevelManager::fromString(const tstring& arg) const { tstring s = helpers::toUpper(arg); @@ -171,12 +166,16 @@ LogLevelManager::fromString(const tstring& arg) const if (ret != NOT_SET_LOG_LEVEL) return ret; } - + + helpers::getLogLog ().error ( + LOG4CPLUS_TEXT ("Unrecognized log level: ") + + arg); + return NOT_SET_LOG_LEVEL; } -void +void LogLevelManager::pushToStringMethod(LogLevelToStringMethod newToString) { LogLevelToStringMethodRec rec; @@ -186,7 +185,7 @@ LogLevelManager::pushToStringMethod(LogLevelToStringMethod newToString) } -void +void LogLevelManager::pushToStringMethod(LogLevelToStringMethod_1_0 newToString) { LogLevelToStringMethodRec rec; @@ -196,11 +195,11 @@ LogLevelManager::pushToStringMethod(LogLevelToStringMethod_1_0 newToString) } -void +void LogLevelManager::pushFromStringMethod(StringToLogLevelMethod newFromString) { fromStringMethods.push_back (newFromString); } - + } // namespace log4cplus diff --git a/src/loglog.cxx b/src/loglog.cxx index 0e174e10c..7fb7b9f51 100644 --- a/src/loglog.cxx +++ b/src/loglog.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/logloguser.cxx b/src/logloguser.cxx index 2804c22b7..e97052fef 100644 --- a/src/logloguser.cxx +++ b/src/logloguser.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/mdc.cxx b/src/mdc.cxx index 6d83ed649..faec501ff 100644 --- a/src/mdc.cxx +++ b/src/mdc.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/ndc.cxx b/src/ndc.cxx index e17285593..a8fdfe88d 100644 --- a/src/ndc.cxx +++ b/src/ndc.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/nteventlogappender.cxx b/src/nteventlogappender.cxx index cc2d19a5e..eb71270e8 100644 --- a/src/nteventlogappender.cxx +++ b/src/nteventlogappender.cxx @@ -3,7 +3,7 @@ // Created: 4/2003 // Author: Michael CATANZARITI // -// Copyright 2003-2010 Michael CATANZARITI +// Copyright 2003-2013 Michael CATANZARITI // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/nullappender.cxx b/src/nullappender.cxx index 67111934c..5a6fd05ca 100644 --- a/src/nullappender.cxx +++ b/src/nullappender.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/objectregistry.cxx b/src/objectregistry.cxx index edc6c9889..d81c82b51 100644 --- a/src/objectregistry.cxx +++ b/src/objectregistry.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/patternlayout.cxx b/src/patternlayout.cxx index 2771d081f..7c98a82a4 100644 --- a/src/patternlayout.cxx +++ b/src/patternlayout.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -75,7 +76,8 @@ namespace pattern struct FormattingInfo { int minLen; std::size_t maxLen; - bool leftAlign; + bool leftAlign : 1; + bool trimStart : 1; FormattingInfo() { reset(); } void reset(); @@ -104,7 +106,8 @@ class PatternConverter private: int minLen; std::size_t maxLen; - bool leftAlign; + bool leftAlign : 1; + bool trimStart : 1; }; @@ -199,6 +202,21 @@ class DatePatternConverter : public PatternConverter { }; +/** + * This PatternConverter is used to format an environment variable + */ +class EnvPatternConverter : public PatternConverter { +public: + EnvPatternConverter(const FormattingInfo& info, + const log4cplus::tstring& env); + virtual void convert(tstring & result, + const spi::InternalLoggingEvent& event); + +private: + log4cplus::tstring envKey; +}; + + //! This pattern is used to format miliseconds since process start. class RelativeTimestampConverter: public PatternConverter { public: @@ -297,20 +315,22 @@ class PatternParser // FormattingInfo methods: //////////////////////////////////////////////// -void +void FormattingInfo::reset() { minLen = -1; - maxLen = 0x7FFFFFFF; + maxLen = std::numeric_limits::max (); leftAlign = false; + trimStart = true; } -void +void FormattingInfo::dump(helpers::LogLog& loglog) { tostringstream buf; buf << LOG4CPLUS_TEXT("min=") << minLen << LOG4CPLUS_TEXT(", max=") << maxLen - << LOG4CPLUS_TEXT(", leftAlign=") << std::boolalpha << leftAlign; + << LOG4CPLUS_TEXT(", leftAlign=") << std::boolalpha << leftAlign + << LOG4CPLUS_TEXT(", trimStart=") << std::boolalpha << trimStart; loglog.debug(buf.str()); } @@ -326,6 +346,7 @@ PatternConverter::PatternConverter(const FormattingInfo& i) minLen = i.minLen; maxLen = i.maxLen; leftAlign = i.leftAlign; + trimStart = i.trimStart; } @@ -339,7 +360,12 @@ PatternConverter::formatAndAppend( std::size_t len = s.length(); if (len > maxLen) - output << s.substr(len - maxLen); + { + if (trimStart) + output << s.substr(len - maxLen); + else + output << s.substr(0, maxLen); + } else if (static_cast(len) < minLen) { std::ios_base::fmtflags const original_flags = output.flags (); @@ -525,6 +551,30 @@ DatePatternConverter::convert(tstring & result, } +//////////////////////////////////////////////// +// EnvPatternConverter methods: +//////////////////////////////////////////////// + + +EnvPatternConverter::EnvPatternConverter( + const FormattingInfo& info, const tstring& env) + : PatternConverter(info) + , envKey(env) +{ } + + +void +EnvPatternConverter::convert(tstring & result, + const spi::InternalLoggingEvent&) +{ + if (! internal::get_env_var (result, envKey)) + { + // Variable doesn't exist, return empty string. + result.clear (); + } +} + + // // // @@ -540,7 +590,7 @@ RelativeTimestampConverter::convert (tstring & result, { tostringstream & oss = internal::get_ptd ()->layout_oss; detail::clear_tostringstream (oss); - formatRelativeTimestamp (oss, event); + log4cplus::formatRelativeTimestamp (oss, event); oss.str ().swap (result); } @@ -580,7 +630,30 @@ void log4cplus::pattern::MDCPatternConverter::convert (tstring & result, const spi::InternalLoggingEvent& event) { - result = event.getMDC (key); + if (!key.empty()) + { + result = event.getMDC (key); + } + else + { + result.clear (); + + MappedDiagnosticContextMap const & mdcMap = event.getMDCCopy(); + + for (MappedDiagnosticContextMap::const_iterator it = mdcMap.begin(); + it != mdcMap.end(); ++it) + { + tstring const & name(it->first); + tstring const & value(it->second); + + result += LOG4CPLUS_TEXT("{"); + result += name; + result += LOG4CPLUS_TEXT(", "); + result += value; + result += LOG4CPLUS_TEXT("}"); + + } + } } @@ -742,7 +815,9 @@ PatternParser::parse() case DOT_STATE: currentLiteral += c; - if(c >= LOG4CPLUS_TEXT('0') && c <= LOG4CPLUS_TEXT('9')) { + if (c == LOG4CPLUS_TEXT('-')) + formattingInfo.trimStart = false; + else if(c >= LOG4CPLUS_TEXT('0') && c <= LOG4CPLUS_TEXT('9')) { formattingInfo.maxLen = c - LOG4CPLUS_TEXT('0'); state = MAX_STATE; } @@ -819,6 +894,12 @@ PatternParser::finalizeConverter(tchar c) } break; + case LOG4CPLUS_TEXT('E'): + pc = new EnvPatternConverter(formattingInfo, extractOption()); + //getLogLog().debug("Environment converter."); + //formattingInfo.dump(getLogLog()); + break; + case LOG4CPLUS_TEXT('F'): pc = new BasicPatternConverter (formattingInfo, diff --git a/src/pointer.cxx b/src/pointer.cxx index a800a8591..da1db3c95 100644 --- a/src/pointer.cxx +++ b/src/pointer.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/property.cxx b/src/property.cxx index e2dd7ce13..bc594cbd8 100644 --- a/src/property.cxx +++ b/src/property.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2002-2010 Tad E. Smith +// Copyright 2002-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -102,38 +102,13 @@ trim_ws (tstring & str) } -} // namespace - - - -/////////////////////////////////////////////////////////////////////////////// -// Properties ctors and dtor -/////////////////////////////////////////////////////////////////////////////// - -Properties::Properties() -{ -} - - - -Properties::Properties(tistream& input) -{ - init(input); -} - - - -Properties::Properties(const tstring& inputFile, unsigned flags) +void +imbue_file_from_flags (tistream & file, unsigned flags) { - if (inputFile.empty ()) - return; - - tifstream file; - - switch (flags & fEncodingMask) + switch (flags & (Properties::fEncodingMask << Properties::fEncodingShift)) { #if defined (LOG4CPLUS_HAVE_CODECVT_UTF8_FACET) && defined (UNICODE) - case fUTF8: + case Properties::fUTF8: file.imbue ( std::locale (file.getloc (), new std::codecvt_utf8)); + // TODO: This should actually be a custom "null" facet + // that just copies the chars to wchar_t buffer. + new std::codecvt)); break; #endif #if defined (LOG4CPLUS_HAVE_CODECVT_UTF32_FACET) && defined (UNICODE) - case fUTF32: + case Properties::fUTF32: file.imbue ( std::locale (file.getloc (), new std::codecvt_utf32= 7 + 1 + 1 + && is_space (buffer[7])) + { + tstring included (buffer, 8) ; + trim_ws (included); + + tifstream file; + imbue_file_from_flags (file, flags); + + file.open (LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME(included).c_str(), + std::ios::binary); + if (! file.good ()) + helpers::getLogLog ().error ( + LOG4CPLUS_TEXT ("could not open file ") + included); + + init (file); + } } } diff --git a/src/queue.cxx b/src/queue.cxx index 5630fad5b..085e6643d 100644 --- a/src/queue.cxx +++ b/src/queue.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -79,7 +79,9 @@ Queue::put_event (spi::InternalLoggingEvent const & ev) } catch (std::runtime_error const & e) { - (void)e; + log4cplus::helpers::getLogLog().error( + LOG4CPLUS_TEXT("put_event() exception: ") + + LOG4CPLUS_C_STR_TO_TSTRING(e.what())); return ret_flags; } @@ -114,7 +116,9 @@ Queue::signal_exit (bool drain) } catch (std::runtime_error const & e) { - (void)e; + log4cplus::helpers::getLogLog().error( + LOG4CPLUS_TEXT("signal_exit() exception: ") + + LOG4CPLUS_C_STR_TO_TSTRING(e.what())); ret_flags |= ERROR_BIT; return ret_flags; } @@ -174,7 +178,9 @@ Queue::get_events (queue_storage_type * buf) } catch (std::runtime_error const & e) { - (void)e; + log4cplus::helpers::getLogLog().error( + LOG4CPLUS_TEXT("get_events() exception: ") + + LOG4CPLUS_C_STR_TO_TSTRING(e.what())); ret_flags |= ERROR_BIT; } diff --git a/src/rootlogger.cxx b/src/rootlogger.cxx index ff0122059..799f70c5b 100644 --- a/src/rootlogger.cxx +++ b/src/rootlogger.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/sleep.cxx b/src/sleep.cxx index 901dddcde..094be8896 100644 --- a/src/sleep.cxx +++ b/src/sleep.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -48,7 +48,10 @@ static inline int unix_nanosleep (const struct timespec *req, struct timespec *rem) { -#if defined (LOG4CPLUS_HAVE_CLOCK_NANOSLEEP) +#if defined (LOG4CPLUS_HAVE_CLOCK_NANOSLEEP) \ + && ! defined (__BIONIC__) + // We do not allow Android with Bionic C library to use + // clock_nanosleep() as it is missing declaration in headers. return clock_nanosleep (CLOCK_REALTIME, 0, req, rem); #elif defined (LOG4CPLUS_HAVE_NANOSLEEP) diff --git a/src/snprintf.cxx b/src/snprintf.cxx index 8dbb5a9a5..3c9e13426 100644 --- a/src/snprintf.cxx +++ b/src/snprintf.cxx @@ -1,15 +1,15 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. -// +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. +// // Redistribution and use in source and binary forms, with or without modifica- // tion, 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 ``AS IS'' AND ANY EXPRESSED 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 @@ -107,7 +107,7 @@ vstprintf (tchar * dest, std::size_t dest_size, tchar const * fmt, if (ret >= 0) assert (static_cast(ret) <= dest_size); - + return ret; } @@ -125,13 +125,22 @@ vsntprintf (tchar * dest, std::size_t dest_size, tchar const * fmt, int ret; #if defined (UNICODE) -# if defined (LOG4CPLUS_HAVE__VSNWPRINTF_S) && defined (_TRUNCATE) +# if defined (LOG4CPLUS_HAVE__VSWPRINTF_P) + ret = _vswprintf_p (dest, dest_size, fmt, args); +# elif defined (LOG4CPLUS_HAVE__VSNWPRINTF_S) && defined (_TRUNCATE) ret = _vsnwprintf_s (dest, dest_size, _TRUNCATE, fmt, args); +# elif defined (LOG4CPLUS_HAVE_VSNWPRINTF) + ret = vsnwprintf (dest, dest_size, fmt, args); +# elif defined (LOG4CPLUS_HAVE__VSNWPRINTF) + ret = _vsnwprintf (dest, dest_size, fmt, args); # else - ret = std::vswprintf (dest, dest_size, fmt, args); + using namespace std; + ret = vswprintf (dest, dest_size, fmt, args); # endif #else -# if defined (LOG4CPLUS_HAVE_VSNPRINTF_S) && defined (_TRUNCATE) +# if defined (LOG4CPLUS_HAVE__VSPRINTF_P) + ret = _vsprintf_p (dest, dest_size, fmt, args); +# elif defined (LOG4CPLUS_HAVE_VSNPRINTF_S) && defined (_TRUNCATE) ret = vsnprintf_s (dest, dest_size, _TRUNCATE, fmt, args); # elif defined (LOG4CPLUS_HAVE__VSNPRINTF_S) && defined (_TRUNCATE) ret = _vsnprintf_s (dest, dest_size, _TRUNCATE, fmt, args); @@ -143,7 +152,7 @@ vsntprintf (tchar * dest, std::size_t dest_size, tchar const * fmt, # error "None of vsnprintf_s, _vsnprintf_s, vsnprintf or _vsnprintf is available." # endif #endif - + return ret; } #endif @@ -162,23 +171,32 @@ snprintf_buf::print (tchar const * fmt, ...) { assert (fmt); + tchar const * str = 0; + int ret = 0; std::va_list args; - va_start (args, fmt); - tchar const * ret = print_va_list (fmt, args); - va_end (args); - return ret; + + do + { + va_start (args, fmt); + ret = print_va_list (str, fmt, args); + va_end (args); + } + while (ret == -1); + + return str; } -tchar const * -snprintf_buf::print_va_list(tchar const * fmt, std::va_list args) +int +snprintf_buf::print_va_list (tchar const * & str, tchar const * fmt, + std::va_list args) { int printed; std::size_t const fmt_len = std::char_traits::length (fmt); std::size_t buf_size = buf.size (); std::size_t const output_estimate = fmt_len + fmt_len / 2 + 1; if (output_estimate > buf_size) - buf.resize (output_estimate); + buf.resize (buf_size = output_estimate); #if defined (LOG4CPLUS_USE_POOR_MANS_SNPRINTF) std::FILE * & fnull = internal::get_ptd ()->fnull; @@ -186,56 +204,56 @@ snprintf_buf::print_va_list(tchar const * fmt, std::va_list args) { fnull = std::fopen (NULL_FILE, "wb"); if (! fnull) - { LogLog::getLogLog ()->error ( - LOG4CPLUS_TEXT ("Could not open NULL_FILE.")); - buf.clear (); - buf.push_back (0); - return &buf[0]; - } + LOG4CPLUS_TEXT ("Could not open NULL_FILE."), true); } - + printed = vftprintf (fnull, fmt, args); if (printed == -1) - { LogLog::getLogLog ()->error ( - LOG4CPLUS_TEXT ("Error printing into NULL_FILE.")); - buf.clear (); - buf.push_back (0); - return &buf[0]; - } + LOG4CPLUS_TEXT ("Error printing into NULL_FILE."), true); buf.resize (printed + 1); int sprinted = vstprintf (&buf[0], buf.size (), fmt, args); - if (sprinted == -1) - { + if (sprinted == -1 || sprinted >= buf.size ()) LogLog::getLogLog ()->error ( - LOG4CPLUS_TEXT ("Error printing into string.")); - buf.clear (); - buf.push_back (0); - return &buf[0]; - } + LOG4CPLUS_TEXT ("Error printing into string."), true); + assert (printed == sprinted); - + buf[sprinted] = 0; #else - do + printed = vsntprintf (&buf[0], buf_size - 1, fmt, args); + if (printed == -1) { - printed = vsntprintf (&buf[0], buf_size - 1, fmt, args); - if (printed == -1) +#if defined (EILSEQ) + if (errno == EILSEQ) { - buf_size *= 2; - buf.resize (buf_size); + LogLog::getLogLog ()->error ( + LOG4CPLUS_TEXT ("Character conversion error when printing")); + // Return zero to terminate the outer loop in + // snprintf_buf::print(). + return 0; } - else - buf[printed] = 0; +#endif + + buf_size *= 2; + buf.resize (buf_size); + } + else if (printed >= static_cast(buf_size - 1)) + { + buf_size = printed + 2; + buf.resize (buf_size); + printed = -1; } - while (printed == -1); + else + buf[printed] = 0; #endif - return &buf[0]; + str = &buf[0]; + return printed; } diff --git a/src/socket-unix.cxx b/src/socket-unix.cxx index ca84b7948..24d8fe0e9 100644 --- a/src/socket-unix.cxx +++ b/src/socket-unix.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ #if defined (LOG4CPLUS_HAVE_ARPA_INET_H) #include #endif - + #if defined (LOG4CPLUS_HAVE_ERRNO_H) #include #endif @@ -60,13 +60,25 @@ #include #endif +#ifdef LOG4CPLUS_HAVE_FCNTL_H +#include +#endif + #ifdef LOG4CPLUS_HAVE_UNISTD_H #include #endif +#ifdef LOG4CPLUS_HAVE_POLL_H +#include +#endif + namespace log4cplus { namespace helpers { +// from lockfile.cxx +LOG4CPLUS_PRIVATE bool trySetCloseOnExec (int fd, + helpers::LogLog & loglog = helpers::getLogLog ()); + namespace { @@ -103,7 +115,7 @@ get_host_by_name (char const * hostname, std::string * name, struct addrinfo const & ai = *res; assert (ai.ai_family == AF_INET); - + if (name) *name = ai.ai_canonname; @@ -150,8 +162,8 @@ get_host_by_name (char const * hostname, std::string * name, SOCKET_TYPE openSocket(unsigned short port, SocketState& state) { - int sock = ::socket(AF_INET, SOCK_STREAM, 0); - if(sock < 0) { + socket_holder sock_holder (::socket(AF_INET, SOCK_STREAM, 0)); + if(sock_holder.sock < 0) { return INVALID_SOCKET_VALUE; } @@ -162,27 +174,25 @@ openSocket(unsigned short port, SocketState& state) int optval = 1; socklen_t optlen = sizeof (optval); - int ret = setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, &optval, optlen ); + int ret = setsockopt (sock_holder.sock, SOL_SOCKET, SO_REUSEADDR, &optval, + optlen); if (ret != 0) { - helpers::getLogLog ().warn ("setsockopt() failed: " - + helpers::convertIntegerToString (errno)); + int const eno = errno; + helpers::getLogLog ().warn (LOG4CPLUS_TEXT ("setsockopt() failed: ") + + helpers::convertIntegerToString (eno)); } - int retval = bind(sock, reinterpret_cast(&server), - sizeof(server)); + int retval = bind(sock_holder.sock, + reinterpret_cast(&server), sizeof(server)); if (retval < 0) - goto error; + return INVALID_SOCKET_VALUE; - if (::listen(sock, 10)) - goto error; + if (::listen(sock_holder.sock, 10)) + return INVALID_SOCKET_VALUE; state = ok; - return to_log4cplus_socket (sock); - -error: - close (sock); - return INVALID_SOCKET_VALUE; + return to_log4cplus_socket (sock_holder.detach ()); } @@ -190,7 +200,6 @@ SOCKET_TYPE connectSocket(const tstring& hostn, unsigned short port, bool udp, SocketState& state) { struct sockaddr_in server; - int sock; int retval; std::memset (&server, 0, sizeof (server)); @@ -202,26 +211,23 @@ connectSocket(const tstring& hostn, unsigned short port, bool udp, SocketState& server.sin_port = htons(port); server.sin_family = AF_INET; - sock = ::socket(AF_INET, (udp ? SOCK_DGRAM : SOCK_STREAM), 0); - if(sock < 0) { + socket_holder sock_holder ( + ::socket(AF_INET, (udp ? SOCK_DGRAM : SOCK_STREAM), 0)); + if (sock_holder.sock < 0) return INVALID_SOCKET_VALUE; - } socklen_t namelen = sizeof (server); while ( - (retval = ::connect(sock, reinterpret_cast(&server), - namelen)) + (retval = ::connect(sock_holder.sock, + reinterpret_cast(&server), namelen)) == -1 && (errno == EINTR)) ; - if (retval == INVALID_OS_SOCKET_VALUE) - { - ::close(sock); + if (retval == INVALID_OS_SOCKET_VALUE) return INVALID_SOCKET_VALUE; - } state = ok; - return to_log4cplus_socket (sock); + return to_log4cplus_socket (sock_holder.detach ()); } @@ -277,7 +283,7 @@ acceptSocket(SOCKET_TYPE sock, SocketState& state) while( (clientSock = accept_wrap (accept, to_os_socket (sock), - reinterpret_cast(&net_client), &len)) + reinterpret_cast(&net_client), &len)) == -1 && (errno == EINTR)) ; @@ -298,14 +304,20 @@ closeSocket(SOCKET_TYPE sock) } +int +shutdownSocket(SOCKET_TYPE sock) +{ + return ::shutdown(to_os_socket (sock), SHUT_RDWR); +} + long read(SOCKET_TYPE sock, SocketBuffer& buffer) { long res, readbytes = 0; - + do - { + { res = ::read(to_os_socket (sock), buffer.getBuffer() + readbytes, buffer.getMaxSize() - readbytes); if( res <= 0 ) { @@ -313,7 +325,7 @@ read(SOCKET_TYPE sock, SocketBuffer& buffer) } readbytes += res; } while( readbytes < static_cast(buffer.getMaxSize()) ); - + return readbytes; } @@ -361,7 +373,7 @@ getHostname (bool fqdn) break; } #if defined (LOG4CPLUS_HAVE_ENAMETOOLONG) - else if (ret != 0 && errno == ENAMETOOLONG) + else if (errno == ENAMETOOLONG) // Out buffer was too short. Retry with buffer twice the size. hn.resize (hn.size () * 2, 0); #endif @@ -398,7 +410,7 @@ setTCPNoDelay (SOCKET_TYPE sock, bool val) if ((result = setsockopt(sock, level, TCP_NODELAY, &enabled, sizeof(enabled))) != 0) set_last_socket_error (errno); - + return result; #else @@ -409,6 +421,170 @@ setTCPNoDelay (SOCKET_TYPE sock, bool val) } +// +// ServerSocket OS dependent stuff +// + +ServerSocket::ServerSocket(unsigned short port) +{ + int fds[2] = {-1, -1}; + int ret; + + sock = openSocket (port, state); + if (sock == INVALID_SOCKET_VALUE) + goto error; + +#if defined (LOG4CPLUS_HAVE_PIPE2) && defined (O_CLOEXEC) + ret = pipe2 (fds, O_CLOEXEC); + if (ret != 0) + goto error; + +#elif defined (LOG4CPLUS_HAVE_PIPE) + ret = pipe (fds); + if (ret != 0) + goto error; + + trySetCloseOnExec (fds[0]); + trySetCloseOnExec (fds[1]); + +#else +# error You are missing both pipe() or pipe2(). +#endif + + interruptHandles[0] = fds[0]; + interruptHandles[1] = fds[1]; + return; + +error:; + err = get_last_socket_error (); + state = not_opened; + + if (sock != INVALID_SOCKET_VALUE) + closeSocket (sock); + + if (fds[0] != -1) + ::close (fds[0]); + + if (fds[1] != -1) + ::close (fds[1]); +} + +Socket +ServerSocket::accept () +{ + struct pollfd pollfds[2]; + + struct pollfd & interrupt_pipe = pollfds[0]; + interrupt_pipe.fd = interruptHandles[0]; + interrupt_pipe.events = POLLIN; + interrupt_pipe.revents = 0; + + struct pollfd & accept_fd = pollfds[1]; + accept_fd.fd = to_os_socket (sock); + accept_fd.events = POLLIN; + accept_fd.revents = 0; + + do + { + interrupt_pipe.revents = 0; + accept_fd.revents = 0; + + int ret = poll (pollfds, 2, -1); + switch (ret) + { + // Error. + case -1: + if (errno == EINTR) + // Signal has interrupted the call. Just re-run it. + continue; + + set_last_socket_error (errno); + return Socket (INVALID_SOCKET_VALUE, not_opened, errno); + + // Timeout. This should not happen though. + case 0: + continue; + + default: + // Some descriptor is ready. + + if ((interrupt_pipe.revents & POLLIN) == POLLIN) + { + // Read byte from interruption pipe. + + helpers::getLogLog ().debug ( + LOG4CPLUS_TEXT ("ServerSocket::accept- ") + LOG4CPLUS_TEXT ("accept() interrupted by other thread")); + + char ch; + ret = ::read (interrupt_pipe.fd, &ch, 1); + if (ret == -1) + { + int const eno = errno; + helpers::getLogLog ().warn ( + LOG4CPLUS_TEXT ("ServerSocket::accept- read() failed: ") + + helpers::convertIntegerToString (eno)); + set_last_socket_error (eno); + return Socket (INVALID_SOCKET_VALUE, not_opened, eno); + } + + // Return Socket with state set to accept_interrupted. + + return Socket (INVALID_SOCKET_VALUE, accept_interrupted, 0); + } + else if ((accept_fd.revents & POLLIN) == POLLIN) + { + helpers::getLogLog ().debug ( + LOG4CPLUS_TEXT ("ServerSocket::accept- ") + LOG4CPLUS_TEXT ("accepting connection")); + + SocketState st = not_opened; + SOCKET_TYPE clientSock = acceptSocket (sock, st); + int eno = 0; + if (clientSock == INVALID_SOCKET_VALUE) + eno = get_last_socket_error (); + + return Socket (clientSock, st, eno); + } + else + return Socket (INVALID_SOCKET_VALUE, not_opened, 0); + } + } + while (true); +} + + +void +ServerSocket::interruptAccept () +{ + char ch = 'I'; + int ret; + + do + { + ret = ::write (interruptHandles[1], &ch, 1); + } + while (ret == -1 && errno == EINTR); + + if (ret == -1) + { + int const eno = errno; + helpers::getLogLog ().warn ( + LOG4CPLUS_TEXT ("ServerSocket::interruptAccept- write() failed: ") + + helpers::convertIntegerToString (eno)); + } +} + + +ServerSocket::~ServerSocket() +{ + if (interruptHandles[0] != -1) + ::close (interruptHandles[0]); + + if (interruptHandles[1] != -1) + ::close (interruptHandles[1]); +} + } } // namespace log4cplus #endif // LOG4CPLUS_USE_BSD_SOCKETS diff --git a/src/socket-win32.cxx b/src/socket-win32.cxx index 0f74dccf5..aee68dbfe 100644 --- a/src/socket-win32.cxx +++ b/src/socket-win32.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ #include #include #include +#include ///////////////////////////////////////////////////////////////////////////// @@ -88,7 +89,8 @@ init_winsock_worker () // Wait for state change. while (true) { - switch (winsock_state) + LONG state = InterlockedExchangeAdd (&winsock_state, 0); + switch (state) { case WS_INITIALIZED: return; @@ -96,7 +98,7 @@ init_winsock_worker () case WS_INITIALIZING: log4cplus::thread::yield (); continue; - + default: assert (0); loglog->error (LOG4CPLUS_TEXT ("Unknown WinSock state."), true); @@ -223,7 +225,7 @@ connectSocket(const tstring& hostn, unsigned short port, bool udp, SocketState& INT ret = WSAStringToAddress (const_cast(hostn.c_str ()), AF_INET, 0, reinterpret_cast(&insock), &insock_size); - if (ret == SOCKET_ERROR || insock_size != sizeof (insock)) + if (ret == SOCKET_ERROR || insock_size != static_cast(sizeof (insock))) { state = bad_address; goto error; @@ -265,6 +267,8 @@ acceptSocket(SOCKET_TYPE sock, SocketState & state) if (connected_socket != INVALID_OS_SOCKET_VALUE) state = ok; + else + set_last_socket_error (WSAGetLastError ()); return to_log4cplus_socket (connected_socket); } @@ -278,16 +282,23 @@ closeSocket(SOCKET_TYPE sock) } +int +shutdownSocket(SOCKET_TYPE sock) +{ + return ::shutdown (to_os_socket (sock), SD_BOTH); +} + long read(SOCKET_TYPE sock, SocketBuffer& buffer) { long res, read = 0; - + os_socket_type const osSocket = to_os_socket (sock); + do - { - res = ::recv(to_os_socket (sock), - buffer.getBuffer() + read, + { + res = ::recv(osSocket, + buffer.getBuffer() + read, static_cast(buffer.getMaxSize() - read), 0); if (res == SOCKET_ERROR) @@ -295,10 +306,16 @@ read(SOCKET_TYPE sock, SocketBuffer& buffer) set_last_socket_error (WSAGetLastError ()); return res; } + + // A return of 0 indicates the socket is closed, + // return to prevent an infinite loop. + if (res == 0) + return read; + read += res; } while (read < static_cast(buffer.getMaxSize())); - + return read; } @@ -329,6 +346,8 @@ write(SOCKET_TYPE sock, const std::string & buffer) tstring getHostname (bool fqdn) { + init_winsock (); + char const * hostname = "unknown"; int ret; std::vector hn (1024, 0); @@ -375,6 +394,196 @@ setTCPNoDelay (SOCKET_TYPE sock, bool val) } +// +// ServerSocket OS dependent stuff +// + +namespace +{ + +static +bool +setSocketBlocking (SOCKET_TYPE s) +{ + u_long val = 0; + int ret = ioctlsocket (to_os_socket (s), FIONBIO, &val); + if (ret == SOCKET_ERROR) + { + set_last_socket_error (WSAGetLastError ()); + return false; + } + else + return true; +} + +static +bool +removeSocketEvents (SOCKET_TYPE s, HANDLE ev) +{ + // Clean up socket events handling. + + int ret = WSAEventSelect (to_os_socket (s), ev, 0); + if (ret == SOCKET_ERROR) + { + set_last_socket_error (WSAGetLastError ()); + return false; + } + else + return true; +} + + +static +bool +socketEventHandlingCleanup (SOCKET_TYPE s, HANDLE ev) +{ + bool ret = removeSocketEvents (s, ev); + ret = setSocketBlocking (s) && ret; + ret = WSACloseEvent (ev) && ret; + return ret; +} + + +} // namespace + + +ServerSocket::ServerSocket(unsigned short port) +{ + sock = openSocket (port, state); + if (sock == INVALID_SOCKET_VALUE) + { + err = get_last_socket_error (); + return; + } + + HANDLE ev = WSACreateEvent (); + if (ev == WSA_INVALID_EVENT) + { + err = WSAGetLastError (); + closeSocket (sock); + sock = INVALID_SOCKET_VALUE; + } + else + { + assert (sizeof (std::ptrdiff_t) >= sizeof (HANDLE)); + interruptHandles[0] = reinterpret_cast(ev); + } +} + +Socket +ServerSocket::accept () +{ + int const N_EVENTS = 2; + HANDLE events[N_EVENTS] = { + reinterpret_cast(interruptHandles[0]) }; + HANDLE & accept_ev = events[1]; + int ret; + + // Create event and prime socket to set the event on FD_ACCEPT. + + accept_ev = WSACreateEvent (); + if (accept_ev == WSA_INVALID_EVENT) + { + set_last_socket_error (WSAGetLastError ()); + goto error; + } + + ret = WSAEventSelect (to_os_socket (sock), accept_ev, FD_ACCEPT); + if (ret == SOCKET_ERROR) + { + set_last_socket_error (WSAGetLastError ()); + goto error; + } + + do + { + // Wait either for interrupt event or actual connection coming in. + + DWORD wsawfme = WSAWaitForMultipleEvents (N_EVENTS, events, FALSE, + WSA_INFINITE, TRUE); + switch (wsawfme) + { + case WSA_WAIT_TIMEOUT: + case WSA_WAIT_IO_COMPLETION: + // Retry after timeout or APC. + continue; + + // This is interrupt signal/event. + case WSA_WAIT_EVENT_0: + { + // Reset the interrupt event back to non-signalled state. + + ret = WSAResetEvent (reinterpret_cast(interruptHandles[0])); + + // Clean up socket events handling. + + ret = socketEventHandlingCleanup (sock, accept_ev); + + // Return Socket with state set to accept_interrupted. + + return Socket (INVALID_SOCKET_VALUE, accept_interrupted, 0); + } + + // This is accept_ev. + case WSA_WAIT_EVENT_0 + 1: + { + // Clean up socket events handling. + + ret = socketEventHandlingCleanup (sock, accept_ev); + + // Finally, call accept(). + + SocketState st = not_opened; + SOCKET_TYPE clientSock = acceptSocket (sock, st); + int eno = 0; + if (clientSock == INVALID_SOCKET_VALUE) + eno = get_last_socket_error (); + + return Socket (clientSock, st, eno); + } + + case WSA_WAIT_FAILED: + default: + set_last_socket_error (WSAGetLastError ()); + goto error; + } + } + while (true); + + +error:; + DWORD eno = get_last_socket_error (); + + // Clean up socket events handling. + + if (sock != INVALID_SOCKET_VALUE) + { + (void) removeSocketEvents (sock, accept_ev); + (void) setSocketBlocking (sock); + } + + if (accept_ev != WSA_INVALID_EVENT) + WSACloseEvent (accept_ev); + + set_last_socket_error (eno); + return Socket (INVALID_SOCKET_VALUE, not_opened, eno); +} + + +void +ServerSocket::interruptAccept () +{ + (void) WSASetEvent (reinterpret_cast(interruptHandles[0])); +} + + +ServerSocket::~ServerSocket() +{ + (void) WSACloseEvent (reinterpret_cast(interruptHandles[0])); +} + + + } } // namespace log4cplus { namespace helpers { #endif // LOG4CPLUS_USE_WINSOCK diff --git a/src/socket.cxx b/src/socket.cxx index c5e5de783..938de0a0d 100644 --- a/src/socket.cxx +++ b/src/socket.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -83,6 +83,14 @@ AbstractSocket::close() } +void +AbstractSocket::shutdown() +{ + if(sock != INVALID_SOCKET_VALUE) { + shutdownSocket(sock); + } +} + bool AbstractSocket::isOpen() const @@ -92,7 +100,6 @@ AbstractSocket::isOpen() const - AbstractSocket& AbstractSocket::operator=(const AbstractSocket& rhs) { @@ -199,40 +206,4 @@ Socket::write(const std::string & buffer) } - - - -////////////////////////////////////////////////////////////////////////////// -// ServerSocket ctor and dtor -////////////////////////////////////////////////////////////////////////////// - -ServerSocket::ServerSocket(unsigned short port) -{ - sock = openSocket(port, state); - if(sock == INVALID_SOCKET_VALUE) { - err = get_last_socket_error (); - } -} - - - -ServerSocket::~ServerSocket() -{ -} - - - -////////////////////////////////////////////////////////////////////////////// -// ServerSocket methods -////////////////////////////////////////////////////////////////////////////// - -Socket -ServerSocket::accept() -{ - SocketState st = not_opened; - SOCKET_TYPE clientSock = acceptSocket(sock, st); - return Socket(clientSock, st, 0); -} - - } } // namespace log4cplus { namespace helpers { diff --git a/src/socketappender.cxx b/src/socketappender.cxx index cd06440cb..7fafd3d16 100644 --- a/src/socketappender.cxx +++ b/src/socketappender.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ // limitations under the License. #include +#include #include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include namespace log4cplus { @@ -168,7 +170,7 @@ SocketAppender::~SocketAppender() // SocketAppender public methods ////////////////////////////////////////////////////////////////////////////// -void +void SocketAppender::close() { helpers::getLogLog().debug( @@ -231,9 +233,16 @@ SocketAppender::append(const spi::InternalLoggingEvent& event) #endif helpers::SocketBuffer buffer(LOG4CPLUS_MAX_MESSAGE_SIZE - sizeof(unsigned int)); - convertToBuffer (buffer, event, serverName); - helpers::SocketBuffer msgBuffer(LOG4CPLUS_MAX_MESSAGE_SIZE); + try + { + convertToBuffer (buffer, event, serverName); + } + catch (std::runtime_error const & ex) + { + return; + } + helpers::SocketBuffer msgBuffer(LOG4CPLUS_MAX_MESSAGE_SIZE); msgBuffer.appendInt(static_cast(buffer.getSize())); msgBuffer.appendBuffer(buffer); @@ -315,8 +324,8 @@ readFromBuffer(SocketBuffer& buffer) // TODO: Pass MDC through. spi::InternalLoggingEvent ev (loggerName, ll, ndc, - MappedDiagnosticContextMap (), message, thread, Time(sec, usec), file, - line); + MappedDiagnosticContextMap (), message, thread, internal::empty_str, + Time(sec, usec), file, line); ev.setFunction (function); return ev; } diff --git a/src/socketbuffer.cxx b/src/socketbuffer.cxx index fe8f61ec2..3ab80368e 100644 --- a/src/socketbuffer.cxx +++ b/src/socketbuffer.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -23,6 +23,10 @@ #include #include +#if defined (LOG4CPLUS_HAVE_SYS_TYPES_H) +#include +#endif + #if !defined(_WIN32) # include #else @@ -118,7 +122,7 @@ SocketBuffer::readInt() std::memcpy (&ret, buffer + pos, sizeof(ret)); ret = ntohl(ret); pos += sizeof(unsigned int); - + return ret; } @@ -188,8 +192,10 @@ void SocketBuffer::appendByte(unsigned char val) { if((pos + sizeof(unsigned char)) > maxsize) { - getLogLog().error(LOG4CPLUS_TEXT("SocketBuffer::appendByte()- Attempt to write beyond end of buffer")); - return; + getLogLog().error( + LOG4CPLUS_TEXT("SocketBuffer::appendByte()-") + LOG4CPLUS_TEXT(" Attempt to write beyond end of buffer"), + true); } buffer[pos] = static_cast(val); @@ -203,8 +209,10 @@ void SocketBuffer::appendShort(unsigned short val) { if((pos + sizeof(unsigned short)) > maxsize) { - getLogLog().error(LOG4CPLUS_TEXT("SocketBuffer::appendShort()- Attempt to write beyond end of buffer")); - return; + getLogLog().error( + LOG4CPLUS_TEXT("SocketBuffer::appendShort()-") + LOG4CPLUS_TEXT("Attempt to write beyond end of buffer"), + true); } unsigned short s = htons(val); @@ -219,7 +227,10 @@ void SocketBuffer::appendInt(unsigned int val) { if((pos + sizeof(unsigned int)) > maxsize) { - getLogLog().error(LOG4CPLUS_TEXT("SocketBuffer::appendInt()- Attempt to write beyond end of buffer")); + getLogLog().error( + LOG4CPLUS_TEXT("SocketBuffer::appendInt()-") + LOG4CPLUS_TEXT(" Attempt to write beyond end of buffer"), + true); return; } @@ -235,12 +246,14 @@ void SocketBuffer::appendString(const tstring& str) { std::size_t const strlen = str.length(); - static std::size_t const sizeOfChar = sizeof (tchar) == 1 ? 1 : 2; + std::size_t const sizeOfChar = sizeof (tchar) == 1 ? 1 : 2; if((pos + sizeof(unsigned int) + strlen * sizeOfChar) > maxsize) { - getLogLog().error(LOG4CPLUS_TEXT("SocketBuffer::appendString()-") - LOG4CPLUS_TEXT(" Attempt to write beyond end of buffer")); + getLogLog().error( + LOG4CPLUS_TEXT("SocketBuffer::appendString()-") + LOG4CPLUS_TEXT(" Attempt to write beyond end of buffer"), + true); return; } @@ -250,7 +263,7 @@ SocketBuffer::appendString(const tstring& str) pos += strlen; size = pos; #else - for(tstring::size_type i=0; i(str[i])); } #endif @@ -262,7 +275,10 @@ void SocketBuffer::appendBuffer(const SocketBuffer& buf) { if((pos + buf.getSize()) > maxsize) { - getLogLog().error(LOG4CPLUS_TEXT("SocketBuffer::appendBuffer()- Attempt to write beyond end of buffer")); + getLogLog().error( + LOG4CPLUS_TEXT("SocketBuffer::appendBuffer()-") + LOG4CPLUS_TEXT(" Attempt to write beyond end of buffer"), + true); return; } diff --git a/src/stringhelper-clocale.cxx b/src/stringhelper-clocale.cxx index 24b58ac3c..f04d195f4 100644 --- a/src/stringhelper-clocale.cxx +++ b/src/stringhelper-clocale.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/stringhelper-cxxlocale.cxx b/src/stringhelper-cxxlocale.cxx index 579a1c54b..c57bff5fc 100644 --- a/src/stringhelper-cxxlocale.cxx +++ b/src/stringhelper-cxxlocale.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/stringhelper-iconv.cxx b/src/stringhelper-iconv.cxx index ddc08ca1d..2e4d6c67e 100644 --- a/src/stringhelper-iconv.cxx +++ b/src/stringhelper-iconv.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -76,7 +76,7 @@ struct iconv_handle if (handle == iconv_error_handle) { std::ostringstream oss; - oss << "iconv_open failed: " << errno; + oss << "iconv_open(" << to << ", " << from << ") failed: " << errno; std::cerr << oss.str () << std::endl; throw std::runtime_error (oss.str ().c_str ()); } @@ -84,17 +84,22 @@ struct iconv_handle ~iconv_handle () { - if (handle != iconv_error_handle) + try { - int ret = iconv_close (handle); - if (ret == -1) + if (handle != iconv_error_handle) { - std::ostringstream oss; - oss << "iconv_close failed: " << errno; - std::cerr << oss.str () << std::endl; - throw std::runtime_error (oss.str ().c_str ()); + int ret = iconv_close (handle); + if (ret == -1) + { + std::ostringstream oss; + oss << "iconv_close failed: " << errno; + std::cerr << oss.str () << std::endl; + throw std::runtime_error (oss.str ().c_str ()); + } } } + catch (std::runtime_error const &) + { } } size_t diff --git a/src/stringhelper.cxx b/src/stringhelper.cxx index 219e957da..a2cf849ed 100644 --- a/src/stringhelper.cxx +++ b/src/stringhelper.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/syncprims.cxx b/src/syncprims.cxx index b81af85da..1c3ef0a76 100644 --- a/src/syncprims.cxx +++ b/src/syncprims.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -40,7 +40,7 @@ syncprims_throw_exception (char const * const msg, char const * const file, int line) { std::ostringstream oss; - oss << file << ":" << line << msg; + oss << file << ":" << line << ": " << msg; throw std::runtime_error (oss.str ()); } diff --git a/src/syslogappender.cxx b/src/syslogappender.cxx index 6343df53c..6b8cdc67e 100644 --- a/src/syslogappender.cxx +++ b/src/syslogappender.cxx @@ -3,7 +3,7 @@ // Created: 6/2001 // Author: Tad E. Smith // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/threads.cxx b/src/threads.cxx index 3e77ea069..c35593b88 100644 --- a/src/threads.cxx +++ b/src/threads.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ # include # include #elif defined (LOG4CPLUS_USE_WIN32_THREADS) -# include +# include #endif #include #include @@ -78,7 +78,7 @@ blockAllSignals() sigset_t signal_set; sigfillset (&signal_set); pthread_sigmask (SIG_BLOCK, &signal_set, 0); -#endif +#endif } @@ -94,6 +94,12 @@ yield() #endif } +#if defined(LOG4CPLUS_SINGLE_THREADED) +static log4cplus::tstring thread_name(LOG4CPLUS_TEXT("single")) + LOG4CPLUS_INIT_PRIORITY (LOG4CPLUS_INIT_PRIORITY_BASE - 1); +static log4cplus::tstring thread_name2(thread_name) + LOG4CPLUS_INIT_PRIORITY (LOG4CPLUS_INIT_PRIORITY_BASE - 1); +#endif LOG4CPLUS_EXPORT log4cplus::tstring const & @@ -108,7 +114,11 @@ getCurrentThreadName() tmp.str ().swap (name); } #else - static log4cplus::tstring const name (LOG4CPLUS_TEXT ("single")); + log4cplus::tstring & name = thread_name; + if (LOG4CPLUS_UNLIKELY(name.empty())) + { + name = LOG4CPLUS_TEXT("single"); + } #endif return name; @@ -133,7 +143,7 @@ get_current_thread_name_alt (log4cplus::tostream * s) #elif defined (__CYGWIN__) unsigned long tid = cygwin::get_current_win32_thread_id (); os << tid; - + #else os << getCurrentThreadName (); @@ -160,13 +170,35 @@ getCurrentThreadName2() } #else - static log4cplus::tstring const name (getCurrentThreadName ()); + log4cplus::tstring & name = thread_name2; + if (LOG4CPLUS_UNLIKELY(name.empty())) + { + name = getCurrentThreadName(); + } #endif return name; } +LOG4CPLUS_EXPORT void setCurrentThreadName(const log4cplus::tstring & name) +{ +#if ! defined (LOG4CPLUS_SINGLE_THREADED) + log4cplus::internal::get_thread_name_str() = name; +#else + thread_name = name; +#endif +} + +LOG4CPLUS_EXPORT void setCurrentThreadName2(const log4cplus::tstring & name) +{ +#if ! defined (LOG4CPLUS_SINGLE_THREADED) + log4cplus::internal::get_thread_name2_str() = name; +#else + thread_name2 = name; +#endif +} + } } // namespace log4cplus { namespace thread { @@ -192,7 +224,7 @@ namespace log4cplus { namespace thread { namespace impl { #if defined(LOG4CPLUS_USE_PTHREADS) -void* +void* ThreadStart::threadStartFuncWorker(void * arg) #elif defined(LOG4CPLUS_USE_WIN32_THREADS) unsigned @@ -425,7 +457,7 @@ AbstractThread::~AbstractThread() { } -} } // namespace log4cplus { namespace thread { +} } // namespace log4cplus { namespace thread { #endif // LOG4CPLUS_SINGLE_THREADED diff --git a/src/timehelper.cxx b/src/timehelper.cxx index e19d7778e..df19cf0a9 100644 --- a/src/timehelper.cxx +++ b/src/timehelper.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -53,6 +53,8 @@ #define LOG4CPLUS_NEED_LOCALTIME_R #endif +#include + namespace log4cplus { namespace helpers { @@ -268,14 +270,14 @@ Time::getFormattedTime(const log4cplus::tstring& fmt_orig, bool use_gmtime) cons internal::gft_scratch_pad & gft_sp = internal::get_gft_scratch_pad (); gft_sp.reset (); - gft_sp.fmt.assign (fmt_orig); - gft_sp.ret.reserve (static_cast(gft_sp.fmt.size () * 1.35)); + std::size_t const fmt_orig_size = gft_sp.fmt.size (); + gft_sp.ret.reserve (fmt_orig_size + fmt_orig_size / 2); State state = TEXT; - // Walk the format string and process all occurences of %q and %Q. + // Walk the format string and process all occurences of %q, %Q and %s. - for (log4cplus::tstring::const_iterator fmt_it = gft_sp.fmt.begin (); - fmt_it != gft_sp.fmt.end (); ++fmt_it) + for (log4cplus::tstring::const_iterator fmt_it = fmt_orig.begin (); + fmt_it != fmt_orig.end (); ++fmt_it) { switch (state) { @@ -344,7 +346,7 @@ Time::getFormattedTime(const log4cplus::tstring& fmt_orig, bool use_gmtime) cons // Finally call strftime/wcsftime to format the rest of the string. - gft_sp.ret.swap (gft_sp.fmt); + gft_sp.fmt.swap (gft_sp.ret); std::size_t buffer_size = gft_sp.fmt.size () + 1; std::size_t len; diff --git a/src/tls.cxx b/src/tls.cxx index 2f8bc017d..66d787772 100644 --- a/src/tls.cxx +++ b/src/tls.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/version.cxx b/src/version.cxx index 8f848d717..cd00b9e2e 100644 --- a/src/version.cxx +++ b/src/version.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -28,7 +28,7 @@ namespace log4cplus { #if ! defined (LOG4CPLUS_VERSION_STR_SUFFIX) -#define LOG4CPLUS_VERSION_STR_SUFFIX "-RC5" +#define LOG4CPLUS_VERSION_STR_SUFFIX "" #endif unsigned const version = LOG4CPLUS_VERSION; diff --git a/src/win32consoleappender.cxx b/src/win32consoleappender.cxx index 8afbd43b3..0fb1a3acd 100644 --- a/src/win32consoleappender.cxx +++ b/src/win32consoleappender.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -33,13 +33,29 @@ #include #include +/* list of available colors which can be OR'ed together and provided as an INT in the config file, e.g.: + log4cplus.appender.INFO_MSGS.TextColor=36 + for red text on green background + +#define FOREGROUND_BLUE 0x0001 // text color contains blue. +#define FOREGROUND_GREEN 0x0002 // text color contains green. +#define FOREGROUND_RED 0x0004 // text color contains red. +#define FOREGROUND_INTENSITY 0x0008 // text color is intensified. +#define BACKGROUND_BLUE 0x0010 // background color contains blue. +#define BACKGROUND_GREEN 0x0020 // background color contains green. +#define BACKGROUND_RED 0x0040 // background color contains red. +#define BACKGROUND_INTENSITY 0x0080 // background color is intensified. +*/ + namespace log4cplus { -Win32ConsoleAppender::Win32ConsoleAppender (bool allocConsole) +Win32ConsoleAppender::Win32ConsoleAppender (bool allocConsole, bool logToStdErr, unsigned int textColor) : alloc_console (allocConsole) + , log_to_std_err (logToStdErr) + , text_color (textColor) { } @@ -47,8 +63,12 @@ Win32ConsoleAppender::Win32ConsoleAppender ( helpers::Properties const & properties) : Appender (properties) , alloc_console (true) + , log_to_std_err (false) + , text_color (0) { properties.getBool (alloc_console, LOG4CPLUS_TEXT ("AllocConsole")); + properties.getBool (log_to_std_err, LOG4CPLUS_TEXT ("logToStdErr")); + properties.getUInt (text_color, LOG4CPLUS_TEXT ("TextColor")); } @@ -73,7 +93,8 @@ Win32ConsoleAppender::append (spi::InternalLoggingEvent const & event) // it will fail. AllocConsole (); - HANDLE const console_out = GetStdHandle (STD_OUTPUT_HANDLE); + HANDLE const console_out = GetStdHandle ( + log_to_std_err ? STD_ERROR_HANDLE : STD_OUTPUT_HANDLE); if (console_out == INVALID_HANDLE_VALUE) { helpers::getLogLog ().error ( @@ -153,28 +174,67 @@ Win32ConsoleAppender::write_console (void * console_void, tchar const * s, HANDLE console_out = static_cast(console_void); DWORD const total_to_write = static_cast(str_len); DWORD total_written = 0; + BOOL ret = FALSE; + unsigned int oldColor = 0; + + if (text_color) + { + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + ret = GetConsoleScreenBufferInfo (console_out, &csbiInfo); + if (! ret) + { + helpers::getLogLog().error( + LOG4CPLUS_TEXT("Win32ConsoleAppender::write_console:") + LOG4CPLUS_TEXT(" GetConsoleScreenBufferInfo failed")); + // fallback to standard gray on black + oldColor = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED; + goto output; + } + + // store old color first + oldColor = csbiInfo.wAttributes; + + // set new color + ret = SetConsoleTextAttribute (console_out, text_color); + if (! ret) + { + helpers::getLogLog().error( + LOG4CPLUS_TEXT("Win32ConsoleAppender::write_console:") + LOG4CPLUS_TEXT(" SetConsoleTextAttribute failed")); + } + } +output:; do { DWORD const to_write = (std::min) (64*1024 - 1, total_to_write - total_written); DWORD written = 0; - BOOL ret = WriteConsole (console_out, s + total_written, to_write, - &written, 0); + ret = WriteConsole (console_out, s + total_written, to_write, &written, + 0); if (! ret) { helpers::getLogLog ().error ( LOG4CPLUS_TEXT ("Win32ConsoleAppender::write_console") LOG4CPLUS_TEXT ("- WriteConsole has failed.")); - return; + break; } total_written += written; } while (total_written != total_to_write); -} + if (text_color) + { + // restore old color again + ret = SetConsoleTextAttribute (console_out, oldColor); + if (! ret) + helpers::getLogLog().error( + LOG4CPLUS_TEXT("Win32ConsoleAppender::write_console:") + LOG4CPLUS_TEXT(" SetConsoleTextAttribute failed")); + } +} } // namespace log4cplus diff --git a/src/win32debugappender.cxx b/src/win32debugappender.cxx index b83e0f6be..d7e56a082 100644 --- a/src/win32debugappender.cxx +++ b/src/win32debugappender.cxx @@ -4,7 +4,7 @@ // Author: Eduardo Francos, Odalio SARL // // -// Copyright 2003-2010 Odalio SARL +// Copyright 2003-2013 Odalio SARL // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3a72f5972..3e5b37d8d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,7 +12,7 @@ function(log4cplus_add_test _name) # message (STATUS "${_name} sources: ${_srcs}") add_executable (${_name} ${_srcs}) target_link_libraries (${_name} ${log4cplus}) - add_test(${_name} ${_name}) + add_test(NAME ${_name} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${_name}) endfunction() diff --git a/tests/Makefile.in b/tests/Makefile.in index a5edde4de..2893fb8cd 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -73,7 +73,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -174,6 +177,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/appender_test/Makefile.in b/tests/appender_test/Makefile.in index 4524c299a..38fce9357 100644 --- a/tests/appender_test/Makefile.in +++ b/tests/appender_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/appender_test/main.cxx b/tests/appender_test/main.cxx index 5ecfee961..16310669a 100644 --- a/tests/appender_test/main.cxx +++ b/tests/appender_test/main.cxx @@ -29,6 +29,7 @@ printAppenderList(SharedAppenderPtrList list) int main() { + log4cplus::initialize (); LogLog::getLogLog()->setInternalDebugging(true); { AppenderAttachableImpl aai; diff --git a/tests/configandwatch_test/Makefile.in b/tests/configandwatch_test/Makefile.in index 1303455fd..a3ddef2d0 100644 --- a/tests/configandwatch_test/Makefile.in +++ b/tests/configandwatch_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -153,6 +156,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/configandwatch_test/main.cxx b/tests/configandwatch_test/main.cxx index d237afe5d..e5a7d4efe 100644 --- a/tests/configandwatch_test/main.cxx +++ b/tests/configandwatch_test/main.cxx @@ -32,6 +32,7 @@ int main() { tcout << LOG4CPLUS_TEXT("Entering main()...") << endl; + log4cplus::initialize (); LogLog::getLogLog()->setInternalDebugging(true); Logger root = Logger::getRoot(); try diff --git a/tests/customloglevel_test/Makefile.in b/tests/customloglevel_test/Makefile.in index cf3d08fbb..e36349ed2 100644 --- a/tests/customloglevel_test/Makefile.in +++ b/tests/customloglevel_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -154,6 +157,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/customloglevel_test/main.cxx b/tests/customloglevel_test/main.cxx index 766272e36..459e7a751 100644 --- a/tests/customloglevel_test/main.cxx +++ b/tests/customloglevel_test/main.cxx @@ -18,45 +18,44 @@ main() { cout << "Entering main()..." << endl; { - SharedAppenderPtr append_1(new ConsoleAppender()); - append_1->setName(LOG4CPLUS_TEXT("First")); -// append_1->setLayout( std::auto_ptr(new TTCCLayout()) ); - cout << "Getting root logger...DONE" << endl; - Logger::getRoot().addAppender(append_1); - - Logger root = Logger::getRoot(); - Logger test = Logger::getInstance(LOG4CPLUS_TEXT("test")); - Logger subTest = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest")); - LogLevelManager& llm = getLogLevelManager(); - - LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); - - LOG4CPLUS_FATAL(root, "\nSetting test.subtest to WARN"); - subTest.setLogLevel(WARN_LOG_LEVEL); - LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); - - LOG4CPLUS_FATAL(root, "\nSetting test to CRITICAL"); - test.setLogLevel(CRITICAL_LOG_LEVEL); - LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); - - LOG4CPLUS_FATAL(root, "\nSetting test.subtest to NOT_SET_LOG_LEVEL"); - subTest.setLogLevel(NOT_SET_LOG_LEVEL); - LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel()) << '\n'); - - writeLogMessage(); - cout << "Returned from writeLogMessage()..." << endl; + log4cplus::initialize (); + SharedAppenderPtr append_1(new ConsoleAppender()); + append_1->setName(LOG4CPLUS_TEXT("First")); + // append_1->setLayout( std::auto_ptr(new TTCCLayout()) ); + cout << "Getting root logger...DONE" << endl; + Logger::getRoot().addAppender(append_1); + + Logger root = Logger::getRoot(); + Logger test = Logger::getInstance(LOG4CPLUS_TEXT("test")); + Logger subTest = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest")); + LogLevelManager& llm = getLogLevelManager(); + + LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); + + LOG4CPLUS_FATAL(root, "Setting test.subtest to WARN"); + subTest.setLogLevel(WARN_LOG_LEVEL); + LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); + + LOG4CPLUS_FATAL(root, "Setting test to CRITICAL"); + test.setLogLevel(CRITICAL_LOG_LEVEL); + LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); + + LOG4CPLUS_FATAL(root, "Setting test.subtest to NOT_SET_LOG_LEVEL"); + subTest.setLogLevel(NOT_SET_LOG_LEVEL); + LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); + + writeLogMessage(); + cout << "Returned from writeLogMessage()..." << endl; } cout << "REALLY exiting main()..." << endl; return 0; } - - diff --git a/tests/fileappender_test/Makefile.in b/tests/fileappender_test/Makefile.in index 8d4834e51..1bcc14edf 100644 --- a/tests/fileappender_test/Makefile.in +++ b/tests/fileappender_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/fileappender_test/main.cxx b/tests/fileappender_test/main.cxx index 391fd047d..b31f1aa3d 100644 --- a/tests/fileappender_test/main.cxx +++ b/tests/fileappender_test/main.cxx @@ -14,6 +14,7 @@ const int LOOP_COUNT = 20000; int main() { + log4cplus::initialize (); helpers::LogLog::getLogLog()->setInternalDebugging(true); SharedAppenderPtr append_1( new RollingFileAppender(LOG4CPLUS_TEXT("Test.log"), 5*1024, 5)); diff --git a/tests/filter_test/Makefile.in b/tests/filter_test/Makefile.in index 668f2fec1..2e96a4029 100644 --- a/tests/filter_test/Makefile.in +++ b/tests/filter_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/filter_test/main.cxx b/tests/filter_test/main.cxx index 31d223ddb..b3fb3e7fa 100644 --- a/tests/filter_test/main.cxx +++ b/tests/filter_test/main.cxx @@ -28,6 +28,7 @@ int main() { tcout << "Entering main()..." << endl; + log4cplus::initialize (); LogLog::getLogLog()->setInternalDebugging(true); Logger root = Logger::getRoot(); try { diff --git a/tests/hierarchy_test/Makefile.in b/tests/hierarchy_test/Makefile.in index c3c32923b..9b3ff9295 100644 --- a/tests/hierarchy_test/Makefile.in +++ b/tests/hierarchy_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/hierarchy_test/main.cxx b/tests/hierarchy_test/main.cxx index 9e9a77215..3263f8e97 100644 --- a/tests/hierarchy_test/main.cxx +++ b/tests/hierarchy_test/main.cxx @@ -11,6 +11,7 @@ using namespace log4cplus::helpers; int main() { + log4cplus::initialize (); { Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("test")); diff --git a/tests/loglog_test/Makefile.in b/tests/loglog_test/Makefile.in index 69e3d825b..2886a84e8 100644 --- a/tests/loglog_test/Makefile.in +++ b/tests/loglog_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/loglog_test/main.cxx b/tests/loglog_test/main.cxx index bed79115e..0bb8d0701 100644 --- a/tests/loglog_test/main.cxx +++ b/tests/loglog_test/main.cxx @@ -16,6 +16,7 @@ void printMsgs() { int main() { + log4cplus::initialize (); printMsgs(); cout << "Turning on debug..." << endl; diff --git a/tests/ndc_test/Makefile.in b/tests/ndc_test/Makefile.in index 03eaf1ece..aa115057f 100644 --- a/tests/ndc_test/Makefile.in +++ b/tests/ndc_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/ndc_test/main.cxx b/tests/ndc_test/main.cxx index 4608917ef..3eccdd09c 100644 --- a/tests/ndc_test/main.cxx +++ b/tests/ndc_test/main.cxx @@ -15,11 +15,15 @@ int main() { cout << "Entering main()..." << endl; + log4cplus::initialize (); LogLog::getLogLog()->setInternalDebugging(true); try { SharedObjectPtr append_1(new ConsoleAppender()); append_1->setName(LOG4CPLUS_TEXT("First")); - append_1->setLayout( std::auto_ptr(new log4cplus::TTCCLayout()) ); + append_1->setLayout( + std::auto_ptr( + new log4cplus::PatternLayout( + LOG4CPLUS_TEXT ("%-5p %c <%x> - %m%n")))); Logger::getRoot().addAppender(append_1); Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("test")); diff --git a/tests/ostream_test/Makefile.in b/tests/ostream_test/Makefile.in index c30e5f9b6..8b771563a 100644 --- a/tests/ostream_test/Makefile.in +++ b/tests/ostream_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/ostream_test/main.cxx b/tests/ostream_test/main.cxx index b7cefcebc..df4e1a315 100644 --- a/tests/ostream_test/main.cxx +++ b/tests/ostream_test/main.cxx @@ -11,6 +11,7 @@ using namespace log4cplus; int main() { + log4cplus::initialize (); SharedAppenderPtr append_1(new ConsoleAppender()); append_1->setName(LOG4CPLUS_TEXT("First")); Logger::getRoot().addAppender(append_1); diff --git a/tests/patternlayout_test/Makefile.in b/tests/patternlayout_test/Makefile.in index 7478fb91a..47d1f0a79 100644 --- a/tests/patternlayout_test/Makefile.in +++ b/tests/patternlayout_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/patternlayout_test/main.cxx b/tests/patternlayout_test/main.cxx index f57d4dcca..ba5466bc8 100644 --- a/tests/patternlayout_test/main.cxx +++ b/tests/patternlayout_test/main.cxx @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -18,12 +19,15 @@ int main() { cout << "Entering main()..." << endl; + log4cplus::initialize (); LogLog::getLogLog()->setInternalDebugging(true); try { SharedObjectPtr append_1(new ConsoleAppender()); append_1->setName(LOG4CPLUS_TEXT("First")); - log4cplus::tstring pattern = LOG4CPLUS_TEXT("%d{%m/%d/%y %H:%M:%S,%Q} [%t] %-5p %c{2} %%%x%% - %m [%l]%n"); + log4cplus::getMDC ().put (LOG4CPLUS_TEXT ("key"), + LOG4CPLUS_TEXT ("MDC value")); + log4cplus::tstring pattern = LOG4CPLUS_TEXT("%d{%m/%d/%y %H:%M:%S,%Q} [%t] %-5p %c{2} %%%x%% - %X{key} - %m [%l]%n"); // std::tstring pattern = LOG4CPLUS_TEXT("%d{%c} [%t] %-5p [%.15c{3}] %%%x%% - %m [%l]%n"); append_1->setLayout( std::auto_ptr(new PatternLayout(pattern)) ); Logger::getRoot().addAppender(append_1); diff --git a/tests/performance_test/Makefile.in b/tests/performance_test/Makefile.in index 70430ab2a..a170c3de8 100644 --- a/tests/performance_test/Makefile.in +++ b/tests/performance_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/performance_test/main.cxx b/tests/performance_test/main.cxx index 9536c28f9..f07afbfa8 100644 --- a/tests/performance_test/main.cxx +++ b/tests/performance_test/main.cxx @@ -26,6 +26,7 @@ int main() { tcout << LOG4CPLUS_TEXT("Entering main()...") << endl; + log4cplus::initialize (); PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus.properties")); Logger root = Logger::getRoot(); try { diff --git a/tests/priority_test/Makefile.in b/tests/priority_test/Makefile.in index da971e2d8..8bf8a03e5 100644 --- a/tests/priority_test/Makefile.in +++ b/tests/priority_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/priority_test/main.cxx b/tests/priority_test/main.cxx index 62653e158..7d31cb522 100644 --- a/tests/priority_test/main.cxx +++ b/tests/priority_test/main.cxx @@ -18,6 +18,7 @@ int main() { cout << "Entering main()..." << endl; + log4cplus::initialize (); { SharedAppenderPtr append_1(new ConsoleAppender()); append_1->setName(LOG4CPLUS_TEXT("First")); diff --git a/tests/propertyconfig_test/Makefile.in b/tests/propertyconfig_test/Makefile.in index 9d4aa4fbe..8be8afb62 100644 --- a/tests/propertyconfig_test/Makefile.in +++ b/tests/propertyconfig_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -153,6 +156,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/propertyconfig_test/main.cxx b/tests/propertyconfig_test/main.cxx index fd7487e5e..59ed1d94c 100644 --- a/tests/propertyconfig_test/main.cxx +++ b/tests/propertyconfig_test/main.cxx @@ -15,6 +15,7 @@ int main() { tcout << LOG4CPLUS_TEXT("Entering main()...") << endl; + log4cplus::initialize (); LogLog::getLogLog()->setInternalDebugging(true); Logger root = Logger::getRoot(); try { diff --git a/tests/socket_test/Makefile.in b/tests/socket_test/Makefile.in index 6c72efe9b..2c22a7c6b 100644 --- a/tests/socket_test/Makefile.in +++ b/tests/socket_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/socket_test/main.cxx b/tests/socket_test/main.cxx index d52b87b09..f2a267f01 100644 --- a/tests/socket_test/main.cxx +++ b/tests/socket_test/main.cxx @@ -14,6 +14,7 @@ using namespace log4cplus; int main(int argc, char **argv) { + log4cplus::initialize (); log4cplus::helpers::sleep(1); tstring serverName = (argc > 1 ? LOG4CPLUS_C_STR_TO_TSTRING(argv[1]) : tstring()); // tstring host = LOG4CPLUS_TEXT("192.168.2.10"); diff --git a/tests/thread_test/Makefile.in b/tests/thread_test/Makefile.in index 2fa041df5..aba2a81b0 100644 --- a/tests/thread_test/Makefile.in +++ b/tests/thread_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/thread_test/main.cxx b/tests/thread_test/main.cxx index c54100f20..dfeb0b75f 100644 --- a/tests/thread_test/main.cxx +++ b/tests/thread_test/main.cxx @@ -76,6 +76,7 @@ class TestThread : public AbstractThread { int main() { + log4cplus::initialize(); try { auto_ptr slowObject(new SlowObject()); diff --git a/tests/timeformat_test/Makefile.in b/tests/timeformat_test/Makefile.in index 9babaa335..e3c248e6e 100644 --- a/tests/timeformat_test/Makefile.in +++ b/tests/timeformat_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. @@ -76,7 +76,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -152,6 +155,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/timeformat_test/main.cxx b/tests/timeformat_test/main.cxx index 3cdfd4f8c..2fc99fd48 100644 --- a/tests/timeformat_test/main.cxx +++ b/tests/timeformat_test/main.cxx @@ -14,6 +14,7 @@ int main() { std::cout << "Entering main()..." << std::endl; + log4cplus::initialize (); try { Time time;
Conversion Character
EUsed to output the value of a given environment variable. The + * name of is supplied as an argument in brackets. If the variable does + * exist then empty string will be used. + * + * For example, the pattern %E{HOME} will output the contents + * of the HOME environment variable. + *
FUsed to output the file name where the logging request was @@ -436,6 +447,17 @@ namespace log4cplus { *
XUsed to output the MDC (mapped diagnostic context) + * associated with the thread that generated the logging + * event. It takes optional key parameter. Without the key + * paramter (%%X), it outputs the whole MDC map. With the key + * (%%X{key}), it outputs just the key's value. + *
"%%"The sequence "%%" outputs a single percent sign. *