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