]> git.stg.codes - stg.git/blob - projects/sgauthstress/build
Merge branch 'fix-gts-auth-errors'
[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     printf "################################################################################\n"
63     printf "# Sorry, but sgauthstress currently supported by Linux, FreeBSD 4.x-8.x        #\n"
64     printf "################################################################################\n"
65     exit 1
66 fi
67
68 printf "#############################################################################\n"
69 printf "       Building sgauthstress for $sys $release\n"
70 printf "#############################################################################\n"
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 printf "Checking CC... "
112 $CC --version > /dev/null 2> /dev/null
113 if [ $? != 0 ]
114 then
115     printf "FAIL!\n"
116     printf "$CC not found\n"
117     exit;
118 fi
119 printf "found\n"
120 printf "Checking CXX... "
121 $CXX --version > /dev/null 2> /dev/null
122 if [ $? != 0 ]
123 then
124     printf "FAIL!\n"
125     printf "$CXX not found\n"
126     exit;
127 fi
128 printf "found\n"
129
130 printf "Checking endianess... "
131 printf "int main() { int probe = 0x00000001; return *(char *)&probe; }\n" > build_check.c
132 $CC $CFLAGS $LDFLAGS build_check.c -o fake > /dev/null 2> /dev/null
133 if [ $? != 0 ]
134 then
135     printf "FAIL!\n"
136     printf "Endianess checking failed\n"
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         printf "Little Endian\n"
146     else
147         ARCH=be
148         CXXFLAGS="$CXXFLAGS -DARCH_BE"
149         CFLAGS="$CFLAGS -DARCH_BE"
150         printf "Big Endian\n"
151     fi
152 fi
153 rm -f fake
154 rm -f build_check.c
155
156 printf "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     printf "no\n"
162 else
163     CHECK_FBCLIENT=yes
164     printf "yes\n"
165 fi
166 rm -f fake
167
168 printf "Checking for mysql_config... "
169 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
170 if [ $? != 0 ]
171 then
172     printf "no\n";
173     printf "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         printf "no\n"
179     else
180         CHECK_MYSQLCLIENT=yes
181         printf "yes\n"
182     fi
183     rm -f fake
184 else
185     printf "yes\n"
186     printf "Checking for mysql_config --cflags... "
187     MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
188     if [ $? != 0 ]
189     then
190         CHECK_MYSQLCLIENT=no
191         printf "no\n"
192     else
193         printf "[$MYSQL_CFLAGS]\n"
194         printf "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             printf "no\n"
200         else
201             CHECK_MYSQLCLIENT=yes
202             printf "[$MYSQL_LDFLAGS]\n"
203         fi
204     fi
205 fi
206
207 printf "Checking for pg_config... "
208 PG_VERSION=`pg_config --version 2> /dev/null`
209 if [ $? != 0 ]
210 then
211     printf "no\n";
212     printf "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         printf "no\n"
218     else
219         CHECK_PQ=yes
220         printf "yes\n"
221     fi
222     rm -f fake
223 else
224     printf "yes\n";
225     printf "Checking for pg_config --includedir... "
226     PG_CFLAGS=`pg_config --includedir 2> /dev/null`
227     if [ $? != 0 ]
228     then
229         CHECK_PQ=no
230         printf "no\n"
231     else
232         printf "[$PG_CFLAGS]\n"
233         printf "Checking for pg_config --libdir... "
234         PG_LDFLAGS=`pg_config --libdir 2> /dev/null`
235         if [ $? != 0 ]
236         then
237             CHECK_PQ=no
238             printf "no\n"
239         else
240             CHECK_PQ=yes
241             printf "[$PG_LDFLAGS]\n"
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 printf "OS=$OS\n" > $CONFFILE
269 printf "STG_TIME=yes\n" >> $CONFFILE
270 printf "DEBUG=$DEBUG\n" >> $CONFFILE
271 printf "DIR_BUILD=$BUILD_DIR\n" >> $CONFFILE
272 printf "DIR_LIB=\$(DIR_BUILD)/../../lib\n" >> $CONFFILE
273 printf "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs\n" >> $CONFFILE
274 printf "DIR_INCLUDE=\$(DIR_BUILD)/../../include\n" >> $CONFFILE
275 printf "DIR_MOD=\$(DIR_BUILD)/../stargazer/modules\n" >> $CONFFILE
276 printf "DIR_PLUGINS=\$(DIR_BUILD)/../stargazer/plugins\n" >> $CONFFILE
277 printf "ARCH=$ARCH\n" >> $CONFFILE
278 printf "DEFS=$DEFS\n" >> $CONFFILE
279 printf "STG_LIBS=" >> $CONFFILE
280 for lib in $STG_LIBS
281 do
282     printf "$lib " >> $CONFFILE
283 done
284 printf "\n" >> $CONFFILE
285 printf "PLUGINS=" >> $CONFFILE
286 for plugin in $PLUGINS
287 do
288     printf "$plugin " >> $CONFFILE
289 done
290 printf "\n" >> $CONFFILE
291 printf "LIB_THREAD=$LIB_THREAD\n" >> $CONFFILE
292 printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE
293 printf "CFLAGS=$CFLAGS\n" >> $CONFFILE
294 printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE
295 printf "PREFIX=$PREFIX\n" >> $CONFFILE
296 printf "BIN_MODE=$BIN_MODE\n" >> $CONFFILE
297 printf "DATA_MODE=$DATA_MODE\n" >> $CONFFILE
298 printf "DIR_MODE=$DIR_MODE\n" >> $CONFFILE
299 printf "OWNER=$OWNER\n" >> $CONFFILE
300 $MAKE $MAKEOPTS