Below is a part of my Makefile (has errors). I just want the difference between the epoch and the epoch max and print them. But I am not sure what the mistake is. Could someone help me with this. Thanks
EPOCH_MAX = 1400000000
identifier:
epoch = $(shell date +%s)
echo $(epoch)
residue = $(epoch)-$(EPOCH_MAX)
echo $(residue)
I get the following error
epoch = 1400767572
make: epoch: Command not found
make: *** [identifier] Error 127
You are mixing up Makefile variables and shell variables. The following code is what you probably want:
EPOCH_MAX = 1400000000
epoch = $(shell date +%s )
identifier:
echo $(epoch)
(( residue = $(epoch) - $(EPOCH_MAX) )) || true ;\
echo $${residue}
EDIT: As MadScientist stressed, this isn't portable at all. Better is e.g.:
EPOCH_MAX = 1400000000
identifier:
epoch=$(shell date +%s ); \
echo $$epoch; \
residue=`expr $$epoch - $(EPOCH_MAX)`; \
echo $$residue