Skip to content

Commit

Permalink
Commit 33
Browse files Browse the repository at this point in the history
- New macro `NC_MAKETARGET_SUBST_UNQUOTED()` has been created in
  `not-autotools.m4`
- `AC_DEFUN()` has been replaced with `m4_define()` for registering the
  `NC_GLOBAL_LITERALS()` macro (this fixes `autopoint` bug “error: required
  file 'build-aux/config.rpath' not found”)
- Code review (macro `NC_MAKETARGET_SUBST()` in `not-autotools.m4`)
- Documentation
  • Loading branch information
madmurphy committed Sep 23, 2021
1 parent 3ff54e3 commit fdcbcc2
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 14 deletions.
14 changes: 14 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ Change Log
==========


1.1.0
------

Changes:

* New macro `NC_MAKETARGET_SUBST_UNQUOTED()` has been created in
`not-autotools.m4`
* `AC_DEFUN()` has been replaced with `m4_define()` for registering the
`NC_GLOBAL_LITERALS()` macro (this fixes `autopoint` bug “error: required
file 'build-aux/config.rpath' not found”)
* Code review (macro `NC_MAKETARGET_SUBST()` in `not-autotools.m4`)
* Documentation


1.0.0
------

Expand Down
89 changes: 76 additions & 13 deletions m4/not-autotools.m4
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,11 @@ dnl This macro can be invoked only after having invoked `AC_INIT()`.
dnl
dnl Expansion type: shell code
dnl Requires: `NA_SANITIZE_VARNAME()` and `NA_ESC_APOS()`
dnl Version: 1.0.1
dnl Version: 1.0.2
dnl Author: madmurphy
dnl
dnl **************************************************************************
AC_DEFUN([NC_GLOBAL_LITERALS],
m4_define([NC_GLOBAL_LITERALS],
[m4_pushdef([_lit_], m4_quote(NA_SANITIZE_VARNAME([$1])))[]m4_define([GL_]_lit_,
m4_normalize([$2]))
AC_SUBST(_lit_, ['NA_ESC_APOS(m4_normalize([$2]))'])[]m4_popdef([_lit_])[]m4_if(m4_eval([$# > 2]), [1],
Expand Down Expand Up @@ -596,7 +596,7 @@ AC_DEFUN([NA_HELP_STRINGS],
[m4_text_wrap(m4_car($1)[,], [ ])m4_newline()NA_HELP_STRINGS(m4_dquote(m4_shift($1))m4_if([$#], [1], [], [, m4_shift($@)]))])])


dnl NC_MAKETARGET_SUBST(target[, [[prerequisites, ]order-only-pr, ]recipe])
dnl NC_MAKETARGET_SUBST(target[[, prereq[, o-only-prereq]], recipe])
dnl **************************************************************************
dnl
dnl Creates a `make` substitution containing a target declaration
Expand All @@ -622,6 +622,8 @@ dnl echo 'Hello world' && date;
dnl
dnl Exactly like the second argument of `AC_SUBST()`, all arguments here
dnl except the first one support shell expansion and must be properly quoted.
dnl For a version of this macro that does not require shell quotes, please
dnl refer to `NC_MAKETARGET_SUBST_UNQUOTED()`.
dnl
dnl Example #1: Target name and recipe
dnl
Expand Down Expand Up @@ -691,7 +693,7 @@ dnl used for the recipe's content. The Make variable is a newly created
dnl substitution named exactly like the target – but please notice the
dnl different way in which hyphens are treated in the two names. The content
dnl of this substitution is left to you, so you will have to make sure
dnl yourself that it is a suitable content for a recipe.
dnl yourself that its content will be suitable for a recipe.
dnl
dnl configure.ac:
dnl
Expand All @@ -709,9 +711,11 @@ dnl ...
dnl echo-test:
dnl $(echo_test)
dnl
dnl This macro can be invoked only after having invoked `AC_INIT()`.
dnl
dnl Expansion type: shell code
dnl Requires: `NA_SANITIZE_VARNAME()`
dnl Version: 1.0.1
dnl Version: 1.0.2
dnl Author: madmurphy
dnl
dnl **************************************************************************
Expand All @@ -725,11 +729,69 @@ AC_DEFUN([NC_MAKETARGET_SUBST], [
], [
AS_VAR_SET([_na_recipe_], m4_argn([$#], $@))
AC_SUBST([na_target_]__tgtname__,
['$1:m4_if([$#], [2], ['@S|@'\n'], [$#], [3],
[m4_ifblank([$2], ['], [ '$2])@S|@'\n'],
[m4_ifblank([$3],
[m4_ifblank([$2], ['], [ '$2])],
[m4_ifblank([$2], [ | '$3], [ '$2' | '$3])])@S|@'\n'])"@S|@@{:@echo "${_na_recipe_}" | ${SED} s/^/\\t/g@:}@"])
['$1:]m4_if([$#], [2],
[['@S|@'\n']],
[$#], [3],
[m4_ifblank([$2], [[']], [[ '$2]])@S|@'\n'],
[m4_ifblank([$3],
[m4_ifblank([$2], [[']], [[ '$2]])],
[m4_ifblank([$2], [[ | '$3]], [[ '$2' | '$3]])])@S|@'\n'])["@S|@@{:@echo "${_na_recipe_}" | ${SED} s/^/\\t/g@:}@"])
AS_UNSET([_na_recipe_])
])
AM_SUBST_NOTMAKE([na_target_]__tgtname__)
m4_popdef([__tgtname__])
])


dnl NC_MAKETARGET_SUBST_UNQUOTED(target[[, prereq[, o-only-prereq]], recipe])
dnl **************************************************************************
dnl
dnl Creates a `make` substitution containing a target declaration, with
dnl backquote expansion protection
dnl
dnl This is a quote-safe version of `NC_MAKETARGET_SUBST()`. The `prereq`,
dnl `ord-only-prereq` and `recipe` arguments do not need shell quotes, which
dnl will be escaped if found.
dnl
dnl Example:
dnl
dnl # configure.ac:
dnl NC_MAKETARGET_SUBST_UNQUOTED([echo-test],
dnl [foo],
dnl [bar],
dnl [echo foobar])
dnl
dnl # Makefile.am:
dnl @na_target_echo_test@
dnl
dnl Usage is identical to `NC_MAKETARGET_SUBST()`. Please refer to that macro
dnl for the documentation.
dnl
dnl This macro can be invoked only after having invoked `AC_INIT()`.
dnl
dnl Expansion type: shell code
dnl Requires: `NA_SANITIZE_VARNAME()`
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
AC_DEFUN([NC_MAKETARGET_SUBST_UNQUOTED], [
m4_pushdef([__tgtname__],
m4_quote(NA_SANITIZE_VARNAME([$1])))
AC_REQUIRE([AC_PROG_SED])
m4_if([$#], [0], [], [$#], [1], [
AC_SUBST(__tgtname__)
AC_SUBST([na_target_]__tgtname__, ['$1:'@S|@'\n\t''@S|@@{:@__tgtname__@:}@'])
], [
AS_VAR_SET([_na_recipe_], ["]_AS_QUOTE(m4_dquote(m4_argn([$#], $@)))["])
AC_SUBST([na_target_]__tgtname__,
['$1:]m4_if([$#], [2],
[['@S|@'\n']],
[$#], [3],
[m4_ifblank([$2], [[']], [[ '"]_AS_QUOTE([[$2]])["]])@S|@'\n'],
[m4_ifblank([$3],
[m4_ifblank([$2], [[']], [[ '"]_AS_QUOTE([[$2]])["]])],
[m4_ifblank([$2], [[ | '"]_AS_QUOTE([[$3]])["]], [[ '"]_AS_QUOTE([[$2]])["' | '"]_AS_QUOTE([[$3]])["]])])@S|@'\n'])["@S|@@{:@echo "${_na_recipe_}" | ${SED} s/^/\\t/g@:}@"])
AS_UNSET([_na_recipe_])
])
AM_SUBST_NOTMAKE([na_target_]__tgtname__)
Expand All @@ -739,9 +801,10 @@ AC_DEFUN([NC_MAKETARGET_SUBST], [


dnl **************************************************************************
dnl NOTE: The `NA_` prefix (which stands for "Not Autotools") and the `NC_`
dnl prefix (which stands for "Not autoConf") are used with the purpose
dnl of avoiding collisions with the default Autotools prefixes `AC_`,
dnl NOTE: The `NA_` prefix (which stands for "Not Autotools"), the `NC_`
dnl prefix (which stands for "Not autoConf") and the `NM_` prefix
dnl (which stands for "Not autoMake") are used with the purpose of
dnl avoiding collisions with the default Autotools prefixes `AC_`,
dnl `AM_`, `AS_`, `AX_`, `LT_`.
dnl **************************************************************************

Expand Down
9 changes: 9 additions & 0 deletions m4/not-extended-config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@ AC_DEFUN_ONCE([NC_CONFIG_SHADOW_DIR], [
dnl NC_SHADOW_AFTER_OUTPUT[(if-merge-cmds[, if-sandbox-cmds])]
dnl **********************************************************************
dnl
dnl Example:
dnl
dnl NC_SHADOW_AFTER_OUTPUT([
dnl AC_MSG_NOTICE([updating the source code with `${ac_make} all-official-sources`...])
dnl "${ac_make}" all-official-sources
dnl ])
dnl
dnl **********************************************************************
AC_DEFUN_ONCE([NC_SHADOW_AFTER_OUTPUT],
[m4_ifset([NC_THREATENED_LIST],
[m4_ifnblank(m4_quote(]m4_dquote(][$][1][$][2][)[),
Expand Down
1 change: 1 addition & 0 deletions macro-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,5 @@ project.
* [NM_QUERY_PROGS()](m4/not-autotools.m4#L502)
* [NA_HELP_STRINGS()](m4/not-autotools.m4#L545)
* [NC_MAKETARGET_SUBST()](m4/not-autotools.m4#L599)
* [NC_MAKETARGET_SUBST_UNQUOTED()](m4/not-autotools.m4#L746)

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Not Autotools",
"version": "1.0.0",
"version": "1.1.0",
"description": "A collection of awesome and self-documented M4-ish macros for GNU Autotools",
"homepage": "https://github.com/madmurphy/not-autotools",
"author": "[email protected]",
Expand Down

0 comments on commit fdcbcc2

Please sign in to comment.