]> git.stg.codes - stg.git/blob - projects/stargazer/build
Translate and remove some comments
[stg.git] / projects / stargazer / build
1 #!/bin/sh
2
3 #   $Revision: 1.57 $
4 #   $Author: faust $
5 #   $Date: 2010/05/09 12:39:01 $
6 ######################################################
7
8 # Installation path prefix
9
10 #PREFIX=""
11
12 # Binaries access bits
13
14 BIN_MODE=0755
15
16 # Data files access bits
17
18 DATA_MODE=0644
19
20 # Dir access bits
21
22 DIR_MODE=0755
23
24 # Binaries and data files owner
25
26 OWNER=root
27
28 # Name of the firebird's group
29 # Need for chown directory with firebird db
30
31 FIREBIRD_GROUP=firebird
32
33 # Database address
34 # Firebird must have priviledges to read/write for specified path
35
36 DB_ADDRESS="localhost:/var/stargazer/stargazer.fdb"
37
38 # Database user
39 # This user must have priviledges to create database
40
41 DB_USER="stg"
42
43 # Database password
44
45 DB_PASSWORD="123456"
46
47 # Full path to isql utility
48 # Note: Debian users have to specify path to isql-fb utility
49
50 FIREBIRD_ISQL="/opt/firebird/bin/isql"
51
52 OS=unknown
53 sys=`uname -s`
54 release=`uname -r | cut -b1`
55 BUILD_DIR=`pwd`
56 CONFFILE="../../Makefile.conf"
57 VAR_DIR="./inst/var/stargazer"
58 MIN_XMLRPCC_VERSION="1.06.27"
59 XMLRPC_FEATURES="c++2 abyss-server"
60
61
62 if [ -z $1 ]
63 then
64     DEFS="$DEFS -DNDEBUG"
65     MAKEOPTS="-j1"
66 else
67     if [ "$1" = "debug" ]
68     then
69         DEFS="$DEFS -DDEBUG"
70         MAKEOPTS="-j1"
71         CXXFLAGS="$CXXFLAGS -g3 -W -Wall"
72     else
73         DEFS="$DEFS -DNDEBUG"
74         MAKEOPTS="-j1"
75     fi
76 fi
77
78 CXXFLAGS="$CXXFLAGS -I/usr/local/include"
79 LDFLAGS="$LDFLAGS -L/usr/local/lib"
80
81 if [ "$sys" = "Linux" ]
82 then
83     OS=linux
84     release=""
85     ETC_DIR="./inst/linux/etc/stargazer"
86     MAKE="make"
87 fi
88
89 if [ "$sys" = "FreeBSD" ]
90 then
91     case $release in
92         4) OS=bsd;;
93         5) OS=bsd5;;
94         6) OS=bsd5;;
95         7) OS=bsd7;;
96         8) OS=bsd7;;
97         *) OS=unknown;;
98     esac
99     ETC_DIR="./inst/freebsd/etc/stargazer"
100     MAKE="gmake"
101 fi
102
103 if [ "$OS" = "unknown" ]
104 then 
105     echo "#############################################################################"
106     echo "# Sorry, but stargazer currently supported by Linux, FreeBSD 4.x, 5.x, 6.x  #"
107     echo "#############################################################################"
108     exit 1
109 fi
110
111 echo "#############################################################################"
112 echo "       Building STG 2.4 for $sys $release"
113 echo "#############################################################################"
114
115 STG_LIBS="stg_logger.lib 
116           stg_locker.lib
117           crypto.lib 
118           common.lib 
119           script_executer.lib 
120           conffiles.lib
121           pinger.lib 
122           dotconfpp.lib"
123
124 PLUGINS="authorization/ao
125          authorization/inetaccess
126          configuration/sgconfig
127          other/ping
128          other/rscript
129          other/radius
130          store/files
131          capture/cap_nf"
132
133 if [ "$OS" = "linux" ]
134 then
135     DEFS="$DEFS -DLINUX"
136     PLUGINS="$PLUGINS
137              capture/ether_linux
138              capture/ipq_linux"
139     SHELL="/bin/bash"
140     LIB_THREAD=-lpthread
141 else
142     if [ "$OS" = "bsd" ]
143     then
144         DEFS="$DEFS -DFREE_BSD"
145         LIB_THREAD=-lc_r
146     else
147         DEFS="$DEFS -DFREE_BSD5"
148         if [ "$OS" = "bsd7" ]
149         then
150             LIB_THREAD=-lpthread
151         else
152             LIB_THREAD=-lc_r
153         fi
154     fi
155     PLUGINS="$PLUGINS
156              capture/ether_freebsd
157              capture/divert_freebsd"
158     SHELL="/usr/local/bin/bash"
159 fi
160
161 echo -n "Checking gcc... "
162 gcc --version > /dev/null 2> /dev/null
163 if [ $? != 0 ]
164 then
165     echo "FAIL!"
166     echo "gcc not found"
167     exit;
168 fi
169 echo "found"
170 echo -n "Checking g++... "
171 g++ --version > /dev/null 2> /dev/null
172 if [ $? != 0 ]
173 then
174     echo "FAIL!"
175     echo "g++ not found"
176     exit;
177 fi
178 echo "found"
179
180 echo -n "Checking endianess... "
181 echo "int main() { int probe = 0x00000001; return *(char *)&probe; }" > build_check.c
182 gcc $CXXFLAGS $LDFLAGS build_check.c -o fake > /dev/null 2> /dev/null
183 if [ $? != 0 ]
184 then
185     echo "FAIL!"
186     echo "Endianess checking failed"
187     exit;
188 else
189     ./fake
190     if [ $? = 1 ]
191     then
192         ARCH=le
193         CXXFLAGS="$CXXFLAGS -DARCH_LE"
194         echo "Little Endian"
195     else
196         ARCH=be
197         CXXFLAGS="$CXXFLAGS -DARCH_BE"
198         echo "Big Endian"
199     fi
200 fi
201 rm -f fake
202
203 echo -n "Checking for -lexpat... "
204 echo "int main() { return 0; }" > build_check.c
205 gcc $CXXFLAGS $LDFLAGS build_check.c -lexpat -o fake > /dev/null 2> /dev/null
206 if [ $? != 0 ]
207 then
208     CHECK_EXPAT=no
209     echo "no"
210 else
211     CHECK_EXPAT=yes
212     echo "yes"
213 fi
214 rm -f fake
215
216 echo -n "Checking for -lfbclient... "
217 gcc $CXXFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null
218 if [ $? != 0 ]
219 then
220     CHECK_FBCLIENT=no
221     echo "no"
222 else
223     CHECK_FBCLIENT=yes
224     echo "yes"
225 fi
226 rm -f fake
227
228 echo -n "Checking for mysql_config... "
229 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
230 if [ $? != 0 ]
231 then
232     echo "no";
233     echo -n "Checking for -lmysqlclient... "
234     gcc $CXXFLAGS $LDFLAGS build_check.c -lmysqlclient_r $LIB_THREAD -o fake > /dev/null 2> /dev/null
235     if [ $? != 0 ]
236     then
237         CHECK_MYSQLCLIENT=no
238         echo "no"
239     else
240         CHECK_MYSQLCLIENT=yes
241         echo "yes"
242     fi
243     rm -f fake
244 else
245     echo "yes"
246     echo -n "Checking for mysql_config --cflags... "
247     MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
248     if [ $? != 0 ]
249     then
250         CHECK_MYSQLCLIENT=no
251         echo "no"
252     else
253         #CXXFLAGS="$CXXFLAGS $MYSQL_CFLAGS"
254         echo "[$MYSQL_CFLAGS]"
255         echo -n "Checking for mysql_config --libs_r... "
256         MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
257         if [ $? != 0 ]
258         then
259             CHECK_MYSQLCLIENT=no
260             echo "no"
261         else
262             CHECK_MYSQLCLIENT=yes
263             #LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS"
264             echo "[$MYSQL_LDFLAGS]"
265         fi
266     fi
267 fi
268
269 echo -n "Checking for pg_config... "
270 PG_VERSION=`pg_config --version 2> /dev/null`
271 if [ $? != 0 ]
272 then
273     echo "no";
274     echo -n "Checking for -lpq... "
275     gcc $CXXFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null
276     if [ $? != 0 ]
277     then
278         CHECK_PQ=no
279         echo "no"
280     else
281         CHECK_PQ=yes
282         echo "yes"
283     fi
284     rm -f fake
285 else
286     echo "yes";
287     echo -n "Checking for pg_config --includedir... "
288     PG_CFLAGS=`pg_config --includedir 2> /dev/null`
289     if [ $? != 0 ]
290     then
291         CHECK_PQ=no
292         echo "no"
293     else
294         echo "[$PG_CFLAGS]"
295         echo -n "Checking for pg_config --libdir... "
296         PG_LDFLAGS=`pg_config --libdir 2> /dev/null`
297         if [ $? != 0 ]
298         then
299             CHECK_PQ=no
300             echo "no"
301         else
302             CHECK_PQ=yes
303             echo "[$PG_LDFLAGS]"
304         fi
305     fi
306 fi
307
308 echo -n "Checking for xmlrpc-c-config... "
309 XMLRPCC_VERSION=`xmlrpc-c-config $XMLRPC_FEATURES --version 2> /dev/null`
310 if [ $? != 0 ]
311 then
312     echo "no";
313     echo -n "Checking for -lxmlrpc... "
314     gcc $CXXFLAGS $LDFLAGS build_check.c -lxmlrpc $LIB_THREAD -o fake > /dev/null 2> /dev/null
315     if [ $? != 0 ]
316     then
317         CHECK_XMLRPC=no
318         echo "no"
319     else
320         CHECK_XMLRPC=yes
321         echo "yes"
322     fi
323     rm -f fake
324 elif [ "$XMLRPCC_VERSION" \< "$MIN_XMLRPCC_VERSION" ]
325 then
326     echo "no (need at least $MIN_XMLRPCC_VERSION, actual $XMLRPCC_VERSION)";
327     CHECK_XMLRPC=no
328 else
329     echo "yes (version $XMLRPCC_VERSION)";
330     echo -n "Checking for xmlrpc-c-config --cflags... "
331     XMLRPC_CFLAGS=`xmlrpc-c-config $XMLRPC_FEATURES --cflags 2> /dev/null`
332     if [ $? != 0 ]
333     then
334         CHECK_XMLRPC=no
335         echo "no"
336     else
337         echo "[$XMLRPC_CFLAGS]"
338         echo -n "Checking for xmlrpc-c-config --libs... "
339         XMLRPC_LDFLAGS=`xmlrpc-c-config $XMLRPC_FEATURES --libs 2> /dev/null`
340         if [ $? != 0 ]
341         then
342             CHECK_XMLRPC=no
343             echo "no"
344         else
345             CHECK_XMLRPC=yes
346             echo "[$XMLRPC_LDFLAGS]"
347         fi
348     fi
349 fi
350
351 rm -f build_check.c
352
353 if [ "$CHECK_EXPAT" != "yes" ]
354 then
355     echo "-lexpat not found!"
356     exit 1
357 fi
358
359 if [ "$CHECK_FBCLIENT" = "yes" ]
360 then
361     STG_LIBS="$STG_LIBS
362               ibpp.lib"
363     PLUGINS="$PLUGINS
364              store/firebird"
365 fi
366
367 if [ "$CHECK_PQ" = "yes" ]
368 then
369     PLUGINS="$PLUGINS
370              store/postgresql"
371 fi
372
373 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
374 then
375     PLUGINS="$PLUGINS
376              store/mysql"
377 fi
378
379 if [ "$CHECK_XMLRPC" = "yes" ]
380 then
381     PLUGINS="$PLUGINS
382              configuration/rpcconfig"
383 fi
384
385 echo "OS=$OS" > $CONFFILE
386 echo "STG_TIME=yes" >> $CONFFILE
387 echo "DIR_BUILD=$BUILD_DIR" >> $CONFFILE
388 echo "DIR_LIB=\$(DIR_BUILD)/../../lib" >> $CONFFILE
389 echo "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs" >> $CONFFILE
390 echo "DIR_INCLUDE=\$(DIR_BUILD)/../../include" >> $CONFFILE
391 echo "DIR_MOD=\$(DIR_BUILD)/modules" >> $CONFFILE
392 echo "DIR_PLUGINS=\$(DIR_BUILD)/plugins" >> $CONFFILE
393 echo "ARCH=$ARCH" >> $CONFFILE
394 echo "CHECK_EXPAT=$CHECK_EXPAT" >> $CONFFILE
395 echo "CHECK_FBCLIENT=$CHECK_FBCLIENT" >> $CONFFILE
396 echo "CHECK_MYSQLCLIENT=$CHECK_MYSQLCLIENT" >> $CONFFILE
397 echo "CHECK_PQ=$CHECK_PQ" >> $CONFFILE
398 echo "CHECK_XMLRPC=$CHECK_XMLRPC" >> $CONFFILE
399 echo "DEFS=$DEFS" >> $CONFFILE
400 echo -n "STG_LIBS=" >> $CONFFILE
401 for lib in $STG_LIBS
402 do
403     echo -n "$lib " >> $CONFFILE
404 done
405 echo "" >> $CONFFILE
406 echo -n "PLUGINS=" >> $CONFFILE
407 for plugin in $PLUGINS
408 do
409     echo -n "$plugin " >> $CONFFILE
410 done
411 echo "" >> $CONFFILE
412 echo "SHELL=$SHELL" >> $CONFFILE
413 echo "CXXFLAGS=$CXXFLAGS" >> $CONFFILE
414 echo "LDFLAGS=$LDFLAGS" >> $CONFFILE
415 echo "LIB_THREAD=$LIB_THREAD" >> $CONFFILE
416 echo "PREFIX=$PREFIX" >> $CONFFILE
417 echo "BIN_MODE=$BIN_MODE" >> $CONFFILE
418 echo "DATA_MODE=$DATA_MODE" >> $CONFFILE
419 echo "DIR_MODE=$DIR_MODE" >> $CONFFILE
420 echo "OWNER=$OWNER" >> $CONFFILE
421 echo "VAR_DIR=$VAR_DIR" >> $CONFFILE
422 echo "ETC_DIR=$ETC_DIR" >> $CONFFILE
423 echo "DB_ADDRESS=$DB_ADDRESS" >> $CONFFILE
424 echo "DB_USER=$DB_USER" >> $CONFFILE
425 echo "DB_PASSWORD=$DB_PASSWORD" >> $CONFFILE
426 echo "FIREBIRD_ISQL=$FIREBIRD_ISQL" >> $CONFFILE
427 echo "FIREBIRD_GROUP=$FIREBIRD_GROUP" >> $CONFFILE
428
429 mkdir -p modules
430
431 if [ "$1" != "debug" ]
432 then
433     $MAKE $MAKEOPTS
434 else
435     echo -e "\n\n\nDebug build. Type $MAKE explicitly"
436 fi