2020-03-31 12:59:53 +00:00
|
|
|
# in: PROJECT_ROOT
|
2018-03-26 15:14:54 +00:00
|
|
|
# in: PKGNAME
|
|
|
|
# in: FEATURES (optional)
|
|
|
|
# in: BUILD_INFO (optional)
|
2018-05-09 17:05:29 +00:00
|
|
|
# in: OPENSSL (optional)
|
|
|
|
# in: OPENSSL_FOUND (optional)
|
2018-11-03 15:23:31 +00:00
|
|
|
# in: SOURCE_DATE_EPOCH (optional)
|
2018-03-26 15:14:54 +00:00
|
|
|
|
2020-03-31 12:59:53 +00:00
|
|
|
ifndef PROJECT_ROOT
|
|
|
|
$(error PROJECT_ROOT not defined)
|
|
|
|
endif
|
|
|
|
|
2018-03-26 15:14:54 +00:00
|
|
|
ifndef PKGNAME
|
|
|
|
$(error PKGNAME not defined)
|
|
|
|
endif
|
|
|
|
|
2018-05-09 17:05:29 +00:00
|
|
|
ifndef OPENSSL
|
|
|
|
ifdef OPENSSL_FOUND
|
|
|
|
OPENSSL= $(OPENSSL_FOUND)/bin/openssl
|
|
|
|
else
|
|
|
|
OPENSSL= openssl
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2018-03-26 15:14:54 +00:00
|
|
|
BASENAME?= basename
|
|
|
|
CUT?= cut
|
2018-05-09 17:05:29 +00:00
|
|
|
DATE?= date
|
|
|
|
DIFF?= diff
|
2018-03-26 15:14:54 +00:00
|
|
|
GIT?= git
|
|
|
|
GREP?= grep
|
2018-05-09 17:05:29 +00:00
|
|
|
RM?= rm
|
2018-03-26 15:14:54 +00:00
|
|
|
SED?= sed
|
2018-05-09 17:05:29 +00:00
|
|
|
SORT?= sort
|
|
|
|
TR?= tr
|
|
|
|
WC?= wc
|
2018-03-26 15:14:54 +00:00
|
|
|
|
2020-03-31 12:59:53 +00:00
|
|
|
GITDIR:= $(wildcard $(PROJECT_ROOT).git)
|
|
|
|
ifdef VERSION
|
|
|
|
VERSION_FILE:= $(wildcard $(PROJECT_ROOT)VERSION)
|
|
|
|
endif
|
|
|
|
ifdef HASHES
|
|
|
|
HASHES_FILE:= $(wildcard $(PROJECT_ROOT)HASHES)
|
|
|
|
endif
|
|
|
|
NEWS_FILE:= $(firstword $(wildcard $(PROJECT_ROOT)NEWS*))
|
2018-03-26 15:14:54 +00:00
|
|
|
|
2020-03-29 14:23:21 +00:00
|
|
|
ifdef GITDIR
|
2020-03-31 12:59:53 +00:00
|
|
|
BUILD_VERSION:= $(shell cd $(PROJECT_ROOT) && $(GIT) describe --tags --dirty --always)
|
2020-03-29 14:23:21 +00:00
|
|
|
BUILD_INFO+= V:GIT
|
|
|
|
else
|
2020-03-31 12:59:53 +00:00
|
|
|
ifdef VERSION_FILE
|
|
|
|
BUILD_VERSION:= $(shell $(CAT) $(VERSION_FILE))
|
|
|
|
BUILD_INFO+= V:FILE
|
|
|
|
else
|
|
|
|
BUILD_VERSION:= $(shell cd $(PROJECT_ROOT) && $(BASENAME) $(PWD)|\
|
2018-03-26 15:14:54 +00:00
|
|
|
$(GREP) $(PKGNAME)-|\
|
|
|
|
$(SED) 's/.*$(PKGNAME)-\(.*\)/\1/g')
|
|
|
|
BUILD_INFO+= V:DIR
|
|
|
|
endif
|
2018-05-09 17:05:29 +00:00
|
|
|
ifdef HASHES_FILE
|
|
|
|
BUILD_INFO+= HDIFF:$(shell $(OPENSSL) dgst -sha1 -r *.[hc]|\
|
|
|
|
$(SORT) -k 2 >HASHES~;\
|
|
|
|
$(DIFF) -u HASHES HASHES~|\
|
|
|
|
$(GREP) '^-[^-]'|$(WC) -l|$(TR) -d ' ';\
|
|
|
|
$(RM) HASHES~)
|
|
|
|
endif
|
2018-03-26 15:14:54 +00:00
|
|
|
ifdef NEWS_FILE
|
|
|
|
NEWS_SHA:= $(shell $(OPENSSL) dgst -sha1 -r $(NEWS_FILE) |\
|
|
|
|
$(CUT) -c -7)
|
|
|
|
BUILD_INFO+= N:$(NEWS_SHA)
|
|
|
|
endif
|
|
|
|
endif # GITDIR
|
|
|
|
|
2018-05-09 17:05:29 +00:00
|
|
|
ifdef SOURCE_DATE_EPOCH
|
|
|
|
BUILD_DATE:= $(shell \
|
|
|
|
$(DATE) -u -d "@$(SOURCE_DATE_EPOCH)" "+%Y-%m-%d" 2>/dev/null||\
|
|
|
|
$(DATE) -u -r "$(SOURCE_DATE_EPOCH)" "+%Y-%m-%d" 2>/dev/null||\
|
|
|
|
$(DATE) -u "+%Y-%m-%d")
|
|
|
|
else
|
2018-03-26 15:14:54 +00:00
|
|
|
BUILD_DATE:= $(shell date +%Y-%m-%d)
|
2018-05-09 17:05:29 +00:00
|
|
|
endif
|
2020-03-31 12:59:53 +00:00
|
|
|
BUILD_CPPFLAGS+=-D"BUILD_PKGNAME=\"$(PKGNAME)\"" \
|
2018-03-26 15:14:54 +00:00
|
|
|
-D"BUILD_VERSION=\"$(BUILD_VERSION)\"" \
|
|
|
|
-D"BUILD_DATE=\"$(BUILD_DATE)\"" \
|
|
|
|
-D"BUILD_INFO=\"$(BUILD_INFO)\"" \
|
|
|
|
-D"BUILD_FEATURES=\"$(FEATURES)\""
|
|
|
|
|
|
|
|
# out: NEWS_FILE
|
|
|
|
# out: NEWS_SHA
|
|
|
|
# out: VERSION_FILE
|
2018-05-09 17:05:29 +00:00
|
|
|
# out: GITDIR
|
2018-03-26 15:14:54 +00:00
|
|
|
# out: BUILD_VERSION
|
|
|
|
# out: BUILD_DATE
|
|
|
|
# out: BUILD_INFO
|
|
|
|
# out: BUILD_CPPFLAGS
|