m1n1/version.sh
Hector Martin 4c2c4085f1 Makefile: Add multiple methods of determining the version number
This fixes m1n1 stage2 version numbers (for .tar.gz downloads) as long
as the directory name is left intact, and also supports packagers
passing their own version number if needed.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-12-04 14:59:47 +09:00

17 lines
379 B
Bash
Executable file

#!/bin/sh
cd "$(dirname "$0")"
dirbase="$(basename "$(pwd)")"
if [ -n "$M1N1_VERSION_TAG" ]; then
version="$M1N1_VERSION_TAG"
elif [ -e ".git" ]; then
version="$(git describe --tags --always --dirty)"
elif [ "${dirbase:0:5}" == "m1n1-" ]; then
version="${dirbase:5}"
version="v${version##v}"
else
version="unknown"
fi
echo "#define BUILD_TAG \"$version\""