]> granicus.if.org Git - sudo/commitdiff
Add --enable-pvs-studio configure option to create PVS-Studio.cfg.
authorTodd C. Miller <Todd.Miller@sudo.ws>
Sun, 21 Oct 2018 14:46:09 +0000 (08:46 -0600)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Sun, 21 Oct 2018 14:46:09 +0000 (08:46 -0600)
INSTALL
configure
configure.ac

diff --git a/INSTALL b/INSTALL
index ea3e8b678b0d356539e5f087c94e071bcb1e8a6c..b8f9be6d5a928bf87ad5e240873eeabae589a058 100644 (file)
--- 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
index f95056ecadad056d61314c713aa457371ba3c9be..f5e6a4682eb9d963f768aecc0760e9c53319e7bc 100755 (executable)
--- 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 :
                ;;
 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 <<EOF
 #define RTLD_PRELOAD_VAR "$RTLD_PRELOAD_VAR"
index c013a75166e933f7e68a59838b9714c0a033f726..ff9efb4468c355a3652d0dab675ab6199433a680 100644 (file)
@@ -1614,6 +1614,9 @@ AC_ARG_ENABLE(gss_krb5_ccache_name,
 [AS_HELP_STRING([--enable-gss-krb5-ccache-name], [Use GSS-API to set the Kerberos V cred cache name])],
 [check_gss_krb5_ccache_name=$enableval], [check_gss_krb5_ccache_name=no])
 
+AC_ARG_ENABLE(pvs-studio,
+[AS_HELP_STRING([--enable-pvs-studio], [Create a PVS-Studio.cfg file.])])
+
 dnl
 dnl C compiler checks
 dnl
@@ -2256,6 +2259,37 @@ case "$host" in
                ;;
 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;;
+           *) 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