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