5 # $Date: 2010/05/09 12:39:01 $
6 ######################################################
8 # Installation path prefix
12 # Binaries access bits
16 # Data files access bits
24 # Binaries and data files owner
30 release=`uname -r | cut -b1`
32 CONFFILE="../../Makefile.conf"
33 VAR_DIR="./inst/var/stargazer"
34 MIN_XMLRPCC_VERSION="1.06.27"
35 XMLRPC_FEATURES="c++2 abyss-server"
41 MAKEOPTS="$MAKEOPTS -j1"
42 CFLAGS="$CFLAGS -ggdb3 -W -Wall"
43 CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall"
50 CFLAGS="$CFLAGS -I/usr/local/include"
51 CXXFLAGS="$CXXFLAGS -I/usr/local/include"
52 LDFLAGS="$LDFLAGS -L/usr/local/lib"
54 if [ "$sys" = "Linux" ]
58 ETC_DIR="./inst/linux/etc/stargazer"
62 if [ "$sys" = "FreeBSD" ]
71 ETC_DIR="./inst/freebsd/etc/stargazer"
75 if [ "$sys" = "Darwin" ]
78 ETC_DIR="./inst/freebsd/etc/stargazer"
82 if [ "$OS" = "unknown" ]
84 printf "#############################################################################\n"
85 printf "# Sorry, but stargazer currently supported by Linux, FreeBSD 4.x, 5.x, 6.x #\n"
86 printf "#############################################################################\n"
90 printf "#############################################################################\n"
91 printf " Building STG 2.4 for $sys $release\n"
92 printf "#############################################################################\n"
104 PLUGINS="authorization/ao
105 authorization/inetaccess
106 configuration/sgconfig
114 if [ "$OS" = "linux" ]
123 DEFS="$DEFS -DFREE_BSD"
126 if [ "$OS" = "bsd7" ]
128 DEFS="$DEFS -DFREE_BSD5"
131 if [ "$OS" == "darwin" ]
133 DEFS="$DEFS -DDARWIN"
141 capture/ether_freebsd
142 capture/divert_freebsd"
155 printf "Checking CC... "
156 $CC --version > /dev/null 2> /dev/null
160 printf "$CC not found\n"
164 printf "Checking CXX... "
165 $CXX --version > /dev/null 2> /dev/null
169 printf "$CXX not found\n"
174 printf "Checking endianess... "
175 printf "int main() { int probe = 0x00000001; return *(char *)&probe; }\n" > build_check.c
176 $CC $CFLAGS $LDFLAGS build_check.c -o fake
180 printf "Endianess checking failed\n"
187 CXXFLAGS="$CXXFLAGS -DARCH_LE"
188 CFLAGS="$CFLAGS -DARCH_LE"
189 printf "Little Endian\n"
192 CXXFLAGS="$CXXFLAGS -DARCH_BE"
193 CFLAGS="$CFLAGS -DARCH_BE"
194 printf "Big Endian\n"
199 printf "Checking for -lexpat... "
200 printf "int main() { return 0; }\n" > build_check.c
201 $CC $CFLAGS $LDFLAGS build_check.c -lexpat -o fake > /dev/null 2> /dev/null
212 printf "Checking for -lfbclient... "
213 $CC $CFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null
224 printf "Checking for mysql_config... "
225 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
229 printf "Checking for -lmysqlclient... "
230 $CC $CFLAGS $LDFLAGS build_check.c -lmysqlclient_r $LIB_THREAD -o fake > /dev/null 2> /dev/null
236 CHECK_MYSQLCLIENT=yes
242 printf "Checking for mysql_config --cflags... "
243 MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
249 printf "[$MYSQL_CFLAGS]\n"
250 printf "Checking for mysql_config --libs_r... "
251 MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
257 CHECK_MYSQLCLIENT=yes
258 printf "[$MYSQL_LDFLAGS]\n"
263 printf "Checking for pg_config... "
264 PG_VERSION=`pg_config --version 2> /dev/null`
268 printf "Checking for -lpq... "
269 $CC $CFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null
281 printf "Checking for pg_config --includedir... "
282 PG_CFLAGS=`pg_config --includedir 2> /dev/null`
288 printf "[$PG_CFLAGS]\n"
289 printf "Checking for pg_config --libdir... "
290 PG_LDFLAGS=`pg_config --libdir 2> /dev/null`
297 printf "[$PG_LDFLAGS]\n"
302 printf "Checking for xmlrpc-c-config... "
303 XMLRPCC_VERSION=`xmlrpc-c-config $XMLRPC_FEATURES --version 2> /dev/null`
307 printf "Checking for -lxmlrpc... "
308 $CC $CFLAGS $LDFLAGS build_check.c -lxmlrpc $LIB_THREAD -o fake > /dev/null 2> /dev/null
318 elif [ "$XMLRPCC_VERSION" \< "$MIN_XMLRPCC_VERSION" ]
320 printf "no (need at least $MIN_XMLRPCC_VERSION, actual $XMLRPCC_VERSION)\n";
323 printf "yes (version $XMLRPCC_VERSION)\n";
324 printf "Checking for xmlrpc-c-config --cflags... "
325 XMLRPC_CFLAGS=`xmlrpc-c-config $XMLRPC_FEATURES --cflags 2> /dev/null`
331 printf "[$XMLRPC_CFLAGS]\n"
332 printf "Checking for xmlrpc-c-config --libs... "
333 XMLRPC_LDFLAGS=`xmlrpc-c-config $XMLRPC_FEATURES --libs 2> /dev/null`
340 printf "[$XMLRPC_LDFLAGS]\n"
345 printf "Checking for -lpcap... "
346 $CC $CFLAGS $LDFLAGS build_check.c -lpcap -o fake > /dev/null 2> /dev/null
357 if [ "$OS" = "linux" ]
359 printf "Checking for linux/netfilter_ipv4/ip_queue.h... "
360 printf "#include <linux/types.h>\n" > build_check.c
361 printf "#include <linux/netfilter_ipv4/ip_queue.h>\n" >> build_check.c
362 printf "int main() { return 0; }\n" >> build_check.c
363 $CC $CFLAGS $LDFLAGS build_check.c -lexpat -o fake > /dev/null 2> /dev/null
370 DEFS="$DEFS -DHAS_IP_QUEUE_H"
380 if [ "$CHECK_EXPAT" != "yes" ]
382 printf "-lexpat not found!\n"
386 if [ "$CHECK_FBCLIENT" = "yes" ]
394 if [ "$CHECK_PQ" = "yes" ]
400 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
406 if [ "$CHECK_XMLRPC" = "yes" ]
409 configuration/rpcconfig"
412 if [ "$CHECK_PCAP" = "yes" ]
418 printf "OS=$OS\n" > $CONFFILE
419 printf "STG_TIME=yes\n" >> $CONFFILE
420 printf "DEBUG=$DEBUG\n" >> $CONFFILE
421 printf "DIR_BUILD=$BUILD_DIR\n" >> $CONFFILE
422 printf "DIR_LIB=\$(DIR_BUILD)/../../lib\n" >> $CONFFILE
423 printf "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs\n" >> $CONFFILE
424 printf "DIR_INCLUDE=\$(DIR_BUILD)/../../include\n" >> $CONFFILE
425 printf "DIR_MOD=\$(DIR_BUILD)/modules\n" >> $CONFFILE
426 printf "DIR_PLUGINS=\$(DIR_BUILD)/plugins\n" >> $CONFFILE
427 printf "ARCH=$ARCH\n" >> $CONFFILE
428 printf "CHECK_EXPAT=$CHECK_EXPAT\n" >> $CONFFILE
429 printf "CHECK_FBCLIENT=$CHECK_FBCLIENT\n" >> $CONFFILE
430 printf "CHECK_MYSQLCLIENT=$CHECK_MYSQLCLIENT\n" >> $CONFFILE
431 printf "CHECK_PQ=$CHECK_PQ\n" >> $CONFFILE
432 printf "CHECK_XMLRPC=$CHECK_XMLRPC\n" >> $CONFFILE
433 printf "CHECK_PCAP=$CHECK_PCAP\n" >> $CONFFILE
434 printf "DEFS=$DEFS\n" >> $CONFFILE
435 printf "STG_LIBS=" >> $CONFFILE
438 printf "$lib " >> $CONFFILE
440 printf "\n" >> $CONFFILE
441 printf "PLUGINS=" >> $CONFFILE
442 for plugin in $PLUGINS
444 printf "$plugin " >> $CONFFILE
446 printf "\n" >> $CONFFILE
447 printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE
448 printf "CFLAGS=$CFLAGS\n" >> $CONFFILE
449 printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE
450 printf "LIB_THREAD=$LIB_THREAD\n" >> $CONFFILE
451 printf "PREFIX=$PREFIX\n" >> $CONFFILE
452 printf "BIN_MODE=$BIN_MODE\n" >> $CONFFILE
453 printf "DATA_MODE=$DATA_MODE\n" >> $CONFFILE
454 printf "DIR_MODE=$DIR_MODE\n" >> $CONFFILE
455 printf "OWNER=$OWNER\n" >> $CONFFILE
456 printf "VAR_DIR=$VAR_DIR\n" >> $CONFFILE
457 printf "ETC_DIR=$ETC_DIR\n" >> $CONFFILE
461 if [ "$1" != "debug" ]
465 printf "\n\n\nDebug build. Type $MAKE explicitly\n"