Last active
June 5, 2018 08:17
-
-
Save larytet/898ec8814dd6b3ceee65532a9916d406 to your computer and use it in GitHub Desktop.
Makefile rule generating a C file with GIT commit
This file contains hidden or 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
GIT_COMMIT_FILE=git_commit_filename.h | |
$(GIT_COMMIT_FILE): phony | |
$(eval GIT_COMMIT_SHA=$(shell git describe --abbrev=6 --always 2>/dev/null || echo 'Error')) | |
@echo SHA=$(GIT_COMMIT_SHA) | |
echo -n "static const char *GIT_COMMIT_SHA = \"$(GIT_COMMIT_SHA)\";" > $(GIT_COMMIT_FILE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
File git_commit_filename.h will end up with a single line
static const char *GIT_COMMIT_SHA="";