]> git.stg.codes - stg.git/blob - projects/stargazer/build
Remove old script_executer code from the source tree
[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 endianess... "
162 echo "int main() { int probe = 0x00000001; return *(char *)&probe; }" > build_check.c
163 gcc $CXXFLAGS $LDFLAGS build_check.c -o fake > /dev/null 2> /dev/null
164 if [ $? != 0 ]
165 then
166     echo "FAIL!"
167     echo "Endianess checking failed"
168     exit;
169 else
170     ./fake
171     if [ $? = 1 ]
172     then
173         ARCH=le
174         CXXFLAGS="$CXXFLAGS -DARCH_LE"
175         echo "Little Endian"
176     else
177         ARCH=be
178         CXXFLAGS="$CXXFLAGS -DARCH_BE"
179         echo "Big Endian"
180     fi
181 fi
182 rm -f fake
183
184 echo -n "Checking for -lexpat... "
185 echo "int main() { return 0; }" > build_check.c
186 gcc $CXXFLAGS $LDFLAGS build_check.c -lexpat -o fake > /dev/null 2> /dev/null
187 if [ $? != 0 ]
188 then
189     CHECK_EXPAT=no
190     echo "no"
191 else
192     CHECK_EXPAT=yes
193     echo "yes"
194 fi
195 rm -f fake
196
197 echo -n "Checking for -lfbclient... "
198 gcc $CXXFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null
199 if [ $? != 0 ]
200 then
201     CHECK_FBCLIENT=no
202     echo "no"
203 else
204     CHECK_FBCLIENT=yes
205     echo "yes"
206 fi
207 rm -f fake
208
209 echo -n "Checking for mysql_config... "
210 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
211 if [ $? != 0 ]
212 then
213     echo "no";
214     echo -n "Checking for -lmysqlclient... "
215     gcc $CXXFLAGS $LDFLAGS build_check.c -lmysqlclient_r $LIB_THREAD -o fake > /dev/null 2> /dev/null
216     if [ $? != 0 ]
217     then
218         CHECK_MYSQLCLIENT=no
219         echo "no"
220     else
221         CHECK_MYSQLCLIENT=yes
222         echo "yes"
223     fi
224     rm -f fake
225 else
226     echo "yes"
227     echo -n "Checking for mysql_config --cflags... "
228     MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
229     if [ $? != 0 ]
230     then
231         CHECK_MYSQLCLIENT=no
232         echo "no"
233     else
234         #CXXFLAGS="$CXXFLAGS $MYSQL_CFLAGS"
235         echo "[$MYSQL_CFLAGS]"
236         echo -n "Checking for mysql_config --libs_r... "
237         MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
238         if [ $? != 0 ]
239         then
240             CHECK_MYSQLCLIENT=no
241             echo "no"
242         else
243             CHECK_MYSQLCLIENT=yes
244             #LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS"
245             echo "[$MYSQL_LDFLAGS]"
246         fi
247     fi
248 fi
249
250 echo -n "Checking for pg_config... "
251 PG_VERSION=`pg_config --version 2> /dev/null`
252 if [ $? != 0 ]
253 then
254     echo "no";
255     echo -n "Checking for -lpq... "
256     gcc $CXXFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null
257     if [ $? != 0 ]
258     then
259         CHECK_PQ=no
260         echo "no"
261     else
262         CHECK_PQ=yes
263         echo "yes"
264     fi
265     rm -f fake
266 else
267     echo "yes";
268     echo -n "Checking for pg_config --includedir... "
269     PG_CFLAGS=`pg_config --includedir 2> /dev/null`
270     if [ $? != 0 ]
271     then
272         CHECK_PQ=no
273         echo "no"
274     else
275         echo "[$PG_CFLAGS]"
276         echo -n "Checking for pg_config --libdir... "
277         PG_LDFLAGS=`pg_config --libdir 2> /dev/null`
278         if [ $? != 0 ]
279         then
280             CHECK_PQ=no
281             echo "no"
282         else
283             CHECK_PQ=yes
284             echo "[$PG_LDFLAGS]"
285         fi
286     fi
287 fi
288
289 echo -n "Checking for xmlrpc-c-config... "
290 XMLRPCC_VERSION=`xmlrpc-c-config $XMLRPC_FEATURES --version 2> /dev/null`
291 if [ $? != 0 ]
292 then
293     echo "no";
294     echo -n "Checking for -lxmlrpc... "
295     gcc $CXXFLAGS $LDFLAGS build_check.c -lxmlrpc $LIB_THREAD -o fake > /dev/null 2> /dev/null
296     if [ $? != 0 ]
297     then
298         CHECK_XMLRPC=no
299         echo "no"
300     else
301         CHECK_XMLRPC=yes
302         echo "yes"
303     fi
304     rm -f fake
305 elif [ "$XMLRPCC_VERSION" \< "$MIN_XMLRPCC_VERSION" ]
306 then
307     echo "no (need at least $MIN_XMLRPCC_VERSION, actual $XMLRPCC_VERSION)";
308     CHECK_XMLRPC=no
309 else
310     echo "yes (version $XMLRPCC_VERSION)";
311     echo -n "Checking for xmlrpc-c-config --cflags... "
312     XMLRPC_CFLAGS=`xmlrpc-c-config $XMLRPC_FEATURES --cflags 2> /dev/null`
313     if [ $? != 0 ]
314     then
315         CHECK_XMLRPC=no
316         echo "no"
317     else
318         echo "[$XMLRPC_CFLAGS]"
319         echo -n "Checking for xmlrpc-c-config --libs... "
320         XMLRPC_LDFLAGS=`xmlrpc-c-config $XMLRPC_FEATURES --libs 2> /dev/null`
321         if [ $? != 0 ]
322         then
323             CHECK_XMLRPC=no
324             echo "no"
325         else
326             CHECK_XMLRPC=yes
327             echo "[$XMLRPC_LDFLAGS]"
328         fi
329     fi
330 fi
331
332 rm -f build_check.c
333
334 if [ "$CHECK_EXPAT" != "yes" ]
335 then
336     echo "-lexpat not found!"
337     exit 1
338 fi
339
340 if [ "$CHECK_FBCLIENT" = "yes" ]
341 then
342     STG_LIBS="$STG_LIBS
343               ibpp.lib"
344     PLUGINS="$PLUGINS
345              store/firebird"
346 fi
347
348 if [ "$CHECK_PQ" = "yes" ]
349 then
350     PLUGINS="$PLUGINS
351              store/postgresql"
352 fi
353
354 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
355 then
356     PLUGINS="$PLUGINS
357              store/mysql"
358 fi
359
360 if [ "$CHECK_XMLRPC" = "yes" ]
361 then
362     PLUGINS="$PLUGINS
363              configuration/rpcconfig"
364 fi
365
366 echo "OS=$OS" > $CONFFILE
367 echo "STG_TIME=yes" >> $CONFFILE
368 echo "DIR_BUILD=$BUILD_DIR" >> $CONFFILE
369 echo "DIR_LIB=\$(DIR_BUILD)/../../lib" >> $CONFFILE
370 echo "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs" >> $CONFFILE
371 echo "DIR_INCLUDE=\$(DIR_BUILD)/../../include" >> $CONFFILE
372 echo "DIR_MOD=\$(DIR_BUILD)/modules" >> $CONFFILE
373 echo "DIR_PLUGINS=\$(DIR_BUILD)/plugins" >> $CONFFILE
374 echo "ARCH=$ARCH" >> $CONFFILE
375 echo "CHECK_EXPAT=$CHECK_EXPAT" >> $CONFFILE
376 echo "CHECK_FBCLIENT=$CHECK_FBCLIENT" >> $CONFFILE
377 echo "CHECK_MYSQLCLIENT=$CHECK_MYSQLCLIENT" >> $CONFFILE
378 echo "CHECK_PQ=$CHECK_PQ" >> $CONFFILE
379 echo "CHECK_XMLRPC=$CHECK_XMLRPC" >> $CONFFILE
380 echo "DEFS=$DEFS" >> $CONFFILE
381 echo -n "STG_LIBS=" >> $CONFFILE
382 for lib in $STG_LIBS
383 do
384     echo -n "$lib " >> $CONFFILE
385 done
386 echo "" >> $CONFFILE
387 echo -n "PLUGINS=" >> $CONFFILE
388 for plugin in $PLUGINS
389 do
390     echo -n "$plugin " >> $CONFFILE
391 done
392 echo "" >> $CONFFILE
393 echo "SHELL=$SHELL" >> $CONFFILE
394 echo "CXXFLAGS=$CXXFLAGS" >> $CONFFILE
395 echo "LDFLAGS=$LDFLAGS" >> $CONFFILE
396 echo "LIB_THREAD=$LIB_THREAD" >> $CONFFILE
397 echo "PREFIX=$PREFIX" >> $CONFFILE
398 echo "BIN_MODE=$BIN_MODE" >> $CONFFILE
399 echo "DATA_MODE=$DATA_MODE" >> $CONFFILE
400 echo "DIR_MODE=$DIR_MODE" >> $CONFFILE
401 echo "OWNER=$OWNER" >> $CONFFILE
402 echo "VAR_DIR=$VAR_DIR" >> $CONFFILE
403 echo "ETC_DIR=$ETC_DIR" >> $CONFFILE
404 echo "DB_ADDRESS=$DB_ADDRESS" >> $CONFFILE
405 echo "DB_USER=$DB_USER" >> $CONFFILE
406 echo "DB_PASSWORD=$DB_PASSWORD" >> $CONFFILE
407 echo "FIREBIRD_ISQL=$FIREBIRD_ISQL" >> $CONFFILE
408 echo "FIREBIRD_GROUP=$FIREBIRD_GROUP" >> $CONFFILE
409
410 mkdir -p modules
411
412 if [ "$1" != "debug" ]
413 then
414     $MAKE $MAKEOPTS
415 else
416     echo -e "\n\n\nDebug build. Type $MAKE explicitly"
417 fi