File: make-build-header.sh

package info (click to toggle)
cadical 2.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,216 kB
  • sloc: cpp: 36,901; ansic: 4,521; sh: 1,770; makefile: 91
file content (95 lines) | stat: -rwxr-xr-x 2,668 bytes parent folder | download
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh

#--------------------------------------------------------------------------#

# Used to generate 'build.hpp', which in turn is used in 'version.cpp' to
# print compile time options, compiler version, and source code version.
# If generating 'build.hpp' fails you can still compile 'version.cpp' by
# using the '-DNBUILD' compile time option.

#--------------------------------------------------------------------------#

die () {
  echo "make-build-header.sh: error: $*" 1>&2
  exit 1
}

warning () {
  echo "make-build-header.sh: warning: $*" 1>&2
}

#--------------------------------------------------------------------------#

[ ! -f VERSION -a ! -f ../VERSION ] && \
die "needs to be called from build sub-directory"

[ -f makefile ] || \
warning "could not find 'makefile'"

#--------------------------------------------------------------------------#
# The version.
#
VERSION="`cat ../VERSION`"
if [ x"$VERSION" = x ]
then
  warning "could not determine 'VERSION'"
else
  echo "#define VERSION \"$VERSION\""
fi

#--------------------------------------------------------------------------#
# The unique GIT hash.
#
IDENTIFIER="`../scripts/get-git-id.sh`"
if [ x"$IDENTIFIER" = x ]
then
  warning "could not determine 'IDENTIFIER' (git id)"
  SHORTID=""
else
  echo "#define IDENTIFIER \"$IDENTIFIER\""
  SHORTID=`echo $IDENTIFIER|cut -c 1-7`
  echo "#define SHORTID \"$SHORTID\""
fi

#--------------------------------------------------------------------------#
# C++ compiler 'CXX' used in 'makefile'.
#
COMPILER="`sed -e '/^CXX=/!d' -e 's,^CXX=,,' makefile 2>/dev/null`"
case x"$COMPILER" in 
  x*g++* | x*clang++*)
    COMPILER="`$COMPILER --version 2>/dev/null|head -1`";;
  *) COMPILER="";;
esac
if [ x"$COMPILER" = x ]
then
  warning "could not determine 'COMPILER' ('CXX')"
else
  echo "#define COMPILER \"$COMPILER\""
fi

#--------------------------------------------------------------------------#
# C++ compiler flags 'CXXFLAGS' used in 'makefile'.
#
FLAGS="`sed -e '/^CXXFLAGS=/!d' -e 's,^CXXFLAGS=,,' makefile 2>/dev/null`"
if [ x"$FLAGS" = x ]
then
  warning "could not determine 'FLAGS' ('CXXFLAGS')"
else
  echo "#define FLAGS \"$FLAGS\""
fi

#--------------------------------------------------------------------------#
# Use time of executing this script at build time.
#
LC_TIME="C" # Avoid umlaut in 'DATE'.
export LC_TIME
# The time and date we compiled the CaDiCaL library.
DATE="`date 2>/dev/null|sed -e 's,  *, ,g'`"
OS="`uname -srmn 2>/dev/null`"
DATE="`echo $DATE $OS|sed -e 's,^ *,,' -e 's, *$,,'`"
if [ x"$DATE" = x" " ]
then
  warning "could not determine 'DATE' (build date and time)"
else
  echo "#define DATE \"$DATE\""
fi