commit 7fcf999c6350b1437962c978ee1fe88af9d38b7d
Author: David Goulet <dgou...@torproject.org>
Date:   Thu Aug 8 10:08:02 2019 -0400

    Print summary at the end of the configure script
    
    Signed-off-by: David Goulet <dgou...@torproject.org>
---
 changes/ticket31373 |   3 +
 configure.ac        | 127 +++++++++++++++++++++++++++++
 m4/pprint.m4        | 228 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 358 insertions(+)

diff --git a/changes/ticket31373 b/changes/ticket31373
new file mode 100644
index 000000000..1f2dea3cd
--- /dev/null
+++ b/changes/ticket31373
@@ -0,0 +1,3 @@
+  o Minor feature (configure, build system):
+    - Output enabled/disabled features at the end of the configure process in a
+      pleasing way. Closes ticket 31373.
diff --git a/configure.ac b/configure.ac
index 9ec123f51..cc64be5ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,6 +8,8 @@ AC_INIT([tor],[0.4.2.0-alpha-dev])
 AC_CONFIG_SRCDIR([src/app/main/tor_main.c])
 AC_CONFIG_MACRO_DIR([m4])
 
+configure_flags="$*"
+
 # DO NOT EDIT THIS DEFINITION BY HAND UNLESS YOU KNOW WHAT YOU'RE DOING.
 #
 # The update_versions.py script updates this definition when the
@@ -2519,3 +2521,128 @@ 
https://trac.torproject.org/projects/tor/wiki/doc/TorFragileHardening
 fi
 
 AC_OUTPUT
