gnu-make to inside - How do I write the 'cd' command in a makefile?
- New special target:
.ONESHELLinstructs make to invoke a single instance of the shell and provide it with the entire recipe, regardless of how many lines it contains. [...]
.ONESHELL: all: cd ~/some_dir pwd # Prints ~/some_dir if cd succeeded
For example, I have something like this in my makefile:
all: cd some_directory
But when I typed
make I saw only 'cd some_directory', like in the
What do you want it to do once it gets there? Each command is executed in a subshell, so the subshell changes directory, but the end result is that the next command is still in the current directory.
With GNU make, you can do something like:
BIN=/bin foo: $(shell cd $(BIN); ls)
To change dir
foo: $(MAKE) -C mydir multi: $(MAKE) -C / -C my-custom-dir ## Equivalent to /my-custom-dir