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