Interesting example from justfile documentation:
where it create mktemp and set it in variable then by concatenation you get a full path to the tar.gz.
Then the Recipe “publish” create the artifact again and push it to a server.
1tmpdir := `mktemp` # Create a tmp file 2version := "0.2.7" 3tardir := tmpdir / "awesomesauce-" + version 4tarball := tardir + ".tar.gz" # use tmpfile path to create a tarball 5 6publish: 7 rm -f {{tarball}} 8 mkdir {{tardir}} 9 cp README.md *.c {{tardir}} 10 tar zcvf {{tarball}} {{tardir}} 11 scp {{tarball}} me@server.com:release/ 12 rm -rf {{tarball}} {{tardir}} This one can be really usefull to define a default value which can be redefine with env variable:
Shell Variable $$var $$( python -c ‘import sys; print(sys.implementation.name)’ )
Make Variable T ?= foo # give a default value T := $(shell whoami) # execute shell immediately to put in the var
PHONY to execute several makefile Example 1
1SUBDIRS = foo bar baz 2 3## dir is a Shell variables 4## SUBDIR and MAKE are Internal make variables 5subdirs: 6 for dir in $(SUBDIRS); do \ 7 $(MAKE) -C $$dir; \ 8 done Example 2
1SUBDIRS = foo bar baz 2 3.PHONY: subdirs $(SUBDIRS) 4subdirs: $(SUBDIRS) 5$(SUBDIRS): 6 $(MAKE) -C $@ 7foo: baz Idea for a testing tools 1git clone xxx /tmp/xxx&& make -C !$/Makefile 2make download le conteneur 3make build le binaire 4make met le dans /use/local/bin 5make clean 6make help Sources: Tutorials
A simple IT blog trying to make sense of it all. Thoughts, discoveries, and documentation from a SysAdmin and DevOps guy — learned by breaking, fixing, and sometimes finding elegant solutions.