640 |
# | [m4_pushdef([$1])_foreach([$1], [$2], [$3])m4_popdef([$1])]) |
# | [m4_pushdef([$1])_foreach([$1], [$2], [$3])m4_popdef([$1])]) |
641 |
# | m4_define([_arg1], [$1]) |
# | m4_define([_arg1], [$1]) |
642 |
# | m4_define([_foreach], |
# | m4_define([_foreach], |
643 |
# | [m4_if([$2], [()], , |
# | [m4_if([$2], [()], , |
644 |
# | [m4_define([$1], _arg1$2)$3[]_foreach([$1], |
# | [m4_define([$1], _arg1$2)$3[]_foreach([$1], |
645 |
# | (shift$2), |
# | (shift$2), |
646 |
# | [$3])])]) |
# | [$3])])]) |
647 |
# |
# |
671 |
# | m4_define([_arg1], [[$1]]) |
# | m4_define([_arg1], [[$1]]) |
672 |
# | m4_define([_foreach], |
# | m4_define([_foreach], |
673 |
# | [m4_if($2, [()], , |
# | [m4_if($2, [()], , |
674 |
# | [m4_define([$1], [_arg1$2])$3[]_foreach([$1], |
# | [m4_define([$1], [_arg1$2])$3[]_foreach([$1], |
675 |
# | [(shift$2)], |
# | [(shift$2)], |
676 |
# | [$3])])]) |
# | [$3])])]) |
677 |
# |
# |
696 |
# | m4_define([_arg1], [$1]) |
# | m4_define([_arg1], [$1]) |
697 |
# | m4_define([_foreach], |
# | m4_define([_foreach], |
698 |
# | [m4_if($2, [], , |
# | [m4_if($2, [], , |
699 |
# | [m4_define([$1], [_arg1($2)])$3[]_foreach([$1], |
# | [m4_define([$1], [_arg1($2)])$3[]_foreach([$1], |
700 |
# | [shift($2)], |
# | [shift($2)], |
701 |
# | [$3])])]) |
# | [$3])])]) |
702 |
# |
# |
867 |
# must keep the expansions of the various level of m4_require separated. |
# must keep the expansions of the various level of m4_require separated. |
868 |
# Right before executing the epilogue of TEST1, we have: |
# Right before executing the epilogue of TEST1, we have: |
869 |
# |
# |
870 |
# GROW - 2: Test...3 |
# GROW - 2: Test...3 |
871 |
# GROW - 1: Test...2 |
# GROW - 1: Test...2 |
872 |
# GROW: Test...1 |
# GROW: Test...1 |
873 |
# BODY: |
# BODY: |
874 |
# |
# |
875 |
# Finally the epilogue of TEST1 undiverts GROW - 2, GROW - 1, and |
# Finally the epilogue of TEST1 undiverts GROW - 2, GROW - 1, and |
876 |
# GROW into the regular flow, BODY. |
# GROW into the regular flow, BODY. |
877 |
# |
# |
878 |
# GROW - 2: |
# GROW - 2: |
879 |
# GROW - 1: |
# GROW - 1: |
880 |
# GROW: |
# GROW: |
881 |
# BODY: Test...3; Test...2; Test...1 |
# BODY: Test...3; Test...2; Test...1 |
882 |
# |
# |
883 |
# (The semicolons are here for clarification, but of course are not |
# (The semicolons are here for clarification, but of course are not |
884 |
# emitted.) This is what Autoconf 2.0 (I think) to 2.13 (I'm sure) |
# emitted.) This is what Autoconf 2.0 (I think) to 2.13 (I'm sure) |
902 |
# |
# |
903 |
# The dependencies between the macros are: |
# The dependencies between the macros are: |
904 |
# |
# |
905 |
# 3 --- 2b |
# 3 --- 2b |
906 |
# / \ is m4_require'd by |
# / \ is m4_require'd by |
907 |
# / \ left -------------------- right |
# / \ left -------------------- right |
908 |
# 2a ------------ 1 |
# 2a ------------ 1 |
909 |
# |
# |
910 |
# If you strictly apply the rules given in the previous section you get: |
# If you strictly apply the rules given in the previous section you get: |
911 |
# |
# |
912 |
# GROW - 2: TEST3 |
# GROW - 2: TEST3 |
913 |
# GROW - 1: TEST2a; TEST2b |
# GROW - 1: TEST2a; TEST2b |
914 |
# GROW: TEST1 |
# GROW: TEST1 |
915 |
# BODY: |
# BODY: |
916 |
# |
# |
917 |
# (TEST2a, although required by TEST3 is not expanded in GROW - 3 |
# (TEST2a, although required by TEST3 is not expanded in GROW - 3 |
918 |
# because is has already been expanded before in GROW - 1, so it has |
# because is has already been expanded before in GROW - 1, so it has |
919 |
# been AC_PROVIDE'd, so it is not expanded again) so when you undivert |
# been AC_PROVIDE'd, so it is not expanded again) so when you undivert |
920 |
# the stack of diversions, you get: |
# the stack of diversions, you get: |
921 |
# |
# |
922 |
# GROW - 2: |
# GROW - 2: |
923 |
# GROW - 1: |
# GROW - 1: |
924 |
# GROW: |
# GROW: |
925 |
# BODY: TEST3; TEST2a; TEST2b; TEST1 |
# BODY: TEST3; TEST2a; TEST2b; TEST1 |
926 |
# |
# |
927 |
# i.e., TEST2a is expanded after TEST3 although the latter required the |
# i.e., TEST2a is expanded after TEST3 although the latter required the |
928 |
# former. |
# former. |
940 |
# In the example above, when TEST2a is expanded, but it's epilogue is |
# In the example above, when TEST2a is expanded, but it's epilogue is |
941 |
# not run yet, you have: |
# not run yet, you have: |
942 |
# |
# |
943 |
# GROW - 2: |
# GROW - 2: |
944 |
# GROW - 1: TEST2a |
# GROW - 1: TEST2a |
945 |
# GROW: Elaboration of TEST1 |
# GROW: Elaboration of TEST1 |
946 |
# BODY: |
# BODY: |
947 |
# |
# |
948 |
# The epilogue of TEST2a emits it immediately: |
# The epilogue of TEST2a emits it immediately: |
949 |
# |
# |
950 |
# GROW - 2: |
# GROW - 2: |
951 |
# GROW - 1: |
# GROW - 1: |
952 |
# GROW: Elaboration of TEST1 |
# GROW: Elaboration of TEST1 |
953 |
# BODY: TEST2a |
# BODY: TEST2a |
954 |
# |
# |
955 |
# TEST2b then requires TEST3, so right before the epilogue of TEST3, you |
# TEST2b then requires TEST3, so right before the epilogue of TEST3, you |
956 |
# have: |
# have: |
957 |
# |
# |
958 |
# GROW - 2: TEST3 |
# GROW - 2: TEST3 |
959 |
# GROW - 1: Elaboration of TEST2b |
# GROW - 1: Elaboration of TEST2b |
960 |
# GROW: Elaboration of TEST1 |
# GROW: Elaboration of TEST1 |
961 |
# BODY: TEST2a |
# BODY: TEST2a |
962 |
# |
# |
963 |
# The epilogue of TEST3 emits it: |
# The epilogue of TEST3 emits it: |
964 |
# |
# |
965 |
# GROW - 2: |
# GROW - 2: |
966 |
# GROW - 1: Elaboration of TEST2b |
# GROW - 1: Elaboration of TEST2b |
967 |
# GROW: Elaboration of TEST1 |
# GROW: Elaboration of TEST1 |
968 |
# BODY: TEST2a; TEST3 |
# BODY: TEST2a; TEST3 |
969 |
# |
# |
970 |
# TEST2b is now completely expanded, and emitted: |
# TEST2b is now completely expanded, and emitted: |
971 |
# |
# |
972 |
# GROW - 2: |
# GROW - 2: |
973 |
# GROW - 1: |
# GROW - 1: |
974 |
# GROW: Elaboration of TEST1 |
# GROW: Elaboration of TEST1 |
975 |
# BODY: TEST2a; TEST3; TEST2b |
# BODY: TEST2a; TEST3; TEST2b |
976 |
# |
# |
977 |
# and finally, TEST1 is finished and emitted: |
# and finally, TEST1 is finished and emitted: |
978 |
# |
# |
979 |
# GROW - 2: |
# GROW - 2: |
980 |
# GROW - 1: |
# GROW - 1: |
981 |
# GROW: |
# GROW: |
982 |
# BODY: TEST2a; TEST3; TEST2b: TEST1 |
# BODY: TEST2a; TEST3; TEST2b: TEST1 |
983 |
# |
# |
984 |
# The idea, is simple, but the implementation is a bit evolved. If you |
# The idea, is simple, but the implementation is a bit evolved. If you |
985 |
# are like me, you will want to see the actual functioning of this |
# are like me, you will want to see the actual functioning of this |
992 |
# |
# |
993 |
# We consider the macros above, and this configure.ac: |
# We consider the macros above, and this configure.ac: |
994 |
# |
# |
995 |
# AC_INIT |
# AC_INIT |
996 |
# TEST1 |
# TEST1 |
997 |
# |
# |
998 |
# You should keep the definitions of _m4_defun_pro, _m4_defun_epi, and |
# You should keep the definitions of _m4_defun_pro, _m4_defun_epi, and |
999 |
# m4_require at hand to follow the steps. |
# m4_require at hand to follow the steps. |
1462 |
[dnl Can't use m4_default here instead of m4_if, because m4_default uses |
[dnl Can't use m4_default here instead of m4_if, because m4_default uses |
1463 |
dnl [ and ] as quotes. |
dnl [ and ] as quotes. |
1464 |
m4_bpatsubst(````$1'''', |
m4_bpatsubst(````$1'''', |
1465 |
m4_if(``$2'',, ``[ ]+'', ``$2''), |
m4_if(``$2'',, ``[ ]+'', ``$2''), |
1466 |
``], ['')]dnl |
``], ['')]dnl |
1467 |
m4_changequote([, ])>>) |
m4_changequote([, ])>>) |
1468 |
m4_changequote([, ]) |
m4_changequote([, ]) |
1492 |
# |
# |
1493 |
# This macro is robust to active symbols. |
# This macro is robust to active symbols. |
1494 |
# m4_define(active, ACTIVE) |
# m4_define(active, ACTIVE) |
1495 |
# m4_strip([ active active ])end |
# m4_strip([ active active ])end |
1496 |
# => active activeend |
# => active activeend |
1497 |
# |
# |
1498 |
# This macro is fun! Because we want to preserve active symbols, STRING |
# This macro is fun! Because we want to preserve active symbols, STRING |
1507 |
# character, since there are two leading `['; equally for the last pattern. |
# character, since there are two leading `['; equally for the last pattern. |
1508 |
m4_define([m4_strip], |
m4_define([m4_strip], |
1509 |
[m4_bpatsubsts([[$1]], |
[m4_bpatsubsts([[$1]], |
1510 |
[[ ]+], [ ], |
[[ ]+], [ ], |
1511 |
[^\(..\) ], [\1], |
[^\(..\) ], [\1], |
1512 |
[ \(..\)$], [\1])]) |
[ \(..\)$], [\1])]) |
1513 |
|
|
1613 |
# |
# |
1614 |
# m4_text_wrap([Super long documentation.], [ ], [ --too-wide ], 30) |
# m4_text_wrap([Super long documentation.], [ ], [ --too-wide ], 30) |
1615 |
# => --too-wide |
# => --too-wide |
1616 |
# => Super long |
# => Super long |
1617 |
# => documentation. |
# => documentation. |
1618 |
# |
# |
1619 |
# FIXME: there is no checking of a longer PREFIX than WIDTH, but do |
# FIXME: there is no checking of a longer PREFIX than WIDTH, but do |
1620 |
# we really want to bother with people trying each single corner |
# we really want to bother with people trying each single corner |