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
31 major=`printf "%s" "$release" | cut -d. -f1`
33 CONFFILE="../../Makefile.conf"
34 VAR_DIR="./inst/var/stargazer"
35 MIN_XMLRPCC_VERSION="1.06.27"
36 XMLRPC_FEATURES="c++2 abyss-server"
42 MAKEOPTS="$MAKEOPTS -j1"
43 CFLAGS="$CFLAGS -ggdb3 -W -Wall"
44 CXXFLAGS="$CXXFLAGS -ggdb3 -W -Wall"
51 CFLAGS="$CFLAGS -I/usr/local/include"
52 CXXFLAGS="$CXXFLAGS -I/usr/local/include"
53 LDFLAGS="$LDFLAGS -L/usr/local/lib"
55 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 is currently supported by Linux, FreeBSD and Darwin. #\n"
86 printf "#############################################################################\n"
90 printf "#############################################################################\n"
91 printf " Building STG 2.4 for $sys $release\n"
92 printf "#############################################################################\n"
103 PLUGINS="authorization/ao
104 authorization/inetaccess
105 configuration/sgconfig
112 if [ "$OS" = "linux" ]
122 DEFS="$DEFS -DFREE_BSD"
125 if [ "$OS" = "bsd7" ]
127 DEFS="$DEFS -DFREE_BSD5"
130 if [ "$OS" == "darwin" ]
132 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 "#include <expat.h>\nint 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 iconv 2nd argument... "
213 printf "#include <iconv.h>\nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c
214 $CC $CFLAGS $LDFLAGS -Werror build_check.c $LIBICONV -o fake > /dev/null 2> /dev/null
219 DEFS="$DEFS -DCONST_ICONV"
224 printf "Checking for fb_config... "
225 FB_VERSION=`fb_config --version 2> /dev/null`
229 printf "Checking for -lfbclient... "
230 printf "int main() { return 0; }\n" > build_check.c
231 $CC $CFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null
238 FB_LDFLAGS="-lfbclient"
245 printf "Checking for fb_config --cflags... "
246 FB_CFLAGS=`fb_config --cflags`
252 printf "[$FB_CFLAGS]\n"
253 printf "Checking for fb_config --libs "
254 FB_LDFLAGS=`fb_config --libs`
261 printf "[$FB_LDFLAGS]\n"
267 printf "Checking for mysql_config... "
268 printf "#include <mysql.h>\nint main() { return 0; }\n" > build_check.c
269 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
273 printf "Checking for -lmysqlclient... "
274 $CC $CFLAGS $LDFLAGS build_check.c -lmysqlclient_r $LIB_THREAD -o fake > /dev/null 2> /dev/null
280 CHECK_MYSQLCLIENT=yes
282 MYSQL_LDFLAGS="-lmysqlclient_r"
288 printf "Checking for mysql_config --cflags... "
289 MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
295 printf "[$MYSQL_CFLAGS]\n"
296 printf "Checking for mysql_config --libs_r... "
297 MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
303 CHECK_MYSQLCLIENT=yes
304 printf "[$MYSQL_LDFLAGS]\n"
309 printf "Checking for pg_config... "
310 printf "#include <libpq-fe.h>\nint main() { return 0; }\n" > build_check.c
311 PG_VERSION=`pg_config --version 2> /dev/null`
315 printf "Checking for -lpq... "
316 $CC $CFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null
328 printf "Checking for pg_config --includedir... "
329 PG_CFLAGS="-I"`pg_config --includedir 2> /dev/null`
335 printf "[$PG_CFLAGS]\n"
336 printf "Checking for pg_config --libdir... "
337 PG_LDFLAGS="-L"`pg_config --libdir 2> /dev/null`
344 printf "[$PG_LDFLAGS]\n"
349 printf "Checking for xmlrpc-c-config... "
350 printf "#include <xmlrpc-c/base.hpp>\nint main() { return 0; }\n" > build_check.c
351 XMLRPCC_VERSION=`xmlrpc-c-config $XMLRPC_FEATURES --version 2> /dev/null`
355 printf "Checking for -lxmlrpc... "
356 $CC $CFLAGS $LDFLAGS build_check.c -lxmlrpc $LIB_THREAD -o fake > /dev/null 2> /dev/null
366 elif [ "$XMLRPCC_VERSION" \< "$MIN_XMLRPCC_VERSION" ]
368 printf "no (need at least $MIN_XMLRPCC_VERSION, actual $XMLRPCC_VERSION)\n";
371 printf "yes (version $XMLRPCC_VERSION)\n";
372 printf "Checking for xmlrpc-c-config --cflags... "
373 XMLRPC_CFLAGS=`xmlrpc-c-config $XMLRPC_FEATURES --cflags 2> /dev/null`
379 printf "[$XMLRPC_CFLAGS]\n"
380 printf "Checking for xmlrpc-c-config --libs... "
381 XMLRPC_LDFLAGS=`xmlrpc-c-config $XMLRPC_FEATURES --libs 2> /dev/null`
388 printf "[$XMLRPC_LDFLAGS]\n"
393 printf "Checking for -lnfnetlink... "
394 printf "#include <stdint.h>\n#include <netinet/in.h>\n#include <linux/netfilter.h>\nint main() { return 0; }\n" > build_check.c
395 $CC $CFLAGS $LDFLAGS build_check.c -lnfnetlink -o fake > /dev/null 2> /dev/null
402 NETLINK_LDFLAGS="-lnfnetlink"
407 printf "Checking for -lnetfilter_queue... "
408 printf "#include <stdint.h>\n#include <libnetfilter_queue/libnetfilter_queue.h>\nint main() { return 0; }\n" > build_check.c
409 $CC $CFLAGS $LDFLAGS build_check.c -lnetfilter_queue -o fake > /dev/null 2> /dev/null
416 NFQ_LDFLAGS="-lnetfilter_queue"
421 printf "Checking for -lyajl... "
422 pkg-config --version > /dev/null 2> /dev/null
425 pkg-config --atleast-version=2.0.0 yajl
432 printf `pkg-config --modversion yajl`"\n"
435 printf "#include <stdio.h>\n" > build_check.c
436 printf "#include <yajl/yajl_version.h>\n" >> build_check.c
437 printf "int main() { printf(\"%%d\", yajl_version()); return 0; }\n" >> build_check.c
438 $CC $CFLAGS $LDFLAGS build_check.c -lyajl -o fake > /dev/null 2> /dev/null
444 YAJL_VERSION=`./fake`
445 if [ $YAJL_VERSION -ge 20000 ]
448 printf "${YAJL_VERSION}\n"
451 printf "no. Need at least version 2.0.0, existing version is ${YAJL_VERSION}\n"
457 printf "Checking for boost::scoped_ptr... "
458 printf "#include <boost/scoped_ptr.hpp>\nint main() { boost::scoped_ptr<int> test(new int(1)); return 0; }\n" > build_check.cpp
459 $CXX $CXXFLAGS $LDFLAGS build_check.cpp -o fake # > /dev/null 2> /dev/null
462 CHECK_BOOST_SCOPED_PTR=no
465 CHECK_BOOST_SCOPED_PTR=yes
470 if [ "$OS" = "linux" ]
472 printf "Checking for linux/netfilter_ipv4/ip_queue.h... "
473 printf "#include <linux/types.h>\n" > build_check.c
474 printf "#include <linux/netfilter_ipv4/ip_queue.h>\n" >> build_check.c
475 printf "int main() { return 0; }\n" >> build_check.c
476 $CC $CFLAGS $LDFLAGS build_check.c -o fake > /dev/null 2> /dev/null
483 DEFS="$DEFS -DHAS_IP_QUEUE_H"
492 rm -f build_check.cpp
494 if [ "$CHECK_EXPAT" != "yes" ]
496 printf -- "-lexpat not found!\n"
500 if [ "$CHECK_FBCLIENT" = "yes" ]
508 if [ "$CHECK_PQ" = "yes" ]
514 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
520 if [ "$CHECK_XMLRPC" = "yes" ]
523 configuration/rpcconfig"
526 if [ "$CHECK_NFNETLINK" = "yes" -a "$CHECK_NFQ" = "yes" ]
532 if [ "$CHECK_YAJL" = "yes" -a "$CHECK_BOOST_SCOPED_PTR" = "yes" ]
540 printf "OS=$OS\n" > $CONFFILE
541 printf "STG_TIME=yes\n" >> $CONFFILE
542 printf "DEBUG=$DEBUG\n" >> $CONFFILE
543 printf "DIR_BUILD=$BUILD_DIR\n" >> $CONFFILE
544 printf "DIR_LIB=\$(DIR_BUILD)/../../lib\n" >> $CONFFILE
545 printf "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs\n" >> $CONFFILE
546 printf "DIR_INCLUDE=\$(DIR_BUILD)/../../include\n" >> $CONFFILE
547 printf "DIR_MOD=\$(DIR_BUILD)/modules\n" >> $CONFFILE
548 printf "DIR_PLUGINS=\$(DIR_BUILD)/plugins\n" >> $CONFFILE
549 printf "ARCH=$ARCH\n" >> $CONFFILE
550 printf "CHECK_EXPAT=$CHECK_EXPAT\n" >> $CONFFILE
551 printf "CHECK_FBCLIENT=$CHECK_FBCLIENT\n" >> $CONFFILE
552 if [ "$CHECK_FBCLIENT" = "yes" ]
554 printf "FB_CFLAGS=$FB_CFLAGS\n" >> $CONFFILE
555 printf "FB_LDFLAGS=$FB_LDFLAGS\n" >> $CONFFILE
557 printf "CHECK_MYSQLCLIENT=$CHECK_MYSQLCLIENT\n" >> $CONFFILE
558 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
560 printf "MYSQL_CFLAGS=$MYSQL_CFLAGS\n" >> $CONFFILE
561 printf "MYSQL_LDFLAGS=$MYSQL_LDFLAGS\n" >> $CONFFILE
563 printf "CHECK_PQ=$CHECK_PQ\n" >> $CONFFILE
564 if [ "$CHECK_PQ" = "yes" ]
566 printf "PG_CFLAGS=$PG_CFLAGS\n" >> $CONFFILE
567 printf "PG_LDFLAGS=$PG_LDFLAGS\n" >> $CONFFILE
569 printf "CHECK_XMLRPC=$CHECK_XMLRPC\n" >> $CONFFILE
570 if [ "$CHECK_XMLRPC" = "yes" ]
572 printf "XMLRPC_CFLAGS=$XMLRPC_CFLAGS\n" >> $CONFFILE
573 printf "XMLRPC_LDFLAGS=$XMLRPC_LDFLAGS\n" >> $CONFFILE
575 printf "CHECK_NFNETLINK=$CHECK_NFNETLINK\n" >> $CONFFILE
576 if [ "$CHECK_NFNETLINK" = "yes" ]
578 printf "NETLINK_LDFLAGS=$NETLINK_LDFLAGS\n" >> $CONFFILE
580 printf "CHECK_NFQ=$CHECK_NFQ\n" >> $CONFFILE
581 if [ "$CHECK_NFQ" = "yes" ]
583 printf "NFQ_LDFLAGS=$NFQ_LDFLAGS\n" >> $CONFFILE
585 printf "DEFS=$DEFS\n" >> $CONFFILE
586 printf "STG_LIBS=" >> $CONFFILE
589 printf "$lib " >> $CONFFILE
591 printf "\n" >> $CONFFILE
592 printf "PLUGINS=" >> $CONFFILE
593 for plugin in $PLUGINS
595 printf "$plugin " >> $CONFFILE
597 printf "\n" >> $CONFFILE
598 printf "CC=$CC\n" >> $CONFFILE
599 printf "CXX=$CXX\n" >> $CONFFILE
600 printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE
601 printf "CFLAGS=$CFLAGS\n" >> $CONFFILE
602 printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE
603 printf "LIB_THREAD=$LIB_THREAD\n" >> $CONFFILE
604 printf "LIBICONV=$LIBICONV\n" >> $CONFFILE
605 printf "PREFIX=$PREFIX\n" >> $CONFFILE
606 printf "BIN_MODE=$BIN_MODE\n" >> $CONFFILE
607 printf "DATA_MODE=$DATA_MODE\n" >> $CONFFILE
608 printf "DIR_MODE=$DIR_MODE\n" >> $CONFFILE
609 printf "OWNER=$OWNER\n" >> $CONFFILE
610 printf "VAR_DIR=$VAR_DIR\n" >> $CONFFILE
611 printf "ETC_DIR=$ETC_DIR\n" >> $CONFFILE
615 if [ "$1" != "debug" ]
619 printf "\n\n\nDebug build. Type $MAKE explicitly\n"