Created
April 3, 2020 09:44
-
-
Save mosmeh/6e3bf8b70f0ab9278fe23de4be4a241c to your computer and use it in GitHub Desktop.
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
#include <stdio.h> | |
#ifndef FOO_VERSION | |
#define FOO_VERSION "unknown" | |
#endif | |
int main(void) { | |
printf("version " FOO_VERSION | |
#ifdef FOO_COMMIT | |
" (commit " FOO_COMMIT ")" | |
#endif | |
"\n"); | |
return 0; | |
} |
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
OBJS := foo | |
VERSION := $(shell cat VERSION 2> /dev/null) | |
COMMIT := $(shell git describe --always --tags --dirty 2> /dev/null) | |
CFLAGS := $(if $(VERSION),-DFOO_VERSION=\"$(VERSION)\") $(if $(COMMIT),-DFOO_COMMIT=\"$(COMMIT)\") | |
.PHONY: all clean | |
all: $(OBJS) | |
clean: | |
$(RM) $(OBJS) | |
foo: foo.c |
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
0.1.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment