]> git.stg.codes - stg.git/blob - projects/sgconv/build
Ticket 37. The 'equals' object changed to 'equal' in the testobject::test<7>()
[stg.git] / projects / sgconv / build
1 #!/bin/sh
2
3 #   $Revision: 1.20 $
4 #   $Author: faust $
5 #   $Date: 2010/04/14 08:58:43 $
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 VAR_DIR="./inst/var/stargazer"
20
21 if [ "$1" = "debug" ]
22 then
23    DEFS="$DEFS -DDEBUG"
24    MAKEOPTS="$MAKEOPTS -j1"
25    CFLAGS="$CFLAGS -ggdb3 -W -Wall -Wextra"
26    CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall -Wextra"
27    DEBUG="yes"
28 else
29    DEFS="$DEFS -DNDEBUG"
30    DEBUG="no"
31 fi
32
33 CFLAGS="$CFLAGS -ggdb3 -W -Wall -I/usr/local/include"
34 CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall -I/usr/local/include"
35 LDFLAGS="$LDFLAGS -L/usr/local/lib"
36
37 if [ "$sys" = "Linux" ]
38 then
39     OS=linux
40     MAKE="make"
41 fi
42
43 if [ "$sys" = "FreeBSD" ]
44 then
45     case $major in
46         4) OS=bsd;;
47         5) OS=bsd5;;
48         6) OS=bsd5;;
49         7) OS=bsd7;;
50         *) OS=bsd7;;
51     esac
52     MAKE="gmake"
53 fi
54
55 if [ "$sys" = "Darwin" ]
56 then
57     OS=darwin
58     ETC_DIR="./inst/freebsd/etc/stargazer"
59     MAKE="gmake"
60 fi
61
62 if [ "$OS" = "unknown" ]
63 then
64     printf "#############################################################################\n"
65     printf "# Sorry, but sgconv is currently supported by Linux, FreeBSD and Darwin.    #\n"
66     printf "#############################################################################\n"
67     exit 1
68 fi
69
70 printf "#############################################################################\n"
71 printf "       Building sgconv for $sys $release\n"
72 printf "#############################################################################\n"
73
74 STG_LIBS="logger.lib
75           locker.lib
76           crypto.lib
77           common.lib
78           conffiles.lib
79           dotconfpp.lib"
80
81 PLUGINS="store/files"
82
83 if [ "$OS" = "linux" ]
84 then
85     DEFS="$DEFS -DLINUX"
86     LIB_THREAD=-lpthread
87 else
88     LIBICONV="-liconv"
89     if [ "$OS" = "bsd" ]
90     then
91         DEFS="$DEFS -DFREE_BSD"
92         LIB_THREAD=-lc_r
93     else
94         if [ "$OS" = "bsd7" ]
95         then
96             DEFS="$DEFS -DFREE_BSD5"
97             LIB_THREAD=-lpthread
98         else
99             if [ "$OS" == "darwin" ]
100             then
101                 DEFS="$DEFS -DDARWIN"
102                 LIB_THREAD=-lpthread
103                 LIBICONV=""
104             else
105                 LIB_THREAD=-lc_r
106             fi
107         fi
108     fi
109 fi
110
111 if [ -z "$CC" ]
112 then
113     CC=gcc
114 fi
115
116 if [ -z "$CXX" ]
117 then
118     CXX=g++
119 fi
120
121 printf "Checking CC... "
122 $CC --version > /dev/null 2> /dev/null
123 if [ $? != 0 ]
124 then
125     printf "FAIL!\n"
126     printf "$CC not found\n"
127     exit;
128 fi
129 printf "found\n"
130 printf "Checking CXX... "
131 $CXX --version > /dev/null 2> /dev/null
132 if [ $? != 0 ]
133 then
134     printf "FAIL!\n"
135     printf "$CXX not found\n"
136     exit;
137 fi
138 printf "found\n"
139
140 printf "Checking endianess... "
141 printf "int main() { int probe = 0x00000001; return *(char *)&probe; }\n" > build_check.c
142 $CC $CFLAGS $LDFLAGS -L/usr/lib/mysql -L/usr/local/lib/mysql build_check.c -o fake > /dev/null 2> /dev/null
143 if [ $? != 0 ]
144 then
145     printf "FAIL!\n"
146     printf "Endianess checking failed\n"
147     exit;
148 else
149     ./fake
150     if [ $? = 1 ]
151     then
152         ARCH=le
153         CXXFLAGS="$CXXFLAGS -DARCH_LE"
154         CFLAGS="$CFLAGS -DARCH_LE"
155         printf "Little Endian\n"
156     else
157         ARCH=be
158         CXXFLAGS="$CXXFLAGS -DARCH_BE"
159         CFLAGS="$CFLAGS -DARCH_BE"
160         printf "Big Endian\n"
161     fi
162 fi
163 rm -f fake
164
165 printf "Checking for iconv 2nd argument... "
166 printf "#include <iconv.h>\nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c
167 $CC $CFLAGS $LDFLAGS -Werror build_check.c $LIBICONV -o fake > /dev/null 2> /dev/null
168 if [ $? != 0 ]
169 then
170     printf "non-const\n"
171 else
172     DEFS="$DEFS -DCONST_ICONV"
173     printf "const\n"
174 fi
175 rm -f fake
176
177 printf "Checking for fb_config... "
178 FB_VERSION=`fb_config --version 2> /dev/null`
179 if [ "$?" != "0" ]
180 then
181     printf "no\n"
182     printf "Checking for -lfbclient... "
183     printf "int main() { return 0; }\n" > build_check.c
184     $CC $CFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null
185     if [ $? != 0 ]
186     then
187         CHECK_FBCLIENT=no
188         printf "no\n"
189     else
190         FB_CFLAGS=""
191         FB_LDFLAGS="-lfbclient"
192         CHECK_FBCLIENT=yes
193         printf "yes\n"
194     fi
195     rm -f fake
196 else
197     printf "yes\n"
198     printf "Checking for fb_config --cflags... "
199     FB_CFLAGS=`fb_config --cflags`
200     if [ "$?" != "0" ]
201     then
202         CHECK_FBCLIENT=no
203         printf "no\n"
204     else
205         printf "[$FB_CFLAGS]\n"
206         printf "Checking for fb_config --libs "
207         FB_LDFLAGS=`fb_config --libs`
208         if [ "$?" != "0" ]
209         then
210             CHECK_FBCLIENT=no
211             printf "no\n"
212         else
213             CHECK_FBCLIENT=yes
214             printf "[$FB_LDFLAGS]\n"
215         fi
216     fi
217 fi
218
219 printf "Checking for mysql_config... "
220 printf "#include <mysql.h>\nint main() { return 0; }\n" > build_check.c
221 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
222 if [ $? != 0 ]
223 then
224     printf "no\n";
225     printf "Checking for -lmysqlclient... "
226     $CC $CFLAGS $LDFLAGS build_check.c -lmysqlclient_r $LIB_THREAD -o fake > /dev/null 2> /dev/null
227     if [ $? != 0 ]
228     then
229         CHECK_MYSQLCLIENT=no
230         printf "no\n"
231     else
232         CHECK_MYSQLCLIENT=yes
233         printf "yes\n"
234     fi
235     rm -f fake
236 else
237     printf "yes\n"
238     printf "Checking for mysql_config --cflags... "
239     MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
240     if [ $? != 0 ]
241     then
242         CHECK_MYSQLCLIENT=no
243         printf "no\n"
244     else
245         printf "[$MYSQL_CFLAGS]\n"
246         printf "Checking for mysql_config --libs_r... "
247         MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
248         if [ $? != 0 ]
249         then
250             CHECK_MYSQLCLIENT=no
251             printf "no\n"
252         else
253             CHECK_MYSQLCLIENT=yes
254             printf "[$MYSQL_LDFLAGS]\n"
255         fi
256     fi
257 fi
258
259 printf "Checking for pg_config... "
260 printf "#include <libpq-fe.h>\nint main() { return 0; }\n" > build_check.c
261 PG_VERSION=`pg_config --version 2> /dev/null`
262 if [ $? != 0 ]
263 then
264     printf "no\n";
265     printf "Checking for -lpq... "
266     $CC $CFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null
267     if [ $? != 0 ]
268     then
269         CHECK_PQ=no
270         printf "no\n"
271     else
272         CHECK_PQ=yes
273         printf "yes\n"
274     fi
275     rm -f fake
276 else
277     printf "yes\n";
278     printf "Checking for pg_config --includedir... "
279     PG_CFLAGS="-I"`pg_config --includedir 2> /dev/null`
280     if [ $? != 0 ]
281     then
282         CHECK_PQ=no
283         printf "no\n"
284     else
285         printf "[$PG_CFLAGS]\n"
286         printf "Checking for pg_config --libdir... "
287         PG_LDFLAGS="-L"`pg_config --libdir 2> /dev/null`
288         if [ $? != 0 ]
289         then
290             CHECK_PQ=no
291             printf "no\n"
292         else
293             CHECK_PQ=yes
294             printf "[$PG_LDFLAGS]\n"
295         fi
296     fi
297 fi
298
299 rm -f build_check.c
300
301 if [ "$CHECK_FBCLIENT" = "yes" ]
302 then
303     STG_LIBS="$STG_LIBS
304           ibpp.lib"
305     PLUGINS="$PLUGINS
306          store/firebird"
307 fi
308
309 if [ "$CHECK_PQ" = "yes" ]
310 then
311     PLUGINS="$PLUGINS
312              store/postgresql"
313 fi
314
315 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
316 then
317     PLUGINS="$PLUGINS
318          store/mysql"
319 fi
320
321 printf "OS=$OS\n" > $CONFFILE
322 printf "STG_TIME=yes\n" >> $CONFFILE
323 printf "DEBUG=$DEBUG\n" >> $CONFFILE
324 printf "DIR_BUILD=$BUILD_DIR\n" >> $CONFFILE
325 printf "DIR_LIB=\$(DIR_BUILD)/../../lib\n" >> $CONFFILE
326 printf "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs\n" >> $CONFFILE
327 printf "DIR_INCLUDE=\$(DIR_BUILD)/../../include\n" >> $CONFFILE
328 printf "DIR_MOD=\$(DIR_BUILD)/../stargazer/modules\n" >> $CONFFILE
329 printf "DIR_PLUGINS=\$(DIR_BUILD)/../stargazer/plugins\n" >> $CONFFILE
330 printf "ARCH=$ARCH\n" >> $CONFFILE
331 printf "CHECK_FBCLIENT=$CHECK_FBCLIENT\n" >> $CONFFILE
332 if [ "$CHECK_FBCLIENT" = "yes" ]
333 then
334     printf "FB_CFLAGS=$FB_CFLAGS\n" >> $CONFFILE
335     printf "FB_LDFLAGS=$FB_LDFLAGS\n" >> $CONFFILE
336 fi
337 printf "CHECK_MYSQLCLIENT=$CHECK_MYSQLCLIENT\n" >> $CONFFILE
338 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
339 then
340     printf "MYSQL_CFLAGS=$MYSQL_CFLAGS\n" >> $CONFFILE
341     printf "MYSQL_LDFLAGS=$MYSQL_LDFLAGS\n" >> $CONFFILE
342 fi
343 printf "CHECK_PQ=$CHECK_PQ\n" >> $CONFFILE
344 if [ "$CHECK_PQ" = "yes" ]
345 then
346     printf "PG_CFLAGS=$PG_CFLAGS\n" >> $CONFFILE
347     printf "PG_LDFLAGS=$PG_LDFLAGS\n" >> $CONFFILE
348 fi
349 printf "DEFS=$DEFS\n" >> $CONFFILE
350 printf "STG_LIBS=" >> $CONFFILE
351 for lib in $STG_LIBS
352 do
353     printf "$lib " >> $CONFFILE
354 done
355 printf "\n" >> $CONFFILE
356 printf "PLUGINS=" >> $CONFFILE
357 for plugin in $PLUGINS
358 do
359     printf "$plugin " >> $CONFFILE
360 done
361 printf "\n" >> $CONFFILE
362 printf "CC=$CC\n" >> $CONFFILE
363 printf "CXX=$CXX\n" >> $CONFFILE
364 printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE
365 printf "CFLAGS=$CFLAGS\n" >> $CONFFILE
366 printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE
367 printf "LIB_THREAD=$LIB_THREAD\n" >> $CONFFILE
368 printf "LIBICONV=$LIBICONV\n" >> $CONFFILE
369 printf "PREFIX=$PREFIX\n" >> $CONFFILE
370 printf "BIN_MODE=$BIN_MODE\n" >> $CONFFILE
371 printf "DATA_MODE=$DATA_MODE\n" >> $CONFFILE
372 printf "DIR_MODE=$DIR_MODE\n" >> $CONFFILE
373 printf "OWNER=$OWNER\n" >> $CONFFILE
374 printf "VAR_DIR=$VAR_DIR\n" >> $CONFFILE
375
376 mkdir -p ../stargazer/modules
377
378 if [ "$1" != "debug" ]
379 then
380     $MAKE $MAKEOPTS
381 else
382     printf "\n\n\nDebug build. Type $MAKE explicitly\n"
383 fi