How to generate a unique directory for each run using Makefile

DIR_ID := $(shell date +"d%Y%m%dt%H%M%Sm%3N")
# this command will provide a directory name 
# having a format of d20201214t234015m289
# which contains date(YYYYMMDD) after the first "d"
# time (hhmmss) after "t" and millisecond (NNN) after "m".
# The millisecond is added not to have same directory names. 

	@echo $(DIR_ID)
	mkdir -p $(DIR_ID)

In command line, one can execute to have 10 different directories in sequence.

$ for i in $(seq 1 10); do echo $i; make ; done

About albertsk

Professor at the University of Hawaii
This entry was posted in Uncategorized. Bookmark the permalink.