Another patch I've had lying around for a while... It's easy to use a custom skeleton, just by using the '-S <skeleton>' flag. But it's harder to customize their sub-includes because they have fixed paths, for example in lalr1.cc:
m4_include(b4_skeletonsdir/[c++.m4]) Attached patch sets the directory of any custom skeleton, and then the b4_skeletonsdir, as '-I' search-path flags to m4, and makes the c++.m4 include path unqualified. If it makes sense for adoption, I can change all the various other system skeleton files similarly and submit a larger patch as github PR, but hopefully attached (which is all I personally use) is enough to explain the idea. Anthony commit 137b4cacfd100ece3873b974f0ef50ad484cc35b Author: Anthony Heading <anthony.heading@localhost> Date: Fri Aug 27 02:46:29 2021 -0400 Add the directory of the default system skeleton file to the m4 search path. When a user-defined skeleton is used, prepend that path also. Change lalr1.cpp to search for c++.m4 instead of using only the system dir. diff --git data/skeletons/lalr1.cc data/skeletons/lalr1.cc index 7cb69d3d..ec0a68ee 100644 --- data/skeletons/lalr1.cc +++ data/skeletons/lalr1.cc @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. -m4_include(b4_skeletonsdir/[c++.m4]) +m4_include([c++.m4]) # api.value.type=variant is valid. m4_define([b4_value_type_setup_variant]) diff --git src/output.c src/output.c index 4b1bb0d8..b0c074d7 100644 --- src/output.c +++ src/output.c @@ -29,6 +29,7 @@ #include <spawn-pipe.h> #include <timevar.h> #include <wait-process.h> +#include <dirname.h> #include "complain.h" #include "files.h" @@ -757,6 +758,13 @@ output_skeleton (void) if (*M4_GNU_OPTION) argv[i++] = M4_GNU_OPTION; + char *userdir = dir_name(skel); + if (strcmp(userdir, skeldir)) { + argv[i++] = "-I"; + argv[i++] = userdir; + } + argv[i++] = "-I"; + argv[i++] = skeldir; argv[i++] = "-I"; argv[i++] = datadir; /* Some future version of GNU M4 (most likely 1.6) may treat the
commit 137b4cacfd100ece3873b974f0ef50ad484cc35b Author: Anthony Heading <anthony.heading@localhost> Date: Fri Aug 27 02:46:29 2021 -0400 Add the directory of the default system skeleton file to the m4 search path. When a user-defined skeleton is used, prepend that path also. Change lalr1.cpp to search for c++.m4 instead of using only the system dir. diff --git data/skeletons/lalr1.cc data/skeletons/lalr1.cc index 7cb69d3d..ec0a68ee 100644 --- data/skeletons/lalr1.cc +++ data/skeletons/lalr1.cc @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. -m4_include(b4_skeletonsdir/[c++.m4]) +m4_include([c++.m4]) # api.value.type=variant is valid. m4_define([b4_value_type_setup_variant]) diff --git src/output.c src/output.c index 4b1bb0d8..b0c074d7 100644 --- src/output.c +++ src/output.c @@ -29,6 +29,7 @@ #include <spawn-pipe.h> #include <timevar.h> #include <wait-process.h> +#include <dirname.h> #include "complain.h" #include "files.h" @@ -757,6 +758,13 @@ output_skeleton (void) if (*M4_GNU_OPTION) argv[i++] = M4_GNU_OPTION; + char *userdir = dir_name(skel); + if (strcmp(userdir, skeldir)) { + argv[i++] = "-I"; + argv[i++] = userdir; + } + argv[i++] = "-I"; + argv[i++] = skeldir; argv[i++] = "-I"; argv[i++] = datadir; /* Some future version of GNU M4 (most likely 1.6) may treat the