From 4c82e18ac12ee70bf94201781bffd0167bc728f1 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sun, 21 Oct 2018 08:46:09 -0600 Subject: [PATCH] Add --enable-pvs-studio configure option to create PVS-Studio.cfg. --- INSTALL | 11 ++++++++--- configure | 39 +++++++++++++++++++++++++++++++++++++++ configure.ac | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/INSTALL b/INSTALL index ea3e8b678..b8f9be6d5 100644 --- a/INSTALL +++ b/INSTALL @@ -365,11 +365,16 @@ Optional features: Enable potentially offensive sudo insults from the classic version of sudo. + --enable-pvs-studio + Generate a sample PVS-Studio.cfg file based on the compiler and + platform type. The "pvs-studio" Makefile target can then be + used if PVS-Studio is installed. + Operating system-specific options: --disable-setreuid - Disable use of the setreuid() function for operating systems - where it is broken. For instance, 4.4BSD has setreuid() - that is not fully functional. + Disable use of the setreuid() function for operating systems + where it is broken. For instance, 4.4BSD has setreuid() that + is not fully functional. --disable-setresuid Disable use of the setresuid() function for operating systems diff --git a/configure b/configure index f95056eca..f5e6a4682 100755 --- a/configure +++ b/configure @@ -969,6 +969,7 @@ enable_timestamp_type enable_offensive_insults enable_package_build enable_gss_krb5_ccache_name +enable_pvs_studio enable_shared enable_static with_pic @@ -1659,6 +1660,7 @@ Optional Features: --enable-package-build Enable options for package building. --enable-gss-krb5-ccache-name Use GSS-API to set the Kerberos V cred cache name + --enable-pvs-studio Create a PVS-Studio.cfg file. --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] @@ -6877,6 +6879,12 @@ else fi +# Check whether --enable-pvs-studio was given. +if test "${enable_pvs_studio+set}" = set; then : + enableval=$enable_pvs_studio; +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 : @@ -16435,6 +16443,37 @@ fi ;; esac +if test X"$enable_pvs_studio" = X"yes"; then + # Determine preprocessor type + case "$CC" in + *clang*) preprocessor=clang;; + *gcc*) preprocessor=gcc;; + *) + case `$CC --version 2>&1` in + *clang*) preprocessor=clang;; + *gcc*) preprocessor=gcc;; + *) as_fn_error $? "Compiler must be gcc or clang for PVS-Studio." "$LINENO" 5;; + esac + ;; + esac + + # Determine platform (currently linux or macos) + case "$host" in + x86_64-*-linux*) pvs_platform=linux64;; + *86-*-linux*) pvs_platform=linux32;; + darwin*) pvs_platform=macos;; + *) as_fn_error $? "PVS-Studio does not support $host_os." "$LINENO" 5;; + esac + + # create basic PVS-Studio.cfg file + cat > PVS-Studio.cfg <<-EOF + preprocessor = $preprocessor + platform = $pvs_platform + analysis-mode = 4 + language = C +EOF +fi + if test -n "$with_noexec"; then cat >>confdefs.h <&1` in + *clang*) preprocessor=clang;; + *gcc*) preprocessor=gcc;; + *) AC_MSG_ERROR([Compiler must be gcc or clang for PVS-Studio.]);; + esac + ;; + esac + + # Determine platform (currently linux or macos) + case "$host" in + x86_64-*-linux*) pvs_platform=linux64;; + *86-*-linux*) pvs_platform=linux32;; + darwin*) pvs_platform=macos;; + *) AC_MSG_ERROR([PVS-Studio does not support $host_os.]);; + esac + + # create basic PVS-Studio.cfg file + cat > PVS-Studio.cfg <<-EOF + preprocessor = $preprocessor + platform = $pvs_platform + analysis-mode = 4 + language = C +EOF +fi + dnl dnl Library preloading to support NOEXEC dnl -- 2.40.0