forked from LLNL/libmsr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·133 lines (113 loc) · 3.13 KB
/
install.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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# install.sh
# This file MUST be executed for correct installation.
# usage:
# install.sh /path/to/install
cmakever=
cont=
cyantxt="\033[0;36m"
redtxt="\033[0;31m"
greentxt="\033[0;32m"
endtxt="\033[0m"
echo -e $cyantxt"********************"$endtxt
echo -e $cyantxt"* Libmsr Installer *"$endtxt
echo -e $cyantxt"********************\n"$endtxt
#################
# Check for GCC #
#################
GCCVER=$(which gcc)
echo -e $cyantxt"Checking for gcc: $endtxt${GCCVER}"
if [[ $? != 0 ]]; then
echo -e $redtxt"ERROR: gcc not found. (why don't you have gcc?)"$endtxt
fi
#######################
# Check CMake Version #
#######################
cmakever="$(cmake --version | grep -E -o [0-9][.][0-9])"
echo -e $cyantxt"CMake Version: $endtxt${cmakever}"
if [[ $cmakever < 2.8 ]]; then
echo -e $redtxt"ERROR: cmake 2.8 or newer required\n"$endtxt
exit 3
fi
###########################
# Detect CPU Architecture #
###########################
echo -e $cyantxt"Compiling autoconfiguration tool."$endtxt
gcc autoconf.c -o _autoconf_
if [[ $? != 0 ]]; then
echo -e $redtxt"ERROR: could not compile autoconf file. Terminating...\n"$endtxt
exit 4
fi
echo -e $cyantxt"Generating master header file."$endtxt
if [ $# -eq 1 ]; then
./_autoconf_
else
echo $2
./_autoconf_ $2
fi
if [[ $? != 0 ]]; then
echo -e $redtxt"ERROR: could not generate master header file. Terminating...\n"$endtxt
exit 5
fi
cp platform_headers/master.h include/master.h
if [[ $? != 0 ]]; then
echo -e $redtxt"ERROR: unable to install master header file. Terminating...\n"$endtxt
exit 6
fi
######################################
# Congfigure CMake w/Build Directory #
######################################
# No build directory specified, so create one.
if [ -z "$1" ]; then
if [ -e "BUILD" ]; then
echo -e "Directory BUILD exists. overwrite? (y/n)"
read cont
if [ "$cont" = "y" ]; then
rm -r BUILD
mkdir BUILD
if [[ $? != 0 ]]; then
echo -e "$redtxt ERROR: could not create BUILD directory. Terminating...\n$endtxt"
exit 2
fi
fi
else
mkdir BUILD
fi
echo -e $cyantxt"Configuring cmake."$endtxt
cmake . -DCMAKE_INSTALL_PREFIX=./BUILD
# User specified build directory.
else
mkdir $1
echo -e $cyantxt"Configuring cmake."$endtxt
cmake . -DCMAKE_INSTALL_PREFIX="$1"
fi
##################
# Compile Libmsr #
##################
make
if [[ $? != 0 ]]
then
echo -e $redtxt"ERROR: unable to compile source code. Terminating...\n"$endtxt
exit 8
fi
##################
# Install Libmsr #
##################
make install
if [[ $? != 0 ]]
then
echo -e $redtxt"ERROR: unable to install library. Terminating...\n"$endtxt
exit 9
fi
#####################################
# Generate HTML/Latex Documentation #
#####################################
make doc
make latex_doc
echo -e $cyantxt"Copying latex doc into documentation directory."$endtxt
raw_date=$(date)
mod_date=${raw_date// /_}
cd dox/latex && cp refman.pdf ../../documentation/doxygen_${mod_date}.pdf
############################
# Terminate Install Script #
############################
echo -e $cyantxt"Done\n"$endtxt