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