I'd like to make something of my own like the shell
macro where you can say $(shell command)
.
Unfortunately, I haven't found anything online about how to do this.
Is that possible?
In GNU make you can do something like the following. Imagine you want to generate the .h
and .cpp
file names from a simple file name without extension to be added as a sources of some rule. You can write:
define h_and_cpp_sources
$(1).h $(1).cpp
endef
This generates a Makefile macro that gets the first parameter as $(1)
, second as $(2)
, and so on. Then:
target: $(call h_and_cpp_sources,file)
...
This will construct the rule:
target: file.h file.cpp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With