]> git.stg.codes - stg.git/blob - projects/convertor/build
В заголовочный файл rpcconfig.h добавлен ctime для (используется тип
[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 endianess... "
87 echo "int main() { int probe = 0x00000001; return *(char *)&probe; }" > build_check.c
88 gcc $CXXFLAGS $LDFLAGS -L/usr/lib/mysql -L/usr/local/lib/mysql build_check.c -o fake > /dev/null 2> /dev/null
89 if [ $? != 0 ]
90 then
91     echo "FAIL!"
92     echo "Endianess checking failed"
93     exit;
94 else
95     ./fake
96     if [ $? = 1 ]
97     then
98         ARCH=le
99         CXXFLAGS="$CXXFLAGS -DARCH_LE"
100         echo "Little Endian"
101     else
102         ARCH=be
103         CXXFLAGS="$CXXFLAGS -DARCH_BE"
104         echo "Big Endian"
105     fi
106 fi
107 rm -f fake
108
109 echo -n "Checking for -lfbclient... "
110 gcc $CXXFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null
111 if [ $? != 0 ]
112 then
113     CHECK_FBCLIENT=no
114     echo "no"
115 else
116     CHECK_FBCLIENT=yes
117     echo "yes"
118 fi
119 rm -f fake
120
121 echo -n "Checking for mysql_config... "
122 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
123 if [ $? != 0 ]
124 then
125     echo "no";
126     echo -n "Checking for -lmysqlclient... "
127     gcc $CXXFLAGS $LDFLAGS build_check.c -lmysqlclient_r $LIB_THREAD -o fake > /dev/null 2> /dev/null
128     if [ $? != 0 ]
129     then
130         CHECK_MYSQLCLIENT=no
131         echo "no"
132     else
133         CHECK_MYSQLCLIENT=yes
134         echo "yes"
135     fi
136     rm -f fake
137 else
138     echo "yes"
139     echo -n "Checking for mysql_config --cflags... "
140     MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
141     if [ $? != 0 ]
142     then
143         CHECK_MYSQLCLIENT=no
144         echo "no"
145     else
146         #CXXFLAGS="$CXXFLAGS $MYSQL_CFLAGS"
147         echo "[$MYSQL_CFLAGS]"
148         echo -n "Checking for mysql_config --libs_r... "
149         MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
150         if [ $? != 0 ]
151         then
152             CHECK_MYSQLCLIENT=no
153             echo "no"
154         else
155             CHECK_MYSQLCLIENT=yes
156             #LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS"
157             echo "[$MYSQL_LDFLAGS]"
158         fi
159     fi
160 fi
161
162 echo -n "Checking for pg_config... "
163 PG_VERSION=`pg_config --version 2> /dev/null`
164 if [ $? != 0 ]
165 then
166     echo "no";
167     echo -n "Checking for -lpq... "
168     gcc $CXXFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null
169     if [ $? != 0 ]
170     then
171         CHECK_PQ=no
172         echo "no"
173     else
174         CHECK_PQ=yes
175         echo "yes"
176     fi
177     rm -f fake
178 else
179     echo "yes";
180     echo -n "Checking for pg_config --includedir... "
181     PG_CFLAGS=`pg_config --includedir 2> /dev/null`
182     if [ $? != 0 ]
183     then
184         CHECK_PQ=no
185         echo "no"
186     else
187         echo "[$PG_CFLAGS]"
188         echo -n "Checking for pg_config --libdir... "
189         PG_LDFLAGS=`pg_config --libdir 2> /dev/null`
190         if [ $? != 0 ]
191         then
192             CHECK_PQ=no
193             echo "no"
194         else
195             CHECK_PQ=yes
196             echo "[$PG_LDFLAGS]"
197         fi
198     fi
199 fi
200
201 rm -f build_check.c
202
203 if [ "$CHECK_FBCLIENT" = "yes" ]
204 then
205     STG_LIBS="$STG_LIBS
206           ibpp.lib"
207     PLUGINS="$PLUGINS
208          store/firebird"
209 fi
210
211 if [ "$CHECK_PQ" = "yes" ]
212 then
213     PLUGINS="$PLUGINS
214              store/postgresql"
215 fi
216
217 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
218 then
219     PLUGINS="$PLUGINS
220          store/mysql"
221 fi
222
223 echo "OS=$OS" > $CONFFILE
224 echo "STG_TIME=yes" >> $CONFFILE
225 echo "DIR_BUILD=$BUILD_DIR" >> $CONFFILE
226 echo "DIR_LIB=\$(DIR_BUILD)/../../lib" >> $CONFFILE
227 echo "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs" >> $CONFFILE
228 echo "DIR_INCLUDE=\$(DIR_BUILD)/../../include" >> $CONFFILE
229 echo "DIR_MOD=\$(DIR_BUILD)/../stargazer/modules" >> $CONFFILE
230 echo "DIR_PLUGINS=\$(DIR_BUILD)/../stargazer/plugins" >> $CONFFILE
231 echo "ARCH=$ARCH" >> $CONFFILE
232 echo "CHECK_FBCLIENT=$CHECK_FBCLIENT" >> $CONFFILE
233 echo "DEFS=$DEFS" >> $CONFFILE
234 echo -n "STG_LIBS=" >> $CONFFILE
235 for lib in $STG_LIBS
236 do
237     echo -n "$lib " >> $CONFFILE
238 done
239 echo "" >> $CONFFILE
240 echo -n "PLUGINS=" >> $CONFFILE
241 for plugin in $PLUGINS
242 do
243     echo -n "$plugin " >> $CONFFILE
244 done
245 echo "" >> $CONFFILE
246 echo "SHELL=$SHELL" >> $CONFFILE
247 echo "CXXFLAGS=$CXXFLAGS" >> $CONFFILE
248 echo "LDFLAGS=$LDFLAGS" >> $CONFFILE
249 echo "LIB_THREAD=$LIB_THREAD" >> $CONFFILE
250 echo "PREFIX=$PREFIX" >> $CONFFILE
251 echo "BIN_MODE=$BIN_MODE" >> $CONFFILE
252 echo "DATA_MODE=$DATA_MODE" >> $CONFFILE
253 echo "OWNER=$OWNER" >> $CONFFILE
254 echo "VAR_DIR=$VAR_DIR" >> $CONFFILE
255
256 mkdir -p ../stargazer/modules
257
258 $MAKE $MAKEOPTS
259