]> git.stg.codes - stg.git/blob - projects/convertor/build
Extra semicolon removed
[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 $CFLAGS $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         CFLAGS="$CFLAGS -DARCH_LE"
131         echo "Little Endian"
132     else
133         ARCH=be
134         CXXFLAGS="$CXXFLAGS -DARCH_BE"
135         CFLAGS="$CFLAGS -DARCH_BE"
136         echo "Big Endian"
137     fi
138 fi
139 rm -f fake
140
141 echo -n "Checking for -lfbclient... "
142 $CC $CFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null
143 if [ $? != 0 ]
144 then
145     CHECK_FBCLIENT=no
146     echo "no"
147 else
148     CHECK_FBCLIENT=yes
149     echo "yes"
150 fi
151 rm -f fake
152
153 echo -n "Checking for mysql_config... "
154 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
155 if [ $? != 0 ]
156 then
157     echo "no";
158     echo -n "Checking for -lmysqlclient... "
159     $CC $CFLAGS $LDFLAGS build_check.c -lmysqlclient_r $LIB_THREAD -o fake > /dev/null 2> /dev/null
160     if [ $? != 0 ]
161     then
162         CHECK_MYSQLCLIENT=no
163         echo "no"
164     else
165         CHECK_MYSQLCLIENT=yes
166         echo "yes"
167     fi
168     rm -f fake
169 else
170     echo "yes"
171     echo -n "Checking for mysql_config --cflags... "
172     MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
173     if [ $? != 0 ]
174     then
175         CHECK_MYSQLCLIENT=no
176         echo "no"
177     else
178         echo "[$MYSQL_CFLAGS]"
179         echo -n "Checking for mysql_config --libs_r... "
180         MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
181         if [ $? != 0 ]
182         then
183             CHECK_MYSQLCLIENT=no
184             echo "no"
185         else
186             CHECK_MYSQLCLIENT=yes
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 $CFLAGS $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=$CFLAGS" >> $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