- # ==============================================================================
- # git 情報
- # ==============================================================================
-
- # ------------------------------------------------------------------------------
- # git のタグなどから取得可能なバージョン情報を DEFINE に設定します。
- #
- # VERSION : git tag (v[Major].[Minor].[Release] の [Major].[Minor].[Release] 部分)
- # MAJOR : git tag (v[Major].[Minor].[Release] の [Major] 部分)
- # MINOR : git tag (v[Major].[Minor].[Release] の [Minor] 部分)
- # RELEASE : git tag (v[Major].[Minor].[Release] の [Release] 部分)
- # REVISION : git revision
- # DATETIME : datetime (ISO8601形式)
- # ------------------------------------------------------------------------------
- VERSION := $(shell $(GIT) tag | $(SORT) -V | $(TAIL) -1 | $(SED) -e 's/^[^0-9]\+//')
- REVISION := $(shell $(GIT) rev-parse --short HEAD)
- DATETIME := $(shell $(DATE) "+%Y%m%dT%H%M%S")
-
- ifeq ($(strip $(VERSION)),)
- VERSION := v0.0.1
- REVISION := 0
- endif
-
- MAJOR := $(shell $(ECHO) $(VERSION) | $(SED) -e 's/^[a-zA-Z]*\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)$$/\1/')
- MINOR := $(shell $(ECHO) $(VERSION) | $(SED) -e 's/^[a-zA-Z]*\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)$$/\2/')
- RELEASE := $(shell $(ECHO) $(VERSION) | $(SED) -e 's/^[a-zA-Z]*\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)$$/\3/')
-
- DEFINE += -DVERSION='"$(VERSION)"' -DMAJOR='"$(MAJOR)"' -DMINOR='"$(MINOR)"' -DRELEASE='"$(RELEASE)"'
- DEFINE += -DREVISION='"$(REVISION)"'
- DEFINE += -DDATETIME='"$(DATETIME)"'
-