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