Open tkoskela opened 12 months ago
I think this should be doable without sed
by passing the date, time and the git information through preprocessor variables and then having some #ifdef
blocks in the code that grab the value. This would have the advantage of
1) Not having to deal with special characters in sed
2) Not relying on writing source files from the Makefile
3) Being able to default to something meaningful if something fails.
4) Improving the readability
Yes, but also see the linked answer on how to sort out dependencies and updates:
How about this? It creates a source file but from within Make (which I think is more reliable than sed!)
deps.obj.inc: $(SRCS_NODS) system.make
touch $(COMMENT)
$(ECHOSTR) "module datestamp" > datestamp.f90
$(ECHOSTR) " implicit none" >> datestamp.f90
$(ECHOSTR) ' character(len=*), parameter :: datestr="'`date "+%Y/%m/%d at %H:%M %z"`'"' >> datestamp.f90
$(ECHOSTR) ' character(len=*), parameter :: commentver="'`git describe --abbrev=4 --dirty --always --tags`'"' >> datestamp.f90
$(ECHOSTR) "end module datestamp" >> datestamp.f90
./makedeps makedeps.txt $^
sed /"^mpi.o"/D makedeps.txt > deps.obj.inc
The alternative would be to create a file datestamp.fpp
or something which had DATE and VERSION within it, and to run that through a preprocessor to create datestamp.f90.
Currently the makefile extracts the current date and time and the git branch and hash via a mixture of sed and shell commands. I found this fails, e.g. when I have a
/
in the git branch name. There might be a safer way to get this information.https://github.com/OrderN/CONQUEST-release/blob/3a6e1f697e0bd3fd1101715e56bf3c7b7a7fde63/src/Makefile#L61