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