From 02a231ed70f2116c607b831c6a48b3490bd9a804 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Sun, 1 Feb 2015 17:34:27 +0200 Subject: [PATCH 1/1] Fixes in dealing with external libs. --- projects/rscriptd/build | 2 + projects/sgauth/build | 2 + projects/sgauthstress/build | 69 +++++++++++++-- projects/sgconf/build | 2 + projects/sgconf_xml/build | 2 + projects/sgconv/build | 65 ++++++++++++-- projects/stargazer/build | 84 ++++++++++++++++--- projects/stargazer/plugins/Makefile.in | 2 +- .../plugins/capture/nfqueue/Makefile | 2 +- .../plugins/configuration/rpcconfig/Makefile | 4 +- .../stargazer/plugins/store/firebird/Makefile | 3 - .../stargazer/plugins/store/mysql/Makefile | 3 - .../plugins/store/postgresql/Makefile | 7 +- 13 files changed, 202 insertions(+), 45 deletions(-) diff --git a/projects/rscriptd/build b/projects/rscriptd/build index 5af638eb..da5c3b5b 100755 --- a/projects/rscriptd/build +++ b/projects/rscriptd/build @@ -172,6 +172,8 @@ do done printf "\n" >> $CONFFILE printf "LIB_THREAD=$LIB_THREAD\n" >> $CONFFILE +printf "CC=$CC\n" >> $CONFFILE +printf "CXX=$CXX\n" >> $CONFFILE printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE printf "CFLAGS=$CFLAGS\n" >> $CONFFILE printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE diff --git a/projects/sgauth/build b/projects/sgauth/build index 53648455..0e7e5f01 100755 --- a/projects/sgauth/build +++ b/projects/sgauth/build @@ -174,6 +174,8 @@ do done printf "\n" >> $CONFFILE printf "LIB_THREAD=$LIB_THREAD\n" >> $CONFFILE +printf "CC=$CC\n" >> $CONFFILE +printf "CXX=$CXX\n" >> $CONFFILE printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE printf "CFLAGS=$CFLAGS\n" >> $CONFFILE printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE diff --git a/projects/sgauthstress/build b/projects/sgauthstress/build index 8f3395f9..1593af28 100755 --- a/projects/sgauthstress/build +++ b/projects/sgauthstress/build @@ -156,17 +156,47 @@ fi rm -f fake rm -f build_check.c -printf "Checking for -lfbclient... " -$CC $CFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null -if [ $? != 0 ] +printf "Checking for fb_config... " +FB_VERSION=`fb_config --version 2> /dev/null` +if [ "$?" != "0" ] then - CHECK_FBCLIENT=no printf "no\n" + printf "Checking for -lfbclient... " + printf "int main() { return 0; }\n" > build_check.c + $CXX $CXXFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null + if [ $? != 0 ] + then + CHECK_FBCLIENT=no + printf "no\n" + else + FB_CFLAGS="" + FB_LDFLAGS="-lfbclient" + CHECK_FBCLIENT=yes + printf "yes\n" + fi + rm -f fake else - CHECK_FBCLIENT=yes printf "yes\n" + printf "Checking for fb_config --cflags... " + FB_CFLAGS=`fb_config --cflags` + if [ "$?" != "0" ] + then + CHECK_FBCLIENT=no + printf "no\n" + else + printf "[$FB_CFLAGS]\n" + printf "Checking for fb_config --libs " + FB_LDFLAGS=`fb_config --libs` + if [ "$?" != "0" ] + then + CHECK_FBCLIENT=no + printf "no\n" + else + CHECK_FBCLIENT=yes + printf "[$FB_LDFLAGS]\n" + fi + fi fi -rm -f fake printf "Checking for mysql_config... " MYSQL_VERSION=`mysql_config --version 2> /dev/null` @@ -208,12 +238,13 @@ else fi printf "Checking for pg_config... " +printf "#include \nint main() { return 0; }\n" > build_check.c PG_VERSION=`pg_config --version 2> /dev/null` if [ $? != 0 ] then printf "no\n"; printf "Checking for -lpq... " - $CC $CFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null + $CXX $CXXFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null if [ $? != 0 ] then CHECK_PQ=no @@ -226,7 +257,7 @@ then else printf "yes\n"; printf "Checking for pg_config --includedir... " - PG_CFLAGS=`pg_config --includedir 2> /dev/null` + PG_CFLAGS="-I"`pg_config --includedir 2> /dev/null` if [ $? != 0 ] then CHECK_PQ=no @@ -234,7 +265,7 @@ else else printf "[$PG_CFLAGS]\n" printf "Checking for pg_config --libdir... " - PG_LDFLAGS=`pg_config --libdir 2> /dev/null` + PG_LDFLAGS="-L"`pg_config --libdir 2> /dev/null` if [ $? != 0 ] then CHECK_PQ=no @@ -278,6 +309,24 @@ printf "DIR_INCLUDE=\$(DIR_BUILD)/../../include\n" >> $CONFFILE printf "DIR_MOD=\$(DIR_BUILD)/../stargazer/modules\n" >> $CONFFILE printf "DIR_PLUGINS=\$(DIR_BUILD)/../stargazer/plugins\n" >> $CONFFILE printf "ARCH=$ARCH\n" >> $CONFFILE +printf "CHECK_FBCLIENT=$CHECK_FBCLIENT\n" >> $CONFFILE +if [ "$CHECK_FBCLIENT" = "yes" ] +then + printf "FB_CFLAGS=$FB_CFLAGS\n" >> $CONFFILE + printf "FB_LDFLAGS=$FB_LDFLAGS\n" >> $CONFFILE +fi +printf "CHECK_MYSQLCLIENT=$CHECK_MYSQLCLIENT\n" >> $CONFFILE +if [ "$CHECK_MYSQLCLIENT" = "yes" ] +then + printf "MYSQL_CFLAGS=$MYSQL_CFLAGS\n" >> $CONFFILE + printf "MYSQL_LDFLAGS=$MYSQL_LDFLAGS\n" >> $CONFFILE +fi +printf "CHECK_PQ=$CHECK_PQ\n" >> $CONFFILE +if [ "$CHECK_PQ" = "yes" ] +then + printf "PG_CFLAGS=$PG_CFLAGS\n" >> $CONFFILE + printf "PG_LDFLAGS=$PG_LDFLAGS\n" >> $CONFFILE +fi printf "DEFS=$DEFS\n" >> $CONFFILE printf "STG_LIBS=" >> $CONFFILE for lib in $STG_LIBS @@ -292,6 +341,8 @@ do done printf "\n" >> $CONFFILE printf "LIB_THREAD=$LIB_THREAD\n" >> $CONFFILE +printf "CC=$CC\n" >> $CONFFILE +printf "CXX=$CXX\n" >> $CONFFILE printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE printf "CFLAGS=$CFLAGS\n" >> $CONFFILE printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE diff --git a/projects/sgconf/build b/projects/sgconf/build index a498e0c5..0b25a1ca 100755 --- a/projects/sgconf/build +++ b/projects/sgconf/build @@ -191,6 +191,8 @@ do done printf "\n" >> $CONFFILE printf "LIB_THREAD=$LIB_THREAD\n" >> $CONFFILE +printf "CC=$CC\n" >> $CONFFILE +printf "CXX=$CXX\n" >> $CONFFILE printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE printf "CFLAGS=$CFLAGS\n" >> $CONFFILE printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE diff --git a/projects/sgconf_xml/build b/projects/sgconf_xml/build index 34cd804f..7b83359b 100755 --- a/projects/sgconf_xml/build +++ b/projects/sgconf_xml/build @@ -184,6 +184,8 @@ do done printf "\n" >> $CONFFILE printf "LIB_THREAD=$LIB_THREAD\n" >> $CONFFILE +printf "CC=$CC\n" >> $CONFFILE +printf "CXX=$CXX\n" >> $CONFFILE printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE printf "CFLAGS=$CFLAGS\n" >> $CONFFILE printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE diff --git a/projects/sgconv/build b/projects/sgconv/build index e8ad9200..d158d320 100755 --- a/projects/sgconv/build +++ b/projects/sgconv/build @@ -160,17 +160,47 @@ else fi rm -f fake -printf "Checking for -lfbclient... " -$CC $CFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null -if [ $? != 0 ] +printf "Checking for fb_config... " +FB_VERSION=`fb_config --version 2> /dev/null` +if [ "$?" != "0" ] then - CHECK_FBCLIENT=no printf "no\n" + printf "Checking for -lfbclient... " + printf "int main() { return 0; }\n" > build_check.c + $CXX $CXXFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null + if [ $? != 0 ] + then + CHECK_FBCLIENT=no + printf "no\n" + else + FB_CFLAGS="" + FB_LDFLAGS="-lfbclient" + CHECK_FBCLIENT=yes + printf "yes\n" + fi + rm -f fake else - CHECK_FBCLIENT=yes printf "yes\n" + printf "Checking for fb_config --cflags... " + FB_CFLAGS=`fb_config --cflags` + if [ "$?" != "0" ] + then + CHECK_FBCLIENT=no + printf "no\n" + else + printf "[$FB_CFLAGS]\n" + printf "Checking for fb_config --libs " + FB_LDFLAGS=`fb_config --libs` + if [ "$?" != "0" ] + then + CHECK_FBCLIENT=no + printf "no\n" + else + CHECK_FBCLIENT=yes + printf "[$FB_LDFLAGS]\n" + fi + fi fi -rm -f fake printf "Checking for mysql_config... " printf "#include \nint main() { return 0; }\n" > build_check.c @@ -219,7 +249,7 @@ if [ $? != 0 ] then printf "no\n"; printf "Checking for -lpq... " - $CC $CFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null + $CXX $CXXFLAGS $LDFLAGS build_check.c -lpq $LIB_THREAD -o fake > /dev/null 2> /dev/null if [ $? != 0 ] then CHECK_PQ=no @@ -232,7 +262,7 @@ then else printf "yes\n"; printf "Checking for pg_config --includedir... " - PG_CFLAGS=`pg_config --includedir 2> /dev/null` + PG_CFLAGS="-I"`pg_config --includedir 2> /dev/null` if [ $? != 0 ] then CHECK_PQ=no @@ -240,7 +270,7 @@ else else printf "[$PG_CFLAGS]\n" printf "Checking for pg_config --libdir... " - PG_LDFLAGS=`pg_config --libdir 2> /dev/null` + PG_LDFLAGS="-L"`pg_config --libdir 2> /dev/null` if [ $? != 0 ] then CHECK_PQ=no @@ -285,6 +315,23 @@ printf "DIR_MOD=\$(DIR_BUILD)/../stargazer/modules\n" >> $CONFFILE printf "DIR_PLUGINS=\$(DIR_BUILD)/../stargazer/plugins\n" >> $CONFFILE printf "ARCH=$ARCH\n" >> $CONFFILE printf "CHECK_FBCLIENT=$CHECK_FBCLIENT\n" >> $CONFFILE +if [ "$CHECK_FBCLIENT" = "yes" ] +then + printf "FB_CFLAGS=$FB_CFLAGS\n" >> $CONFFILE + printf "FB_LDFLAGS=$FB_LDFLAGS\n" >> $CONFFILE +fi +printf "CHECK_MYSQLCLIENT=$CHECK_MYSQLCLIENT\n" >> $CONFFILE +if [ "$CHECK_MYSQLCLIENT" = "yes" ] +then + printf "MYSQL_CFLAGS=$MYSQL_CFLAGS\n" >> $CONFFILE + printf "MYSQL_LDFLAGS=$MYSQL_LDFLAGS\n" >> $CONFFILE +fi +printf "CHECK_PQ=$CHECK_PQ\n" >> $CONFFILE +if [ "$CHECK_PQ" = "yes" ] +then + printf "PG_CFLAGS=$PG_CFLAGS\n" >> $CONFFILE + printf "PG_LDFLAGS=$PG_LDFLAGS\n" >> $CONFFILE +fi printf "DEFS=$DEFS\n" >> $CONFFILE printf "STG_LIBS=" >> $CONFFILE for lib in $STG_LIBS diff --git a/projects/stargazer/build b/projects/stargazer/build index f8fb7363..238ae194 100755 --- a/projects/stargazer/build +++ b/projects/stargazer/build @@ -208,18 +208,48 @@ else fi rm -f fake -printf "Checking for -lfbclient... " -printf "int main() { return 0; }\n" > build_check.c -$CXX $CXXFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null -if [ $? != 0 ] +printf "Checking for fb_config... " +FB_VERSION=`fb_config --version 2> /dev/null` +if [ "$?" != "0" ] then - CHECK_FBCLIENT=no printf "no\n" + printf "Checking for -lfbclient... " + printf "int main() { return 0; }\n" > build_check.c + $CXX $CXXFLAGS $LDFLAGS build_check.c -lfbclient $LIB_THREAD -o fake > /dev/null 2> /dev/null + if [ $? != 0 ] + then + CHECK_FBCLIENT=no + printf "no\n" + else + FB_CFLAGS="" + FB_LDFLAGS="-lfbclient" + CHECK_FBCLIENT=yes + printf "yes\n" + fi + rm -f fake else - CHECK_FBCLIENT=yes printf "yes\n" + printf "Checking for fb_config --cflags... " + FB_CFLAGS=`fb_config --cflags` + if [ "$?" != "0" ] + then + CHECK_FBCLIENT=no + printf "no\n" + else + printf "[$FB_CFLAGS]\n" + printf "Checking for fb_config --libs " + FB_LDFLAGS=`fb_config --libs` + if [ "$?" != "0" ] + then + CHECK_FBCLIENT=no + printf "no\n" + else + CHECK_FBCLIENT=yes + printf "[$FB_LDFLAGS]\n" + fi + fi fi -rm -f fake + printf "Checking for mysql_config... " printf "#include \nint main() { return 0; }\n" > build_check.c @@ -235,6 +265,8 @@ then printf "no\n" else CHECK_MYSQLCLIENT=yes + MYSQL_CFLAGS="" + MYSQL_LDFLAGS="-lmysqlclient_r" printf "yes\n" fi rm -f fake @@ -281,7 +313,7 @@ then else printf "yes\n"; printf "Checking for pg_config --includedir... " - PG_CFLAGS=`pg_config --includedir 2> /dev/null` + PG_CFLAGS="-I"`pg_config --includedir 2> /dev/null` if [ $? != 0 ] then CHECK_PQ=no @@ -289,7 +321,7 @@ else else printf "[$PG_CFLAGS]\n" printf "Checking for pg_config --libdir... " - PG_LDFLAGS=`pg_config --libdir 2> /dev/null` + PG_LDFLAGS="-L"`pg_config --libdir 2> /dev/null` if [ $? != 0 ] then CHECK_PQ=no @@ -354,6 +386,7 @@ then printf "no\n" else CHECK_NFNETLINK=yes + NETLINK_LDFLAGS="-lnfnetlink" printf "yes\n" fi rm -f fake @@ -367,6 +400,7 @@ then printf "no\n" else CHECK_NFQ=yes + NFQ_LDFLAGS="-lnetfilter_queue" printf "yes\n" fi rm -f fake @@ -430,7 +464,6 @@ if [ "$CHECK_NFNETLINK" = "yes" -a "$CHECK_NFQ" = "yes" ] then PLUGINS="$PLUGINS capture/nfqueue" - NFQ_LIBS="-lnfnetlink -lnetfilter_queue" fi printf "OS=$OS\n" > $CONFFILE @@ -445,13 +478,40 @@ printf "DIR_PLUGINS=\$(DIR_BUILD)/plugins\n" >> $CONFFILE printf "ARCH=$ARCH\n" >> $CONFFILE printf "CHECK_EXPAT=$CHECK_EXPAT\n" >> $CONFFILE printf "CHECK_FBCLIENT=$CHECK_FBCLIENT\n" >> $CONFFILE +if [ "$CHECK_FBCLIENT" = "yes" ] +then + printf "FB_CFLAGS=$FB_CFLAGS\n" >> $CONFFILE + printf "FB_LDFLAGS=$FB_LDFLAGS\n" >> $CONFFILE +fi printf "CHECK_MYSQLCLIENT=$CHECK_MYSQLCLIENT\n" >> $CONFFILE +if [ "$CHECK_MYSQLCLIENT" = "yes" ] +then + printf "MYSQL_CFLAGS=$MYSQL_CFLAGS\n" >> $CONFFILE + printf "MYSQL_LDFLAGS=$MYSQL_LDFLAGS\n" >> $CONFFILE +fi printf "CHECK_PQ=$CHECK_PQ\n" >> $CONFFILE +if [ "$CHECK_PQ" = "yes" ] +then + printf "PG_CFLAGS=$PG_CFLAGS\n" >> $CONFFILE + printf "PG_LDFLAGS=$PG_LDFLAGS\n" >> $CONFFILE +fi printf "CHECK_XMLRPC=$CHECK_XMLRPC\n" >> $CONFFILE +if [ "$CHECK_XMLRPC" = "yes" ] +then + printf "XMLRPC_CFLAGS=$XMLRPC_CFLAGS\n" >> $CONFFILE + printf "XMLRPC_LDFLAGS=$XMLRPC_LDFLAGS\n" >> $CONFFILE +fi printf "CHECK_NFNETLINK=$CHECK_NFNETLINK\n" >> $CONFFILE +if [ "$CHECK_NFNETLINK" = "yes" ] +then + printf "NETLINK_LDFLAGS=$NETLINK_LDFLAGS\n" >> $CONFFILE +fi printf "CHECK_NFQ=$CHECK_NFQ\n" >> $CONFFILE +if [ "$CHECK_NFQ" = "yes" ] +then + printf "NFQ_LDFLAGS=$NFQ_LDFLAGS\n" >> $CONFFILE +fi printf "DEFS=$DEFS\n" >> $CONFFILE -printf "NFQ_LIBS=$NFQ_LIBS\n" >> $CONFFILE printf "STG_LIBS=" >> $CONFFILE for lib in $STG_LIBS do @@ -464,6 +524,8 @@ do printf "$plugin " >> $CONFFILE done printf "\n" >> $CONFFILE +printf "CC=$CC\n" >> $CONFFILE +printf "CXX=$CXX\n" >> $CONFFILE printf "CXXFLAGS=$CXXFLAGS\n" >> $CONFFILE printf "CFLAGS=$CFLAGS\n" >> $CONFFILE printf "LDFLAGS=$LDFLAGS\n" >> $CONFFILE diff --git a/projects/stargazer/plugins/Makefile.in b/projects/stargazer/plugins/Makefile.in index efb5d984..e1ced728 100644 --- a/projects/stargazer/plugins/Makefile.in +++ b/projects/stargazer/plugins/Makefile.in @@ -25,7 +25,7 @@ endif all: $(PROG) $(PROG): $(OBJS) - $(CXX) $^ $(STGLIBS_PATHS) $(STGLIBS_LIBS) $(LIBS) $(LDFLAGS) -o $(PROG) + $(CXX) $^ $(LDFLAGS) $(STGLIBS_PATHS) $(STGLIBS_LIBS) $(LIBS) -o $(PROG) $(LN) -fs "`pwd`/$(PROG)" $(DIR_MOD)/$(PROG) clean: diff --git a/projects/stargazer/plugins/capture/nfqueue/Makefile b/projects/stargazer/plugins/capture/nfqueue/Makefile index a9f4a803..05a87af6 100644 --- a/projects/stargazer/plugins/capture/nfqueue/Makefile +++ b/projects/stargazer/plugins/capture/nfqueue/Makefile @@ -4,7 +4,7 @@ PROG = mod_cap_nfqueue.so SRCS = ./nfqueue.cpp -LIBS += $(NFQ_LIBS) $(LIB_THREAD) +LIBS += $(NFQ_LDFLAGS) $(NETLINK_LDFLAGS) $(LIB_THREAD) STGLIBS = common \ logger diff --git a/projects/stargazer/plugins/configuration/rpcconfig/Makefile b/projects/stargazer/plugins/configuration/rpcconfig/Makefile index cbbe79c6..732b0e11 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/Makefile +++ b/projects/stargazer/plugins/configuration/rpcconfig/Makefile @@ -15,9 +15,7 @@ SRCS = ./rpcconfig.cpp \ ./admins_methods.cpp \ ./messages_methods.cpp -XMLRPC_C_LIBS = $(shell xmlrpc-c-config c++2 abyss-server --libs) - -LIBS += $(XMLRPC_C_LIBS) \ +LIBS += $(XMLRPC_LDFLAGS) \ $(LIB_THREAD) ifneq ($(OS),linux) diff --git a/projects/stargazer/plugins/store/firebird/Makefile b/projects/stargazer/plugins/store/firebird/Makefile index a6fb9ccd..cbe8156b 100644 --- a/projects/stargazer/plugins/store/firebird/Makefile +++ b/projects/stargazer/plugins/store/firebird/Makefile @@ -22,9 +22,6 @@ STGLIBS = ibpp \ logger \ crypto -FB_CFLAGS = $(shell fb_config --cflags) -FB_LDFLAGS = $(shell fb_config --libs) - CXXFLAGS += $(FB_CFLAGS) LDFLAGS += $(FB_LDFLAGS) diff --git a/projects/stargazer/plugins/store/mysql/Makefile b/projects/stargazer/plugins/store/mysql/Makefile index 25a29798..d676c81a 100644 --- a/projects/stargazer/plugins/store/mysql/Makefile +++ b/projects/stargazer/plugins/store/mysql/Makefile @@ -12,9 +12,6 @@ STGLIBS = common \ crypto \ logger -MYSQL_CFLAGS = $(shell mysql_config --cflags) -MYSQL_LDFLAGS = $(shell mysql_config --libs_r) - CXXFLAGS += $(MYSQL_CFLAGS) LIBS += $(MYSQL_LDFLAGS) diff --git a/projects/stargazer/plugins/store/postgresql/Makefile b/projects/stargazer/plugins/store/postgresql/Makefile index ef090f17..b59fbbfa 100644 --- a/projects/stargazer/plugins/store/postgresql/Makefile +++ b/projects/stargazer/plugins/store/postgresql/Makefile @@ -19,11 +19,8 @@ STGLIBS = common \ crypto \ logger -PG_CFLAGS = $(shell pg_config --includedir) -PG_LDFLAGS = $(shell pg_config --libdir) - -CXXFLAGS += -I $(PG_CFLAGS) -LDFLAGS += -L $(PG_LDFLAGS) +CXXFLAGS += $(PG_CFLAGS) +LDFLAGS += $(PG_LDFLAGS) LIBS += -lpq -- 2.44.2