Date: Sunday, March 14, 2021 @ 00:23:06 Author: foutrelis Revision: 409837
Prepare bump to 1.0.0 for protobuf 3.15 rebuild Added: usbguard/trunk/fix-compilation-errors-with-PEGTL-3.2.0.patch usbguard/trunk/increase-C++-version-to-c++17.patch Modified: usbguard/trunk/PKGBUILD Deleted: usbguard/trunk/make-explicitly-treat-pthread-as-first-level-depende.patch ------------------------------------------------------------+ PKGBUILD | 21 fix-compilation-errors-with-PEGTL-3.2.0.patch | 199 +++ increase-C++-version-to-c++17.patch | 65 + make-explicitly-treat-pthread-as-first-level-depende.patch | 598 ----------- 4 files changed, 276 insertions(+), 607 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2021-03-13 22:59:51 UTC (rev 409836) +++ PKGBUILD 2021-03-14 00:23:06 UTC (rev 409837) @@ -2,10 +2,10 @@ # Contributor: Ian Beringer <[email protected]> pkgname=usbguard -pkgver=0.7.5 -pkgrel=4 +pkgver=1.0.0 +pkgrel=0 pkgdesc='Software framework for implementing USB device authorization policies' -url='https://github.com/dkopecek/usbguard' +url='https://github.com/USBGuard/usbguard' arch=('x86_64') license=('GPL2') depends=('glibc' 'libqb' 'libqb.so' 'libsodium' 'libcap-ng' 'protobuf' 'polkit' 'dbus-glib' @@ -14,17 +14,20 @@ provides=('libusbguard.so') backup=(etc/usbguard/usbguard-daemon.conf etc/usbguard/rules.conf) -source=(https://github.com/dkopecek/usbguard/releases/download/${pkgname}-${pkgver}/${pkgname}-${pkgver}.tar.gz{,.sig} - make-explicitly-treat-pthread-as-first-level-depende.patch) -sha512sums=('b14f1cfaec676b5bc2f3aa2bda8be96ea8a6b3f02fc78f0fa7a58dd079c57886aae2c33a9e99cb9ccd53e5d6fa27712b978a2d19cd58b75dda34516d8caed0c4' +source=(https://github.com/USBGuard/usbguard/releases/download/${pkgname}-${pkgver}/${pkgname}-${pkgver}.tar.gz{,.asc} + increase-C++-version-to-c++17.patch + fix-compilation-errors-with-PEGTL-3.2.0.patch) +sha512sums=('068a9be8bd5ea05efcdad79e2c4beb5e8b646b4703fbe1f8bb262e37ae9a6284a6eeb811a6bd441250a38bce1e45b7f44ad15726aa5963da2e1b56e85f5e16fd' 'SKIP' - '02232be248aa11e543b0cd2f26e3ff735267b58bb3a255fc32e390f0efff302e4b749fee3927942585a799f0e7571836bc085f89aef43df5517a678b04596e5a') -validpgpkeys=('FD9B3F9DCEBB5537A8FAF5213B0C109510712034') # Daniel Kopeček <[email protected]> + '4b17564e2b21f1378d6369536d47a658e5f018ea9aef47ff726c272d3d40ae5ffadd3ca5ff7304c916cbf169c288b38fb9280dab61ff2edf9e4878847085ae78' + '31ebb71aa9c9d5dcec378d6974d63fe6f2675f748bdff6498a027f9840e0da03ad66c86d240eeccdceb4c1f2a966f6c528c8630226892d94271dac3ae11d1697') +validpgpkeys=('DE78B93EAED8A620F5AA14DF52F7E84653274B59') # Radovan Sroka <[email protected]> prepare() { cd ${pkgname}-${pkgver} + patch -Np1 -i ../increase-C++-version-to-c++17.patch + patch -Np1 -i ../fix-compilation-errors-with-PEGTL-3.2.0.patch sed 's|/usr/include/catch|/usr/include/catch2|g' -i configure.ac - patch -Np1 < ../make-explicitly-treat-pthread-as-first-level-depende.patch autoreconf -fiv } Added: fix-compilation-errors-with-PEGTL-3.2.0.patch =================================================================== --- fix-compilation-errors-with-PEGTL-3.2.0.patch (rev 0) +++ fix-compilation-errors-with-PEGTL-3.2.0.patch 2021-03-14 00:23:06 UTC (rev 409837) @@ -0,0 +1,199 @@ +From 1c5433ef01b69a0f4c6277c742d703889f9ffb00 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zolt=C3=A1n=20Fridrich?= <[email protected]> +Date: Mon, 1 Mar 2021 16:25:03 +0100 +Subject: [PATCH] Fix Compilation errors with PEGTL 3.2.0 (#453) + +(cherry picked from commit 4bf21aedcb260314996f0fa521ef4a3a6ae4a2bb) +--- + configure.ac | 2 +- + src/Library/RuleParser/Grammar.hpp | 46 +++++++++++----------- + src/Library/UEventParser.cpp | 8 ++++ + src/Library/UMockdevDeviceDefinition.cpp | 20 +++++++--- + src/Library/public/usbguard/RuleParser.cpp | 12 ++++++ + 5 files changed, 58 insertions(+), 30 deletions(-) + +diff --git a/configure.ac b/configure.ac +index acca0e8..73021b6 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -768,7 +768,7 @@ echo " libseccomp: $libseccomp_summary" + echo " libcap-ng: $libcap_ng_summary" + echo " protobuf: $protobuf_summary" + echo " Catch: $catch_summary" +-echo " PEGTL: $pegtl_summary; version <= 2.6.0: $have_pegtl_lte_260" ++echo " PEGTL: $pegtl_summary; version <= 3.2.0: $have_pegtl_lte_320" + echo " GDBus: $dbus_summary" + echo " umockdev: $umockdev_summary" + echo +diff --git a/src/Library/RuleParser/Grammar.hpp b/src/Library/RuleParser/Grammar.hpp +index c80eb2d..aebb727 100644 +--- a/src/Library/RuleParser/Grammar.hpp ++++ b/src/Library/RuleParser/Grammar.hpp +@@ -34,29 +34,29 @@ namespace usbguard + /* + * Rule language keywords + */ +- struct str_allow : TAOCPP_PEGTL_STRING("allow") {}; +- struct str_block : TAOCPP_PEGTL_STRING("block") {}; +- struct str_reject : TAOCPP_PEGTL_STRING("reject") {}; +- struct str_match : TAOCPP_PEGTL_STRING("match") {}; +- struct str_device : TAOCPP_PEGTL_STRING("device") {}; +- +- struct str_name : TAOCPP_PEGTL_STRING("name") {}; +- struct str_hash : TAOCPP_PEGTL_STRING("hash") {}; +- struct str_parent_hash : TAOCPP_PEGTL_STRING("parent-hash") {}; +- struct str_via_port : TAOCPP_PEGTL_STRING("via-port") {}; +- struct str_with_interface : TAOCPP_PEGTL_STRING("with-interface") {}; +- struct str_with_connect_type : TAOCPP_PEGTL_STRING("with-connect-type") {}; +- struct str_serial : TAOCPP_PEGTL_STRING("serial") {}; +- struct str_if : TAOCPP_PEGTL_STRING("if") {}; +- struct str_id : TAOCPP_PEGTL_STRING("id") {}; +- struct str_label : TAOCPP_PEGTL_STRING("label") {}; +- +- struct str_all_of : TAOCPP_PEGTL_STRING("all-of") {}; +- struct str_one_of : TAOCPP_PEGTL_STRING("one-of") {}; +- struct str_none_of : TAOCPP_PEGTL_STRING("none-of") {}; +- struct str_equals : TAOCPP_PEGTL_STRING("equals") {}; +- struct str_equals_ordered : TAOCPP_PEGTL_STRING("equals-ordered") {}; +- struct str_match_all: TAOCPP_PEGTL_STRING("match-all") {}; ++ struct str_allow : TAO_PEGTL_STRING("allow") {}; ++ struct str_block : TAO_PEGTL_STRING("block") {}; ++ struct str_reject : TAO_PEGTL_STRING("reject") {}; ++ struct str_match : TAO_PEGTL_STRING("match") {}; ++ struct str_device : TAO_PEGTL_STRING("device") {}; ++ ++ struct str_name : TAO_PEGTL_STRING("name") {}; ++ struct str_hash : TAO_PEGTL_STRING("hash") {}; ++ struct str_parent_hash : TAO_PEGTL_STRING("parent-hash") {}; ++ struct str_via_port : TAO_PEGTL_STRING("via-port") {}; ++ struct str_with_interface : TAO_PEGTL_STRING("with-interface") {}; ++ struct str_with_connect_type : TAO_PEGTL_STRING("with-connect-type") {}; ++ struct str_serial : TAO_PEGTL_STRING("serial") {}; ++ struct str_if : TAO_PEGTL_STRING("if") {}; ++ struct str_id : TAO_PEGTL_STRING("id") {}; ++ struct str_label : TAO_PEGTL_STRING("label") {}; ++ ++ struct str_all_of : TAO_PEGTL_STRING("all-of") {}; ++ struct str_one_of : TAO_PEGTL_STRING("one-of") {}; ++ struct str_none_of : TAO_PEGTL_STRING("none-of") {}; ++ struct str_equals : TAO_PEGTL_STRING("equals") {}; ++ struct str_equals_ordered : TAO_PEGTL_STRING("equals-ordered") {}; ++ struct str_match_all: TAO_PEGTL_STRING("match-all") {}; + + /* + * Generic rule attribute +diff --git a/src/Library/UEventParser.cpp b/src/Library/UEventParser.cpp +index 1fb23ec..fba90e1 100644 +--- a/src/Library/UEventParser.cpp ++++ b/src/Library/UEventParser.cpp +@@ -28,7 +28,11 @@ + + #include <fstream> + ++#if TAO_PEGTL_VERSION_MAJOR >= 3 ++#include <tao/pegtl/contrib/trace.hpp> ++#else + #include <tao/pegtl/contrib/tracer.hpp> ++#endif + using namespace tao; + + namespace usbguard +@@ -130,7 +134,11 @@ namespace usbguard + tao::pegtl::parse<G, UEventParser::actions>(in, uevent); + } + else { ++#if TAO_PEGTL_VERSION_MAJOR >= 3 ++ tao::pegtl::complete_trace<G, UEventParser::actions>(in, uevent); ++#else + tao::pegtl::parse<G, UEventParser::actions, tao::pegtl::tracer>(in, uevent); ++#endif + } + } + catch (...) { +diff --git a/src/Library/UMockdevDeviceDefinition.cpp b/src/Library/UMockdevDeviceDefinition.cpp +index a8abb09..d63870e 100644 +--- a/src/Library/UMockdevDeviceDefinition.cpp ++++ b/src/Library/UMockdevDeviceDefinition.cpp +@@ -26,7 +26,11 @@ + #include <Common/Utility.hpp> + + #include <tao/pegtl.hpp> ++#if TAO_PEGTL_VERSION_MAJOR >= 3 ++#include <tao/pegtl/contrib/trace.hpp> ++#else + #include <tao/pegtl/contrib/tracer.hpp> ++#endif + + namespace usbguard + { +@@ -49,12 +53,12 @@ namespace usbguard + * S:linkname: device node symlink (without the /dev/ prefix); ignored right now. + */ + +- struct str_path_prefix : TAOCPP_PEGTL_STRING("P:") {}; +- struct str_property_prefix : TAOCPP_PEGTL_STRING("E:") {}; +- struct str_ascii_attr_prefix : TAOCPP_PEGTL_STRING("A:") {}; +- struct str_binary_attr_prefix : TAOCPP_PEGTL_STRING("H:") {}; +- struct str_link_prefix : TAOCPP_PEGTL_STRING("L:") {}; +- struct str_name_prefix : TAOCPP_PEGTL_STRING("N:") {}; ++ struct str_path_prefix : TAO_PEGTL_STRING("P:") {}; ++ struct str_property_prefix : TAO_PEGTL_STRING("E:") {}; ++ struct str_ascii_attr_prefix : TAO_PEGTL_STRING("A:") {}; ++ struct str_binary_attr_prefix : TAO_PEGTL_STRING("H:") {}; ++ struct str_link_prefix : TAO_PEGTL_STRING("L:") {}; ++ struct str_name_prefix : TAO_PEGTL_STRING("N:") {}; + + struct line_rest + : star<not_at<ascii::eol>, not_at<eof>, ascii::any> {}; +@@ -330,7 +334,11 @@ namespace usbguard + + try { + tao::pegtl::string_input<> input(definitions_string, "<string>"); ++#if TAO_PEGTL_VERSION_MAJOR >= 3 ++ tao::pegtl::complete_trace<UMockdevParser::grammar, UMockdevParser::actions>(input, definitions, umockdev_name); ++#else + tao::pegtl::parse<UMockdevParser::grammar, UMockdevParser::actions, tao::pegtl::tracer>(input, definitions, umockdev_name); ++#endif + } + catch (...) { + USBGUARD_LOG(Error) << "UMockdevDeviceDefinition: " << "<string>" << ": parsing failed at line <LINE>"; +diff --git a/src/Library/public/usbguard/RuleParser.cpp b/src/Library/public/usbguard/RuleParser.cpp +index 140bf14..288d81e 100644 +--- a/src/Library/public/usbguard/RuleParser.cpp ++++ b/src/Library/public/usbguard/RuleParser.cpp +@@ -34,7 +34,11 @@ + #include <stdexcept> + #include <stdlib.h> + ++#if TAO_PEGTL_VERSION_MAJOR >= 3 ++#include <tao/pegtl/contrib/trace.hpp> ++#else + #include <tao/pegtl/contrib/tracer.hpp> ++#endif + + namespace usbguard + { +@@ -48,7 +52,11 @@ namespace usbguard + tao::pegtl::parse<RuleParser::rule_grammar, RuleParser::rule_parser_actions>(input, rule); + } + else { ++#if TAO_PEGTL_VERSION_MAJOR >= 3 ++ tao::pegtl::complete_trace<RuleParser::rule_grammar, RuleParser::rule_parser_actions>(input, rule); ++#else + tao::pegtl::parse<RuleParser::rule_grammar, RuleParser::rule_parser_actions, tao::pegtl::tracer>(input, rule); ++#endif + } + + return rule; +@@ -56,7 +64,11 @@ namespace usbguard + catch (const tao::pegtl::parse_error& ex) { + RuleParserError error(rule_spec); + error.setHint(ex.what()); ++#if TAO_PEGTL_VERSION_MAJOR >= 3 ++ error.setOffset(ex.positions().front().column); ++#else + error.setOffset(ex.positions[0].byte_in_line); ++#endif + + if (!file.empty() || line != 0) { + error.setFileInfo(file, line); Added: increase-C++-version-to-c++17.patch =================================================================== --- increase-C++-version-to-c++17.patch (rev 0) +++ increase-C++-version-to-c++17.patch 2021-03-14 00:23:06 UTC (rev 409837) @@ -0,0 +1,65 @@ +From 5197c44fcfca14fedf62264deb5b1a7c09cd958f Mon Sep 17 00:00:00 2001 +From: Zoltan Fridrich <[email protected]> +Date: Thu, 18 Feb 2021 12:54:24 +0100 +Subject: [PATCH] Increase C++ version to c++17 + +(cherry picked from commit 8c86264986685bf646c65228abce2432e08e3c4c) +--- + README.adoc | 5 +++-- + configure.ac | 6 +++--- + 2 files changed, 6 insertions(+), 5 deletions(-) + +diff --git a/README.adoc b/README.adoc +index ae4a6c2..3845ba5 100644 +--- a/README.adoc ++++ b/README.adoc +@@ -15,7 +15,7 @@ image::https://img.shields.io/github/license/USBGuard/usbguard.svg[License, link + == About + + USBGuard is a software framework for implementing USB device authorization policies (what kind of USB devices are authorized) as well as method of use policies (how a USB device may interact with the system). +-Simply put, it is a USB device whitelisting tool. ++Simply put, it is a USB device allowlisting tool. + + WARNING: The 0.x releases are not production ready packages. + They serve for tech-preview and user feedback purposes only. +@@ -35,7 +35,8 @@ Please share your feedback or request a feature in the Github issue trackers for + + == Compilation & Installation + +-To compile the sources from a release tarball, you'll need the development files for: ++To compile the source code, you will require at least C{plus}{plus}17. + ++If you are compiling sources from a release tarball, you'll need the development files for: + + * https://github.com/ClusterLabs/libqb[libqb] - used for local UNIX socket based IPC + * https://github.com/google/protobuf[protobuf] - used for IPC message (de)serialization +diff --git a/configure.ac b/configure.ac +index 9a337a1..acca0e8 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -54,7 +54,7 @@ AX_CHECK_COMPILE_FLAG([-Wno-implicit-fallthrough], + # + # Final project CXXFLAGS are set after configure checks. + # +-CXXFLAGS="-std=c++11 $EXTERNAL_CXXFLAGS" ++CXXFLAGS="-std=c++17 $EXTERNAL_CXXFLAGS" + CFLAGS="-std=c99 $EXTERNAL_CFLAGS" + CPPFLAGS="-DHAVE_BUILD_CONFIG_H $EXTERNAL_CPPFLAGS" + +@@ -350,7 +350,7 @@ if test "x$with_bundled_catch" = xyes; then + catch_summary="bundled; $catch_CFLAGS $catch_LIBS" + else + SAVE_CPPFLAGS=$CPPFLAGS +- CPPFLAGS="-std=c++11 $CPPFLAGS -I/usr/include/catch" ++ CPPFLAGS="-std=c++17 $CPPFLAGS -I/usr/include/catch" + AC_LANG_PUSH([C++]) + AC_CHECK_HEADER([catch.hpp], [], [AC_MSG_FAILURE(catch.hpp not found or not usable. Re-run with --with-bundled-catch to use the bundled library.)]) + AC_LANG_POP +@@ -383,7 +383,7 @@ AC_SUBST([pegtl_AC_CFLAGS]) + AC_SUBST([pegtl_LIBS]) + + SAVE_CPPFLAGS=$CPPFLAGS +-CPPFLAGS="-std=c++11 $CPPFLAGS $pegtl_AC_CFLAGS" ++CPPFLAGS="-std=c++17 $CPPFLAGS $pegtl_AC_CFLAGS" + AC_LANG_PUSH([C++]) + AC_CHECK_HEADER([tao/pegtl.hpp], + [AC_DEFINE([HAVE_TAO_PEGTL_HPP], [1], [PEGTL header file with .hpp extension is present])], Deleted: make-explicitly-treat-pthread-as-first-level-depende.patch =================================================================== --- make-explicitly-treat-pthread-as-first-level-depende.patch 2021-03-13 22:59:51 UTC (rev 409836) +++ make-explicitly-treat-pthread-as-first-level-depende.patch 2021-03-14 00:23:06 UTC (rev 409837) @@ -1,598 +0,0 @@ -From 2887cb6a49a9b04e968af00dc7d38d051785b600 Mon Sep 17 00:00:00 2001 -From: Levente Polyak <[email protected]> -Date: Fri, 11 Oct 2019 23:14:40 +0200 -Subject: [PATCH] make: explicitly treat pthread as first level dependency - -Certain environments need to handle pthread explicitly and pass -appropriate flags (like -pthread) to make the compiler/linker happy. -Invoke the AX_PTHREAD macro to populate the pthread related flags and -pass them accordingly. -This fixes certain linking issues for the first level dependency -usage pthread_sigmask. ---- - Makefile.am | 12 +- - configure.ac | 1 + - m4/ax_pthread.m4 | 485 ++++++++++++++++++++++++++++++++++++++++++ - src/Tests/Makefile.am | 12 +- - 4 files changed, 506 insertions(+), 4 deletions(-) - create mode 100644 m4/ax_pthread.m4 - -diff --git a/Makefile.am b/Makefile.am -index ceb9a33..b73f564 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -348,6 +348,9 @@ usbguard_daemon_SOURCES=\ - src/Daemon/LinuxAuditBackend.hpp \ - src/Daemon/LinuxAuditBackend.cpp - -+usbguard_daemon_CXXFLAGS=\ -+ $(PTHREAD_CFLAGS) -+ - usbguard_daemon_CPPFLAGS=\ - -fPIE \ - $(AM_CPPFLAGS) \ -@@ -361,7 +364,8 @@ usbguard_daemon_LDADD=\ - @ldap_LIBS@ \ - @seccomp_LIBS@ \ - @libcapng_LIBS@ \ -- @audit_LIBS@ -+ @audit_LIBS@ \ -+ $(PTHREAD_LIBS) - - EXTRA_DIST +=\ - README.adoc \ -@@ -408,13 +412,17 @@ usbguard_SOURCES=\ - src/CLI/usbguard-remove-user.cpp \ - src/CLI/usbguard-remove-user.hpp - -+usbguard_CXXFLAGS=\ -+ $(PTHREAD_CFLAGS) -+ - usbguard_CPPFLAGS=\ - -fPIE \ - $(AM_CPPFLAGS) \ - -I$(top_srcdir)/src/CLI - - usbguard_LDADD=\ -- $(top_builddir)/libusbguard.la -+ $(top_builddir)/libusbguard.la \ -+ ${PTHREAD_LIBS} - - if BASH_COMPLETION_ENABLED - bashcompletiondir = $(BASH_COMPLETION_DIR) -diff --git a/configure.ac b/configure.ac -index 2ccd714..44b31b7 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -142,6 +142,7 @@ AC_SUBST([atomic_LIBS]) - # - # Checks for required libraries. - # -+AX_PTHREAD - AC_MSG_CHECKING([for NETLINK_KOBJECT_UEVENT definition]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ - #include <linux/netlink.h> -diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 -new file mode 100644 -index 0000000..d218d1a ---- /dev/null -+++ b/m4/ax_pthread.m4 -@@ -0,0 +1,485 @@ -+# =========================================================================== -+# http://www.gnu.org/software/autoconf-archive/ax_pthread.html -+# =========================================================================== -+# -+# SYNOPSIS -+# -+# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -+# -+# DESCRIPTION -+# -+# This macro figures out how to build C programs using POSIX threads. It -+# sets the PTHREAD_LIBS output variable to the threads library and linker -+# flags, and the PTHREAD_CFLAGS output variable to any special C compiler -+# flags that are needed. (The user can also force certain compiler -+# flags/libs to be tested by setting these environment variables.) -+# -+# Also sets PTHREAD_CC to any special C compiler that is needed for -+# multi-threaded programs (defaults to the value of CC otherwise). (This -+# is necessary on AIX to use the special cc_r compiler alias.) -+# -+# NOTE: You are assumed to not only compile your program with these flags, -+# but also to link with them as well. For example, you might link with -+# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS -+# -+# If you are only building threaded programs, you may wish to use these -+# variables in your default LIBS, CFLAGS, and CC: -+# -+# LIBS="$PTHREAD_LIBS $LIBS" -+# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -+# CC="$PTHREAD_CC" -+# -+# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant -+# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to -+# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). -+# -+# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the -+# PTHREAD_PRIO_INHERIT symbol is defined when compiling with -+# PTHREAD_CFLAGS. -+# -+# ACTION-IF-FOUND is a list of shell commands to run if a threads library -+# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it -+# is not found. If ACTION-IF-FOUND is not specified, the default action -+# will define HAVE_PTHREAD. -+# -+# Please let the authors know if this macro fails on any platform, or if -+# you have any other suggestions or comments. This macro was based on work -+# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help -+# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by -+# Alejandro Forero Cuervo to the autoconf macro repository. We are also -+# grateful for the helpful feedback of numerous users. -+# -+# Updated for Autoconf 2.68 by Daniel Richard G. -+# -+# LICENSE -+# -+# Copyright (c) 2008 Steven G. Johnson <[email protected]> -+# Copyright (c) 2011 Daniel Richard G. <[email protected]> -+# -+# This program is free software: you can redistribute it and/or modify it -+# under the terms of the GNU General Public License as published by the -+# Free Software Foundation, either version 3 of the License, or (at your -+# option) any later version. -+# -+# This program is distributed in the hope that it will be useful, but -+# WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -+# Public License for more details. -+# -+# You should have received a copy of the GNU General Public License along -+# with this program. If not, see <http://www.gnu.org/licenses/>. -+# -+# As a special exception, the respective Autoconf Macro's copyright owner -+# gives unlimited permission to copy, distribute and modify the configure -+# scripts that are the output of Autoconf when processing the Macro. You -+# need not follow the terms of the GNU General Public License when using -+# or distributing such scripts, even though portions of the text of the -+# Macro appear in them. The GNU General Public License (GPL) does govern -+# all other use of the material that constitutes the Autoconf Macro. -+# -+# This special exception to the GPL applies to versions of the Autoconf -+# Macro released by the Autoconf Archive. When you make and distribute a -+# modified version of the Autoconf Macro, you may extend this special -+# exception to the GPL to apply to your modified version as well. -+ -+#serial 22 -+ -+AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) -+AC_DEFUN([AX_PTHREAD], [ -+AC_REQUIRE([AC_CANONICAL_HOST]) -+AC_REQUIRE([AC_PROG_CC]) -+AC_REQUIRE([AC_PROG_SED]) -+AC_LANG_PUSH([C]) -+ax_pthread_ok=no -+ -+# We used to check for pthread.h first, but this fails if pthread.h -+# requires special compiler flags (e.g. on Tru64 or Sequent). -+# It gets checked for in the link test anyway. -+ -+# First of all, check if the user has set any of the PTHREAD_LIBS, -+# etcetera environment variables, and if threads linking works using -+# them: -+if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then -+ ax_pthread_save_CC="$CC" -+ ax_pthread_save_CFLAGS="$CFLAGS" -+ ax_pthread_save_LIBS="$LIBS" -+ AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) -+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -+ LIBS="$PTHREAD_LIBS $LIBS" -+ AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) -+ AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes]) -+ AC_MSG_RESULT([$ax_pthread_ok]) -+ if test "x$ax_pthread_ok" = "xno"; then -+ PTHREAD_LIBS="" -+ PTHREAD_CFLAGS="" -+ fi -+ CC="$ax_pthread_save_CC" -+ CFLAGS="$ax_pthread_save_CFLAGS" -+ LIBS="$ax_pthread_save_LIBS" -+fi -+ -+# We must check for the threads library under a number of different -+# names; the ordering is very important because some systems -+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the -+# libraries is broken (non-POSIX). -+ -+# Create a list of thread flags to try. Items starting with a "-" are -+# C compiler flags, and other items are library names, except for "none" -+# which indicates that we try without any flags at all, and "pthread-config" -+# which is a program returning the flags for the Pth emulation library. -+ -+ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" -+ -+# The ordering *is* (sometimes) important. Some notes on the -+# individual items follow: -+ -+# pthreads: AIX (must check this before -lpthread) -+# none: in case threads are in libc; should be tried before -Kthread and -+# other compiler flags to prevent continual compiler warnings -+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 -+# (Note: HP C rejects this with "bad form for `-t' option") -+# -pthreads: Solaris/gcc (Note: HP C also rejects) -+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -+# doesn't hurt to check since this sometimes defines pthreads and -+# -D_REENTRANT too), HP C (must be checked before -lpthread, which -+# is present but should not be used directly; and before -mthreads, -+# because the compiler interprets this as "-mt" + "-hreads") -+# -mthreads: Mingw32/gcc, Lynx/gcc -+# pthread: Linux, etcetera -+# --thread-safe: KAI C++ -+# pthread-config: use pthread-config program (for GNU Pth library) -+ -+case $host_os in -+ -+ freebsd*) -+ -+ # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) -+ # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) -+ -+ ax_pthread_flags="-kthread lthread $ax_pthread_flags" -+ ;; -+ -+ hpux*) -+ -+ # From the cc(1) man page: "[-mt] Sets various -D flags to enable -+ # multi-threading and also sets -lpthread." -+ -+ ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags" -+ ;; -+ -+ openedition*) -+ -+ # IBM z/OS requires a feature-test macro to be defined in order to -+ # enable POSIX threads at all, so give the user a hint if this is -+ # not set. (We don't define these ourselves, as they can affect -+ # other portions of the system API in unpredictable ways.) -+ -+ AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING], -+ [ -+# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS) -+ AX_PTHREAD_ZOS_MISSING -+# endif -+ ], -+ [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])]) -+ ;; -+ -+ solaris*) -+ -+ # On Solaris (at least, for some versions), libc contains stubbed -+ # (non-functional) versions of the pthreads routines, so link-based -+ # tests will erroneously succeed. (N.B.: The stubs are missing -+ # pthread_cleanup_push, or rather a function called by this macro, -+ # so we could check for that, but who knows whether they'll stub -+ # that too in a future libc.) So we'll check first for the -+ # standard Solaris way of linking pthreads (-mt -lpthread). -+ -+ ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" -+ ;; -+esac -+ -+# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) -+ -+AS_IF([test "x$GCC" = "xyes"], -+ [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"]) -+ -+# The presence of a feature test macro requesting re-entrant function -+# definitions is, on some systems, a strong hint that pthreads support is -+# correctly enabled -+ -+case $host_os in -+ darwin* | hpux* | linux* | osf* | solaris*) -+ ax_pthread_check_macro="_REENTRANT" -+ ;; -+ -+ aix* | freebsd*) -+ ax_pthread_check_macro="_THREAD_SAFE" -+ ;; -+ -+ *) -+ ax_pthread_check_macro="--" -+ ;; -+esac -+AS_IF([test "x$ax_pthread_check_macro" = "x--"], -+ [ax_pthread_check_cond=0], -+ [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) -+ -+# Are we compiling with Clang? -+ -+AC_CACHE_CHECK([whether $CC is Clang], -+ [ax_cv_PTHREAD_CLANG], -+ [ax_cv_PTHREAD_CLANG=no -+ # Note that Autoconf sets GCC=yes for Clang as well as GCC -+ if test "x$GCC" = "xyes"; then -+ AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], -+ [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ -+# if defined(__clang__) && defined(__llvm__) -+ AX_PTHREAD_CC_IS_CLANG -+# endif -+ ], -+ [ax_cv_PTHREAD_CLANG=yes]) -+ fi -+ ]) -+ax_pthread_clang="$ax_cv_PTHREAD_CLANG" -+ -+ax_pthread_clang_warning=no -+ -+# Clang needs special handling, because older versions handle the -pthread -+# option in a rather... idiosyncratic way -+ -+if test "x$ax_pthread_clang" = "xyes"; then -+ -+ # Clang takes -pthread; it has never supported any other flag -+ -+ # (Note 1: This will need to be revisited if a system that Clang -+ # supports has POSIX threads in a separate library. This tends not -+ # to be the way of modern systems, but it's conceivable.) -+ -+ # (Note 2: On some systems, notably Darwin, -pthread is not needed -+ # to get POSIX threads support; the API is always present and -+ # active. We could reasonably leave PTHREAD_CFLAGS empty. But -+ # -pthread does define _REENTRANT, and while the Darwin headers -+ # ignore this macro, third-party headers might not.) -+ -+ PTHREAD_CFLAGS="-pthread" -+ PTHREAD_LIBS= -+ -+ ax_pthread_ok=yes -+ -+ # However, older versions of Clang make a point of warning the user -+ # that, in an invocation where only linking and no compilation is -+ # taking place, the -pthread option has no effect ("argument unused -+ # during compilation"). They expect -pthread to be passed in only -+ # when source code is being compiled. -+ # -+ # Problem is, this is at odds with the way Automake and most other -+ # C build frameworks function, which is that the same flags used in -+ # compilation (CFLAGS) are also used in linking. Many systems -+ # supported by AX_PTHREAD require exactly this for POSIX threads -+ # support, and in fact it is often not straightforward to specify a -+ # flag that is used only in the compilation phase and not in -+ # linking. Such a scenario is extremely rare in practice. -+ # -+ # Even though use of the -pthread flag in linking would only print -+ # a warning, this can be a nuisance for well-run software projects -+ # that build with -Werror. So if the active version of Clang has -+ # this misfeature, we search for an option to squash it. -+ -+ AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread], -+ [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG], -+ [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown -+ # Create an alternate version of $ac_link that compiles and -+ # links in two steps (.c -> .o, .o -> exe) instead of one -+ # (.c -> exe), because the warning occurs only in the second -+ # step -+ ax_pthread_save_ac_link="$ac_link" -+ ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' -+ ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"` -+ ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" -+ ax_pthread_save_CFLAGS="$CFLAGS" -+ for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do -+ AS_IF([test "x$ax_pthread_try" = "xunknown"], [break]) -+ CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" -+ ac_link="$ax_pthread_save_ac_link" -+ AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], -+ [ac_link="$ax_pthread_2step_ac_link" -+ AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], -+ [break]) -+ ]) -+ done -+ ac_link="$ax_pthread_save_ac_link" -+ CFLAGS="$ax_pthread_save_CFLAGS" -+ AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no]) -+ ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" -+ ]) -+ -+ case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in -+ no | unknown) ;; -+ *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; -+ esac -+ -+fi # $ax_pthread_clang = yes -+ -+if test "x$ax_pthread_ok" = "xno"; then -+for ax_pthread_try_flag in $ax_pthread_flags; do -+ -+ case $ax_pthread_try_flag in -+ none) -+ AC_MSG_CHECKING([whether pthreads work without any flags]) -+ ;; -+ -+ -mt,pthread) -+ AC_MSG_CHECKING([whether pthreads work with -mt -lpthread]) -+ PTHREAD_CFLAGS="-mt" -+ PTHREAD_LIBS="-lpthread" -+ ;; -+ -+ -*) -+ AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) -+ PTHREAD_CFLAGS="$ax_pthread_try_flag" -+ ;; -+ -+ pthread-config) -+ AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) -+ AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) -+ PTHREAD_CFLAGS="`pthread-config --cflags`" -+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" -+ ;; -+ -+ *) -+ AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) -+ PTHREAD_LIBS="-l$ax_pthread_try_flag" -+ ;; -+ esac -+ -+ ax_pthread_save_CFLAGS="$CFLAGS" -+ ax_pthread_save_LIBS="$LIBS" -+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -+ LIBS="$PTHREAD_LIBS $LIBS" -+ -+ # Check for various functions. We must include pthread.h, -+ # since some functions may be macros. (On the Sequent, we -+ # need a special flag -Kthread to make this header compile.) -+ # We check for pthread_join because it is in -lpthread on IRIX -+ # while pthread_create is in libc. We check for pthread_attr_init -+ # due to DEC craziness with -lpthreads. We check for -+ # pthread_cleanup_push because it is one of the few pthread -+ # functions on Solaris that doesn't have a non-functional libc stub. -+ # We try pthread_create on general principles. -+ -+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h> -+# if $ax_pthread_check_cond -+# error "$ax_pthread_check_macro must be defined" -+# endif -+ static void routine(void *a) { a = 0; } -+ static void *start_routine(void *a) { return a; }], -+ [pthread_t th; pthread_attr_t attr; -+ pthread_create(&th, 0, start_routine, 0); -+ pthread_join(th, 0); -+ pthread_attr_init(&attr); -+ pthread_cleanup_push(routine, 0); -+ pthread_cleanup_pop(0) /* ; */])], -+ [ax_pthread_ok=yes], -+ []) -+ -+ CFLAGS="$ax_pthread_save_CFLAGS" -+ LIBS="$ax_pthread_save_LIBS" -+ -+ AC_MSG_RESULT([$ax_pthread_ok]) -+ AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) -+ -+ PTHREAD_LIBS="" -+ PTHREAD_CFLAGS="" -+done -+fi -+ -+# Various other checks: -+if test "x$ax_pthread_ok" = "xyes"; then -+ ax_pthread_save_CFLAGS="$CFLAGS" -+ ax_pthread_save_LIBS="$LIBS" -+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -+ LIBS="$PTHREAD_LIBS $LIBS" -+ -+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. -+ AC_CACHE_CHECK([for joinable pthread attribute], -+ [ax_cv_PTHREAD_JOINABLE_ATTR], -+ [ax_cv_PTHREAD_JOINABLE_ATTR=unknown -+ for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do -+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>], -+ [int attr = $ax_pthread_attr; return attr /* ; */])], -+ [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break], -+ []) -+ done -+ ]) -+ AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ -+ test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ -+ test "x$ax_pthread_joinable_attr_defined" != "xyes"], -+ [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], -+ [$ax_cv_PTHREAD_JOINABLE_ATTR], -+ [Define to necessary symbol if this constant -+ uses a non-standard name on your system.]) -+ ax_pthread_joinable_attr_defined=yes -+ ]) -+ -+ AC_CACHE_CHECK([whether more special flags are required for pthreads], -+ [ax_cv_PTHREAD_SPECIAL_FLAGS], -+ [ax_cv_PTHREAD_SPECIAL_FLAGS=no -+ case $host_os in -+ solaris*) -+ ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" -+ ;; -+ esac -+ ]) -+ AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ -+ test "x$ax_pthread_special_flags_added" != "xyes"], -+ [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" -+ ax_pthread_special_flags_added=yes]) -+ -+ AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], -+ [ax_cv_PTHREAD_PRIO_INHERIT], -+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], -+ [[int i = PTHREAD_PRIO_INHERIT;]])], -+ [ax_cv_PTHREAD_PRIO_INHERIT=yes], -+ [ax_cv_PTHREAD_PRIO_INHERIT=no]) -+ ]) -+ AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ -+ test "x$ax_pthread_prio_inherit_defined" != "xyes"], -+ [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.]) -+ ax_pthread_prio_inherit_defined=yes -+ ]) -+ -+ CFLAGS="$ax_pthread_save_CFLAGS" -+ LIBS="$ax_pthread_save_LIBS" -+ -+ # More AIX lossage: compile with *_r variant -+ if test "x$GCC" != "xyes"; then -+ case $host_os in -+ aix*) -+ AS_CASE(["x/$CC"], -+ [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], -+ [#handle absolute path differently from PATH based program lookup -+ AS_CASE(["x$CC"], -+ [x/*], -+ [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], -+ [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) -+ ;; -+ esac -+ fi -+fi -+ -+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" -+ -+AC_SUBST([PTHREAD_LIBS]) -+AC_SUBST([PTHREAD_CFLAGS]) -+AC_SUBST([PTHREAD_CC]) -+ -+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -+if test "x$ax_pthread_ok" = "xyes"; then -+ ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) -+ : -+else -+ ax_pthread_ok=no -+ $2 -+fi -+AC_LANG_POP -+])dnl AX_PTHREAD -diff --git a/src/Tests/Makefile.am b/src/Tests/Makefile.am -index 64fa71f..d8c8879 100644 ---- a/src/Tests/Makefile.am -+++ b/src/Tests/Makefile.am -@@ -115,8 +115,12 @@ test_unit_SOURCES=\ - Unit/test_UMockdevDeviceDefinition.cpp \ - Unit/test_UMockdevDeviceDefinition.data.hpp - -+test_unit_CXXFLAGS=\ -+ $(PTHREAD_CFLAGS) -+ - test_unit_LDADD=\ -- $(top_builddir)/libusbguard.la -+ $(top_builddir)/libusbguard.la \ -+ $(PTHREAD_LIBS) - - test_unit_LDFLAGS=\ - -static -@@ -128,6 +132,10 @@ test_regression_SOURCES=\ - Regression/test_Rule_ghi247.cpp \ - Regression/github-PR209-config-parser.cpp - -+test_regression_CXXFLAGS=\ -+ $(PTHREAD_CFLAGS) -+ - test_regression_LDADD=\ -- $(top_builddir)/libusbguard.la -+ $(top_builddir)/libusbguard.la \ -+ $(PTHREAD_LIBS) - --- -2.23.0 -
