Skip to content

Commit

Permalink
Commit 42
Browse files Browse the repository at this point in the history
- New macros `n4_list_append_list()`, `n4_list_append_members()`,
  `n4_pluralize()`, `n4_list_prepend_list()` and `n4_list_prepend_members()`
  have been created in `not-m4sugar.m4`; macros `NA_MODULE_CHECK_PKGS()` and
  `NA_MODULES_CHECK_PKGS()` have been created in `not-autotools.m4`
- Documentation
  • Loading branch information
madmurphy committed Dec 13, 2022
1 parent 42f0348 commit f904607
Show file tree
Hide file tree
Showing 7 changed files with 346 additions and 18 deletions.
12 changes: 12 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ Change Log
==========


2.6.0
-----

Changes:

* New macros `n4_list_append_list()`, `n4_list_append_members()`,
`n4_pluralize()`, `n4_list_prepend_list()` and `n4_list_prepend_members()`
have been created in `not-m4sugar.m4`; macros `NA_MODULE_CHECK_PKGS()` and
`NA_MODULES_CHECK_PKGS()` have been created in `not-autotools.m4`
* Documentation


2.5.0
-----

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ copied and pasted, or included directly in a build directory. This has the
advantage of not slowing down the project's evolution, and backward
incompatible changes do not break existing packages.

Finally, a further subtle difference is that the **Not Autotools** macros
compared to the **Autoconf Archive** macros on average rely on the m4
preprocessor more than they rely on the shell. This means that whenever is
possible the expansions of **Not Autotools** macros will leave only literals in
the `configure` script generated, without much shell code. This should
guarantee a wide compatibility between different platform.

A way to think of the **Not Autotools** project is as “a possible staging
laboratory for the **Autoconf Archive**”. Here the macros often change
radically, or even disappear, without caring too much for backward
Expand Down
2 changes: 1 addition & 1 deletion introspect/not-autoversion-introspect.m4
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ m4_define([NR_GET_VERSION_REPORT],


dnl NR_GET_VERSION_EVENT_NAME(project-major, project-minor, project-micro,
dnl root-vstate, event1[, event2[, ... eventN]])
dnl root-vstate, event1[, event2[, ... eventN]])
dnl **************************************************************************
dnl
dnl Similar to `NR_HISTORY_GET_VERSION_EVENT_NAME()`, but not bound to any
Expand Down
88 changes: 88 additions & 0 deletions m4/not-autotools.m4
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,94 @@ AC_DEFUN([NM_AUTO_QUERY_PROGS],
[test "x@S|@{]_lit_[}" != x])[]NM_AUTO_QUERY_PROGS(m4_shift($@))])])


