Skip to content
Snippets Groups Projects
Commit 48adeca0 authored by Assaf Gordon's avatar Assaf Gordon
Browse files

Makefile: Auto-generate version string from Git version

parent f6b0439e
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,9 @@
SHELL := /bin/bash -e
VERSION_FILE=./src/utils/version/version.h
# define our object and binary directories
export OBJ_DIR = obj
export BIN_DIR = bin
......@@ -69,7 +72,7 @@ UTIL_SUBDIRS = $(SRC_DIR)/utils/bedFile \
BUILT_OBJECTS = $(OBJ_DIR)/*.o
all:
all: gitversion
[ -d $(OBJ_DIR) ] || mkdir -p $(OBJ_DIR)
[ -d $(BIN_DIR) ] || mkdir -p $(BIN_DIR)
......@@ -115,3 +118,17 @@ test: all
@cd test; sh test.sh
.PHONY: test
.PHONY: gitversion
gitversion:
@( BEDTOOLS_VERSION="" ; \
[ -e "$(VERSION_FILE)" ] && BEDTOOLS_VERSION=$$(grep "define VERSION " "$(VERSION_FILE)" | cut -f3 -d" " | sed 's/"//g') ; \
GIT_VERSION=$$(git describe --always --tags --dirty) ; \
echo "BEDTOOLS_VERSION = $$BEDTOOLS_VERSION" ; \
echo "GIT_VERSION = $$GIT_VERSION" ; \
if [ "$${GIT_VERSION}" != "$${BEDTOOLS_VERSION}" ] ; then \
mkdir -p ./src/utils/version ; \
echo "Updating version file." ; \
printf "#ifndef VERSION_H\n#define VERSION_H\n\n#define VERSION \"$${GIT_VERSION}\"\n\n#endif /* VERSION_H */\n" > $(VERSION_FILE) ; \
$(MAKE) clean ; \
fi )
#ifndef VERSION_H
#define VERSION_H
// define the version. All tools in the
// suite carry the same version number.
#define VERSION "2.15.0"
#endif /* VERSION_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment