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