Skip to content

Commit

Permalink
Update Makefile VERSION assignment to avoid errors when not in a git …
Browse files Browse the repository at this point in the history
…repository

Simplify the VERSION assignment to prevent the "fatal: not a git repository (or any of the parent directories): .git" error when building from a source archive. The VERSION variable now checks if the Makefile is within a git working tree before attempting to use git tags. If not, it defaults to "v0.7", avoiding errors in non-git environments.
  • Loading branch information
hmgle committed Mar 2, 2024
1 parent feb4f32 commit 7d995e2
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# "Makefile" for graftcp.
# Copyright (C) 2016, 2018, 2020, 2021, 2023 Hmgle <[email protected]>
# Copyright (C) 2016, 2018, 2020, 2021, 2023, 2024 Hmgle <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -19,7 +19,8 @@ ifneq ($(KERNEL), Linux)
$(error only support Linux now.)
endif

VERSION = $(shell git describe --tags --always)
VERSION = $(shell git rev-parse --is-inside-work-tree 1>/dev/null 2>&1 && \
git describe --tags --always || echo "v0.7")

# CROSS_COMPILE can be set on the command line
# make CROSS_COMPILE=arm-linux-gnueabi-
Expand All @@ -45,9 +46,6 @@ else
CFLAGS += -O2 -DNDEBUG
endif

ifneq ($(shell echo $(VERSION) | head -c 1), v)
VERSION=v0.7
endif
CFLAGS += -DVERSION=\"$(VERSION)\"

SRC := $(wildcard *.c)
Expand Down

0 comments on commit 7d995e2

Please sign in to comment.