Hi list,
I'm not a m4/autotools expert and such i'm a bit stuck with codes below (from "m4/universal.m4")
https://github.com/pure-data/pure-data/blob/master/m4/universal.m4#L68
$1[]_CFLAGS="$[]$1[]_CFLAGS $_pd_universal" $1[]_LDFLAGS="$[]$1[]_LDFLAGS $_pd_universal"
What's the meaning of the "$1[]" and "$[]$1[]" syntaxes?
I guess it is related to macro expansion (to properly obtained ARCH_CFLAGS and ARCH_LDFLAGS), but is that anybody could give me some explanations about that trick?
On 08/16/2015 05:27 PM, nicolas.danet@free.fr wrote:
Hi list,
I'm not a m4/autotools expert and such i'm a bit stuck with codes below (from "m4/universal.m4")
why do you want to know?
many consider m4 as dark magic, and there's a reason for that. usually you should just *use* the m4-macros, rather than trying to understand them.
https://github.com/pure-data/pure-data/blob/master/m4/universal.m4#L68
$1[]_CFLAGS="$[]$1[]_CFLAGS $_pd_universal" $1[]_LDFLAGS="$[]$1[]_LDFLAGS $_pd_universal"
What's the meaning of the "$1[]" and "$[]$1[]" syntaxes?
those are expanded during m4-expansion to proper values, depending on the arguments to the enclosing m4-macro.
e.g. calling `PD_CHECK_UNIVERSAL(KNORZ)` (in configure.ac), will expand those variables to KNORZ_CFLAGS resp. KNORZ_LDFLAGS.
iirc, the empty expansion syntax ("$[]") is mainly there for proper escaping.
gfmsdr IOhannes
"Want to know" isn't it the food of hackers? Ok, so "[]" are there to get proper escaping and expension. I can not find any link on the web that explain comprehensively that trick. But it doesn't matter, and anyway thanks for reply.