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