]> git.stg.codes - stg.git/blob - projects/sgconv/build
Convertor project is renamed to "sgconv".
[stg.git] / projects / sgconv / 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 DEBUG="yes"
24
25 if [ "$sys" = "Linux" ]
26 then
27     OS=linux
28     release=""
29     MAKE="make"
30 fi
31
32 if [ "$sys" = "FreeBSD" ]
33 then
34     case $release in
35         4) OS=bsd;;
36         5) OS=bsd5;;
37         6) OS=bsd5;;
38         7) OS=bsd7;;
39         8) OS=bsd7;;
40         9) OS=bsd7;;
41         *) OS=unknown;;
42     esac
43     MAKE="gmake"
44 fi
45
46 if [ "$OS" = "unknown" ]
47 then 
48     echo "#############################################################################"
49     echo "# Sorry, but convertor currently supported by Linux, FreeBSD 4.x, 5.x, 6.x  #"
50     echo "#############################################################################"
51     exit 1
52 fi
53
54 echo "#############################################################################"
55 echo "       Building convertor for $sys $release"
56 echo "#############################################################################"
57
58 STG_LIBS="logger.lib 
59           locker.lib
60           crypto.lib 
61           common.lib 
62           conffiles.lib
63           dotconfpp.lib"
64
65 PLUGINS="store/files"
66
67 if [ "$OS" = "linux" ]
68 then
69     DEFS="$DEFS -DLINUX"
70     LIB_THREAD=-lpthread
71 else
72     if [ "$OS" = "bsd" ]
73     then
74         DEFS="$DEFS -DFREE_BSD"
75         LIB_THREAD=-lc_r
76     else
77         DEFS="$DEFS -DFREE_BSD5"
78         if [ "$OS" = "bsd7" ]
79         then
80             LIB_THREAD=-lpthread
81         else
82             LIB_THREAD=-lc_r
83         fi
84     fi
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 "DEBUG=$DEBUG" >> $CONFFILE
256 echo "DIR_BUILD=$BUILD_DIR" >> $CONFFILE
257 echo "DIR_LIB=\$(DIR_BUILD)/../../lib" >> $CONFFILE
258 echo "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs" >> $CONFFILE
259 echo "DIR_INCLUDE=\$(DIR_BUILD)/../../include" >> $CONFFILE
260 echo "DIR_MOD=\$(DIR_BUILD)/../stargazer/modules" >> $CONFFILE
261 echo "DIR_PLUGINS=\$(DIR_BUILD)/../stargazer/plugins" >> $CONFFILE
262 echo "ARCH=$ARCH" >> $CONFFILE
263 echo "CHECK_FBCLIENT=$CHECK_FBCLIENT" >> $CONFFILE
264 echo "DEFS=$DEFS" >> $CONFFILE
265 echo -n "STG_LIBS=" >> $CONFFILE
266 for lib in $STG_LIBS
267 do
268     echo -n "$lib " >> $CONFFILE
269 done
270 echo "" >> $CONFFILE
271 echo -n "PLUGINS=" >> $CONFFILE
272 for plugin in $PLUGINS
273 do
274     echo -n "$plugin " >> $CONFFILE
275 done
276 echo "" >> $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