In the makefile, I define the variable using the directive define. This variable will contain a custom list of commands that I want to execute.
I would like this variable to get a list of files (e.g. files .foo). These files are created at runtime of the makefile. For example makefile:
MY_VAR = $(wildcard *.foo)
define MY_VAR2
echo $(1) $(MY_VAR)
endef
foo: create_files
$(call MY_VAR2, ls)
rm -f *.foo
create_files:
touch foo.foo
touch bar.foo
I do not get the desired results. It appears to be MY_VAR2priced after the announcement.
Is there a way to get the desired behavior?
change
The command $(shell), as indicated by sateesh , works for the example above. However, this does not work for the example below. The main difference in this example is that new files are created internally MY_VAR2.
MY_VAR = $(wildcard *.foo)
TEST_VAR = $(shell ls *.foo)
define MY_VAR2
@touch foo.foo
@touch bar.foo
@echo "MY_VAR" $(1) $(MY_VAR)
@echo "TEST_VAR" $(1) $(TEST_VAR)
endef
foo:
$(call MY_VAR2, ls)
@rm -f *.foo
, . ?