forked from maise-guide/maise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdep-spg
120 lines (117 loc) · 3.95 KB
/
dep-spg
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
#!/bin/bash
#setup
ver="1.11.2.1"
url="https://github.com/spglib/spglib/archive/v$ver.tar.gz"
dir="spglib.tar.gz"
test_OS=$(uname)
test_cmake=$(cmake --version 2>&1 | grep -o "command not found")
test_wget=$(wget --version 2>&1 | grep -o "command not found")
test_curl=$(curl --version 2>&1 | grep -o "command not found")
#commands
if [ "$test_wget" != "command not found" ]; then
GET="wget $url -O $dir"
elif [ "$test_curl" != "command not found" ]; then
GET="curl -L --output $dir $url"
fi
if [ "$test_OS" == Linux ]; then
SED="sed -i"
LIBTOOL="libtoolize"
elif [ "$test_OS" == Darwin ]; then
SED="sed -i -e"
LIBTOOL="glibtoolize"
fi
#working directories
mkdir -p lib/include
mkdir -p dep-ext
cd dep-ext
#download
if [ ! -e spglib.tar.gz ] ; then
echo "downloading...spglib-1.11.2.1 to $PWD"
echo "downloading...spglib-1.11.2.1 to $PWD" &> spglib.log
$GET >> spglib.log 2>&1
fi
#unpack
if [ ! -e spglib-$ver ] ; then
echo "unpacking.....in $PWD"
echo "unpacking.....in $PWD" >> spglib.log 2>&1
tar -xf spglib.tar.gz >> spglib.log 2>&1
fi
#compiling
echo "compiling.....in $PWD/spglib-$ver"
echo "compiling.....in $PWD/spglib-$ver" >> spglib.log 2>&1
cd spglib-$ver
#compile with cmake or autotools
if [ "$test_cmake" != "command not found" ]; then
mkdir -p _build
cd _build
cmake .. >> ../spglib.log 2>&1
make >> ../spglib.log 2>&1
make >> spglib.log >> ../spglib.log 2>&1 && make install DESTDIR=$PWD/../ >> ../spglib.log 2>&1
cd ../
else
#compile with autotools
mkdir -p m4 > /dev/null 2>&1
test_libtool=$($LIBTOOL --version 2>&1 | grep -o "command not found")
$SED "s/AM_PROG_LIBTOOL/LT_INIT/" configure.ac
if [ "$test_OS" != Darwin ]; then
$SED "s/m4_esyscmd_s/m4_esyscmd/" configure.ac
if [ "$test_libtool" == "command not found" ]; then
LIBTOOL="$PWD/lib-tool/usr/bin/libtoolize --force --install --copy"
dir="libtool.deb"
url="http://ftp.br.debian.org/debian/pool/main/libt/libtool/libtool_2.4.2-1.11_all.deb"
if [ "$test_wget" != "command not found" ]; then
GET="wget $url -O $dir"
elif [ "$test_curl" != "command not found" ]; then
GET="curl -L --output $dir $url"
fi
mkdir -p lib-tool 2>&1
cd lib-tool 2>&1
$GET >> ../../spglib.log 2>&1
ar -x $dir >> ../../spglib.log 2>&1
tar -xf data.tar.xz >> ../../spglib.log 2>&1
old="=/usr"
new="=$PWD/usr"
sed -i "s@$old@$new@" ./usr/bin/libtoolize
export ACLOCAL_PATH=$PWD/usr/share/aclocal:$ACLOCAL_PATH
unlink $PWD/usr/share/libtool/config/config.guess
unlink $PWD/usr/share/libtool/config/config.sub
cd ../ 2>&1
fi
fi
aclocal >> ../spglib.log 2>&1
autoheader >> ../spglib.log 2>&1
$LIBTOOL >> ../spglib.log 2>&1
touch INSTALL NEWS README AUTHORS
automake -acf >> ../spglib.log 2>&1
autoconf >> ../spglib.log 2>&1
./configure >> ../spglib.log 2>&1
if [ "$test_libtool" == "command not found" ]; then
cp ./config.guess ./lib-tool/usr/share/libtool/config
cp ./config.sub ./lib-tool/usr/share/libtool/config
aclocal >> ../spglib.log 2>&1
autoheader >> ../spglib.log 2>&1
$LIBTOOL >> ../spglib.log 2>&1
automake -acf >> ../spglib.log 2>&1
autoconf >> ../spglib.log 2>&1
./configure >> ../spglib.log 2>&1
fi
make >> ../spglib.log 2>&1 && make install DESTDIR=$PWD >> ../spglib.log 2>&1
fi
#installation to ./lib
echo "installing....to $PWD/../../lib"
echo "installing....to $PWD/../../lib" >> ../spglib.log 2>&1
cp ./usr/local/lib/libsymspg.a ../../lib >> ../spglib.log 2>&1
cp ./src/spglib.h ../../lib/include >> ../spglib.log 2>&1
cd ../../ >> ../spglib.log 2>&1
#installation check
if [ ! -e ./lib/libsymspg.a ]; then
echo "spglib installation failed!"
echo "spglib installation failed!"
else
echo "Done"
fi
exit
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.