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