+
+#
+# Mini-report on what will be built.
+#
+
+PPRINT_INIT
+PPRINT_SET_INDENT(1)
+PPRINT_SET_TS(65)
+
+AS_ECHO
+AS_ECHO("Tor Version: ${PPRINT_COLOR_BLDBLU}Tor $PACKAGE_VERSION 
$PPRINT_COLOR_RST")
+AS_ECHO
+
+PPRINT_SUBTITLE([Build Features])
+
+PPRINT_PROP_STRING([Compiler], [$CC])
+PPRINT_PROP_STRING([Host OS], [$host_os])
+AS_ECHO
+
+test "x$enable_gcc_warnings" = "xyes" && value=1 || value=0
+PPRINT_PROP_BOOL([Verbose Warnings (--enable-gcc-warnings)], $value)
+
+test "x$enable_fatal_warnings" = "xyes" && value=1 || value=0
+PPRINT_PROP_BOOL([Warnings are fatal (--enable-fatal-warnings)], $value)
+
+test "x$enable_rust" = "xyes" && value=1 || value=0
+PPRINT_PROP_BOOL([Rust support (--enable-rust)], $value)
+
+test "x$enable_android" = "xyes" && value=1 || value=0
+PPRINT_PROP_BOOL([Android support (--enable-android)], $value)
+
+test "x$enable_systemd" = "xyes" && value=1 || value=0
+PPRINT_PROP_BOOL([Systemd support (--enable-systemd)], $value)
+
+AS_ECHO
+PPRINT_SUBTITLE([Static Build])
+
+test "x$enable_static_tor" = "xyes" && value=1 || value=0
+PPRINT_PROP_BOOL([tor (--enable-static-tor)], $value)
+
+if test "x$enable_static_libevent" = "xyes"; then
+  PPRINT_PROP_STRING([libevent], [$TOR_LIBDIR_libevent])
+else
+  PPRINT_PROP_BOOL([libevent (--enable-static-libevent)], $value)
+fi
+
+if test "x$enable_static_openssl" = "xyes"; then
+  PPRINT_PROP_STRING([libssl], [$TOR_LIBDIR_openssl])
+else
+  PPRINT_PROP_BOOL([libssl (--enable-static-openssl)], $value)
+fi
+
+if test "x$enable_static_zlib" = "xyes"; then
+  PPRINT_PROP_STRING([zlib1g], [$TOR_LIBDIR_zlib])
+else
+  PPRINT_PROP_BOOL([zlib1g (--enable-static-zlib)], $value)
+fi
+
+AS_ECHO
+PPRINT_SUBTITLE([Optional Libraries])
+
+test "x$enable_nss" = "xyes" && value=1 || value=0
+PPRINT_PROP_BOOL([libnss (--enable-nss)], $value)
+
+test "x$enable_seccomp" != "xno" && value=1 || value=0
+PPRINT_PROP_BOOL([libseccomp (--disable-seccomp)], $value)
+
+test "x$enable_libscrypt" != "xno" && value=1 || value=0
+PPRINT_PROP_BOOL([libscrypt (--disable-libscrypt)], $value)
+
+AS_ECHO
+PPRINT_SUBTITLE([Hardening])
+
+test "x$enable_gcc_hardening" != "xno" && value=1 || value=0
+PPRINT_PROP_BOOL([Compiler Hardening (--disable-gcc-hardening)], $value)
+
+test "x$enable_linker_hardening" != "xno" && value=1 || value=0
+PPRINT_PROP_BOOL([Linker Hardening (--disable-linker-hardening)], $value)
+
+test "x$enable_fragile_hardening" = "xyes" && value=1 || value=0
+PPRINT_PROP_BOOL([Fragile Hardening (--enable-fragile-hardening, dev only)], 
$value)
+
+AS_ECHO
+PPRINT_SUBTITLE([Modules])
+
+test "x$enable_module_dirauth" != "xno" && value=1 || value=0
+PPRINT_PROP_BOOL([Directory Authority (--disable-module-dirauth)], $value)
+
+AS_ECHO
+PPRINT_SUBTITLE([Documentation])
+
+test "x$enable_manpage" != "xno" && value=1 || value=0
+PPRINT_PROP_BOOL([Man Pages (--disable-manpage)], $value)
+
+test "x$enable_html_manual" != "xno" && value=1 || value=0
+PPRINT_PROP_BOOL([HTML Manual (--disable-html-manual)], $value)
+
+AS_ECHO
+PPRINT_SUBTITLE([Tests])
+
+test "x$enable_unittests" != "xno" && value=1 || value=0
+PPRINT_PROP_BOOL([Unit tests (--disable-unittests)], $value)
+
+test "x$enable_asserts_in_tests" = "xno" && value=1 || value=0
+PPRINT_PROP_BOOL([assert()s disabled (--disable-asserts-in-tests, dev only)], 
$value)
+
+test "x$enable_coverage" = "xyes" && value=1 || value=0
+PPRINT_PROP_BOOL([Code Coverage (--enable-coverage)], $value)
+
+test "x$enable_libfuzzer" = "xyes" && value=1 || value=0
+PPRINT_PROP_BOOL([libFuzzer support (--enable-libfuzzer)], $value)
+
+test "x$enable_oss_fuzz" = "xyes" && value=1 || value=0
+PPRINT_PROP_BOOL([OSS-Fuzz support (--enable-oss-fuzz)], $value)
+
+AS_ECHO
+PPRINT_SUBTITLE([Install Directories])
+
+report_mandir="`eval eval echo $mandir`"
+PPRINT_PROP_STRING([Binaries], [$BINDIR])
+PPRINT_PROP_STRING([Configuration], [$CONFDIR])
+PPRINT_PROP_STRING([Man Pages], [$report_mandir])
+
+AS_ECHO
+AS_ECHO(["Configure Line: ./configure $configure_flags"])
diff --git a/m4/pprint.m4 b/m4/pprint.m4
new file mode 100644
index 000000000..4e8a71c87
--- /dev/null
+++ b/m4/pprint.m4
@@ -0,0 +1,228 @@
+# Pretty printing macros.
+#
+# Copyright (C) 2019 - Philippe Proulx <ppro...@efficios.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License, version 2 only, as
+# published by the Free Software Foundation.
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# As a special exception to the GNU General Public License, if you distribute
+# this file as part of a program that contains a configuration script
+# generated by Autoconf, you may include it under the same distribution terms
+# that you use for the rest of that program.
+
+#serial 1
+
+# PPRINT_INIT(): initializes the pretty printing system.
+#
+# Use this macro before using any other PPRINT_* macro.
+AC_DEFUN([PPRINT_INIT], [
+  m4_define([PPRINT_CONFIG_TS], [50])
+  m4_define([PPRINT_CONFIG_INDENT], [2])
+  PPRINT_YES_MSG=yes
+  PPRINT_NO_MSG=no
+
+  # find tput, which tells us if colors are supported and gives us color codes
+  AC_PATH_PROG([pprint_tput], [tput])
+
+  AS_IF([test -n "$pprint_tput"], [
+    AS_IF([test -n "$PS1" && test `"$pprint_tput" colors` -ge 8 && test -t 1], 
[
+      # interactive shell and colors supported and standard output
+      # file descriptor is opened on a terminal
+      PPRINT_COLOR_TXTBLK="`"$pprint_tput" setaf 0`"
+      PPRINT_COLOR_TXTBLU="`"$pprint_tput" setaf 4`"
+      PPRINT_COLOR_TXTGRN="`"$pprint_tput" setaf 2`"
+      PPRINT_COLOR_TXTCYN="`"$pprint_tput" setaf 6`"
+      PPRINT_COLOR_TXTRED="`"$pprint_tput" setaf 1`"
+      PPRINT_COLOR_TXTPUR="`"$pprint_tput" setaf 5`"
+      PPRINT_COLOR_TXTYLW="`"$pprint_tput" setaf 3`"
+      PPRINT_COLOR_TXTWHT="`"$pprint_tput" setaf 7`"
+      PPRINT_COLOR_BLD=`"$pprint_tput" bold`
+      PPRINT_COLOR_BLDBLK="$PPRINT_COLOR_BLD$PPRINT_COLOR_TXTBLK"
+      PPRINT_COLOR_BLDBLU="$PPRINT_COLOR_BLD$PPRINT_COLOR_TXTBLU"
+      PPRINT_COLOR_BLDGRN="$PPRINT_COLOR_BLD$PPRINT_COLOR_TXTGRN"
+      PPRINT_COLOR_BLDCYN="$PPRINT_COLOR_BLD$PPRINT_COLOR_TXTCYN"
+      PPRINT_COLOR_BLDRED="$PPRINT_COLOR_BLD$PPRINT_COLOR_TXTRED"
+      PPRINT_COLOR_BLDPUR="$PPRINT_COLOR_BLD$PPRINT_COLOR_TXTPUR"
+      PPRINT_COLOR_BLDYLW="$PPRINT_COLOR_BLD$PPRINT_COLOR_TXTYLW"
+      PPRINT_COLOR_BLDWHT="$PPRINT_COLOR_BLD$PPRINT_COLOR_TXTWHT"
+      PPRINT_COLOR_RST="`"$pprint_tput" sgr0`"
+
+      # colored yes and no
+      PPRINT_YES_MSG="$PPRINT_COLOR_BLDGRN$PPRINT_YES_MSG$PPRINT_COLOR_RST"
+      PPRINT_NO_MSG="$PPRINT_COLOR_BLDRED$PPRINT_NO_MSG$PPRINT_COLOR_RST"
+
+      # subtitle color
+      PPRINT_COLOR_SUBTITLE="$PPRINT_COLOR_BLDCYN"
+    ])
+  ])
+])
+
+# PPRINT_SET_INDENT(indent): sets the current indentation.
+#
+# Use PPRINT_INIT() before using this macro.
+AC_DEFUN([PPRINT_SET_INDENT], [
+  m4_define([PPRINT_CONFIG_INDENT], [$1])
+])
+
+# PPRINT_SET_TS(ts): sets the current tab stop.
+#
+# Use PPRINT_INIT() before using this macro.
+AC_DEFUN([PPRINT_SET_TS], [
+  m4_define([PPRINT_CONFIG_TS], [$1])
+])
+
+# PPRINT_SUBTITLE(subtitle): pretty prints a subtitle.
+#
+# The subtitle is put as is in a double-quoted shell string so the user
+# needs to escape ".
+#
+# Use PPRINT_INIT() before using this macro.
+AC_DEFUN([PPRINT_SUBTITLE], [
+  AS_ECHO(["${PPRINT_COLOR_SUBTITLE}$1$PPRINT_COLOR_RST"])
+])
+
+AC_DEFUN([_PPRINT_INDENT], [
+  m4_if(PPRINT_CONFIG_INDENT, 0, [
+  ], [
+    m4_for([pprint_i], [0], m4_eval(PPRINT_CONFIG_INDENT * 2 - 1), [1], [
+      AS_ECHO_N([" "])
+    ])
+  ])
+])
+
+# PPRINT_PROP_STRING(title, value, title_color?): pretty prints a
+# string property.
+#
+# The title is put as is in a double-quoted shell string so the user
+# needs to escape ".
+#
+# The $PPRINT_CONFIG_INDENT variable must be set to the desired indentation
+# level.
+#
+# Use PPRINT_INIT() before using this macro.
+AC_DEFUN([PPRINT_PROP_STRING], [
+  m4_pushdef([pprint_title], [$1])
+  m4_pushdef([pprint_value], [$2])
+  m4_pushdef([pprint_title_color], m4_default([$3], []))
+  m4_pushdef([pprint_title_len], m4_len(pprint_title))
+  m4_pushdef([pprint_spaces_cnt], m4_eval(PPRINT_CONFIG_TS - pprint_title_len 
- (PPRINT_CONFIG_INDENT * 2) - 1))
+
+  m4_if(m4_eval(pprint_spaces_cnt <= 0), [1], [
+    m4_define([pprint_spaces_cnt], [1])
+  ])
+
+  m4_pushdef([pprint_spaces], [])
+
+  m4_for([pprint_i], 0, m4_eval(pprint_spaces_cnt - 1), [1], [
+    m4_append([pprint_spaces], [ ])
+  ])
+
+  _PPRINT_INDENT
+
+  
AS_ECHO_N(["pprint_title_color""pprint_title$PPRINT_COLOR_RST:pprint_spaces"])
+  AS_ECHO(["${PPRINT_COLOR_BLD}pprint_value$PPRINT_COLOR_RST"])
+
+  m4_popdef([pprint_spaces])
+  m4_popdef([pprint_spaces_cnt])
+  m4_popdef([pprint_title_len])
+  m4_popdef([pprint_title_color])
+  m4_popdef([pprint_value])
+  m4_popdef([pprint_title])
+])
+
+# PPRINT_PROP_BOOL(title, value, title_color?): pretty prints a boolean
+# property.
+#
+# The title is put as is in a double-quoted shell string so the user
+# needs to escape ".
+#
+# The value is evaluated at shell runtime. Its evaluation must be
+# 0 (false) or 1 (true).
+#
+# Uses the PPRINT_PROP_STRING() with the "yes" or "no" string.
+#
+# Use PPRINT_INIT() before using this macro.
+AC_DEFUN([PPRINT_PROP_BOOL], [
+  m4_pushdef([pprint_title], [$1])
+  m4_pushdef([pprint_value], [$2])
+
+  test pprint_value -eq 0 && pprint_msg="$PPRINT_NO_MSG" || 
pprint_msg="$PPRINT_YES_MSG"
+
+  m4_if([$#], [3], [
+    PPRINT_PROP_STRING(pprint_title, [$pprint_msg], $3)
+  ], [
+    PPRINT_PROP_STRING(pprint_title, [$pprint_msg])
+  ])
+
+  m4_popdef([pprint_value])
+  m4_popdef([pprint_title])
+])
+
+# PPRINT_PROP_BOOL_CUSTOM(title, value, no_msg, title_color?): pretty prints a 
boolean
+# property.
+#
+# The title is put as is in a double-quoted shell string so the user
+# needs to escape ".
+#
+# The value is evaluated at shell runtime. Its evaluation must be
+# 0 (false) or 1 (true).
+#
+# Uses the PPRINT_PROP_STRING() with the "yes" or "no" string.
+#
+# Use PPRINT_INIT() before using this macro.
+AC_DEFUN([PPRINT_PROP_BOOL_CUSTOM], [
+  m4_pushdef([pprint_title], [$1])
+  m4_pushdef([pprint_value], [$2])
+  m4_pushdef([pprint_value_no_msg], [$3])
+
+  test pprint_value -eq 0 && pprint_msg="$PPRINT_NO_MSG (pprint_value_no_msg)" 
|| pprint_msg="$PPRINT_YES_MSG"
+
+  m4_if([$#], [4], [
+    PPRINT_PROP_STRING(pprint_title, [$pprint_msg], $4)
+  ], [
+    PPRINT_PROP_STRING(pprint_title, [$pprint_msg])
+  ])
+
+  m4_popdef([pprint_value_no_msg])
+  m4_popdef([pprint_value])
+  m4_popdef([pprint_title])
+])
+
+# PPRINT_WARN(msg): pretty prints a warning message.
+#
+# The message is put as is in a double-quoted shell string so the user
+# needs to escape ".
+#
+# Use PPRINT_INIT() before using this macro.
+AC_DEFUN([PPRINT_WARN], [
+  m4_pushdef([pprint_msg], [$1])
+
+  _PPRINT_INDENT
+  AS_ECHO(["${PPRINT_COLOR_TXTYLW}WARNING:$PPRINT_COLOR_RST 
${PPRINT_COLOR_BLDYLW}pprint_msg$PPRINT_COLOR_RST"])
+
+  m4_popdef([pprint_msg])
+])
+
+# PPRINT_ERROR(msg): pretty prints an error message and exits.
+#
+# The message is put as is in a double-quoted shell string so the user
+# needs to escape ".
+#
+# Use PPRINT_INIT() before using this macro.
+AC_DEFUN([PPRINT_ERROR], [
+  m4_pushdef([pprint_msg], [$1])
+
+  AC_MSG_ERROR([${PPRINT_COLOR_BLDRED}pprint_msg$PPRINT_COLOR_RST])
+
+  m4_popdef([pprint_msg])
+])



_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to