From docs, it is necessary to add a target
in .ONESHELL
to make all the commands run in a same sub-shell process. Further discussion on that is here.
This is my makefile
,
.PHONY: clean build
.ONESHELL: deploy
zip := my.zip
clean:
cd ..
rm -f $(zip)
build: clean
npm install .
zip -r ../$(zip) . \
--exclude=package-lock.json \
--exclude=.gitignore \
--exclude=makefile \
--exclude=*.git*
... more lines
So when I do make build
, the zip file in the parent folder gets created. And when I do make clean
(from the same directory) the zip is removed too from the parent folder. What I don't understand it since cd ..
runs in an independent shell process, how does the zip in parent folder gets removed with the make clean
command, since it is not included in .ONESHELL
?
Version: GNU Make 4.1 on Ubuntu 18.04