dnl NA_MODULE_CHECK_PKGS(module-name, [requires-private-check],
dnl [requires-check], [requires-private-nocheck],
dnl [requires-nocheck])
dnl **************************************************************************
dnl
dnl Wrapper macro of `PKG_CHECK_MODULES()` that allows to specify and store
dnl different kind of dependencies separately and declare local libraries that
dnl must not be checked
dnl
dnl Before invoking `PKG_CHECK_MODULES()`, this macro stores two literals,
dnl `[GL_]module-name[_REQUIRES_PRIVATE]` and `[GL_]module-name[_REQUIRES]`,
dnl plus two configure substitutions, `module-name[_REQUIRES_PRIVATE]` and
dnl `module-name[_REQUIRES]`. These can be used for generating the
dnl `Requires.private` and `Requires` variables of a `.pc` file, which can
dnl contain local libraries to be compiled with the package and therefore do
dnl not need to exist before install.
dnl
dnl For example,
dnl
dnl NA_MODULE_CHECK_PKGS([MY_LIBRARY],
dnl dnl Check that these are present (for `Requires.private`)
dnl [glib-2.0 >= 2.66, fribidi, gio-2.0 >= 2.66],
dnl dnl Check that these are present (for `Requires`)
dnl [gtk4 >= 4.5.0],
dnl dnl Don't check that these are present (for `Requires.private`)
dnl [mysublib2],
dnl dnl Don't check that these are present (for `Requires`)
dnl [mysublib3])
dnl
dnl will generate the two m4 macros `GL_MY_LIBRARY_REQUIRES_PRIVATE` and
dnl `GL_MY_LIBRARY_REQUIRES` and the two configure substitutions
dnl `MY_LIBRARY_REQUIRES_PRIVATE` and `MY_LIBRARY_REQUIRES`, and finally will
dnl invoke `PKG_CHECK_MODULES(module-name,
dnl requires-private-check[, ]requires-check)`.
dnl
dnl The `.pc` file can then be set with the following lines:
dnl
dnl ...
dnl Requires.private: @MY_LIBRARY_REQUIRES_PRIVATE@
dnl Requires: @MY_LIBRARY_REQUIRES@
dnl ...
dnl
dnl This macro may be invoked only after having invoked `AC_INIT()`.
dnl
dnl Expansion type: shell code
dnl Requires: `PKG_CHECK_MODULES()` from `pkg.m4` (from `pkgconf` package)
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([NA_MODULE_CHECK_PKGS],
[m4_define([GL_$1_REQUIRES_PRIVATE],
[$2]m4_ifnblank([$4], [[, ]])[$4])[]m4_define([GL_$1_REQUIRES],
[$3]m4_ifnblank([$5], [[, ]])[$5])[]PKG_CHECK_MODULES([$1],
[$2]m4_ifnblank([$3], [[, ]])[$3])
AC_SUBST([$1_REQUIRES_PRIVATE],
[']m4_bpatsubst([[$2]]m4_ifnblank([$4],
[[[, ]]])[[$4]], ['], ['\\''])['])
AC_SUBST([$1_REQUIRES],
[']m4_bpatsubst([[$3]]m4_ifnblank([$5],
[[[, ]]])[[$5]], ['], ['\\''])['])
AM_SUBST_NOTMAKE([$1_REQUIRES])
AM_SUBST_NOTMAKE([$1_REQUIRES_PRIVATE])])


dnl NA_MODULES_CHECK_PKGS(module-args-1[, module-args-2[, ... module-args-N]])
dnl **************************************************************************
dnl
dnl Pluralized version of `NA_MODULE_CHECK_PKGS()`
dnl
dnl Example:
dnl
dnl NA_MODULE_CHECK_PKGS([[MY_LIBRARY_1], [glib-2.0, gio-2.0], [gtk4]],
dnl [[MY_LIBRARY_2], [gnunetworker, gnunetutil, gnunetfs], [gtk4]])
dnl
dnl This macro may be invoked only after having invoked `AC_INIT()`.
dnl
dnl Expansion type: shell code
dnl Requires: `NA_MODULE_CHECK_PKGS()`
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([NA_MODULES_CHECK_PKGS],
[NA_MODULE_CHECK_PKGS($1)m4_if([$#], [0], [], [$#], [1], [],
[m4_newline()[]NA_MODULES_CHECK_PKGS(m4_shift($@))])])


dnl NA_HELP_STRINGS(list1, help1[, list2, help2[, ... listN, helpN]])
dnl **************************************************************************
dnl
Expand Down
222 changes: 218 additions & 4 deletions m4/not-m4sugar.m4
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ dnl -30
dnl -30
dnl
dnl Negative numbers are allowed everywhere. If `counter-name` is an already
dnl existing counter, or a generic macro, it will be overwritten. Use
dnl existing counter or a generic macro it will be overwritten. Use
dnl `m4_undefine()` when you want to unset a counter.
dnl
dnl This macro may be invoked before `AC_INIT()`.
Expand Down Expand Up @@ -1006,6 +1006,215 @@ dnl **************************************************************************
m4_define([n4_void], [m4_divert(-1)$*[]m4_divert()])
dnl n4_list_append_members(list, member1[, member2[, member3[, ... memberN]]])
dnl **************************************************************************
dnl
dnl Append one or more members to a macro containing comma-separated elements
dnl
dnl Example:
dnl
dnl m4_define([my_list], [[one], [two], [three]])
dnl
dnl n4_list_append_members([my_list], [four], [five])
dnl
dnl dnl `[one], [two], [three], [four], [five]`
dnl m4_defn([my_list])
dnl
dnl n4_list_append_members([my_list], [six], [seven])
dnl
dnl dnl `[one], [two], [three], [four], [five], [six], [seven]`
dnl m4_defn([my_list])
dnl
dnl dnl `7`
dnl m4_count(my_list)
dnl
dnl If `list` is not defined it will be defined first.
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: nothing
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([n4_list_append_members],
[m4_define([$1],
m4_ifdef([$1],
[m4_defn([$1])[, ]m4_dquote(m4_shift($@))],
[m4_dquote(m4_shift($@))]))])
dnl n4_list_prepend_members(list, member1[, member2[, member3[, ...
dnl memberN]]])
dnl **************************************************************************
dnl
dnl Prepend one or more members to a macro containing comma-separated elements
dnl
dnl Example:
dnl
dnl m4_define([my_list], [[one], [two], [three]])
dnl
dnl n4_list_prepend_members([my_list], [four], [five])
dnl
dnl dnl `[four], [five], [one], [two], [three]`
dnl m4_defn([my_list])
dnl
dnl dnl `[six], [seven], [four], [five], [one], [two], [three]`
dnl n4_list_prepend_members([my_list], [six], [seven])
dnl
dnl m4_defn([my_list])
dnl
dnl dnl `7`
dnl m4_count(my_list)
dnl
dnl If `list` is not defined it will be defined first.
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: nothing
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([n4_list_prepend_members],
[m4_define([$1],
m4_ifdef([$1],
[m4_dquote(m4_shift($@))[, ]m4_defn([$1])],
[m4_dquote(m4_shift($@))]))])
dnl n4_list_append_list(list, list-to-append)
dnl **************************************************************************
dnl
dnl Append a comma-separated list to a macro containing comma-separated
dnl elements
dnl
dnl Example:
dnl
dnl m4_define([my_list], [[one], [two], [three]])
dnl
dnl n4_list_append_list([my_list], [[four], [five]])
dnl
dnl dnl `[one], [two], [three], [four], [five]`
dnl m4_defn([my_list])
dnl
dnl n4_list_append_list([my_list], [[six], [seven]])
dnl
dnl dnl `[one], [two], [three], [four], [five], [six], [seven]`
dnl m4_defn([my_list])
dnl
dnl dnl `7`
dnl m4_count(my_list)
dnl
dnl If `list` is not defined it will be defined first.
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: nothing
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([n4_list_append_list],
[m4_define([$1],
m4_ifdef([$1],
[m4_defn([$1])[, $2]],
[$2]))])
dnl n4_list_prepend_list(list, list-to-append)
dnl **************************************************************************
dnl
dnl Prepend a comma-separated list to a macro containing comma-separated
dnl elements
dnl
dnl Example:
dnl
dnl m4_define([my_list], [[one], [two], [three]])
dnl
dnl n4_list_prepend_list([my_list], [[four], [five]])
dnl
dnl dnl `[four], [five], [one], [two], [three]`
dnl m4_defn([my_list])
dnl
dnl n4_list_prepend_list([my_list], [[six], [seven]])
dnl
dnl dnl `[six], [seven], [four], [five], [one], [two], [three]`
dnl m4_defn([my_list])
dnl
dnl dnl `7`
dnl m4_count(my_list)
dnl
dnl If `list` is not defined it will be defined first.
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: nothing
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([n4_list_prepend_list],
[m4_define([$1],
m4_ifdef([$1],
[[$2, ]m4_defn([$1])],
[$2]))])
dnl n4_pluralize(original-macro-name, pluralized-macro-name[, separator])
dnl **************************************************************************
dnl
dnl Create a new macro that repeatedly invokes an existing macro
dnl
dnl The new macro created will rely on a deeper level of quote nesting.
dnl
dnl For example,
dnl
dnl m4_define([my_macro],
dnl [arg 1: $1, arg 2: $2, arg 3: $3])
dnl
dnl my_macro([first_a], [second_a], [third_a])
dnl my_macro([first_b], [second_b], [third_b])
dnl
dnl can be rewritten as
dnl
dnl n4_pluralize([my_macro], [my_plural_macro], m4_newline())
dnl
dnl my_plural_macro([[first_a], [second_a], [third_a]],
dnl [[first_b], [second_b], [third_b]])
dnl
dnl Or, to give a more concrete example,
dnl
dnl n4_pluralize([AC_SUBST], [AC_SUBSTS], m4_newline())
dnl
dnl AC_SUBSTS([[VAR1], [VAL1]],
dnl [[VAR2], [VAL2]],
dnl [[VAR3], [VAL3]])
dnl
dnl corresponds to
dnl
dnl AC_SUBST([VAR1], [VAL1])
dnl AC_SUBST([VAR2], [VAL2])
dnl AC_SUBST([VAR3], [VAL3])
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: nothing
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([n4_pluralize],
[m4_define([$2],
[$1($][1)[]m4_if($][#, 0, [], $][#, 1, [],
[$3[]$2(m4_shift(]]m4_dquote([$][@])[[))])])])
dnl n4_define_substrings_as(string, regexp, macro0[, macro1[, ... macroN ]])
dnl **************************************************************************
dnl
Expand Down Expand Up @@ -1123,7 +1332,9 @@ dnl
dnl For example,
dnl
dnl AC_DEFUN([custom_macro], [...foo $1|$2|$3|$4 bar])
dnl AC_MSG_NOTICE([n4_for_each_match([blaablabblac], [\(b\(l\)\)\(a\)], [custom_macro])])
dnl
dnl AC_MSG_NOTICE([n4_for_each_match([blaablabblac],
dnl [\(b\(l\)\)\(a\)], [custom_macro])])
dnl
dnl will print:
dnl
Expand Down Expand Up @@ -1154,7 +1365,9 @@ dnl
dnl For example,
dnl
dnl AC_DEFUN([custom_macro], [XX$3])
dnl AC_MSG_NOTICE([n4_get_replacements([hello you world!!], [\(l\|w\)+\(o\)], [custom_macro])])
dnl
dnl AC_MSG_NOTICE([n4_get_replacements([hello you world!!],
dnl [\(l\|w\)+\(o\)], [custom_macro])])
dnl
dnl will print:
dnl
Expand Down Expand Up @@ -1243,7 +1456,8 @@ m4_define([n4_burn_out],
dnl n4_retrieve(path-or-uri-1[, path-or-uri-2[, ... path-or-uri-N]])
dnl **************************************************************************
dnl
dnl Variadic version of `m4_include()`, with optional support for URIs
dnl Variadic version of `m4_include()`, with optional support for URIs (via
dnl cURL)
dnl
dnl For example,
dnl
Expand Down
Loading

0 comments on commit f904607

Please sign in to comment.