makefile: Generalized git-id determination when simh is used as a submodule

This will support arbitrary location and naming of the simh submodule in the
parent repo's working directory.

It probably won't work for sub sub modules.  Suggestions welcome.
This commit is contained in:
Mark Pizzolato 2017-01-14 12:09:00 -08:00
parent b72ec739be
commit 861d9c8d9c

View file

@ -756,10 +756,10 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin)
ifeq (,$(shell grep 'define SIM_GIT_COMMIT_ID' sim_rev.h | grep 'Format:')) ifeq (,$(shell grep 'define SIM_GIT_COMMIT_ID' sim_rev.h | grep 'Format:'))
GIT_COMMIT_ID=$(shell grep 'define SIM_GIT_COMMIT_ID' sim_rev.h | awk '{ print $$3 }') GIT_COMMIT_ID=$(shell grep 'define SIM_GIT_COMMIT_ID' sim_rev.h | awk '{ print $$3 }')
else else
ifeq (git-submodule,$(shell if $(TEST) -d ../.git; then echo git-submodule; fi)) ifeq (git-submodule,$(if $(shell cd .. ; git rev-parse --git-dir 2>/dev/null),git-submodule))
ifeq (submodule,$(shell grep 'submodule "simh"' ../.gitmodules | awk 'BEGIN { FS = " " } ; { print $$1 }' | awk 'BEGIN { FS = "\[" } ; { print $$2 }')) GIT_COMMIT_ID=$(shell cd .. ; git submodule status | grep "$(notdir $(realpath .))" | awk '{ print $$1 }')
GIT_COMMIT_ID=$(shell cd .. ; git submodule status | grep simh | awk '{ print $$1 }') else
endif GIT_COMMIT_ID=undetermined-git-id
endif endif
endif endif
endif endif