diff --git a/common/Makefile.am b/common/Makefile.am index 76142199..f1b63154 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -29,10 +29,6 @@ AM_CPPFLAGS = \ -DXRDP_LOG_PATH=\"${localstatedir}/log\" \ -DXRDP_SOCKET_PATH=\"${socketdir}\" -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - # -no-suppress is an automake-specific flag which is needed # to prevent us missing compiler errors in some circumstances # (see https://github.com/neutrinolabs/xrdp/pull/1843 ) diff --git a/common/log.h b/common/log.h index 97f17d86..0194a530 100644 --- a/common/log.h +++ b/common/log.h @@ -25,6 +25,13 @@ #include "defines.h" #include "list.h" +/* Check the config_ac.h file is included so we know whether to enable the + * development macros + */ +#ifndef CONFIG_AC_H +# error config_ac.h not visible in log.h +#endif + /* logging buffer size */ #define LOG_BUFFER_SIZE 8192 #define LOGGER_NAME_SIZE 50 @@ -66,7 +73,7 @@ enum logReturns /* enable threading */ /*#define LOG_ENABLE_THREAD*/ -#ifdef XRDP_DEBUG +#ifdef USE_DEVEL_LOGGING #define LOG_PER_LOGGER_LEVEL @@ -77,9 +84,10 @@ enum logReturns * Note: all log levels are relavant to help a developer understand XRDP at * different levels of granularity. * - * Note: the logging function calls are removed when XRDP_DEBUG is NOT defined. + * Note: the logging function calls are removed when USE_DEVEL_LOGGING is + * NOT defined. * - * Note: when the build is configured with --enable-xrdpdebug, then + * Note: when the build is configured with --enable-devel-logging, then * the log level can be configured per the source file name or method name * (with the suffix "()") in the [LoggingPerLogger] * section of the configuration file. @@ -103,7 +111,7 @@ enum logReturns * configure and run XRDP on their machine. * * Note: the logging function calls contain additional code location info when - * XRDP_DEBUG is defined. + * USE_DEVEL_LOGGING is defined. * * @param lvl, the log level * @param msg, the log text as a printf format c-string @@ -116,7 +124,8 @@ enum logReturns * @brief Logging macro for logging the contents of a byte array using a hex * dump format. * - * Note: the logging function calls are removed when XRDP_DEBUG is NOT defined. + * Note: the logging function calls are removed when USE_DEVEL_LOGGING is + * NOT defined. * * @param log_level, the log level * @param message, a message prefix for the hex dump. Note: no printf like diff --git a/common/pixman-region.c b/common/pixman-region.c index 464faf02..ecca41fd 100644 --- a/common/pixman-region.c +++ b/common/pixman-region.c @@ -89,7 +89,7 @@ #define PREFIX(x) pixman_region##x #endif -#ifdef XRDP_DEBUG +#ifdef USE_DEVEL_LOGGING pixman_bool_t PREFIX(_selfcheck) (region_type_t *reg); diff --git a/configure.ac b/configure.ac index d0f120c1..cf626f47 100644 --- a/configure.ac +++ b/configure.ac @@ -98,10 +98,19 @@ AC_ARG_ENABLE(pam-config, AS_HELP_STRING([--enable-pam-config=CONF], [Select PAM config to install: arch, debian, redhat, suse, freebsd, macos, unix (default: autodetect)])) -AC_ARG_ENABLE(xrdpdebug, AS_HELP_STRING([--enable-xrdpdebug], - [Build debug (default: no)]), - [], [enable_xrdpdebug=no]) -AM_CONDITIONAL(XRDP_DEBUG, [test x$enable_xrdpdebug = xyes]) +# Development options. devel_all is first as this provides a default for +# the others +AC_ARG_ENABLE(devel_all, AS_HELP_STRING([--enable-devel-all], + [Enable all development options (default: no)]), + [devel_all=$enableval], [devel_all=no]) +AC_ARG_ENABLE(devel_debug, AS_HELP_STRING([--enable-devel-debug], + [Build exes with no optimisation and debugging symbols (default: no)]), + [devel_debug=$enableval], [devel_debug=$devel_all]) +AM_CONDITIONAL(DEVEL_DEBUG, [test x$devel_debug = xyes ]) +AC_ARG_ENABLE(devel_logging, AS_HELP_STRING([--enable-devel-logging], + [Enable development logging (default: no)]), + [devel_logging=$enableval], [devel_logging=$devel_all]) + AC_ARG_ENABLE(neutrinordp, AS_HELP_STRING([--enable-neutrinordp], [Build neutrinordp module (default: no)]), [], [enable_neutrinordp=no]) @@ -163,7 +172,7 @@ AX_APPEND_COMPILE_FLAGS([-Wwrite-strings]) AM_COND_IF([LINUX], [AX_APPEND_COMPILE_FLAGS([-Werror])]) # bsd has warnings that have not been fixed yet -AM_COND_IF([XRDP_DEBUG], +AM_COND_IF([DEVEL_DEBUG], [AX_APPEND_COMPILE_FLAGS([-g -O0])], [AX_APPEND_COMPILE_FLAGS([-O2])]) @@ -247,6 +256,13 @@ fi AC_SUBST(PAM_RULES) +# Add define for development options to config_ac.h +AC_DEFINE([CONFIG_AC_H],1, [Allow sources to check config_ac.h is included]) +if test x$devel_logging = xyes +then + AC_DEFINE([USE_DEVEL_LOGGING],1,[Enable development logging]) +fi + if test "x$enable_vsock" = "xyes" then enable_vsock=yes @@ -438,21 +454,22 @@ AC_OUTPUT echo "" echo "xrdp will be compiled with:" echo "" -echo " mp3lame $enable_mp3lame" -echo " opus $enable_opus" -echo " fdkaac $enable_fdkaac" -echo " jpeg $enable_jpeg" -echo " turbo jpeg $enable_tjpeg" -echo " rfxcodec $enable_rfxcodec" -echo " painter $enable_painter" -echo " pixman $enable_pixman" -echo " fuse $enable_fuse" -echo " ipv6 $enable_ipv6" -echo " ipv6only $enable_ipv6only" -echo " vsock $enable_vsock" -echo " auth mechanism $auth_mech" -echo " debug $enable_xrdpdebug" -echo " rdpsndaudin $enable_rdpsndaudin" +echo " mp3lame $enable_mp3lame" +echo " opus $enable_opus" +echo " fdkaac $enable_fdkaac" +echo " jpeg $enable_jpeg" +echo " turbo jpeg $enable_tjpeg" +echo " rfxcodec $enable_rfxcodec" +echo " painter $enable_painter" +echo " pixman $enable_pixman" +echo " fuse $enable_fuse" +echo " ipv6 $enable_ipv6" +echo " ipv6only $enable_ipv6only" +echo " vsock $enable_vsock" +echo " auth mechanism $auth_mech" +echo " rdpsndaudin $enable_rdpsndaudin" +echo +echo " development logging $devel_logging" echo "" echo " strict_locations $enable_strict_locations" echo " prefix $prefix" diff --git a/libxrdp/Makefile.am b/libxrdp/Makefile.am index 7f099cf5..c843a531 100644 --- a/libxrdp/Makefile.am +++ b/libxrdp/Makefile.am @@ -14,10 +14,6 @@ AM_LDFLAGS = LIBXRDP_EXTRA_LIBS = -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - if XRDP_NEUTRINORDP AM_CPPFLAGS += -DXRDP_NEUTRINORDP LIBXRDP_EXTRA_LIBS += $(FREERDP_LIBS) diff --git a/libxrdp/xrdp_caps.c b/libxrdp/xrdp_caps.c index 567f3ceb..2ef2543c 100644 --- a/libxrdp/xrdp_caps.c +++ b/libxrdp/xrdp_caps.c @@ -626,7 +626,7 @@ static int xrdp_caps_process_surface_cmds(struct xrdp_rdp *self, struct stream *s, int len) { int cmdFlags; -#ifndef XRDP_DEBUG +#ifndef USE_DEVEL_LOGGING /* TODO: remove UNUSED_VAR once the `cmdFlags` variable is used for more than logging in debug mode */ UNUSED_VAR(cmdFlags); diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c index 7fdf3fc8..ffeffbed 100644 --- a/libxrdp/xrdp_sec.c +++ b/libxrdp/xrdp_sec.c @@ -1406,7 +1406,7 @@ xrdp_sec_recv_fastpath(struct xrdp_sec *self, struct stream *s) int len; int pad; -#ifndef XRDP_DEBUG +#ifndef USE_DEVEL_LOGGING /* TODO: remove UNUSED_VAR once the `ver` variable is used for more than logging in debug mode */ UNUSED_VAR(ver); diff --git a/mc/Makefile.am b/mc/Makefile.am index 130bdcfc..9ed72135 100644 --- a/mc/Makefile.am +++ b/mc/Makefile.am @@ -5,10 +5,6 @@ AM_CPPFLAGS = \ -DXRDP_PID_PATH=\"${localstatedir}/run\" \ -I$(top_srcdir)/common -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - module_LTLIBRARIES = \ libmc.la diff --git a/neutrinordp/Makefile.am b/neutrinordp/Makefile.am index 673a7885..d9c31bc3 100644 --- a/neutrinordp/Makefile.am +++ b/neutrinordp/Makefile.am @@ -6,10 +6,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/common \ $(FREERDP_CFLAGS) -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - module_LTLIBRARIES = \ libxrdpneutrinordp.la diff --git a/sesman/Makefile.am b/sesman/Makefile.am index 78e00416..7d4efa09 100644 --- a/sesman/Makefile.am +++ b/sesman/Makefile.am @@ -11,10 +11,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/common \ -I$(top_srcdir)/sesman/libscp -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - if SESMAN_BSD AUTH_C = verify_user_bsd.c AUTH_LIB = diff --git a/sesman/chansrv/Makefile.am b/sesman/chansrv/Makefile.am index 1a57a563..4f74912c 100644 --- a/sesman/chansrv/Makefile.am +++ b/sesman/chansrv/Makefile.am @@ -11,10 +11,6 @@ AM_CPPFLAGS = \ -DXRDP_SOCKET_PATH=\"${socketdir}\" \ -I$(top_srcdir)/common -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - CHANSRV_EXTRA_LIBS = if XRDP_FUSE diff --git a/sesman/libscp/Makefile.am b/sesman/libscp/Makefile.am index fc382b43..1bb89910 100644 --- a/sesman/libscp/Makefile.am +++ b/sesman/libscp/Makefile.am @@ -5,10 +5,6 @@ AM_CPPFLAGS = \ -DXRDP_PID_PATH=\"${localstatedir}/run\" \ -I$(top_srcdir)/common -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - module_LTLIBRARIES = \ libscp.la diff --git a/sesman/sesman.ini.in b/sesman/sesman.ini.in index b709650d..59f99774 100644 --- a/sesman/sesman.ini.in +++ b/sesman/sesman.ini.in @@ -74,7 +74,8 @@ EnableSyslog=true #EnableProcessId=false [LoggingPerLogger] -; Note: per logger configuration is only used in XRDP_DEBUG builds of XRDP. +; Note: per logger configuration is only used if xrdp is built with +; --enable-devel-logging #sesman.c=INFO #main()=INFO @@ -139,7 +140,8 @@ EnableSyslog=true #EnableProcessId=false [ChansrvLoggingPerLogger] -; Note: per logger configuration is only used in XRDP_DEBUG builds of XRDP. +; Note: per logger configuration is only used if xrdp is built with +; --enable-devel-logging #chansrv.c=INFO #main()=INFO diff --git a/sesman/tools/Makefile.am b/sesman/tools/Makefile.am index ae5d80cd..e49d267a 100644 --- a/sesman/tools/Makefile.am +++ b/sesman/tools/Makefile.am @@ -8,10 +8,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/sesman/libscp \ -I$(top_srcdir)/sesman -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - AM_CFLAGS = $(X_CFLAGS) bin_PROGRAMS = \ diff --git a/tests/common/Makefile.am b/tests/common/Makefile.am index a9b662cb..bf3cf7e6 100644 --- a/tests/common/Makefile.am +++ b/tests/common/Makefile.am @@ -3,10 +3,6 @@ AM_CPPFLAGS = \ -I$(top_builddir) \ -I$(top_srcdir)/common -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \ $(top_srcdir)/tap-driver.sh diff --git a/tests/memtest/Makefile.am b/tests/memtest/Makefile.am index 890f2716..40669125 100644 --- a/tests/memtest/Makefile.am +++ b/tests/memtest/Makefile.am @@ -2,10 +2,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/common -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - check_PROGRAMS = \ memtest diff --git a/tools/devel/tcp_proxy/Makefile.am b/tools/devel/tcp_proxy/Makefile.am index 2e049489..2c5c6c5c 100644 --- a/tools/devel/tcp_proxy/Makefile.am +++ b/tools/devel/tcp_proxy/Makefile.am @@ -2,10 +2,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/common -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - noinst_PROGRAMS = \ tcp_proxy diff --git a/vnc/Makefile.am b/vnc/Makefile.am index 92160771..ebe02c05 100644 --- a/vnc/Makefile.am +++ b/vnc/Makefile.am @@ -5,10 +5,6 @@ AM_CPPFLAGS = \ -DXRDP_PID_PATH=\"${localstatedir}/run\" \ -I$(top_srcdir)/common -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - module_LTLIBRARIES = \ libvnc.la diff --git a/xrdp/Makefile.am b/xrdp/Makefile.am index fe14d88d..1a065d7e 100644 --- a/xrdp/Makefile.am +++ b/xrdp/Makefile.am @@ -16,10 +16,6 @@ AM_CPPFLAGS = \ XRDP_EXTRA_LIBS = -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - if XRDP_RFXCODEC AM_CPPFLAGS += -DXRDP_RFXCODEC AM_CPPFLAGS += -I$(top_srcdir)/librfxcodec/include diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index 3f4f8595..3e5d6238 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -454,7 +454,7 @@ main(int argc, char **argv) const char *pid_file = XRDP_PID_PATH "/xrdp.pid"; int errored_argc; -#ifdef XRDP_DEBUG +#ifdef USE_DEVEL_LOGGING int test; for (test = 0; test < argc; test++) { diff --git a/xrdp/xrdp.ini.in b/xrdp/xrdp.ini.in index 05a5ac87..7f5236ed 100644 --- a/xrdp/xrdp.ini.in +++ b/xrdp/xrdp.ini.in @@ -166,7 +166,8 @@ EnableSyslog=true #EnableProcessId=false [LoggingPerLogger] -; Note: per logger configuration is only used in XRDP_DEBUG builds of XRDP. +; Note: per logger configuration is only used if xrdp is built with +; --enable-devel-logging #xrdp.c=INFO #main()=INFO diff --git a/xup/Makefile.am b/xup/Makefile.am index 1a4fc35b..b51a7fb3 100644 --- a/xup/Makefile.am +++ b/xup/Makefile.am @@ -5,10 +5,6 @@ AM_CPPFLAGS = \ -DXRDP_PID_PATH=\"${localstatedir}/run\" \ -I$(top_srcdir)/common -if XRDP_DEBUG -AM_CPPFLAGS += -DXRDP_DEBUG -endif - module_LTLIBRARIES = \ libxup.la