forked from arminbiere/gimsatul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkconfig.sh
executable file
·41 lines (41 loc) · 873 Bytes
/
mkconfig.sh
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
#!/bin/sh
die () {
echo "`basename $0`: $*" 2>&1
exit
}
[ -f VERSION ] || die "could not find 'VERSION'"
VERSION="`cat VERSION`"
[ -f makefile ] || die "could not find 'makefile' (run './configure' first)"
CC="`sed -e '/^CC/!d;s,^CC=,,' makefile`"
CFLAGS="`sed -e '/^CFLAGS/!d;s,^CFLAGS=,,' makefile`"
case "$CC" in
gcc*|clang*)
CC="`echo $CC|awk '{print \$1}'`"
CC="`$CC --version 2>/dev/null|head -1`"
;;
esac
cat <<EOF
#define COMPILER "$CC $CFLAGS"
EOF
if [ -d .git -a .git/config ]
then
GITID="`git show|head -1|awk '{print $2}'`"
cat <<EOF
#define GITID "$GITID"
EOF
else
cat <<EOF
#define GITID 0
EOF
fi
cat <<EOF
#define VERSION "$VERSION"
EOF
LC_TIME="en_US"
export LC_TIME
DATE="`date 2>/dev/null|sed -e 's, *, ,g'`"
OS="`uname -srmn 2>/dev/null`"
BUILD="`echo $DATE $OS|sed -e 's,^ *,,' -e 's, *$,,'`"
cat << EOF
#define BUILD "$BUILD"
EOF