]> git.stg.codes - stg.git/blob - projects/convertor/build
Extra semicolon and return in void functions 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     LIB_THREAD=-lpthread
69 else
70     if [ "$OS" = "bsd" ]
71     then
72         DEFS="$DEFS -DFREE_BSD"
73         LIB_THREAD=-lc_r
74     else
75         DEFS="$DEFS -DFREE_BSD5"
76         if [ "$OS" = "bsd7" ]
77         then
78             LIB_THREAD=-lpthread
79         else
80             LIB_THREAD=-lc_r
81         fi
82     fi
83 fi
84
85 if [ -z "$CC" ]
86 then
87     CC=gcc
88 fi
89
90 if [ -z "$CXX" ]
91 then
92     CXX=g++
93 fi
94
95 echo -n "Checking CC... "
96 $CC --version > /dev/null 2> /dev/null
97 if [ $? != 0 ]
98 then
99     echo "FAIL!"
100     echo "$CC not found"
101     exit;
102 fi
103 echo "found"
104 echo -n "Checking CXX... "
105 $CXX --version > /dev/null 2> /dev/null
106 if [ $? != 0 ]
107 then
108     echo "FAIL!"
109     echo "$CXX not found"
110     exit;
111 fi
112 echo "found"
113
114 echo -n "Checking endianess... "
115 echo "int main() { int probe = 0x00000001; return *(char *)&probe; }" > build_check.c
116 $CC $CFLAGS $LDFLAGS -L/usr/lib/mysql -L/usr/local/lib/mysql build_check.c -o fake > /dev/null 2> /dev/null
117 if [ $? != 0 ]
118 then
119     echo "FAIL!"
120     echo "Endianess checking failed"
121     exit;
122 else
123     ./fake
124     if [ $? = 1 ]
125     then
126         ARCH=le
127         CXXFLAGS="$CXXFLAGS -DARCH_LE"
128         CFLAGS="$CFLAGS -DARCH_LE"
129         echo "Little Endian"
130     else
131         ARCH=be
132         CXXFLAGS="$CXXFLAGS -DARCH_BE"
133         CFLAGS="$CFLAGS -DARCH_BE"
134         echo "Big Endian"
135     fi
136 fi
137 rm -f fake
138
139 echo -n "Checking for -lfbclient... "
140 $CC $CFLAGS $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 $CFLAGS $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         echo "[$MYSQL_CFLAGS]"
177         echo -n "Checking for mysql_config --libs_r... "
178         MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
179         if [ $? != 0 ]
180         then
181             CHECK_MYSQLCLIENT=no
182             echo "no"
183         else
184             CHECK_MYSQLCLIENT=yes
185             echo "[$MYSQL_LDFLAGS]"
186         fi
187     fi
188 fi
189
190 echo -n "Checking for pg_config... "
191 PG_VERSION=`pg_config --version 2> /dev/null`
192 if [ $? != 0 ]
193 then
194     echo "no";
195     echo -n "Checking for -lpq... "
196     $CC $CFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null
197     if [ $? != 0 ]
198     then
199         CHECK_PQ=no
200         echo "no"
201     else
202         CHECK_PQ=yes
203         echo "yes"
204     fi
205     rm -f fake
206 else
207     echo "yes";
208     echo -n "Checking for pg_config --includedir... "
209     PG_CFLAGS=`pg_config --includedir 2> /dev/null`
210     if [ $? != 0 ]
211     then
212         CHECK_PQ=no
213         echo "no"
214     else
215         echo "[$PG_CFLAGS]"
216         echo -n "Checking for pg_config --libdir... "
217         PG_LDFLAGS=`pg_config --libdir 2> /dev/null`
218         if [ $? != 0 ]
219         then
220             CHECK_PQ=no
221             echo "no"
222         else
223             CHECK_PQ=yes
224             echo "[$PG_LDFLAGS]"
225         fi
226     fi
227 fi
228
229 rm -f build_check.c
230
231 if [ "$CHECK_FBCLIENT" = "yes" ]
232 then
233     STG_LIBS="$STG_LIBS
234           ibpp.lib"
235     PLUGINS="$PLUGINS
236          store/firebird"
237 fi
238
239 if [ "$CHECK_PQ" = "yes" ]
240 then
241     PLUGINS="$PLUGINS
242              store/postgresql"
243 fi
244
245 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
246 then
247     PLUGINS="$PLUGINS
248          store/mysql"
249 fi
250
251 echo "OS=$OS" > $CONFFILE
252 echo "STG_TIME=yes" >> $CONFFILE
253 echo "DIR_BUILD=$BUILD_DIR" >> $CONFFILE
254 echo "DIR_LIB=\$(DIR_BUILD)/../../lib" >> $CONFFILE
255 echo "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs" >> $CONFFILE
256 echo "DIR_INCLUDE=\$(DIR_BUILD)/../../include" >> $CONFFILE
257 echo "DIR_MOD=\$(DIR_BUILD)/../stargazer/modules" >> $CONFFILE
258 echo "DIR_PLUGINS=\$(DIR_BUILD)/../stargazer/plugins" >> $CONFFILE
259 echo "ARCH=$ARCH" >> $CONFFILE
260 echo "CHECK_FBCLIENT=$CHECK_FBCLIENT" >> $CONFFILE
261 echo "DEFS=$DEFS" >> $CONFFILE
262 echo -n "STG_LIBS=" >> $CONFFILE
263 for lib in $STG_LIBS
264 do
265     echo -n "$lib " >> $CONFFILE
266 done
267 echo "" >> $CONFFILE
268 echo -n "PLUGINS=" >> $CONFFILE
269 for plugin in $PLUGINS
270 do
271     echo -n "$plugin " >> $CONFFILE
272 done
273 echo "" >> $CONFFILE
274 echo "CXXFLAGS=$CXXFLAGS" >> $CONFFILE
275 echo "CFLAGS=$CFLAGS" >> $CONFFILE
276 echo "LDFLAGS=$LDFLAGS" >> $CONFFILE
277 echo "LIB_THREAD=$LIB_THREAD" >> $CONFFILE
278 echo "PREFIX=$PREFIX" >> $CONFFILE
279 echo "BIN_MODE=$BIN_MODE" >> $CONFFILE
280 echo "DATA_MODE=$DATA_MODE" >> $CONFFILE
281 echo "DIR_MODE=$DIR_MODE" >> $CONFFILE
282 echo "OWNER=$OWNER" >> $CONFFILE
283 echo "VAR_DIR=$VAR_DIR" >> $CONFFILE
284
285 mkdir -p ../stargazer/modules
286
287 $MAKE $MAKEOPTS
288