aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/prepare-ctemplate-macos.sh
blob: 718dd0bcc28a83d1c66594ecf19d2fea6e21da45 (plain)
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
#!/bin/sh

url="https://github.com/dinhviethoa/ctemplate"

arch="x86_64"
#sysrootpath="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk"

arch_flags=""
for current_arch in $arch ; do
	arch_flags="$arch_flags -arch $current_arch"
done

pushd `dirname $0` > /dev/null
scriptpath=`pwd`
popd > /dev/null
builddir="$scriptpath/../Externals/builds"

#builddir="$HOME/MailCore-Builds/dependencies"
BUILD_TIMESTAMP=`date +'%Y%m%d%H%M%S'`
tempbuilddir="$builddir/workdir/$BUILD_TIMESTAMP"
mkdir -p "$tempbuilddir"
srcdir="$tempbuilddir/src"
logdir="$tempbuilddir/log"
resultdir="$builddir/builds"
tmpdir="$tempbuilddir/tmp"

mkdir -p "$resultdir"
mkdir -p "$logdir"
mkdir -p "$tmpdir"
mkdir -p "$srcdir"

pushd . >/dev/null
mkdir -p "$builddir/downloads"
cd "$builddir/downloads"
if test -d ctemplate ; then
	cd ctemplate
	git pull --rebase
else
	git clone $url
	cd ctemplate
fi
version=`git rev-parse HEAD | cut -c1-10`

if test -f "$resultdir/ctemplate-$version.zip" ; then
	echo install from cache
	popd >/dev/null
	rm -rf ../Externals/ctemplate
	mkdir -p ../Externals/tmp
	unzip -q "$resultdir/ctemplate-$version.zip" -d ../Externals/tmp
	mv "../Externals/tmp/ctemplate-$version/ctemplate" ../Externals
  mkdir -p ../Externals/installed
  ln -sf "$resultdir/ctemplate-$version.zip" ../Externals/installed
	rm -rf ../Externals/tmp
	exit 0
fi
popd >/dev/null

pushd . >/dev/null

cp -R "$builddir/downloads/ctemplate" "$srcdir/ctemplate"
echo building ctemplate
cd "$srcdir/ctemplate"

export CC=clang
export CXX=clang++
export CFLAGS="$arch_flags"
export CXXFLAGS="-std=c++11 -stdlib=libc++ $arch_flags"
./configure --disable-shared --disable-dependency-tracking >> "$logdir/ctemplate-build.log"
#make libctemplate.la >> "$logdir/ctemplate-build.log"
#make libctemplate_nothreads.la >> "$logdir/ctemplate-build.log"
#make install-libLTLIBRARIES "prefix=$tmpdir/bin/ctemplate" >> "$logdir/ctemplate-build.log"
make >> "$logdir/ctemplate-build.log"
make install-libLTLIBRARIES "prefix=$tmpdir/bin/ctemplate" >> "$logdir/ctemplate-build.log"
if test x$? != x0 ; then
	echo build of ctemplate failed
	exit 1
fi

make install-nodist_ctemplateincludeHEADERS "prefix=$tmpdir/bin/ctemplate" >> "$logdir/ctemplate-build.log"
if test x$? != x0 ; then
	echo install of ctemplate failed
	exit 1
fi

echo finished

#mkdir -p "$tmpdir/bin"
cd "$tmpdir/bin"
mkdir -p "ctemplate-$version"
mv ctemplate "ctemplate-$version"
rm -f "$resultdir/ctemplate-$version.zip"
zip -qry "$resultdir/ctemplate-$version.zip" "ctemplate-$version"
rm -f "$resultdir/ctemplate-latest.zip"
cd "$resultdir"
ln -s "ctemplate-$version.zip" "ctemplate-latest.zip"

echo build of ctemplate-$version done

popd >/dev/null

rm -rf ../Externals/ctemplate
mkdir -p ../Externals/tmp
unzip -q "$resultdir/ctemplate-$version.zip" -d ../Externals/tmp
mv "../Externals/tmp/ctemplate-$version/ctemplate" ../Externals
rm -rf ../Externals/tmp

echo cleaning
rm -rf "$tempbuilddir"
echo "$tempbuilddir"