Skip to content

Commit

Permalink
make: evaluate the Git SHA only once
Browse files Browse the repository at this point in the history
  • Loading branch information
Kijewski committed Jun 21, 2014
1 parent 9384b24 commit 1d34522
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
12 changes: 0 additions & 12 deletions Makefile.base
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@ endif
OBJ = $(SRC:%.c=$(BINDIR)$(MODULE)/%.o)
DEP = $(SRC:%.c=$(BINDIR)$(MODULE)/%.d)

GIT_STRING := $(shell git describe --always --abbrev=4 --dirty=-`hostname`)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
ifeq ($(strip $(GIT_BRANCH)),master)
GIT_VERSION = $(GIT_STRING)
else
GIT_VERSION = $(shell echo $(GIT_STRING) $(GIT_BRANCH) | sed 's/ /-/')
endif
ifeq ($(strip $(GIT_VERSION)),)
GIT_VERSION := "UNKNOWN"
endif
export CFLAGS += -DVERSION=\"$(GIT_VERSION)\"

$(BINDIR)$(MODULE).a: $(OBJ) $(ASMOBJ)
$(AD)$(AR) -rc $(BINDIR)$(MODULE).a $(OBJ) $(ASMOBJ)

Expand Down
13 changes: 13 additions & 0 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ endif
# Feature test default CFLAGS and LINKFLAGS for the set compiled.
include $(RIOTBASE)/Makefile.cflags

# make the RIOT version available to the program
GIT_STRING := $(shell git describe --always --abbrev=4 --dirty=-`hostname`)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
ifeq ($(strip $(GIT_BRANCH)),master)
GIT_VERSION = $(GIT_STRING)
else
GIT_VERSION = $(shell echo $(GIT_STRING) $(GIT_BRANCH) | sed 's/ /-/')
endif
ifeq ($(strip $(GIT_VERSION)),)
GIT_VERSION := "UNKNOWN"
endif
export CFLAGS += -DVERSION=\"$(GIT_VERSION)\"

# the binaries to link
BASELIBS += $(BINDIR)$(BOARD)_base.a
BASELIBS += $(BINDIR)${APPLICATION}.a
Expand Down

0 comments on commit 1d34522

Please sign in to comment.