build.sh
3.89 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
155
156
157
158
159
160
161
162
163
#!/bin/bash
# Copyright 2002-2014 the original author or authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# CC/LICENSE
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source DIST_VERSION.inc
ROOT=`pwd`
PREFIX=$ROOT/output
VOICE_DIR=$ROOT/voice
if [ -f "output/libs/esl/include/esl.h" -a -f "output/libs/esl/libesl.a" ]; then
exit 0;
fi
echo "prepare build..."
if [ -z "$DIST_VERSION" ]; then
echo "errno: no DIST_VERSION info"
exit 1
fi
DIRNAME=$ROOT/$DIST_VERSION
if [ -d "$DIRNAME" ]; then
rm -rf $DIRNAME
fi
if [ -d "$PREFIX" ]; then
rm -fr $PREFIX
fi
file=$DIST_VERSION.tar.gz
if [ ! -f $file ]; then
wget http://files.freeswitch.org/freeswitch-1.0.6.tar.gz
fi
if [ ! -f "$file" ]; then
echo "can't find ${file}, build failed";
exit 1;
fi
echo "tar xzf $file..."
tar xzf $file
if [ ! -d "$DIRNAME" ]; then
echo "error: no $DIRNAME"
exit 1
fi
cd $DIRNAME
rm -fr $DIRNAME/libs/esl
cp -fr $ROOT/patch/esl libs/
cp -fr $ROOT/patch/mod_http_cache src/mod/applications/
cp -fr $ROOT/patch/modules.conf ./
cp -r $ROOT/patch/autoload_configs/* conf/autoload_configs/
cp -r $ROOT/patch/mod_http_cache src/mod/applications/
cp -r ../../../platform/fw-mod/record/mod_ccl_record src/mod/applications/
mkdir -p src/mod/applications/mod_ivr_loadbalance
cp ../../../platform/fw-mod/ivrloadbalance/mod_ivr_loadbalance.cpp src/mod/applications/mod_ivr_loadbalance/
patch_files=`ls $ROOT/patch/*.patch`
if [ $? = 0 ] ; then
for f in $patch_files
do
patch -p1 < $f
done
fi
echo "begin to build..."
sed -i '14764,14782s/^/#&/g' configure
CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --prefix=$PREFIX
if [ $? != 0 ] ; then
echo "./configure FAILED! EXIT!";
exit 1;
fi
echo "begin compiling libedit library..."
make -C libs/libedit/
echo "end compiling libedit library..."
echo "begin compiling curl library..."
make -C libs/curl/
echo "end compiling curl library..."
echo "begin compiling esl library..."
sed -i 's/-Werror//g' libs/esl/Makefile
make -C libs/esl/
echo "end compiling esl library..."
make -j 8
make install
if [ ! -f "$PREFIX/bin/freeswitch" ]; then
echo "error: no freeswitch"
exit 1
fi
if [ -d "$PREFIX/conf" ]; then
cp ../../../platform/fw-mod/record/mod_ccl_record/conf/ccl_record.conf.xml $PREFIX/conf/autoload_configs/
mkdir -p $PREFIX/conf/ivr_loadbalance
cp ../../../platform/fw-mod/ivrloadbalance/ivr_loadbalance.conf $PREFIX/conf/ivr_loadbalance/
cp $ROOT/patch/autoload_configs/event_socket.conf.xml $PREFIX/conf/autoload_configs/
cp $ROOT/patch/autoload_configs/logfile.conf.xml $PREFIX/conf/autoload_configs/
cp $ROOT/patch/sip_profiles/agent.xml $PREFIX/conf/sip_profiles/
mkdir -p $PREFIX/conf-new/autoload_configs
cp $ROOT/patch/autoload_configs/modules.conf.xml $PREFIX/conf-new/autoload_configs/
fi
if [ -d "$PREFIX/htdocs" ]; then
rm -fr $PREFIX/htdocs
fi
cd $VOICE_DIR
if [ ! -d $PREFIX/voice ]; then
mkdir -p $PREFIX/voice
fi
cp *.wav $PREFIX/voice/
cd $PREFIX
cp ../freeswitch.sh .
tar cvzf $DIST_VERSION.tgz *
mv $DIST_VERSION.tgz $PREFIX/../$DIST_VERSION.tgz
cd -
rm -rf $PREFIX
mkdir -p $PREFIX
mv $PREFIX/../$DIST_VERSION.tgz $PREFIX/
#dist esl library
if [ ! -d "$PREFIX/libs/esl" ]; then
mkdir -p $PREFIX/libs/esl/
fi
cp -r $PREFIX/../$DIST_VERSION/libs/esl/src/include $PREFIX/libs/esl/
cp $PREFIX/../$DIST_VERSION/libs/esl/libesl.a $PREFIX/libs/esl/
if [ ! -f "$PREFIX/$DIST_VERSION.tgz" ]; then
echo "error: no $PREFIX/$DIST_VERSION.tgz"
exit 1
fi
echo "build binary done success"