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
113 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"
142 capture/ether_freebsd
143 capture/divert_freebsd"
156 printf "Checking CC... "
157 $CC --version > /dev/null 2> /dev/null
161 printf "$CC not found\n"
165 printf "Checking CXX... "
166 $CXX --version > /dev/null 2> /dev/null
170 printf "$CXX not found\n"
175 printf "Checking endianess... "
176 printf "int main() { int probe = 0x00000001; return *(char *)&probe; }\n" > build_check.c
177 $CC $CFLAGS $LDFLAGS build_check.c -o fake
181 printf "Endianess checking failed\n"
188 CXXFLAGS="$CXXFLAGS -DARCH_LE"
189 CFLAGS="$CFLAGS -DARCH_LE"
190 printf "Little Endian\n"
193 CXXFLAGS="$CXXFLAGS -DARCH_BE"
194 CFLAGS="$CFLAGS -DARCH_BE"
195 printf "Big Endian\n"
200 printf "Checking for -lexpat... "
201 printf "#include <expat.h>\nint main() { return 0; }\n" > build_check.c
202 $CC $CFLAGS $LDFLAGS build_check.c -lexpat -o fake > /dev/null 2> /dev/null
213 printf "Checking for iconv 2nd argument... "
214 printf "#include <iconv.h>\nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c
215 $CC $CFLAGS $LDFLAGS -Werror build_check.c $LIBICONV -o fake > /dev/null 2> /dev/null
220 DEFS="$DEFS -DCONST_ICONV"
225 printf "Checking for fb_config... "
226 FB_VERSION=`fb_config --version 2> /dev/null`
230 printf "Checking for -lfbclient... "
231 printf "int main() { return 0; }\n" > build_check.c
232 $CC $CFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null
239 FB_LDFLAGS="-lfbclient"
246 printf "Checking for fb_config --cflags... "
247 FB_CFLAGS=`fb_config --cflags`
253 printf "[$FB_CFLAGS]\n"
254 printf "Checking for fb_config --libs "
255 FB_LDFLAGS=`fb_config --libs`
262 printf "[$FB_LDFLAGS]\n"
268 printf "Checking for mysql_config... "
269 printf "#include <mysql.h>\nint main() { return 0; }\n" > build_check.c
270 MYSQL_VERSION=`mysql_config --version 2> /dev/null`
274 printf "Checking for -lmysqlclient... "
275 $CC $CFLAGS $LDFLAGS build_check.c -lmysqlclient_r $LIB_THREAD -o fake > /dev/null 2> /dev/null
281 CHECK_MYSQLCLIENT=yes
283 MYSQL_LDFLAGS="-lmysqlclient_r"
289 printf "Checking for mysql_config --cflags... "
290 MYSQL_CFLAGS=`mysql_config --cflags 2> /dev/null`
296 printf "[$MYSQL_CFLAGS]\n"
297 printf "Checking for mysql_config --libs_r... "
298 MYSQL_LDFLAGS=`mysql_config --libs_r 2> /dev/null`
304 CHECK_MYSQLCLIENT=yes
305 printf "[$MYSQL_LDFLAGS]\n"
310 printf "Checking for pg_config... "
311 printf "#include <libpq-fe.h>\nint main() { return 0; }\n" > build_check.c
312 PG_VERSION=`pg_config --version 2> /dev/null`
316 printf "Checking for -lpq... "
317 $CC $CFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null
329 printf "Checking for pg_config --includedir... "
330 PG_CFLAGS="-I"`pg_config --includedir 2> /dev/null`
336 printf "[$PG_CFLAGS]\n"
337 printf "Checking for pg_config --libdir... "
338 PG_LDFLAGS="-L"`pg_config --libdir 2> /dev/null`
345 printf "[$PG_LDFLAGS]\n"
350 printf "Checking for xmlrpc-c-config... "
351 printf "#include <xmlrpc-c/base.hpp>\nint main() { return 0; }\n" > build_check.c
352 XMLRPCC_VERSION=`xmlrpc-c-config $XMLRPC_FEATURES --version 2> /dev/null`
356 printf "Checking for -lxmlrpc... "
357 $CC $CFLAGS $LDFLAGS build_check.c -lxmlrpc $LIB_THREAD -o fake > /dev/null 2> /dev/null
367 elif [ "$XMLRPCC_VERSION" \< "$MIN_XMLRPCC_VERSION" ]
369 printf "no (need at least $MIN_XMLRPCC_VERSION, actual $XMLRPCC_VERSION)\n";
372 printf "yes (version $XMLRPCC_VERSION)\n";
373 printf "Checking for xmlrpc-c-config --cflags... "
374 XMLRPC_CFLAGS=`xmlrpc-c-config $XMLRPC_FEATURES --cflags 2> /dev/null`
380 printf "[$XMLRPC_CFLAGS]\n"
381 printf "Checking for xmlrpc-c-config --libs... "
382 XMLRPC_LDFLAGS=`xmlrpc-c-config $XMLRPC_FEATURES --libs 2> /dev/null`
389 printf "[$XMLRPC_LDFLAGS]\n"
394 printf "Checking for -lnfnetlink... "
395 printf "#include <stdint.h>\n#include <netinet/in.h>\n#include <linux/netfilter.h>\nint main() { return 0; }\n" > build_check.c
396 $CC $CFLAGS $LDFLAGS build_check.c -lnfnetlink -o fake > /dev/null 2> /dev/null
403 NETLINK_LDFLAGS="-lnfnetlink"
408 printf "Checking for -lnetfilter_queue... "
409 printf "#include <stdint.h>\n#include <libnetfilter_queue/libnetfilter_queue.h>\nint main() { return 0; }\n" > build_check.c
410 $CC $CFLAGS $LDFLAGS build_check.c -lnetfilter_queue -o fake > /dev/null 2> /dev/null
417 NFQ_LDFLAGS="-lnetfilter_queue"
422 if [ "$OS" = "linux" ]
424 printf "Checking for linux/netfilter_ipv4/ip_queue.h... "
425 printf "#include <linux/types.h>\n" > build_check.c
426 printf "#include <linux/netfilter_ipv4/ip_queue.h>\n" >> build_check.c
427 printf "int main() { return 0; }\n" >> build_check.c
428 $CC $CFLAGS $LDFLAGS build_check.c -o fake > /dev/null 2> /dev/null
435 DEFS="$DEFS -DHAS_IP_QUEUE_H"
445 if [ "$CHECK_EXPAT" != "yes" ]
447 printf -- "-lexpat not found!\n"
451 if [ "$CHECK_FBCLIENT" = "yes" ]
459 if [ "$CHECK_PQ" = "yes" ]
465 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
471 if [ "$CHECK_XMLRPC" = "yes" ]
474 configuration/rpcconfig"
477 if [ "$CHECK_NFNETLINK" = "yes" -a "$CHECK_NFQ" = "yes" ]
483 printf "OS=$OS\n" > $CONFFILE
484 printf "STG_TIME=yes\n" >> $CONFFILE
485 printf "DEBUG=$DEBUG\n" >> $CONFFILE
486 printf "DIR_BUILD=$BUILD_DIR\n" >> $CONFFILE
487 printf "DIR_LIB=\$(DIR_BUILD)/../../lib\n" >> $CONFFILE
488 printf "DIR_LIBSRC=\$(DIR_BUILD)/../../stglibs\n" >> $CONFFILE
489 printf "DIR_INCLUDE=\$(DIR_BUILD)/../../include\n" >> $CONFFILE
490 printf "DIR_MOD=\$(DIR_BUILD)/modules\n" >> $CONFFILE
491 printf "DIR_PLUGINS=\$(DIR_BUILD)/plugins\n" >> $CONFFILE
492 printf "ARCH=$ARCH\n" >> $CONFFILE
493 printf "CHECK_EXPAT=$CHECK_EXPAT\n" >> $CONFFILE
494 printf "CHECK_FBCLIENT=$CHECK_FBCLIENT\n" >> $CONFFILE
495 if [ "$CHECK_FBCLIENT" = "yes" ]
497 printf "FB_CFLAGS=$FB_CFLAGS\n" >> $CONFFILE
498 printf "FB_LDFLAGS=$FB_LDFLAGS\n" >> $CONFFILE
500 printf "CHECK_MYSQLCLIENT=$CHECK_MYSQLCLIENT\n" >> $CONFFILE
501 if [ "$CHECK_MYSQLCLIENT" = "yes" ]
503 printf "MYSQL_CFLAGS=$MYSQL_CFLAGS\n" >> $CONFFILE
504 printf "MYSQL_LDFLAGS=$MYSQL_LDFLAGS\n" >> $CONFFILE
506 printf "CHECK_PQ=$CHECK_PQ\n" >> $CONFFILE
507 if [ "$CHECK_PQ" = "yes" ]
509 printf "PG_CFLAGS=$PG_CFLAGS\n" >> $CONFFILE
510 printf "PG_LDFLAGS=$PG_LDFLAGS\n" >> $CONFFILE
512 printf "CHECK_XMLRPC=$CHECK_XMLRPC\n" >> $CONFFILE
513 if [ "$CHECK_XMLRPC" = "yes" ]
515 printf "XMLRPC_CFLAGS=$XMLRPC_CFLAGS\n" >> $CONFFILE
516 printf "XMLRPC_LDFLAGS=$XMLRPC_LDFLAGS\n" >> $CONFFILE
518 printf "CHECK_NFNETLINK=$CHECK_NFNETLINK\n" >> $CONFFILE
519 if [ "$CHECK_NFNETLINK" = "yes" ]
521 printf "NETLINK_LDFLAGS=$NETLINK_LDFLAGS\n" >> $CONFFILE
523 printf "CHECK_NFQ=$CHECK_NFQ\n" >> $CONFFILE
524 if [ "$CHECK_NFQ" = "yes" ]
526 printf "NFQ_LDFLAGS=$NFQ_LDFLAGS\n" >> $CONFFILE
528 printf "DEFS=$DEFS\n" >> $CONFFILE
529 printf "STG_LIBS=" >> $CONFFILE
532 printf "$lib " >> $CONFFILE
534 printf "\n" >> $CONFFILE
535 printf "PLUGINS=" >> $CONFFILE
536 for plugin in $PLUGINS
538 printf "$plugin " >> $CONFFILE
540 printf "\n" >> $CONFFILE
541 printf "CC=$CC\n" >> $CONFFILE
542 printf "CXX=$CXX\n" >> $CONFFILE
543 printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE
544 printf "CFLAGS=$CFLAGS\n" >> $CONFFILE
545 printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE
546 printf "LIB_THREAD=$LIB_THREAD\n" >> $CONFFILE
547 printf "LIBICONV=$LIBICONV\n" >> $CONFFILE
548 printf "PREFIX=$PREFIX\n" >> $CONFFILE
549 printf "BIN_MODE=$BIN_MODE\n" >> $CONFFILE
550 printf "DATA_MODE=$DATA_MODE\n" >> $CONFFILE
551 printf "DIR_MODE=$DIR_MODE\n" >> $CONFFILE
552 printf "OWNER=$OWNER\n" >> $CONFFILE
553 printf "VAR_DIR=$VAR_DIR\n" >> $CONFFILE
554 printf "ETC_DIR=$ETC_DIR\n" >> $CONFFILE
558 if [ "$1" != "debug" ]
562 printf "\n\n\nDebug build. Type $MAKE explicitly\n"