Skip to content

Commit 4c2c408

Browse files
committed
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 <[email protected]>
1 parent db93de5 commit 4c2c408

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ build/$(NAME).bin: build/$(NAME)-raw.elf
203203

204204
update_tag:
205205
@mkdir -p build
206-
@echo "#define BUILD_TAG \"$$(git describe --tags --always --dirty)\"" > build/build_tag.tmp
206+
@./version.sh > build/build_tag.tmp
207207
@cmp -s build/build_tag.h build/build_tag.tmp 2>/dev/null || \
208208
( mv -f build/build_tag.tmp build/build_tag.h && echo " TAG build/build_tag.h" )
209209

version.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
cd "$(dirname "$0")"
3+
4+
dirbase="$(basename "$(pwd)")"
5+
6+
if [ -n "$M1N1_VERSION_TAG" ]; then
7+
version="$M1N1_VERSION_TAG"
8+
elif [ -e ".git" ]; then
9+
version="$(git describe --tags --always --dirty)"
10+
elif [ "${dirbase:0:5}" == "m1n1-" ]; then
11+
version="${dirbase:5}"
12+
version="v${version##v}"
13+
else
14+
version="unknown"
15+
fi
16+
17+
echo "#define BUILD_TAG \"$version\""

0 commit comments

Comments
 (0)