Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
9183154
m4/nut_arg_with.m4, configure.ac, NEWS.adoc: refactor with ability to…
jimklimov Oct 16, 2025
140f3f5
m4/nut_arg_with.m4: fix passing of conftemp (non-verbatim per se) [#3…
jimklimov Oct 16, 2025
d3d64f8
configure.ac, m4/nut_arg_with.m4: extend newer NUT_ARG_WITH_CUSTOM_DE…
jimklimov Oct 16, 2025
b40b0cd
m4/nut_arg_with.m4: update comments [#3049]
jimklimov Oct 17, 2025
da1b58b
m4/nut_arg_with.m4: more uniquely name the conftemp variables [#3049]
jimklimov Oct 17, 2025
f8b2cc6
m4/nut_arg_with.m4: extend NUT_ARG_ENABLE_CUSTOM_DEFAULT_HELP and NUT…
jimklimov Oct 17, 2025
89dd3fb
m4/nut_arg_with.m4: extend NUT_ARG_ENABLE and NUT_ARG_WITH to optiona…
jimklimov Oct 17, 2025
307572c
m4/nut_arg_with.m4: clarify that parentheses mean "default:" and *_SI…
jimklimov Oct 17, 2025
c3d0523
configure.ac: define "confdir-suffix" via 4-arg syntax of NUT_ARG_WIT…
jimklimov Oct 17, 2025
eb9111c
configure.ac: refactor NUT_ARG_* help and determination of STATEPATH,…
jimklimov Oct 17, 2025
fbd2076
configure.ac: refactor NUT_ARG_* help and determination of POWERDOWNF…
jimklimov Oct 17, 2025
d1deb0f
configure.ac: refactor NUT_ARG_* help and determination of DRVPATH [#…
jimklimov Oct 17, 2025
7640672
configure.ac: refactor NUT_ARG_* help and determination of CGIPATH [#…
jimklimov Oct 19, 2025
593367a
configure.ac: add separators between unrelated subjects, revise comments
jimklimov Oct 19, 2025
de19992
data/html/Makefile.am: ensure that HTML files for CGI are in dist tar…
jimklimov Oct 19, 2025
b660249
configure.ac, *.am: rename "htmldir" to "htmlcgidir", "data/html" to …
jimklimov Oct 19, 2025
917571f
configure.ac: refactor NUT_ARG_* help and determination of CGIDATAPAT…
jimklimov Oct 20, 2025
bf6beac
configure.ac: refactor NUT_ARG_* help and determination of DEFAULT_MA…
jimklimov Oct 20, 2025
75bc281
configure.ac: refactor NUT_ARG_* help and determination of --with-doc…
jimklimov Oct 20, 2025
1a56464
configure.ac: refactor NUT_ARG_* help and determination of --enable-c…
jimklimov Oct 20, 2025
0ae4efd
configure.ac: refactor NUT_ARG_* help and determination of --with-por…
jimklimov Oct 20, 2025
c43fba4
configure.ac: refactor NUT_ARG_* help and determination of --with-log…
jimklimov Oct 20, 2025
b8e7f81
configure.ac: refactor NUT_ARG_* help and determination of --enable-f…
jimklimov Oct 20, 2025
946501a
configure.ac: refactor NUT_ARG_* help and determination of --enable-s…
jimklimov Oct 20, 2025
3560b5d
configure.ac: refactor NUT_ARG_* help and determination of PKGCONFIGD…
jimklimov Oct 20, 2025
ab72756
configure.ac: refactor NUT_ARG_* help and determination of Solaris/il…
jimklimov Oct 20, 2025
207d8d5
configure.ac: refactor NUT_ARG_* help and determination of systemd pa…
jimklimov Oct 20, 2025
6c6fed1
configure.ac: refactor NUT_ARG_* help and determination of --enable-c…
jimklimov Oct 20, 2025
151145c
configure.ac: refactor NUT_ARG_* help and determination of --with-aug…
jimklimov Oct 20, 2025
ad6218b
configure.ac: refactor NUT_ARG_* help and determination of udev, hotp…
jimklimov Oct 20, 2025
2716eb2
configure.ac: move SYSTEM_AIX and CPU_TYPE determination way up, to w…
jimklimov Oct 20, 2025
8492b01
configure.ac: refactor NUT_ARG_* help and determination of --with-val…
jimklimov Oct 20, 2025
02a9961
configure.ac: refactor NUT_ARG_* help and determination of --with-use…
jimklimov Oct 20, 2025
3a9c814
configure.ac: refactor NUT_ARG_* help and determination of --enable-e…
jimklimov Oct 20, 2025
b9edb40
configure.ac: refactor NUT_ARG_* help and determination of --with-CCA…
jimklimov Oct 20, 2025
0bfc5c2
m4/nut_arg_with.m4: introduce NUT_ARG_WITH_LIBOPTS* [#3049]
jimklimov Oct 20, 2025
8d39e48
m4/nut_check_libavahi.m4: refactor to word the help and determine opt…
jimklimov Oct 20, 2025
0c2c391
m4/nut_check_libfreeipmi.m4: refactor to word the help and determine …
jimklimov Oct 21, 2025
f84a17b
m4/nut_arg_with.m4: rearrange NUT_ARG_WITH_LIBOPTS_INCLUDES and NUT_A…
jimklimov Oct 21, 2025
ea3f0cd
m4/nut_arg_with.m4: add NUT_ARG_WITH_LIBOPTS_LIBS_AS_LDFLAGS and NUT_…
jimklimov Oct 21, 2025
15eedd6
m4/nut_check_libgd.m4: refactor to word the help and determine option…
jimklimov Oct 21, 2025
8a97685
configure.ac: rephrase help for (alt)pidpath [#3049]
jimklimov Oct 21, 2025
a48e841
m4/nut_arg_with.m4: extend NUT_ARG_WITH_LIBOPTS* with optional altern…
jimklimov Oct 21, 2025
22be208
m4/nut_check_libgpiod.m4: refactor to word the help and determine opt…
jimklimov Oct 21, 2025
9eba1eb
m4/nut_arg_with.m4: simplify with use of m4_default() [#3049]
jimklimov Oct 21, 2025
ad89aa8
configure.ac, scripts/devd/README.adoc: revise help and doc regarding…
jimklimov Oct 21, 2025
f83c876
configure.ac, NEWS.adoc: there was never a scripts/devd/nut-usbups.ru…
jimklimov Oct 21, 2025
5906d8b
m4/nut_check_libltdl.m4: refactor to word the help and determine opti…
jimklimov Oct 21, 2025
836dfb4
m4/nut_check_libmodbus.m4: refactor to word the help and determine op…
jimklimov Oct 21, 2025
6b81c87
m4/nut_check_libneon.m4: refactor to word the help and determine opti…
jimklimov Oct 21, 2025
d907efe
m4/nut_check_libnss.m4: refactor to word the help and determine optio…
jimklimov Oct 21, 2025
ef7e3ed
m4/nut_check_pkgconfig.m4: refactor NUT_ARG_* help and determination …
jimklimov Oct 21, 2025
2a8024c
m4/nut_check_libopenssl.m4: refactor to word the help and determine o…
jimklimov Oct 21, 2025
7cfd1fd
m4/nut_check_libpowerman.m4: refactor to word the help and determine …
jimklimov Oct 21, 2025
cfcf1c3
m4/nut_check_libnetsnmp.m4: refactor to word the help and determine o…
jimklimov Oct 21, 2025
62be879
m4/nut_check_libusb.m4: refactor to word the help and determine optio…
jimklimov Oct 21, 2025
b3a4d71
m4/nut_arg_with.m4: NUT_ARG_WITH_LIBOPTS_CONFIGSCRIPT_IMPLEM: drop ex…
jimklimov Oct 21, 2025
58b5f81
NEWS.adoc: update entry with PR number
jimklimov Oct 21, 2025
d4a4b3c
m4/nut_check_libnetsnmp.m4: fix new --with-net-snmp-config=auto mode …
jimklimov Oct 21, 2025
dfad3a4
ci_build.sh: check more ARCH and BITS sources for illumos/Solaris pkg…
jimklimov Oct 21, 2025
e46842a
NEWS.adoc: update notes for #3049 and #3140
jimklimov Oct 21, 2025
ec602c5
Revert "m4/nut_arg_with.m4: simplify with use of m4_default() [#3049]"
jimklimov Oct 22, 2025
a5ccab1
m4/nut_arg_with.m4: revise brackets to pass arguments with commas in …
jimklimov Oct 22, 2025
0ca2665
m4/nut_check_libfreeipmi.m4: comment a reminder about numerous libs t…
jimklimov Oct 22, 2025
e98a3ad
m4/nut_check_libfreeipmi.m4: track and report depCFLAGS_SOURCE/depLIB…
jimklimov Oct 22, 2025
5e1491a
m4/nut_check_libgd.m4: track and report depCFLAGS_SOURCE/depLIBS_SOUR…
jimklimov Oct 22, 2025
49a8120
m4/nut_check_libusb.m4: track and report depCFLAGS_SOURCE/depLIBS_SOU…
jimklimov Oct 22, 2025
1bb1379
m4/nut_check_libavahi.m4: track and report depCFLAGS_SOURCE/depLIBS_S…
jimklimov Oct 22, 2025
be7ec67
m4/nut_check_libgpiod.m4: track and report depCFLAGS_SOURCE/depLIBS_S…
jimklimov Oct 22, 2025
c867baf
m4/nut_check_libltdl.m4: track and report depCFLAGS_SOURCE/depLIBS_SO…
jimklimov Oct 22, 2025
2e91a61
m4/nut_check_libnetsnmp.m4: track and report depCFLAGS_SOURCE/depLIBS…
jimklimov Oct 22, 2025
94e648f
m4/nut_check_libmodbus.m4: track and report depCFLAGS_SOURCE/depLIBS_…
jimklimov Oct 22, 2025
51a2396
m4/nut_check_libneon.m4: track and report depCFLAGS_SOURCE/depLIBS_SO…
jimklimov Oct 22, 2025
dc585f2
m4/nut_check_libgpiod.m4: fix the var names we "unset" in the end [#3…
jimklimov Oct 22, 2025
b7c3703
m4/nut_check_libnss.m4: track and report depCFLAGS_SOURCE/depLIBS_SOU…
jimklimov Oct 22, 2025
77fe041
m4/nut_check_libopenssl.m4: track and report depCFLAGS_SOURCE/depLIBS…
jimklimov Oct 22, 2025
e3861ed
m4/nut_check_libpowerman.m4: track and report depCFLAGS_SOURCE/depLIB…
jimklimov Oct 22, 2025
bb7943f
m4/nut_check_libsystemd.m4: track and report depCFLAGS_SOURCE/depLIBS…
jimklimov Oct 22, 2025
9df413e
NEWS.adoc, docs/nut.dict: update about logging the source of CFLAGS/L…
jimklimov Oct 22, 2025
285c532
m4/nut_check_libregex.m4, NEWS.adoc: Added configure script options f…
jimklimov Oct 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ SPELLCHECK_DIRS_MOST = \
spellcheck/docs/man \
spellcheck/conf \
spellcheck/data \
spellcheck/data/html \
spellcheck/data/htmlcgi \
spellcheck/scripts \
spellcheck/scripts/Solaris \
spellcheck/scripts/Windows \
Expand Down
14 changes: 14 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ several `FSD` notifications into one executed action. [PR #3097]
it), if not bundling with NUT-Monitor UI app. By default the respective
interpreter's 'site-packages' or 'dist-packages' location will be used,
so you may have to adjust search paths for any other values. [#3062]
* Streamlined handling of `--with-*` and `--enable-*` options using NUT 'm4'
macros; fixed reporting help for options whose defaults are evaluated.
[issue #3049, PR #3140]
* Automatic `--with-devd` could not detect the need to install a FreeBSD
devd configuration snippet file, because it expected a source that should
not have been there (probably a copy-paste typo in NUT v2.8.0). Also
fixed a missed compiler family dependency when handling `--enable-strip`,
a few logical mismatches of Solaris/illumos packaging options, and default
report vs. setting of `--enable-force-nut-version-header`. Rephrased and
updated many help messages. The `configure` script logs should now clarify
where CFLAGS/LIBS/LDFLAGS values come from ('pkg-config', 'default', user
provided 'confargs' etc.) [#3140]
* Added configure script options for 'libregex' tuning, just so it is on par
with our other optional dependencies. [#3140]

- Fixed CI recipes for PyPI publication of PyNUT(Client) module to also
include the source distribution (was posted for NUT v2.8.1 and v2.8.2
Expand Down
5 changes: 4 additions & 1 deletion ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,13 @@ detect_platform_PKG_CONFIG_PATH_and_FLAGS() {
BUILTIN_PKG_CONFIG_PATH="`$PKG_CONFIG --variable pc_path pkg-config`" || BUILTIN_PKG_CONFIG_PATH=""
case "`echo "$CI_OS_NAME" | $TOLOWER`" in
*openindiana*|*omnios*|*solaris*|*illumos*|*sunos*)
_ARCHES="${ARCH-}"
_ARCHES="${ARCH_TGT-}${ARCH-}${ARCH32-}${ARCH64-}"
_BITS="${BITS-}"
_ISA1=""

[ -n "${_BITS}" ] || \
_BITS="${ARCH_BITS-}"

[ -n "${_BITS}" ] || \
case "${CC}${CXX}${CFLAGS}${CXXFLAGS}${LDFLAGS}" in
*-m64*) _BITS=64 ;;
Expand Down
1,034 changes: 465 additions & 569 deletions configure.ac

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Network UPS Tools: data

SUBDIRS = html
SUBDIRS = htmlcgi

dist_data_DATA = cmdvartab
nodist_data_DATA = driver.list
Expand Down
File renamed without changes.
11 changes: 7 additions & 4 deletions data/html/Makefile.am → data/htmlcgi/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# Network UPS Tools: data/html
# Network UPS Tools: data/htmlcgi

EXTRA_DIST = README.adoc

# install these only if configured --with-cgi
if WITH_CGI
dist_html_DATA = index.html bottom.html nut-banner.png
nodist_html_DATA = header.html
dist_htmlcgi_DATA = index.html bottom.html nut-banner.png
nodist_htmlcgi_DATA = header.html
else
EXTRA_DIST += index.html bottom.html nut-banner.png header.html.in
endif
EXTRA_DIST = README.adoc

SPELLCHECK_SRC = README.adoc

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
4 changes: 2 additions & 2 deletions docs/configure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ CGI client interface

Build and install the optional CGI programs, HTML files, and sample
CGI configuration files. This is not enabled by default, as they
are only useful on web servers. See link:data/html/README[] for additional
information on how to set up CGI programs.
are only useful on web servers. See link:data/htmlcgi/README[] for
additional information on how to set up CGI programs.

NUT Scanner tool
~~~~~~~~~~~~~~~~
Expand Down
4 changes: 3 additions & 1 deletion docs/nut.dict
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
personal_ws-1.1 en 3564 utf-8
personal_ws-1.1 en 3566 utf-8
AAC
AAS
ABI
Expand Down Expand Up @@ -1817,6 +1817,7 @@ compareprocnames
compat
compilerPath
conf
confargs
confdir
config
configparser
Expand Down Expand Up @@ -2211,6 +2212,7 @@ href
htaccess
htm
html
htmlcgi
htmlpath
http
httpd
Expand Down
223 changes: 211 additions & 12 deletions m4/nut_arg_with.m4
Original file line number Diff line number Diff line change
@@ -1,21 +1,220 @@
dnl simplified declaration of some feature options
dnl Simplified declaration of some feature options
dnl Copyright (C)
dnl 2006 Peter Selinger <selinger@users.sourceforge.net>
dnl 2020-2025 Jim Klimov <jimklimov+nut@gmail.com>
dnl Common arguments:
dnl $1 option name (part after `--with-`)
dnl $2 help bit in option name (except legacy short funcs)
dnl $2 or $3 help text (descriptive part)
dnl $3 or $4 default value
dnl $4 or $5 how to represent default in help text (for *_CUSTOM_DEFAULT_HELP)
dnl Note that for some reason use of dollar-number gets expanded below,
dnl but any other variable (e.g. $conftemp straight in help string) is not.
dnl In fact, the generated configure script includes the help wall of text
dnl much earlier than it includes lines that manipulate conftemp (unless it
dnl gets somehow escaped to happen earlier), due to m4 diverts in autoconf code.
dnl So we can use the "EXPAND" methods to convert static text, but not to display
dnl any values determined and changed during `configure` shell script run-time.
dnl See research in https://github.com/networkupstools/nut/issues/3049 for more.

dnl Default expanded once to substitute current variables,
dnl or remove backslashing of verbatim dollars, etc.
dnl NOTE: Not sure if the fuss with uniquely named conftemp is worth it,
dnl or is even remembered between calls. There seems to be 3 calls per name.
AC_DEFUN([NUT_ARG_EXPAND],
[[]m4_esyscmd_s(
[nut_conftemp_]m4_translit([$1], [-], [_])="$2" ;
eval [nut_conftemp_]m4_translit([$1], [-], [_])=\"\${[nut_conftemp_]m4_translit([$1], [-], [_])}\" ;
echo "${[nut_conftemp_]m4_translit([$1], [-], [_])}" ;
dnl # RUNS 3 TIMES # echo "$1 | $2 | [nut_conftemp_]m4_translit([$1], [-], [_])=${[nut_conftemp_]m4_translit([$1], [-], [_])}" >> arg.log ;
)[]])

dnl Working With External Software (might name a variant or other contextual arg)
dnl https://www.gnu.org/software/autoconf/manual/autoconf-2.66/html_node/External-Software.html#External-Software
dnl including concepts of the OS as external software (account names, paths...)

dnl $1 option name (part after `--with-`)
dnl $2 optional "=VALUE" for help tag (after $1)
dnl $3 help text (descriptive part)
dnl $4 default value
dnl $5 how to represent default in help text (for *_CUSTOM_DEFAULT_HELP)
AC_DEFUN([NUT_ARG_WITH_CUSTOM_DEFAULT_HELP],
[ AC_ARG_WITH([$1],
m4_ifval([$2],
[m4_ifval([$5],
[AS_HELP_STRING([--with-$1=$2], [$3 (default: $5)])],
[AS_HELP_STRING([--with-$1=$2], [$3 (default: $4)])])],
[m4_ifval([$5],
[AS_HELP_STRING([--with-$1], [$3 (default: $5)])],
[AS_HELP_STRING([--with-$1], [$3 (default: $4)])])]),
[[nut_with_]m4_translit([$1], [-], [_])="${withval}"],
[[nut_with_]m4_translit([$1], [-], [_])="$4"]
)
])

AC_DEFUN([NUT_ARG_WITH_EXPAND_DEFAULT_HELP],
[
dnl Note: only 4 args expected
dnl NUT_ARG_EXPAND([$1], $3)
NUT_ARG_WITH_CUSTOM_DEFAULT_HELP([$1], [$2], [$3], [$4], NUT_ARG_EXPAND([with_$1], [$4]))
])

AC_DEFUN([NUT_ARG_WITH_EXPAND_DEFAULT_HELP_SINGLEQUOTE],
[
dnl Variant for paths (likely using backslash-dollar in $4)
dnl Note: only 4 args expected
dnl Note: "resolved from" must be not bracketed
NUT_ARG_WITH_CUSTOM_DEFAULT_HELP([$1], [$2], [$3], [$4], resolved from NUT_ARG_EXPAND([with_$1], '[$4]'))
])

AC_DEFUN([NUT_ARG_WITH],
[ AC_ARG_WITH($1,
AS_HELP_STRING([--with-$1], [$2 ($3)]),
[[nut_with_]m4_translit($1, [-], [_])="${withval}"],
[[nut_with_]m4_translit($1, [-], [_])="$3"]
)
[
dnl Note: historicaly only 3 args were expected
dnl Now a second arg may be injected for optional "=VALUE" for help tag (after $1)
dnl Legacy behavior (for static values): default value
dnl and its help representation are the same (verbatim!)
m4_ifval([$4],
[NUT_ARG_WITH_CUSTOM_DEFAULT_HELP([$1], [$2], [$3], [$4], [$4])],
[NUT_ARG_WITH_CUSTOM_DEFAULT_HELP([$1], [], [$2], [$3], [$3])])
])

dnl Special common case for *-includes and *-libs optional parameters
dnl (bracketed in help text to confer optionality)
dnl Options same as NUT_ARG_WITH (4-arg version)
AC_DEFUN([NUT_ARG_WITH_LIBOPTS],
[
AC_ARG_WITH([$1],
[AS_HELP_STRING([@<:@--with-$1=$2@:>@], [$3 (default: $4)])],
[[nut_with_]m4_translit([$1], [-], [_])="${withval}"],
[[nut_with_]m4_translit([$1], [-], [_])="$4"]
)
])

AC_DEFUN([NUT_ARG_WITH_LIBOPTS_INVALID_YESNO],
[
AC_ARG_WITH([$1],
[AS_HELP_STRING([@<:@--with-$1=$2@:>@], [$3 (default: $4)])],
[AS_CASE([${withval}],
[yes|no], [AC_MSG_ERROR([invalid option --with(out)-$1 - see docs/configure.txt])],
[[nut_with_]m4_translit([$1], [-], [_])="${withval}"]
)],
[[nut_with_]m4_translit([$1], [-], [_])="$4"]
)
])

dnl NOTE: The defaulting substituter may be not defined/renamed in some autoconf versions
dnl m4_ifndef([m4_default], [m4_define([m4_default], [m4_ifval([[$1]], [[$1]], [[$2]])])])

dnl Just the (normal-cased) third-party project name is required
dnl $1 project name
dnl $2 default value (optional)
dnl $3 project name spelling for help message (very optional)

AC_DEFUN([NUT_ARG_WITH_LIBOPTS_INCLUDES],
[
m4_ifval([$2],
[NUT_ARG_WITH_LIBOPTS_INVALID_YESNO([]m4_translit([$1], 'A-Z', 'a-z')[-includes], [CFLAGS|auto], [include flags for the ]m4_default([$3], [$1])[ library], [$2])],
[NUT_ARG_WITH_LIBOPTS_INVALID_YESNO([]m4_translit([$1], 'A-Z', 'a-z')[-includes], [CFLAGS|auto], [include flags for the ]m4_default([$3], [$1])[ library], [auto])])
])

dnl Technically LIBS and LDFLAGS are about the same for
dnl most of our m4 code and legacy help messaging... so far.
AC_DEFUN([NUT_ARG_WITH_LIBOPTS_LIBS],
[
m4_ifval([$2],
[NUT_ARG_WITH_LIBOPTS_INVALID_YESNO([]m4_translit([$1], 'A-Z', 'a-z')[-libs], [LIBS|auto], [linker flags for the ]m4_default([$3], [$1])[ library], [$2])],
[NUT_ARG_WITH_LIBOPTS_INVALID_YESNO([]m4_translit([$1], 'A-Z', 'a-z')[-libs], [LIBS|auto], [linker flags for the ]m4_default([$3], [$1])[ library], [auto])])
])

dnl Enable a feature (might name a variant), or yes/no
AC_DEFUN([NUT_ARG_WITH_LIBOPTS_LIBS_AS_LDFLAGS],
[
m4_ifval([$2],
[NUT_ARG_WITH_LIBOPTS_INVALID_YESNO([]m4_translit([$1], 'A-Z', 'a-z')[-libs], [LDFLAGS|auto], [linker flags for the ]m4_default([$3], [$1])[ library], [$2])],
[NUT_ARG_WITH_LIBOPTS_INVALID_YESNO([]m4_translit([$1], 'A-Z', 'a-z')[-libs], [LDFLAGS|auto], [linker flags for the ]m4_default([$3], [$1])[ library], [auto])])
])

AC_DEFUN([NUT_ARG_WITH_LIBOPTS_LDFLAGS],
[
m4_ifval([$2],
[NUT_ARG_WITH_LIBOPTS_INVALID_YESNO([]m4_translit([$1], 'A-Z', 'a-z')[-ldflags], [LDFLAGS|auto], [linker flags for the ]m4_default([$3], [$1])[ library], [$2])],
[NUT_ARG_WITH_LIBOPTS_INVALID_YESNO([]m4_translit([$1], 'A-Z', 'a-z')[-ldflags], [LDFLAGS|auto], [linker flags for the ]m4_default([$3], [$1])[ library], [auto])])
])

dnl Help detect legacy <projectname>-config scripts, assigns "none" if disabled or not found
dnl $1 project name
dnl $2 m4 var to assign
dnl $3 program name(s) to try
dnl $4 default value
dnl $5 project name spelling for help message (very optional)
AC_DEFUN([NUT_ARG_WITH_LIBOPTS_CONFIGSCRIPT_IMPLEM],
[
dnl By default seek in PATH
NUT_ARG_WITH_LIBOPTS([]m4_translit([$1], 'A-Z', 'a-z')[-config], [/path/to/m4_translit([$1], 'A-Z', 'a-z')-config|auto|none], [path to program that reports ]m4_default([$5], [$1])[ configuration], [$4])
AS_CASE([[${nut_with_]m4_translit([$1], [-], [_])[_config}]],
[yes|auto|""], [AC_PATH_PROGS([$2], [$3], [none])],
[no|none], [$2="none"],
[$2=["${nut_with_]m4_translit([$1], [-], [_])[_config}"]]
)
])

dnl Part of stack, use or guess optional parameter $2 (m4 var name); pass others as is
AC_DEFUN([NUT_ARG_WITH_LIBOPTS_CONFIGSCRIPT_IMPLEM_2],
[
m4_ifval([$2],
[NUT_ARG_WITH_LIBOPTS_CONFIGSCRIPT_IMPLEM([$1], [$2], [$3], [$4], [$5])],
[NUT_ARG_WITH_LIBOPTS_CONFIGSCRIPT_IMPLEM([$1], m4_translit(m4_translit([$1], 'a-z', 'A-Z'), [-], [_])[_CONFIG], [$3], [$4], [$5])])
])

dnl Part of stack, use or guess optional parameter $3 (prog names); pass others as is
AC_DEFUN([NUT_ARG_WITH_LIBOPTS_CONFIGSCRIPT_IMPLEM_3],
[
m4_ifval([$3],
[NUT_ARG_WITH_LIBOPTS_CONFIGSCRIPT_IMPLEM_2([$1], [$2], [$3], [$4], [$5])],
[NUT_ARG_WITH_LIBOPTS_CONFIGSCRIPT_IMPLEM_2([$1], [$2], []m4_translit([$1], 'A-Z', 'a-z')[-config], [$4], [$5])])
])

dnl Just the (normal-cased) third-party project name is required
dnl $1 project name
dnl $2 m4 var to assign (optional)
dnl $3 program name(s) to try (optional)
dnl $4 default value (optional)
dnl $5 project name spelling for help message (very optional)
AC_DEFUN([NUT_ARG_WITH_LIBOPTS_CONFIGSCRIPT],
[
m4_ifval([$4],
[NUT_ARG_WITH_LIBOPTS_CONFIGSCRIPT_IMPLEM_3([$1], [$2], [$3], [$4], [$5])],
[NUT_ARG_WITH_LIBOPTS_CONFIGSCRIPT_IMPLEM_3([$1], [$2], [$3], [auto], [$5])])
])

dnl Enable a package feature/ability (might name a variant, or yes/no)
dnl https://www.gnu.org/software/autoconf/manual/autoconf-2.66/html_node/Package-Options.html
AC_DEFUN([NUT_ARG_ENABLE_CUSTOM_DEFAULT_HELP],
[ AC_ARG_ENABLE([$1],
m4_ifval([$2],
[m4_ifval([$5],
[AS_HELP_STRING([--enable-$1=$2], [$3 (default: $5)])],
[AS_HELP_STRING([--enable-$1=$2], [$3 (default: $4)])])],
[m4_ifval([$5],
[AS_HELP_STRING([--enable-$1], [$3 (default: $5)])],
[AS_HELP_STRING([--enable-$1], [$3 (default: $4)])])]),
[[nut_enable_]m4_translit([$1], [-], [_])="${enableval}"],
[[nut_enable_]m4_translit([$1], [-], [_])="$4"]
)
])

AC_DEFUN([NUT_ARG_ENABLE_EXPAND_DEFAULT_HELP],
[
NUT_ARG_ENABLE_CUSTOM_DEFAULT_HELP([$1], [$2], [$3], [$4], NUT_ARG_EXPAND([[enable_]$1], [$4]))
])

AC_DEFUN([NUT_ARG_ENABLE_EXPAND_DEFAULT_HELP_SINGLEQUOTE],
[
NUT_ARG_ENABLE_CUSTOM_DEFAULT_HELP([$1], [$2], [$3], [$4], resolved from NUT_ARG_EXPAND([[enable_]$1], '[$4]'))
])

AC_DEFUN([NUT_ARG_ENABLE],
[ AC_ARG_ENABLE($1,
AS_HELP_STRING([--enable-$1], [$2 ($3)]),
[[nut_enable_]m4_translit($1, [-], [_])="${enableval}"],
[[nut_enable_]m4_translit($1, [-], [_])="$3"]
)
[
m4_ifval([$4],
[NUT_ARG_ENABLE_CUSTOM_DEFAULT_HELP([$1], [$2], [$3], [$4], [$4])],
[NUT_ARG_ENABLE_CUSTOM_DEFAULT_HELP([$1], [], [$2], [$3], [$3])])
])
Loading
Loading