diff --git a/configure.ac b/configure.ac index 43d671bc6e..496c1133c1 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,14 @@ AC_TRY_LINK([],[], ]) LDFLAGS=$LDFLAGS_SAVED +# allow building programs with static link. we need to make it selective +# because loadable modules cannot be statically linked. +AC_ARG_ENABLE([static-link], +AC_HELP_STRING([--enable-static-link], + [build programs with static link [[default=no]]]), + [enable_static_link=yes], [enable_static_link=no]) +AM_CONDITIONAL(USE_STATIC_LINK, test $enable_static_link = yes) + # OS dependent compiler flags case "$host" in *-solaris*) @@ -409,6 +417,7 @@ AC_CONFIG_FILES([Makefile src/lib/bench/example/Makefile src/lib/bench/tests/Makefile src/lib/cc/Makefile + src/lib/cc/tests/Makefile src/lib/python/Makefile src/lib/python/isc/Makefile src/lib/python/isc/datasrc/Makefile @@ -425,6 +434,7 @@ AC_CONFIG_FILES([Makefile src/lib/dns/python/Makefile src/lib/dns/python/tests/Makefile src/lib/exceptions/Makefile + src/lib/exceptions/tests/Makefile src/lib/datasrc/Makefile src/lib/datasrc/tests/Makefile src/lib/xfr/Makefile diff --git a/src/bin/auth/Makefile.am b/src/bin/auth/Makefile.am index 9952f1970e..daa2d26f5a 100644 --- a/src/bin/auth/Makefile.am +++ b/src/bin/auth/Makefile.am @@ -8,6 +8,10 @@ AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin AM_CXXFLAGS = $(B10_CXXFLAGS) +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + pkglibexecdir = $(libexecdir)/@PACKAGE@ CLEANFILES = *.gcno *.gcda auth.spec spec_config.h @@ -50,13 +54,13 @@ b10_auth_SOURCES = auth_srv.cc auth_srv.h b10_auth_SOURCES += change_user.cc change_user.h b10_auth_SOURCES += common.h b10_auth_SOURCES += main.cc -b10_auth_LDADD = $(top_builddir)/src/lib/datasrc/.libs/libdatasrc.a -b10_auth_LDADD += $(top_builddir)/src/lib/dns/.libs/libdns++.a -b10_auth_LDADD += $(top_builddir)/src/lib/config/.libs/libcfgclient.a -b10_auth_LDADD += $(top_builddir)/src/lib/cc/.libs/libcc.a -b10_auth_LDADD += $(top_builddir)/src/lib/exceptions/.libs/libexceptions.a +b10_auth_LDADD = $(top_builddir)/src/lib/datasrc/libdatasrc.la +b10_auth_LDADD += $(top_builddir)/src/lib/dns/libdns++.la +b10_auth_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la +b10_auth_LDADD += $(top_builddir)/src/lib/cc/libcc.la +b10_auth_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la b10_auth_LDADD += $(top_builddir)/src/bin/auth/libasio_link.a -b10_auth_LDADD += $(top_builddir)/src/lib/xfr/.libs/libxfr.a +b10_auth_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la b10_auth_LDADD += $(SQLITE_LIBS) # TODO: config.h.in is wrong because doesn't honor pkgdatadir diff --git a/src/bin/auth/tests/Makefile.am b/src/bin/auth/tests/Makefile.am index ab118abf93..53cd05933a 100644 --- a/src/bin/auth/tests/Makefile.am +++ b/src/bin/auth/tests/Makefile.am @@ -5,6 +5,10 @@ AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\" AM_CXXFLAGS = $(B10_CXXFLAGS) +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + CLEANFILES = *.gcno *.gcda TESTS = @@ -22,13 +26,13 @@ run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) run_unittests_LDADD = $(GTEST_LDADD) run_unittests_LDADD += $(SQLITE_LIBS) -run_unittests_LDADD += $(top_builddir)/src/lib/datasrc/.libs/libdatasrc.a -run_unittests_LDADD += $(top_builddir)/src/lib/dns/.libs/libdns++.a -run_unittests_LDADD += $(top_builddir)/src/lib/config/.libs/libcfgclient.a -run_unittests_LDADD += $(top_builddir)/src/lib/cc/.libs/libcc.a -run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/.libs/libexceptions.a +run_unittests_LDADD += $(top_builddir)/src/lib/datasrc/libdatasrc.la +run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la +run_unittests_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la +run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la +run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la run_unittests_LDADD += $(top_builddir)/src/bin/auth/libasio_link.a -run_unittests_LDADD += $(top_builddir)/src/lib/xfr/.libs/libxfr.a +run_unittests_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la endif noinst_PROGRAMS = $(TESTS) diff --git a/src/bin/host/Makefile.am b/src/bin/host/Makefile.am index ac703b42c9..3879562520 100644 --- a/src/bin/host/Makefile.am +++ b/src/bin/host/Makefile.am @@ -3,12 +3,16 @@ AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns AM_CXXFLAGS = $(B10_CXXFLAGS) +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + CLEANFILES = *.gcno *.gcda bin_PROGRAMS = host host_SOURCES = host.cc -host_LDADD = $(top_builddir)/src/lib/dns/.libs/libdns++.a -host_LDADD += $(top_builddir)/src/lib/exceptions/.libs/libexceptions.a +host_LDADD = $(top_builddir)/src/lib/dns/libdns++.la +host_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la #man_MANS = host.1 #EXTRA_DIST = $(man_MANS) host.xml diff --git a/src/bin/xfrin/tests/Makefile.am b/src/bin/xfrin/tests/Makefile.am index 8395f364e9..1d64225653 100644 --- a/src/bin/xfrin/tests/Makefile.am +++ b/src/bin/xfrin/tests/Makefile.am @@ -7,6 +7,6 @@ PYCOVERAGE = $(PYTHON) check-local: for pytest in $(PYTESTS) ; do \ echo Running test: $$pytest ; \ - env PYTHONPATH=$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/lib/dns/python/.libs:$(abs_top_builddir)/src/bin/xfrin:$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python \ + env PYTHONPATH=$(abs_top_builddir)/src/lib/dns/python/.libs:$(abs_top_builddir)/src/bin/xfrin:$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python \ $(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \ done diff --git a/src/bin/xfrout/tests/Makefile.am b/src/bin/xfrout/tests/Makefile.am index c1c613ea89..fb344aac24 100644 --- a/src/bin/xfrout/tests/Makefile.am +++ b/src/bin/xfrout/tests/Makefile.am @@ -7,6 +7,6 @@ PYCOVERAGE = $(PYTHON) check-local: for pytest in $(PYTESTS) ; do \ echo Running test: $$pytest ; \ - env PYTHONPATH=$(abs_top_builddir)/src/bin/xfrout:$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/lib/dns/python/.libs:$(abs_top_builddir)/src/lib/xfr/.libs \ + env PYTHONPATH=$(abs_top_builddir)/src/bin/xfrout:$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/lib/dns/python/.libs:$(abs_top_builddir)/src/lib/xfr/.libs \ $(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \ done diff --git a/src/lib/bench/example/Makefile.am b/src/lib/bench/example/Makefile.am index 8257b3576d..0563380d4d 100644 --- a/src/lib/bench/example/Makefile.am +++ b/src/lib/bench/example/Makefile.am @@ -1,5 +1,9 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + CLEANFILES = *.gcno *.gcda noinst_PROGRAMS = search_bench diff --git a/src/lib/bench/tests/Makefile.am b/src/lib/bench/tests/Makefile.am index 8fed7ea924..bdae9ded9d 100644 --- a/src/lib/bench/tests/Makefile.am +++ b/src/lib/bench/tests/Makefile.am @@ -2,6 +2,10 @@ AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\" AM_CXXFLAGS = $(B10_CXXFLAGS) +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + CLEANFILES = *.gcno *.gcda TESTS = diff --git a/src/lib/cc/Makefile.am b/src/lib/cc/Makefile.am index 320ba9c125..88c8890e55 100644 --- a/src/lib/cc/Makefile.am +++ b/src/lib/cc/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS = . tests + AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns @@ -19,20 +21,3 @@ session_config.h: session_config.h.pre $(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" session_config.h.pre >$@ BUILT_SOURCES = session_config.h - -TESTS = -if HAVE_GTEST -TESTS += run_unittests -# (TODO: these need to be completed and moved to tests/) -run_unittests_SOURCES = data_unittests.cc session_unittests.cc run_unittests.cc -run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) -# TODO: remove PTHREAD_LDFLAGS (and from configure too) -run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) $(PTHREAD_LDFLAGS) - -run_unittests_LDADD = libcc.la $(GTEST_LDADD) -run_unittests_LDADD += $(top_builddir)/src/lib/dns/.libs/libdns++.a -run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/.libs/libexceptions.a - -endif - -noinst_PROGRAMS = $(TESTS) diff --git a/src/lib/cc/tests/Makefile.am b/src/lib/cc/tests/Makefile.am new file mode 100644 index 0000000000..47ff9f948e --- /dev/null +++ b/src/lib/cc/tests/Makefile.am @@ -0,0 +1,31 @@ +AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib +AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns + +AM_CXXFLAGS = $(B10_CXXFLAGS) +if USE_GXX #XXX: see ../Makefile.am +AM_CXXFLAGS += -Wno-unused-parameter +endif + +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + +CLEANFILES = *.gcno *.gcda + +TESTS = +if HAVE_GTEST +TESTS += run_unittests +# (TODO: these need to be completed and moved to tests/) +run_unittests_SOURCES = data_unittests.cc session_unittests.cc run_unittests.cc +run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) +# TODO: remove PTHREAD_LDFLAGS (and from configure too) +run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) $(PTHREAD_LDFLAGS) + +run_unittests_LDADD = $(GTEST_LDADD) +run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la +run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la +run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la + +endif + +noinst_PROGRAMS = $(TESTS) diff --git a/src/lib/cc/data_unittests.cc b/src/lib/cc/tests/data_unittests.cc similarity index 99% rename from src/lib/cc/data_unittests.cc rename to src/lib/cc/tests/data_unittests.cc index c6a5133073..bb3e4943a2 100644 --- a/src/lib/cc/data_unittests.cc +++ b/src/lib/cc/tests/data_unittests.cc @@ -18,7 +18,7 @@ #include #include -#include +#include using namespace isc::data; diff --git a/src/lib/cc/run_unittests.cc b/src/lib/cc/tests/run_unittests.cc similarity index 100% rename from src/lib/cc/run_unittests.cc rename to src/lib/cc/tests/run_unittests.cc diff --git a/src/lib/cc/session_unittests.cc b/src/lib/cc/tests/session_unittests.cc similarity index 98% rename from src/lib/cc/session_unittests.cc rename to src/lib/cc/tests/session_unittests.cc index 307691fc17..d046b10866 100644 --- a/src/lib/cc/session_unittests.cc +++ b/src/lib/cc/tests/session_unittests.cc @@ -22,10 +22,11 @@ #include #include -#include #include +#include + using namespace isc::cc; TEST(AsioSession, establish) { diff --git a/src/lib/config/tests/Makefile.am b/src/lib/config/tests/Makefile.am index 0939508974..58fd1deffa 100644 --- a/src/lib/config/tests/Makefile.am +++ b/src/lib/config/tests/Makefile.am @@ -6,6 +6,10 @@ if USE_GXX AM_CXXFLAGS += -Wno-unused-parameter endif +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + CLEANFILES = *.gcno *.gcda lib_LTLIBRARIES = libfake_session.la diff --git a/src/lib/datasrc/tests/Makefile.am b/src/lib/datasrc/tests/Makefile.am index b8e6987cc1..6485c2bad4 100644 --- a/src/lib/datasrc/tests/Makefile.am +++ b/src/lib/datasrc/tests/Makefile.am @@ -4,6 +4,10 @@ AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\" AM_CXXFLAGS = $(B10_CXXFLAGS) +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + CLEANFILES = *.gcno *.gcda TESTS = @@ -22,10 +26,10 @@ run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) run_unittests_LDADD = $(GTEST_LDADD) run_unittests_LDADD += $(SQLITE_LIBS) -run_unittests_LDADD += $(top_builddir)/src/lib/datasrc/.libs/libdatasrc.a -run_unittests_LDADD += $(top_builddir)/src/lib/dns/.libs/libdns++.a -run_unittests_LDADD += $(top_builddir)/src/lib/cc/.libs/libcc.a -run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/.libs/libexceptions.a +run_unittests_LDADD += $(top_builddir)/src/lib/datasrc/libdatasrc.la +run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la +run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la +run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la endif noinst_PROGRAMS = $(TESTS) diff --git a/src/lib/dns/tests/Makefile.am b/src/lib/dns/tests/Makefile.am index 790f666e37..165bcaf99b 100644 --- a/src/lib/dns/tests/Makefile.am +++ b/src/lib/dns/tests/Makefile.am @@ -3,6 +3,10 @@ AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\" AM_CXXFLAGS = $(B10_CXXFLAGS) +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + CLEANFILES = *.gcno *.gcda TESTS = @@ -40,8 +44,8 @@ run_unittests_SOURCES += run_unittests.cc run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) run_unittests_LDADD = $(GTEST_LDADD) -run_unittests_LDADD += $(top_builddir)/src/lib/dns/.libs/libdns++.a -run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/.libs/libexceptions.a +run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la +run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la endif noinst_PROGRAMS = $(TESTS) diff --git a/src/lib/exceptions/Makefile.am b/src/lib/exceptions/Makefile.am index 3b5310b2ac..eff83b2b96 100644 --- a/src/lib/exceptions/Makefile.am +++ b/src/lib/exceptions/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS = . tests + AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib AM_CXXFLAGS=$(B10_CXXFLAGS) @@ -6,17 +8,5 @@ libexceptions_la_SOURCES = exceptions.h exceptions.cc CLEANFILES = *.gcno *.gcda -TESTS = -if HAVE_GTEST -TESTS += run_unittests -run_unittests_SOURCES = run_unittests.cc -run_unittests_SOURCES += exceptions_unittest.cc -run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) -run_unittests_LDFLAGS = $(GTEST_LDFLAGS) -run_unittests_LDADD = .libs/libexceptions.a $(GTEST_LDADD) -endif - -noinst_PROGRAMS = $(TESTS) - libexceptions_includedir = $(includedir)/exceptions libexceptions_include_HEADERS = exceptions.h diff --git a/src/lib/exceptions/tests/Makefile.am b/src/lib/exceptions/tests/Makefile.am new file mode 100644 index 0000000000..2444b025c6 --- /dev/null +++ b/src/lib/exceptions/tests/Makefile.am @@ -0,0 +1,23 @@ +AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib +AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns + +AM_CXXFLAGS = $(B10_CXXFLAGS) + +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + +CLEANFILES = *.gcno *.gcda + +TESTS = +if HAVE_GTEST +TESTS += run_unittests +run_unittests_SOURCES = run_unittests.cc +run_unittests_SOURCES += exceptions_unittest.cc +run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) +run_unittests_LDFLAGS = $(GTEST_LDFLAGS) +run_unittests_LDADD = $(GTEST_LDADD) +run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la +endif + +noinst_PROGRAMS = $(TESTS) diff --git a/src/lib/exceptions/exceptions_unittest.cc b/src/lib/exceptions/tests/exceptions_unittest.cc similarity index 100% rename from src/lib/exceptions/exceptions_unittest.cc rename to src/lib/exceptions/tests/exceptions_unittest.cc diff --git a/src/lib/exceptions/run_unittests.cc b/src/lib/exceptions/tests/run_unittests.cc similarity index 100% rename from src/lib/exceptions/run_unittests.cc rename to src/lib/exceptions/tests/run_unittests.cc