From 1d1c90412603171024708231b7a39bea085c4abc Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 4 Sep 2021 19:05:23 +0200 Subject: [PATCH] Configure: Place the argument checks at the beginning of execution The autotool provides a simple mechanism which allows us to move ("divert") the checks we do on the user arguments to the beginning of the script, yet without needing to scatter the code. This is good because we can raise errors very fast, user do not have to wait until many other checks have passed before knowing he has to correct his argument list; yet on our side we can keep related things together. Signed-off-by: Christophe CURIS --- configure.ac | 60 +++++++++++++++++++++++++++++++++++++++++++++++ m4/windowmaker.m4 | 4 +++- m4/wm_i18n.m4 | 8 +++++-- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 4b6a3409..e099d608 100644 --- a/configure.ac +++ b/configure.ac @@ -103,6 +103,7 @@ LT_INIT dnl Debugging Options dnl ================= +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [enable debugging options, @<:@default=no@:>@])], [AS_CASE(["$enableval"], @@ -110,6 +111,7 @@ AC_ARG_ENABLE([debug], [no], [debug=no], [AC_MSG_ERROR([bad value $enableval for --enable-debug])] )], [debug=no]) +m4_divert_pop([INIT_PREPARE])dnl AS_IF([test "x$debug" = "xyes"], [dnl This flag should have already been detected and added, but if user dnl provided an explicit CFLAGS it may not be the case @@ -234,6 +236,7 @@ AS_IF([test "x$debug" = "xyes"], dnl To upload documentation to the Website dnl ====================================== +m4_divert_push([INIT_PREPARE])dnl AC_ARG_WITH([web-repo], [AS_HELP_STRING([--with-web-repo=PATH], [path to your git repository for the Web home page (maintainer stuff)])], [AS_CASE([$withval], @@ -241,6 +244,7 @@ AC_ARG_WITH([web-repo], [no], [WEB_REPO_ROOT=""], [WEB_REPO_ROOT=$withval])], [WEB_REPO_ROOT=""]) +m4_divert_pop([INIT_PREPARE])dnl WM_CHECK_WEBREPODIR @@ -308,24 +312,30 @@ AC_ARG_WITH(incs-from, AS_HELP_STRING([--with-incs-from], [pass compiler flags t dnl Features Configuration dnl ====================== +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([animations], [AS_HELP_STRING([--disable-animations], [disable permanently animations @<:@default=enabled@:>@])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-animations])])], [enable_animations="yes"]) +m4_divert_pop([INIT_PREPARE])dnl + AS_IF([test "x$enable_animations" = "xno"], [unsupported="$unsupported Animations"], [AC_DEFINE([USE_ANIMATIONS], [1], [Defined when user did not request to disable animations]) supported_core="$supported_core Animations"]) +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([mwm-hints], [AS_HELP_STRING([--disable-mwm-hints], [disable support for Motif WM hints @<:@default=enabled@:>@])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-mwm-hints])])], [enable_mwm_hints="yes"]) +m4_divert_pop([INIT_PREPARE])dnl + AS_IF([test "x$enable_mwm_hints" = "xno"], [unsupported="$unsupported MWMHints"], [AC_DEFINE([USE_MWM_HINTS], [1], [Defined when used did not request to disable Motif WM hints]) @@ -335,6 +345,7 @@ AM_CONDITIONAL([USE_MWM_HINTS], [test "x$enable_mwm_hints" != "xno"]) dnl Boehm GC dnl ======== +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([boehm-gc], [AS_HELP_STRING([--enable-boehm-gc], [use Boehm GC instead of the default libc malloc() [default=no]])], [AS_CASE(["$enableval"], @@ -342,6 +353,8 @@ AC_ARG_ENABLE([boehm-gc], [no], [with_boehm_gc=no], [AC_MSG_ERROR([bad value $enableval for --enable-boehm-gc])] )], [with_boehm_gc=no]) +m4_divert_pop([INIT_PREPARE])dnl + AS_IF([test "x$with_boehm_gc" = "xyes"], AC_SEARCH_LIBS([GC_malloc], [gc], [AC_DEFINE(USE_BOEHM_GC, 1, [Define if Boehm GC is to be used])], @@ -350,10 +363,12 @@ AS_IF([test "x$with_boehm_gc" = "xyes"], dnl LCOV dnl ==== +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([lcov], [AS_HELP_STRING([--enable-lcov[=output-directory]], [enable coverage data generation using LCOV (GCC only) [default=no]])], [], [enable_lcov=no]) +m4_divert_pop([INIT_PREPARE])dnl AS_IF([test "x$enable_lcov" != "xno"], [AX_CFLAGS_GCC_OPTION(-fprofile-arcs -ftest-coverage) @@ -386,6 +401,7 @@ WM_FUNC_OPEN_NOFOLLOW dnl Check for strlcat/strlcpy dnl ========================= +m4_divert_push([INIT_PREPARE])dnl AC_ARG_WITH([libbsd], [AS_HELP_STRING([--without-libbsd], [do not use libbsd for strlcat and strlcpy [default=check]])], [AS_IF([test "x$with_libbsd" != "xno"], @@ -393,6 +409,7 @@ AC_ARG_WITH([libbsd], [with_libbsd=] )], [with_libbsd=bsd]) +m4_divert_pop([INIT_PREPARE])dnl tmp_libs=$LIBS AC_SEARCH_LIBS([strlcat],[$with_libbsd], @@ -516,24 +533,30 @@ AC_CHECK_LIB([X11], [XConvertCase], dnl XKB keyboard language status dnl ============================ +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([modelock], [AS_HELP_STRING([--enable-modelock], [XKB keyboard language status support])], [AS_CASE([$enableval], [yes|no], [], [AC_MSG_ERROR([bad value '$enableval' for --enable-modelock])])], [enable_modelock=no]) +m4_divert_pop([INIT_PREPARE])dnl + AS_IF([test "x$enable_modelock" = "xyes"], [AC_DEFINE([XKB_MODELOCK], [1], [whether XKB language MODELOCK should be enabled]) ]) dnl XDND Drag-nd-Drop support dnl ========================= +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([xdnd], [AS_HELP_STRING([--disable-xdnd], [disable support for Drag-and-Drop on the dock @<:@default=enabled@:>@])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --disable-xdnd]) ]) ], [enable_xdnd=yes]) +m4_divert_pop([INIT_PREPARE])dnl + AS_IF([test "x$enable_xdnd" = "xyes"], [supported_core="$supported_core XDnD" AC_DEFINE([USE_DOCK_XDND], [1], [whether Drag-and-Drop on the dock should be enabled])], @@ -543,12 +566,15 @@ AM_CONDITIONAL([USE_DOCK_XDND], [test "x$enable_xdnd" != "xno"]) dnl Support for ICCCM 2.0 Window Manager replacement dnl ================================================ +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([wmreplace], [AS_HELP_STRING([--enable-wmreplace], [support for ICCCM window manager replacement])], [AS_CASE([$enableval], [yes|no], [], [AC_MSG_ERROR([bad value '$enableval' for --enable-wmreplace])])], [enable_wmreplace=no]) +m4_divert_pop([INIT_PREPARE])dnl + AS_IF([test "x$enable_wmreplace" = "xyes"], [AC_DEFINE([USE_ICCCM_WMREPLACE], [1], [define to support ICCCM protocol for window manager replacement]) @@ -557,23 +583,28 @@ AS_IF([test "x$enable_wmreplace" = "xyes"], dnl XShape support dnl ============== +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([shape], [AS_HELP_STRING([--disable-shape], [disable shaped window extension support])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-shape]) ]) ], [enable_shape=auto]) +m4_divert_pop([INIT_PREPARE])dnl + WM_XEXT_CHECK_XSHAPE dnl MIT-SHM support dnl =============== +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([shm], [AS_HELP_STRING([--disable-shm], [disable usage of MIT-SHM extension])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-shm]) ]) ], [enable_shm=auto]) +m4_divert_pop([INIT_PREPARE])dnl WM_XEXT_CHECK_XSHM @@ -585,23 +616,27 @@ WM_EXT_CHECK_XMU dnl XINERAMA support dnl ================ +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([xinerama], [AS_HELP_STRING([--enable-xinerama], [enable Xinerama extension support])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-xinerama]) ]) ], [enable_xinerama=auto]) +m4_divert_pop([INIT_PREPARE])dnl WM_XEXT_CHECK_XINERAMA dnl RandR support dnl ============= +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([randr], [AS_HELP_STRING([--enable-randr], [enable RandR extension support (NOT recommended, buggy)])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-randr]) ]) ], [enable_randr=no]) +m4_divert_pop([INIT_PREPARE])dnl WM_XEXT_CHECK_XRANDR @@ -649,12 +684,14 @@ AC_SUBST(XFT_LIBS) dnl PANGO support dnl ============= dnl The libray can be used by WINGs to get better support on UTF-8 for i18n +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([pango], [AS_HELP_STRING([--disable-pango], [disable Pango text layout support @<:@default=auto@:>@])], [AS_CASE([$enableval], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --disable-pango])] )], [enable_pango=auto]) +m4_divert_pop([INIT_PREPARE])dnl WM_CHECK_LIBPANGO @@ -664,12 +701,14 @@ dnl ============================================== dnl XPM Support dnl =========== +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([xpm], [AS_HELP_STRING([--disable-xpm], [disable use of XPM pixmaps through libXpm])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-xpm])] )], [enable_xpm=auto]) +m4_divert_pop([INIT_PREPARE])dnl WM_IMGFMT_CHECK_XPM @@ -693,67 +732,79 @@ AS_IF([test "x$LIBEXIF" != "x"], dnl PNG Support dnl =========== +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([png], [AS_HELP_STRING([--disable-png], [disable PNG support through libpng])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-png])] )], [enable_png=auto]) +m4_divert_pop([INIT_PREPARE])dnl WM_IMGFMT_CHECK_PNG dnl JPEG Support dnl ============ +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([jpeg], [AS_HELP_STRING([--disable-jpeg], [disable JPEG support through libjpeg])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-jpeg])] )], [enable_jpeg=auto]) +m4_divert_pop([INIT_PREPARE])dnl WM_IMGFMT_CHECK_JPEG dnl GIF Support dnl ============ +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE(gif, [AS_HELP_STRING([--disable-gif], [disable GIF support through libgif or libungif])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-gif])] )], [enable_gif=auto]) +m4_divert_pop([INIT_PREPARE])dnl WM_IMGFMT_CHECK_GIF dnl TIFF Support dnl ============ +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([tiff], [AS_HELP_STRING([--disable-tiff], [disable use of TIFF images through libtiff])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-tiff])] )], [enable_tiff=auto]) +m4_divert_pop([INIT_PREPARE])dnl WM_IMGFMT_CHECK_TIFF dnl WEBP Support dnl ============ +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([webp], [AS_HELP_STRING([--disable-webp], [disable WEBP support through libwebp])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-webp])] )], [enable_webp=auto]) +m4_divert_pop([INIT_PREPARE])dnl WM_IMGFMT_CHECK_WEBP dnl MagicK Support dnl ============== +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([magick], [AS_HELP_STRING([--disable-magick], [disable MAGICK support through libMagickWand])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --enable-magick])] )], [enable_magick=auto]) +m4_divert_pop([INIT_PREPARE])dnl WM_IMGFMT_CHECK_MAGICK @@ -795,6 +846,7 @@ AC_CHECK_HEADERS(stdlib.h) dnl Support for PIXMAPDIR option dnl ============================ +m4_divert_push([INIT_PREPARE])dnl AC_ARG_WITH([pixmapdir], [AS_HELP_STRING([--with-pixmapdir=PATH], [specify where pixmaps are located [DATADIR/pixmaps]])], [AS_CASE([$withval], @@ -803,6 +855,7 @@ AC_ARG_WITH([pixmapdir], [\$*], [], dnl Assumes it starts with a reference to $prefix or a similar variable, ok [AC_MSG_ERROR([bad path '$withval' for pixmapdir, expecting an absolute path])])], [with_pixmapdir=""]) +m4_divert_pop([INIT_PREPARE])dnl AS_IF([test "x$with_pixmapdir" != "x"], [pixmapdir="$with_pixmapdir"], @@ -812,6 +865,7 @@ AC_SUBST([pixmapdir])dnl dnl Support for GNUSTEP_LOCAL_ROOT, for WPrefs.app dnl ============================================== +m4_divert_push([INIT_PREPARE])dnl AC_ARG_WITH([gnustepdir], [AS_HELP_STRING([--with-gnustepdir=PATH], [specify the directory for GNUstep applications])], [AS_CASE([$withval], @@ -821,6 +875,7 @@ AC_ARG_WITH([gnustepdir], [AC_MSG_ERROR([bad path '$withval' for gnustepdir, expecting an absolute path])])], [dnl If no command-line option was given, we use $GNUSTEP_LOCAL_ROOT if it was set with_gnustepdir="$GNUSTEP_LOCAL_ROOT"]) +m4_divert_pop([INIT_PREPARE])dnl AS_IF([test "x$with_gnustepdir" = "x"], [dnl No path specified, use default @@ -837,6 +892,7 @@ AC_SUBST([wprefs_bindir])dnl dnl Support for PKGCONFDIR option dnl ============================= +m4_divert_push([INIT_PREPARE])dnl AC_ARG_WITH([pkgconfdir], [AS_HELP_STRING([--with-pkgconfdir=PATH], [specify where global defaults are located [SYSCONFDIR/WindowMaker]])], [AS_CASE([$withval], @@ -845,6 +901,7 @@ AC_ARG_WITH([pkgconfdir], [\$*], [], dnl Assumes it starts with a reference to $prefix or a similar variable, ok [AC_MSG_ERROR([bad path '$withval' for pkgconfdir, expecting an absolute path])])], [with_pkgconfdir=""]) +m4_divert_pop([INIT_PREPARE])dnl dnl Provide a message when trying to use "--with-defsdatadir" so that user can update its dnl arguments. Otherwise only a warning is issued, which is likely to be missed, which will @@ -860,12 +917,15 @@ AC_SUBST([pkgconfdir])dnl dnl Enable User Defined Menu thing dnl ============================== +m4_divert_push([INIT_PREPARE])dnl AC_ARG_ENABLE([usermenu], [AS_HELP_STRING([--enable-usermenu], [user defined menus for applications])], [AS_CASE([$enableval], [yes|no], [], [AC_MSG_ERROR([bad value '$enableval' for --enable-usermenu])])], [enable_usermenu=no]) +m4_divert_pop([INIT_PREPARE])dnl + AS_IF([test "x$enable_usermenu" = "xyes"], [AC_DEFINE([USER_MENU], [1], [define if you want user defined menus for applications])]) diff --git a/m4/windowmaker.m4 b/m4/windowmaker.m4 index 87263e04..7ebf501e 100644 --- a/m4/windowmaker.m4 +++ b/m4/windowmaker.m4 @@ -30,7 +30,9 @@ m4_pattern_allow([^WM_OSDEP(_[A-Z]*)?$]) # execute ACTION-IF-GIVEN which is supposed to call AC_MSG_ERROR to # stop any further processing and tell the user its arguments are bad AC_DEFUN([WM_DENY_ARG_WITH], -[AS_IF([test "${[with_]m4_translit([$1], [-+.], [___])+set}" = set], [$2])]) +[m4_divert_push([INIT_PREPARE])dnl + AS_IF([test "${[with_]m4_translit([$1], [-+.], [___])+set}" = set], [$2]) + m4_divert_pop([INIT_PREPARE])]) # WM_CHECK_XFT_VERSION(MIN_VERSION, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]) diff --git a/m4/wm_i18n.m4 b/m4/wm_i18n.m4 index 4da91e2c..f645065d 100644 --- a/m4/wm_i18n.m4 +++ b/m4/wm_i18n.m4 @@ -147,7 +147,8 @@ AM_CONDITIONAL([HAVE_XGETTEXT], [test "x$XGETTEXT" != "x"])dnl # wish to customize the menus, and thus can make them translatable # with their own po/mo files without having to touch WMaker's stuff. AC_DEFUN_ONCE([WM_I18N_MENUTEXTDOMAIN], -[AC_ARG_WITH([menu-textdomain], +[m4_divert_push([INIT_PREPARE])dnl + AC_ARG_WITH([menu-textdomain], [AS_HELP_STRING([--with-menu-textdomain=DOMAIN], [specify gettext domain used for menu translations])], [AS_CASE([$withval], @@ -155,6 +156,7 @@ AC_DEFUN_ONCE([WM_I18N_MENUTEXTDOMAIN], [no], [menutextdomain=""], [menutextdomain="$withval"])], [menutextdomain=""]) +m4_divert_pop([INIT_PREPARE])dnl AS_IF([test "x$menutextdomain" != "x"], [AC_DEFINE_UNQUOTED([MENU_TEXTDOMAIN], ["$menutextdomain"], [gettext domain to be used for menu translations]) ]) @@ -167,13 +169,15 @@ dnl dnl X11 needs to redefine the function 'setlocale' to properly initialize itself, dnl we check if user wants to disable this behaviour or if it is not supported AC_DEFUN_ONCE([WM_I18N_XLOCALE], -[AC_ARG_ENABLE([xlocale], +[m4_divert_push([INIT_PREPARE])dnl + AC_ARG_ENABLE([xlocale], [AS_HELP_STRING([--disable-xlocale], [disable initialization of locale for X])], [AS_CASE([$enableval], [yes|no], [], [AC_MSG_ERROR([bad value '$enableval' for --disable-xlocale])])], [enable_xlocale=auto]) +m4_divert_pop([INIT_PREPARE])dnl AS_IF([test "x$enable_xlocale" != "xno"], [AC_CHECK_LIB([X11], [_Xsetlocale], [AC_DEFINE([X_LOCALE], [1],