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