Multiple Types of Pattern Matching in Make

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple Types of Pattern Matching in Make

Rahul Rameshbabu
Hello,

My understanding is that % is a stem pattern matching operation, meaning it
requires at least one character for the pattern match (which makes sense if
there is no suffix). However, I wanted to know if there is a way to pattern
match with empty string given that there is a suffix.

An example is the following situation.

In my filesystem, I have the following files at let's say the same level in
my filesystem for now.

dependencies.config
linux_dependencies.config
windows_dependencies.config

where dependencies.config is a common configuration.

Let's say I write the following Makefile target as an example.

%dependencies.out: %dependencies.config
# Recipe would be here to create the target from the config...

I believe the above would capture 'linux_dependencies.config' and
'windows_dependencies.config' but not 'dependencies.config' since that
would lead to an empty stem. I believe to capture both, a separate rule can
be written for 'dependencies.config'. Not sure if there is a better way to
handle this situation from the Makefile perspective.

It would be interesting if there was some pattern match operator like %%
that can do empty string captures for pattern matching given there is a
non-empty suffix.

Thanks
-- Rahul Rameshbabu
_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Types of Pattern Matching in Make

Kaz Kylheku (gmake)
On 2019-09-26 07:50, Rahul Rameshbabu wrote:
> Let's say I write the following Makefile target as an example.
>
> %dependencies.out: %dependencies.config
> # Recipe would be here to create the target from the config...

In this case, I think we could work around it like this:

%ependencies.out: %ependencies.config

Thus the "d" is just part of the variant prefix of the instances;
it just so happens that all such prefixes end in a "d".

Hey, this is no worse than calling a GNU library "iberty" so that
it can be linked with -liberty on the compiler command line. :)


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make