1# Figure out where the git binary is. 2.for _P in /usr/bin /usr/local/bin 3. if !defined(GIT_CMD) || empty(GIT_CMD) 4. if exists(${_P}/git) 5GIT_CMD= ${_P}/git 6. endif 7. endif 8.endfor 9 10.if !empty(GIT_CMD) && exists(${GIT_CMD}) 11# Set the git branch and hash to export where needed. 12. if !defined(GITBRANCH) || empty(GITBRANCH) 13GITBRANCH!= ${GIT_CMD} -C ${.CURDIR} rev-parse --abbrev-ref HEAD 2>/dev/null | sed -e 's/\^\///' 14. export GITBRANCH 15. endif 16. if !defined(GITREV) || empty(GITREV) 17GITREV!= ${GIT_CMD} -C ${.CURDIR} rev-parse --verify --short HEAD 2>/dev/null || true 18. export GITREV 19. endif 20. if !defined(GITCOUNT) || empty(GITCOUNT) 21GITCOUNT!= ${GIT_CMD} -C ${.CURDIR} rev-list --first-parent --count HEAD 2>/dev/null || true 22. export GITCOUNT 23. endif 24. if !defined(GITEPOCH) || empty(GITEPOCH) 25GITEPOCH!= ${GIT_CMD} -C ${.CURDIR} show -s --format=%ct HEAD 2>/dev/null || true 26. export GITEPOCH 27. endif 28.else 29GITBRANCH= nullbranch 30GITREV= nullhash 31GITCOUNT= nullcount 32GITEPOCH= 0 33. export GITBRANCH 34. export GITREV 35. export GITCOUNT 36. export GITEPOCH 37.endif 38 39# Set the build date, primarily for snapshot builds. 40.if !defined(BUILDDATE) || empty(BUILDDATE) 41BUILDDATE!= date +%Y%m%d 42.export BUILDDATE 43.endif 44 45# Override UNAME_r to allow building ports for a different branch. 46UNAME_r= ${REVISION}-${BRANCH} 47.export UNAME_r 48