]> git.stg.codes - stg.git/blob - projects/convertor/build
Remove sgauthstress from packaging temporarily
[stg.git] / projects / convertor / build
1 #!/bin/sh
2
3 #   $Revision: 1.20 $
4 #   $Author: faust $
5 #   $Date: 2010/04/14 08:58:43 $
6 ######################################################
7
8 OS=unknown
9 sys=`uname -s`
10 release=`uname -r | cut -b1`
11 BUILD_DIR=`pwd`
12 CONFFILE="../../Makefile.conf"
13 PREFIX="/"
14 BIN_MODE=0755
15 DATA_MODE=0644
16 DIR_MODE=0755
17 OWNER=root
18 VAR_DIR="./inst/var/stargazer"
19 DEFS="-DDEBUG"
20 MAKEOPTS="-j1"
21 CXXFLAGS="$CXXFLAGS -g3 -W -Wall -I/usr/local/include"
22 LDFLAGS="$LDFLAGS -L/usr/local/lib"
23
24 if [ "$sys" = "Linux" ]
25 then
26     OS=linux
27     release=""
28     MAKE="make"
29 fi
30
31 if [ "$sys" = "FreeBSD" ]
32 then
33     case $release in
34         4) OS=bsd;;
35         5) OS=bsd5;;
36         6) OS=bsd5;;
37         7) OS=bsd7;;
38         8) OS=bsd7;;
39         *) OS=unknown;;
40     esac
41     MAKE="gmake"
42 fi
43
44 if [ "$OS" = "unknown" ]
45 then 
46     echo "#############################################################################"
47     echo "# Sorry, but convertor currently supported by Linux, FreeBSD 4.x, 5.x, 6.x  #"
48     echo "#############################################################################"
49     exit 1
50 fi
51
52 echo "#############################################################################"
53 echo "       Building convertor for $sys $release"
54 echo "#############################################################################"
55
56 STG_LIBS="logger.lib 
57           locker.lib
58           crypto.lib 
59           common.lib 
60           conffiles.lib
61           dotconfpp.lib"
62
63 PLUGINS="store/files"
64
65 if [ "$OS" = "linux" ]
66 then
67     DEFS="$DEFS -DLINUX"
68     SHELL="/bin/bash"
69     LIB_THREAD=-lpthread
70 else
71     if [ "$OS" = "bsd" ]
72     then
73         DEFS="$DEFS -DFREE_BSD"
74         LIB_THREAD=-lc_r
75     else
76         DEFS="$DEFS -DFREE_BSD5"
77         if [ "$OS" = "bsd7" ]
78         then
79             LIB_THREAD=-lpthread
80         else
81             LIB_THREAD=-lc_r
82         fi
83     fi
84     SHELL="/usr/local/bin/bash"
85 fi
86
87 echo -n "Checking gcc... "
88 gcc --version > /dev/null 2> /dev/null
89 if [ $? != 0 ]
90 then
91     echo "FAIL!"
92     echo "gcc not found"
93     exit;
94 fi
95 echo "found"
96 echo -n "Checking g++... "
97 g++ --version > /dev/null 2> /dev/null
98 if [ $? != 0 ]
99 then
100     echo "FAIL!"
101     echo "g++ not found"
102     exit;
103 fi
104 echo "found"
105
106 echo -n "Checking endianess... "
107 echo "int main() { int probe = 0x00000001; return *(char *)&probe; }" > build_check.c
108 gcc $CXXFLAGS $LDFLAGS -L/usr/lib/mysql -L/usr/local/lib/mysql build_check.c -o fake > /dev/null 2> /dev/null
109 if [ $? != 0 ]
110 then
111     echo "FAIL!"
112     echo "Endianess checking failed"
113     exit;
114 else
115     ./fake
116     if [ $? = 1 ]
117     then
118         ARCH=le
119         CXXFLAGS="$CXXFLAGS -DARCH_LE"
120         echo "Little Endian"
121     else
122         ARCH=be
123         CXXFLAGS="$CXXFLAGS -DARCH_BE"
124         echo "Big Endian"
125     fi
126 fi
127 rm -f fake
128
129 echo -n "Checking for -lfbclient... "
130 gcc $CXXFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null
131 if [ $? != 0 ]
132 then
133     CHECK_FBCLIENT=no
134     echo "no"
135 else
136     CHECK_FBCLIENT=yes
137     echo "yes"
138 fi
139 rm -f fake
140
141 echo -n "Checking for mysql_config... "
142 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
143 if [ $? != 0 ]
144 then
145     echo "no";
146     echo -n "Checking for -lmysqlclient... "
147     gcc $CXXFLAGS $LDFLAGS build_check.c -lmysqlclient_r $LIB_THREAD -o fake > /dev/null 2> /dev/null
148     if [ $? != 0 ]
149     then
150         CHECK_MYSQLCLIENT=no
151         echo "no"
152     else
153         CHECK_MYSQLCLIENT=yes
154         echo "yes"
155     fi
156     rm -f fake
157 else
158     echo "yes"
159     echo -n "Checking for mysql_config --cflags... "
160     MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
161     if [ $? != 0 ]
162     then
163         CHECK_MYSQLCLIENT=no
164         echo "no"
165     else
166         #CXXFLAGS="$CXXFLAGS $MYSQL_CFLAGS"
167         echo "[$MYSQL_CFLAGS]"
168         echo -n "Checking for mysql_config --libs_r... "
169         MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
170         if [ $? != 0 ]
171         then
172             CHECK_MYSQLCLIENT=no
173             echo "no"
174         else
175             CHECK_MYSQLCLIENT=yes
176             #LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS"
177             echo "[$MYSQL_LDFLAGS]"
178         fi
179     fi
180 fi
181
182 echo -n "Checking for pg_config... "
183 PG_VERSION=`pg_config --version 2> /dev/null`
184 if [ $? != 0 ]
185 then
186     echo "no";
187     echo -n "Checking for -lpq... "
188     gcc $CXXFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null
189     if [ $? != 0 ]
190     then
191         CHECK_PQ=no
192         echo "no"
193     else
194         CHECK_PQ=yes
195         echo "yes"
196     fi
197     rm -f fake
198 else
199     echo "yes";
200     echo -n "Checking for pg_config --includedir... "
201     PG_CFLAGS=`pg_config --includedir 2> /dev/null`
202     if [ $? != 0 ]
203     then
204         CHECK_PQ=no
205         echo "no"
206     else
207         echo "[$PG_CFLAGS]"
208         echo -n "Checking for pg_config --libdir... "
209         PG_LDFLAGS=`pg_config --libdir 2> /dev/null`
210         if [ $? != 0 ]
211         then
212             CHECK_PQ=no
213             echo "no"
214         else
215             CHECK_PQ=yes
216             echo "[$PG_LDFLAGS]"
217         fi
218     fi
219 fi
220
221 rm -f build_check.c
222
223 if [ "$CHECK_FBCLIENT" = "yes" ]
224 then
225     STG_LIBS="$STG_LIBS
226           ibpp.lib"
227     PLUGINS="$PLUGINS
228          store/firebird"
229 fi
230
231 if [ "$CHECK_PQ" = "yes" ]
232 then
233     PLUGINS="$PLUGINS
234              store/postgresql"
235 fi
236
237 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
238 then
239     PLUGINS="$PLUGINS
240          store/mysql"
241 fi
242
243 echo "OS=$OS" > $CONFFILE
244 echo "STG_TIME=yes" >> $CONFFILE
245 echo "DIR_BUILD=$BUILD_DIR" >> $CONFFILE
246 echo "DIR_LIB=\$(DIR_BUILD)/../../lib" >> $CONFFILE
247 echo "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs" >> $CONFFILE
248 echo "DIR_INCLUDE=\$(DIR_BUILD)/../../include" >> $CONFFILE
249 echo "DIR_MOD=\$(DIR_BUILD)/../stargazer/modules" >> $CONFFILE
250 echo "DIR_PLUGINS=\$(DIR_BUILD)/../stargazer/plugins" >> $CONFFILE
251 echo "ARCH=$ARCH" >> $CONFFILE
252 echo "CHECK_FBCLIENT=$CHECK_FBCLIENT" >> $CONFFILE
253 echo "DEFS=$DEFS" >> $CONFFILE
254 echo -n "STG_LIBS=" >> $CONFFILE
255 for lib in $STG_LIBS
256 do
257     echo -n "$lib " >> $CONFFILE
258 done
259 echo "" >> $CONFFILE
260 echo -n "PLUGINS=" >> $CONFFILE
261 for plugin in $PLUGINS
262 do
263     echo -n "$plugin " >> $CONFFILE
264 done
265 echo "" >> $CONFFILE
266 echo "SHELL=$SHELL" >> $CONFFILE
267 echo "CXXFLAGS=$CXXFLAGS" >> $CONFFILE
268 echo "LDFLAGS=$LDFLAGS" >> $CONFFILE
269 echo "LIB_THREAD=$LIB_THREAD" >> $CONFFILE
270 echo "PREFIX=$PREFIX" >> $CONFFILE
271 echo "BIN_MODE=$BIN_MODE" >> $CONFFILE
272 echo "DATA_MODE=$DATA_MODE" >> $CONFFILE
273 echo "DIR_MODE=$DIR_MODE" >> $CONFFILE
274 echo "OWNER=$OWNER" >> $CONFFILE
275 echo "VAR_DIR=$VAR_DIR" >> $CONFFILE
276
277 mkdir -p ../stargazer/modules
278
279 $MAKE $MAKEOPTS
280