-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathConfigure
executable file
·85 lines (70 loc) · 3.01 KB
/
Configure
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
#!/bin/bash -x
##
## BISMON ---- its Configure script ---- see github.com/bstarynk/bismon/
## Copyright © 2018 - 2022 CEA (Commissariat à l'énergie atomique et aux énergies alternatives)
## contributed by Basile Starynkevitch (working at CEA, LIST, France)
## <[email protected]> or <[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
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
##
## ----
## Contact me (Basile Starynkevitch) by email
## [email protected] and/or [email protected]
########################################
# the C++ and C compilers; some GCC (see http://gcc.gnu.org/ ...)
if [ -z "$CXX" ]; then
CXX=g++
fi
if [ -z "$CC" ]; then
CC=gcc
fi
# the short git id....
BISMONCONF_SHGIT1=$(git log --format=oneline -q -1 | cut '-d ' -f1 | tr -d '\n' | head -c16)
BISMONCONF_SHGIT2=$(if git status | grep 'nothing to commit' > /dev/null; then echo; else echo +; fi)
BISMONCONF_SHORT_GIT="$BISMONCONF_SHGIT1$BISMONCONF_SHGIT2"
# Now BISMONCONF_SHORT_GIT could be a string like 6f60bfd0a2dad6bd+ if the
# git repository is dirty, and like 9f60bfd0a2dad6bd if it is clean of
# local changes.
if [ "$1" == "--version" ]; then
printf "%s: version gitid %s\n" $(realpath $0) $BISMONCONF_SHORT_GIT
exit 0
fi
BISMON_CONFIGURE_REAL_PATH=$(realpath $0)
BISMON_CONFIGURE_DIR=$(dirname $BISMON_CONFIGURE_REAL_PATH)
$BISMON_CONFIGURE_DIR/timestamp-emit.sh __timestampconf.c
if [ -f BISMON-config ]; then
/bin/mv -vf BISMON-config BISMON-config~
fi
printf "%s: our compiler for C is %s\n" $0 $CC
$CC --version || exit 1
echo
printf "%s: our compiler for C++ is %s\n" $0 $CXX
$CXX --version || exit 1
echo
$CC -O -Wall -c __timestampconf.c || (printf "%s failed to compile __timestampconf.c\n" > /dev/stderr; exit 1)
/bin/mv -f __timestampconf.c __timestampconf.c~
if $CXX -Wall -Wextra -O -g -DBISMON_SHORTGIT=\"$BISMONCONF_SHORT_GIT\" \
-DBISMON_CONFIG_LABEL=\"from-$BISMON_CONFIGURE_REAL_PATH\" \
BISMON-config.cc __timestampconf.o -o BISMON-config -lreadline ; then
printf "%s: successfully build %s\n" "$0" $(realpath BISMON-config)
else
printf "%s: failed to build BISMON-config in %s\n" "$0" $(pwd) > /dev/stderr
exit 1
fi
if [ "$1" == "--dry" -a -x BISMON-config ]; then
printf "%s: dry configuration, did build BISMON-config but do not run it in %s\n" "$0" $(pwd)
exit 0
fi
exec ./BISMON-config "$@"
### end of Configure script in github.com/bstarynk/bismon/