HardenedBSD/release/Makefile.inc1
Glen Barber e5c6913a8d release: sync 'git count' logic with newvers.sh
Sync determining the git count with newvers.sh by adding the
--first-parent argument.  This ensures uname(1) reflects the
file name for snapshots.

Reported by:	Mark Millard
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-03-17 10:57:32 -04:00

46 lines
1.1 KiB
Makefile

#
# $FreeBSD$
#
# Figure out where the git binary is.
.for _P in /usr/bin /usr/local/bin
. if !defined(GIT_CMD) || empty(GIT_CMD)
. if exists(${_P}/git)
GIT_CMD= ${_P}/git
. endif
. endif
.endfor
.if !empty(GIT_CMD) && exists(${GIT_CMD})
# Set the git branch and hash to export where needed.
. if !defined(GITBRANCH) || empty(GITBRANCH)
GITBRANCH!= ${GIT_CMD} -C ${.CURDIR} rev-parse --abbrev-ref HEAD 2>/dev/null | sed -e 's/\^\///'
. export GITBRANCH
. endif
. if !defined(GITREV) || empty(GITREV)
GITREV!= ${GIT_CMD} -C ${.CURDIR} rev-parse --verify --short HEAD 2>/dev/null || true
. export GITREV
. endif
. if !defined(GITCOUNT) || empty(GITCOUNT)
GITCOUNT!= ${GIT_CMD} -C ${.CURDIR} rev-list --first-parent --count HEAD 2>/dev/null || true
. export GITCOUNT
. endif
.else
GITBRANCH= nullbranch
GITREV= nullhash
GITCOUNT= nullcount
. export GITBRANCH
. export GITREV
. export GITCOUNT
.endif
# Set the build date, primarily for snapshot builds.
.if !defined(BUILDDATE) || empty(BUILDDATE)
BUILDDATE!= date +%Y%m%d
.export BUILDDATE
.endif
# Override UNAME_r to allow building ports for a different branch.
UNAME_r= ${REVISION}-${BRANCH}
.export UNAME_r