From c9438ae1a74c7564f98b5c995ccc1a8f212053fd Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Thu, 27 Mar 2014 21:40:28 +0100 Subject: [PATCH] Finetuned Git commit hash retrieval. - Force usage of shell wrapper in order to allow to suppress potential message about git not found (thanks to Greg King). - Do $(info GIT_SHA ...) only if there's something special - as done with the other $(info ...). --- src/Makefile | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Makefile b/src/Makefile index 2c2267ae7..cf25e198b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -27,6 +27,17 @@ LD65_LIB = $(datadir)/lib LD65_OBJ = $(datadir)/lib LD65_CFG = $(datadir)/cfg +ifdef CMD_EXE + NULLDEV = nul: + DIRLIST = $(strip $(foreach dir,$1,$(wildcard $(dir)))) + MKDIR = mkdir $(subst /,\,$1) + RMDIR = $(if $(DIRLIST),rmdir /s /q $(subst /,\,$(DIRLIST))) +else + NULLDEV = /dev/nul + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 +endif + CC = $(CROSS_COMPILE)gcc AR = $(CROSS_COMPILE)ar @@ -39,13 +50,15 @@ ifdef USER_CFLAGS $(info USER_CFLAGS: $(USER_CFLAGS)) endif -ifndef GIT_SHA - GIT_SHA := $(if $(wildcard ../.git),$(shell git rev-parse --short HEAD)) +ifdef GIT_SHA + $(info GIT_SHA: $(GIT_SHA)) +else + GIT_SHA := $(shell git rev-parse --short HEAD 2>$(NULLDEV)) ifneq ($(words $(GIT_SHA)),1) GIT_SHA := N/A + $(info GIT_SHA: N/A) endif endif -$(info GIT_SHA: $(GIT_SHA)) CFLAGS += -MMD -MP -O -I common \ -Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \ @@ -62,15 +75,6 @@ ifdef CROSS_COMPILE EXE_SUFFIX=.exe endif -ifdef CMD_EXE - DIRLIST = $(strip $(foreach dir,$1,$(wildcard $(dir)))) - MKDIR = mkdir $(subst /,\,$1) - RMDIR = $(if $(DIRLIST),rmdir /s /q $(subst /,\,$(DIRLIST))) -else - MKDIR = mkdir -p $1 - RMDIR = $(RM) -r $1 -endif - all bin: $(PROGS) mostlyclean: -- 2.39.5