-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathInstall.sh
More file actions
154 lines (129 loc) · 3.96 KB
/
Copy pathInstall.sh
File metadata and controls
154 lines (129 loc) · 3.96 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
echo "\n----------------------------"
echo "Start of SMART+ compilation."
echo "---------------------------\n"
blue=`tput setaf 4`
red=`tput setaf 1`
reset=`tput sgr0`
#Find the current directory
current_dir=$(pwd)
#Get the file of the bash file (possibly necessary)
bashFileName=${0##*/}
# Detect the platform (similar to $OSTYPE)
OS="`uname`"
case $OS in
'Linux')
OS='Linux'
alias finder='find'
alias nprocs='nproc'
;;
'Darwin')
OS='Mac'
alias finder='gfind'
alias nprocs='sysctl -n hw.ncpu'
;;
'WindowsNT')
OS='Windows'
echo 'No equivalent function known to be equivalent to "find or gfind" : Please search for one and replace this "echo" command in ${bashFileName} and replace it by an "alias"'
;;
*) ;;
esac
#Number of procs used to compil (+1 because if nproc=1 => 1/2=0)
nproc_used=$(( ($(nprocs)+1)/2 ))
#Test if build exist and if it's necessary to erase it
if [ ! -d "build" ]
then
mkdir ${current_dir}/build
echo "Build folder created.\n"
else
echo "Build directory already exists."
while true; do
read -p "Do you want to erase old compilation files (Recommended : No) ? " yn
case $yn in
[YyOo]* ) rm -r ${current_dir}/build/*; break;;
[Nn]* ) break;;
* ) echo "Please answer yes (y) or no (n).";;
esac
done
fi
#Ask for installation of the SMART+ library
while true; do
read -p "Do you want to install SMART+ library (necassary to use libsmartplus.so and simmit) ? " yn
case $yn in
[YyOo]* ) Install_check='OK'; break;;
[Nn]* ) Install_check='NO'; break;;
* ) echo "Please answer yes (y) or no (n).";;
esac
done
#Build SMART+
echo ""
cd ${current_dir}/build
cmake ..
echo ""
make -j${nproc_used}
Install_OK=$?
echo ""
if [ $Install_OK -eq 0 ]
then
if [ "${Install_check}" = "OK" ]
then
make install
fi
make test
Test_OK=$?
#Create the list of the file to copy after compilation
executableToCopy="solver identification L_eff Elastic_props ODF PDF"
objectToCopy="umat_singleM umat_singleT"
# Copy all important files (+ final message)
if [ $Test_OK -eq 0 ]
then
echo "\n---------------------------"
#Treatement of object files
for object in ${objectToCopy}
do
#Copy of the "object".o from build/CMakeFiles/umat.dir/software to build/bin
if [ -f ${current_dir}/build/CMakeFiles/umatM.dir/software/${object}.cpp.o ]
then
cp ${current_dir}/build/CMakeFiles/umatM.dir/software/${object}.cpp.o ${current_dir}/build/bin/${object}.o
fi
#Copy of the "object".o from build/CMakeFiles/umat.dir/software to build/bin
if [ -f ${current_dir}/build/CMakeFiles/umatT.dir/software/${object}.cpp.o ]
then
cp ${current_dir}/build/CMakeFiles/umatT.dir/software/${object}.cpp.o ${current_dir}/build/bin/${object}.o
fi
cp ${current_dir}/build/bin/${object}.o ${current_dir}/exec/${object}.o
echo "${blue}${object}.o${reset} copied in ${blue}${current_dir}/exec${reset}"
done
#Treatement of executable files
for file in ${executableToCopy}
do
#if debug exists, copy of the file from build/bin/Debug to build/bin
if [ -f ${current_dir}/build/bin/Debug/${file} ]
then
cp ${current_dir}/build/bin/Debug/${file} ${current_dir}/build/bin
fi
#if Release exists, copy of the file from build/bin/Debug to build/bin
if [ -f ${current_dir}/build/bin/Release/${file} ]
then
cp ${current_dir}/build/bin/Release/${file} ${current_dir}/build/bin
fi
#Copy the file from build/bin to exec
cp ${current_dir}/build/bin/${file} ${current_dir}/exec
echo "${blue}${file}${reset} copied in ${blue}${current_dir}/exec${reset}"
done
if [ "${Install_check}" = "OK" ]
then
echo "${blue}libsmartplus.so${reset} installed in ${blue}${current_dir}/lib${reset}"
else
echo "${blue}libsmartplus.so${reset} not installed."
fi
echo "---------------------------"
echo "SMART+ compilation done.\n"
else
echo "\n---------------------------"
echo "${red} SMART+ tests failed.\n${reset}"
fi
else
echo "\n---------------------------"
echo "${red} SMART+ compilation failed.\n${reset}"
fi