-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathversion-info
More file actions
executable file
·60 lines (52 loc) · 1.24 KB
/
version-info
File metadata and controls
executable file
·60 lines (52 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
# Generate the build_info.h header
# Use the Git version if Git is available, otherwise fallback to Version
top_srcdir="${1-.}"
test -d "${top_srcdir}" || { \
echo "FATAL: Could not change to top_srcdir '$1'" >&2 ; \
exit 1 ; \
}
version="${top_srcdir}/Version"
# Use GIT_DIR if set
if ! test -n "${GIT_DIR}"
then
GIT_DIR="${top_srcdir}/.git"
fi
if test -d "${GIT_DIR}"
then
# Change tags like vX.Y.Z to X.Y.Z
DESCRIBE=$(git describe --dirty 2>/dev/null)
fi
if test ! -n "${DESCRIBE}"
then
DESCRIBE="unknown-version"
if test -f "${version}"
then
DESCRIBE="v$(cat "${version}")"
fi
fi
if test -n "$2"
then
BUILD_COMPILER="$2"
elif test -n "${CC}"
then
BUILD_COMPILER="$(${CC} --version | head -n1)"
else
BUILD_COMPILER=unknown
fi
cat <<EOM
#define BUILD_VERSION "${DESCRIBE}"
#define BUILD_DATE "$(date -u +%Y-%m-%dT%H:%M:%S%z)"
#define BUILD_ARCH "$(uname -mp)"
#define BUILD_KERNEL "$(uname -sr)"
#define BUILD_OS_VERSION "$(uname -v)"
#define BUILD_COMPILER "${BUILD_COMPILER}"
EOM
echo '#define BUILD_VERSION_INFO_IDENT "$Id$"'
if test -n "${CC}"
then
BUILD_TARGET="$(${CC} -dumpmachine || echo "unknown")"
else
BUILD_TARGET=unknown
fi
echo "#define BUILD_TARGET \"${BUILD_TARGET}\""