Created
December 10, 2018 07:03
-
-
Save shirohana/eb1706d27eafa9d9fc6ee984300aee97 to your computer and use it in GitHub Desktop.
zx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY = inc | |
COUNTER_FILE = COUNTER | |
SOURCE_COUNTER = if [[ ! -e $(COUNTER_FILE) ]]; then touch $(COUNTER_FILE); fi; set -a; source $(COUNTER_FILE); | |
inc: | |
@$(SOURCE_COUNTER) \ | |
echo $$COUNTER; \ | |
echo 'export COUNTER='$$((COUNTER + 1)) > $(COUNTER_FILE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my solution:
references:
https://stackoverflow.com/questions/1909188/define-make-variable-at-rule-execution-time
https://unix.stackexchange.com/questions/196521/anyway-to-pass-a-variable-to-bc-having-a-command-to-be-executed
https://askubuntu.com/questions/229446/how-to-pass-results-of-bc-to-a-variable
https://unix.stackexchange.com/questions/40786/how-to-do-integer-float-calculations-in-bash-or-other-languages-frameworks