diff --git a/configure b/configure index f3e8b0b7..d4757bad 100755 --- a/configure +++ b/configure @@ -650,6 +650,10 @@ EXTENSION_LIBEVENT_LDFLAGS EXTENSION_LIBEVENT_EXT_LIBS EXTENSION_LIBEVENT_LIB have_libevent +NOLIBCHECK +LIBCHECK_LDFLAGS +LIBCHECK_LIBS +CHECK_GETDNS DOXYGEN INSTALL_DATA INSTALL_SCRIPT @@ -10821,6 +10825,9 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' +initial_LIBS=$LIBS +initial_LDFLAGS=$LDFLAGS + # Check whether --enable-rpath was given. @@ -11297,9 +11304,262 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + +# Check for libraries for other things than libgetdns after this point, +# so the getdns libraries can be reset with: +# +# LIBS=$getdns_LIBS +# LDFLAGS=$getdns_LDFLAGS +# +# afterwards. getdns_LIBS=$LIBS getdns_LDFLAGS=$LDFLAGS +#-------------------- libraries needed for libcheck +LIBS=$initial_LIBS +LDFLAGS=$initial_LDFLAGS + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing floor" >&5 +$as_echo_n "checking for library containing floor... " >&6; } +if ${ac_cv_search_floor+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char floor (); +int +main () +{ +return floor (); + ; + return 0; +} +_ACEOF +for ac_lib in '' m; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_floor=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_floor+:} false; then : + break +fi +done +if ${ac_cv_search_floor+:} false; then : + +else + ac_cv_search_floor=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_floor" >&5 +$as_echo "$ac_cv_search_floor" >&6; } +ac_res=$ac_cv_search_floor +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing timer_create" >&5 +$as_echo_n "checking for library containing timer_create... " >&6; } +if ${ac_cv_search_timer_create+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char timer_create (); +int +main () +{ +return timer_create (); + ; + return 0; +} +_ACEOF +for ac_lib in '' rt; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_timer_create=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_timer_create+:} false; then : + break +fi +done +if ${ac_cv_search_timer_create+:} false; then : + +else + ac_cv_search_timer_create=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_timer_create" >&5 +$as_echo "$ac_cv_search_timer_create" >&6; } +ac_res=$ac_cv_search_timer_create +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5 +$as_echo_n "checking for library containing pthread_create... " >&6; } +if ${ac_cv_search_pthread_create+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_create (); +int +main () +{ +return pthread_create (); + ; + return 0; +} +_ACEOF +for ac_lib in '' pthread; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_pthread_create=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_pthread_create+:} false; then : + break +fi +done +if ${ac_cv_search_pthread_create+:} false; then : + +else + ac_cv_search_pthread_create=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_create" >&5 +$as_echo "$ac_cv_search_pthread_create" >&6; } +ac_res=$ac_cv_search_pthread_create +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing srunner_run" >&5 +$as_echo_n "checking for library containing srunner_run... " >&6; } +if ${ac_cv_search_srunner_run+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char srunner_run (); +int +main () +{ +return srunner_run (); + ; + return 0; +} +_ACEOF +for ac_lib in '' check; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_srunner_run=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_srunner_run+:} false; then : + break +fi +done +if ${ac_cv_search_srunner_run+:} false; then : + +else + ac_cv_search_srunner_run=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_srunner_run" >&5 +$as_echo "$ac_cv_search_srunner_run" >&6; } +ac_res=$ac_cv_search_srunner_run +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +CHECK_GETDNS=check_getdns + +LIBCHECK_LIBS=$LIBS + +LIBCHECK_LDFLAGS=$LDFLAGS + +else + +NOLIBCHECK=nolibcheck + +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcheck not found or usable; unit tests will not be compiled and run" >&5 +$as_echo "$as_me: WARNING: libcheck not found or usable; unit tests will not be compiled and run" >&2;} +fi + + +LIBS=$getdns_LIBS +LDFLAGS=$getdns_LDFLAGS +# end libraries needed for libcheck + #-------------------- libevent extension # Check whether --with-libevent was given. @@ -11451,7 +11711,7 @@ fi fi if test x_$have_libevent = x_1; then : - EXTENSION_LIBEVENT_LIB="libgetdns_ext_event.la" + EXTENSION_LIBEVENT_LIB="../libgetdns_ext_event.la" CHECK_EVENT_PROG=check_getdns_event # libunbound version 1.4.22 and older, not linked against libevent, on FreeBSD, # ============================================================================= @@ -11551,8 +11811,12 @@ fi +if test "x$have_libcheck" = x1; then : +fi +LIBS=$getdns_LIBS +LDFLAGS=$getdns_LDFLAGS # end libevent extension #-------------------- libuv extension @@ -11665,7 +11929,7 @@ fi fi if test x_$have_libuv = x_1; then : - EXTENSION_LIBUV_LIB="libgetdns_ext_uv.la" + EXTENSION_LIBUV_LIB="../libgetdns_ext_uv.la" CHECK_UV_PROG=check_getdns_uv { $as_echo "$as_me:${as_lineno-$LINENO}: checking for new signature of uv_timer_cb" >&5 $as_echo_n "checking for new signature of uv_timer_cb... " >&6; } @@ -11715,8 +11979,12 @@ fi +if test "x$have_libcheck" = x1; then : +fi +LIBS=$getdns_LIBS +LDFLAGS=$getdns_LDFLAGS # end libuv extension #-------------------- libev extension @@ -11842,7 +12110,7 @@ fi fi if test x_$have_libev = x_1; then : - EXTENSION_LIBEV_LIB="libgetdns_ext_ev.la" + EXTENSION_LIBEV_LIB="../libgetdns_ext_ev.la" CHECK_EV_PROG=check_getdns_ev fi @@ -11850,12 +12118,13 @@ fi +if test "x$have_libcheck" = x1; then : - -# end libev extension +fi LIBS=$getdns_LIBS LDFLAGS=$getdns_LDFLAGS +# end libev extension # --with-trust-anchor= diff --git a/configure.ac b/configure.ac index c30a589a..2ca944d2 100755 --- a/configure.ac +++ b/configure.ac @@ -59,6 +59,9 @@ AC_SUBST(libtool) AC_PROG_LIBTOOL AC_PROG_INSTALL +initial_LIBS=$LIBS +initial_LDFLAGS=$LDFLAGS + dnl Add option to disable the evil rpath. Check whether to use rpath or not. dnl Adds the --disable-rpath option. Uses trick to edit the ./libtool. AC_DEFUN([ACX_ARG_RPATH], @@ -215,9 +218,35 @@ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_IOCTLSOCKET, 1, [if the function 'ioctlsocket' is available]) ],[AC_MSG_RESULT(no)]) + +# Check for libraries for other things than libgetdns after this point, +# so the getdns libraries can be reset with: +# +# LIBS=$getdns_LIBS +# LDFLAGS=$getdns_LDFLAGS +# +# afterwards. getdns_LIBS=$LIBS getdns_LDFLAGS=$LDFLAGS +#-------------------- libraries needed for libcheck +LIBS=$initial_LIBS +LDFLAGS=$initial_LDFLAGS + +AC_SEARCH_LIBS([floor], [m]) +AC_SEARCH_LIBS([timer_create], [rt]) +AC_SEARCH_LIBS([pthread_create], [pthread]) +AC_SEARCH_LIBS([srunner_run],[check],[ +AC_SUBST(CHECK_GETDNS,[check_getdns]) +AC_SUBST(LIBCHECK_LIBS,[$LIBS]) +AC_SUBST(LIBCHECK_LDFLAGS,[$LDFLAGS])],[ +AC_SUBST(NOLIBCHECK, [nolibcheck]) +AC_MSG_WARN([libcheck not found or usable; unit tests will not be compiled and run])]) + +LIBS=$getdns_LIBS +LDFLAGS=$getdns_LDFLAGS +# end libraries needed for libcheck + #-------------------- libevent extension AC_ARG_WITH([libevent], [AS_HELP_STRING([--with-libevent], [path to libevent (default: search /usr/local ..)])], @@ -265,7 +294,7 @@ AS_IF([test x_$withval = x_no], ) AS_IF([test x_$have_libevent = x_1], - [EXTENSION_LIBEVENT_LIB="libgetdns_ext_event.la"] + [EXTENSION_LIBEVENT_LIB="../libgetdns_ext_event.la"] [CHECK_EVENT_PROG=check_getdns_event] # libunbound version 1.4.22 and older, not linked against libevent, on FreeBSD, # ============================================================================= @@ -309,8 +338,10 @@ AC_SUBST(have_libevent) AC_SUBST(EXTENSION_LIBEVENT_LIB) AC_SUBST(EXTENSION_LIBEVENT_EXT_LIBS) AC_SUBST(EXTENSION_LIBEVENT_LDFLAGS) -AC_SUBST(CHECK_EVENT_PROG) +AS_IF([test "x$have_libcheck" = x1], [AC_SUBST(CHECK_EVENT_PROG)]) +LIBS=$getdns_LIBS +LDFLAGS=$getdns_LDFLAGS # end libevent extension #-------------------- libuv extension @@ -349,7 +380,7 @@ AS_IF([test x_$withval = x_no], ) AS_IF([test x_$have_libuv = x_1], - [EXTENSION_LIBUV_LIB="libgetdns_ext_uv.la"] + [EXTENSION_LIBUV_LIB="../libgetdns_ext_uv.la"] [CHECK_UV_PROG=check_getdns_uv] [AC_MSG_CHECKING([for new signature of uv_timer_cb]) AC_LANG_PUSH(C) @@ -370,8 +401,10 @@ AC_SUBST(have_libuv) AC_SUBST(EXTENSION_LIBUV_LIB) AC_SUBST(EXTENSION_LIBUV_EXT_LIBS) AC_SUBST(EXTENSION_LIBUV_LDFLAGS) -AC_SUBST(CHECK_UV_PROG) +AS_IF([test "x$have_libcheck" = x1], [AC_SUBST(CHECK_UV_PROG)]) +LIBS=$getdns_LIBS +LDFLAGS=$getdns_LDFLAGS # end libuv extension #-------------------- libev extension @@ -412,19 +445,18 @@ AS_IF([test x_$withval = x_no], ) AS_IF([test x_$have_libev = x_1], - [EXTENSION_LIBEV_LIB="libgetdns_ext_ev.la"] + [EXTENSION_LIBEV_LIB="../libgetdns_ext_ev.la"] [CHECK_EV_PROG=check_getdns_ev]) AC_SUBST(have_libev) AC_SUBST(EXTENSION_LIBEV_LIB) AC_SUBST(EXTENSION_LIBEV_EXT_LIBS) AC_SUBST(EXTENSION_LIBEV_LDFLAGS) -AC_SUBST(CHECK_EV_PROG) - -# end libev extension +AS_IF([test "x$have_libcheck" = x1], [AC_SUBST(CHECK_EV_PROG)]) LIBS=$getdns_LIBS LDFLAGS=$getdns_LDFLAGS +# end libev extension # --with-trust-anchor= AC_DEFINE([SYSCONFDIR], [sysconfdir], [System configuration dir]) diff --git a/src/test/Makefile.in b/src/test/Makefile.in index 789a1191..8af838f7 100755 --- a/src/test/Makefile.in +++ b/src/test/Makefile.in @@ -43,23 +43,31 @@ VPATH = @srcdir@ have_libevent = @have_libevent@ have_libuv = @have_libuv@ have_libev = @have_libev@ +NOLIBCHECK = @NOLIBCHECK@ EXTENSION_LIBEVENT_EXT_LIBS=@EXTENSION_LIBEVENT_EXT_LIBS@ EXTENSION_LIBEVENT_LDFLAGS=@EXTENSION_LIBEVENT_LDFLAGS@ +EXTENSION_LIBEVENT_LIB=@EXTENSION_LIBEVENT_LIB@ EXTENSION_LIBUV_EXT_LIBS=@EXTENSION_LIBUV_EXT_LIBS@ EXTENSION_LIBUV_LDFLAGS=@EXTENSION_LIBUV_LDFLAGS@ +EXTENSION_LIBUV_LIB=@EXTENSION_LIBUV_LIB@ EXTENSION_LIBEV_EXT_LIBS=@EXTENSION_LIBEV_EXT_LIBS@ EXTENSION_LIBEV_LDFLAGS=@EXTENSION_LIBEV_LDFLAGS@ +EXTENSION_LIBEV_LIB=@EXTENSION_LIBEV_LIB@ +CHECK_GETDNS=@CHECK_GETDNS@ CHECK_UV_PROG=@CHECK_UV_PROG@ CHECK_EVENT_PROG=@CHECK_EVENT_PROG@ CHECK_EV_PROG=@CHECK_EV_PROG@ CC=@CC@ CFLAGS=-Wall -std=c99 -I$(srcdir)/.. -I$(srcdir) -I.. $(cflags) @CFLAGS@ -LDFLAGS=@LDFLAGS@ -L.. -LDLIBS=@LIBS@ ../libgetdns.la -lcheck -lm -lrt -PROGRAMS=tests_dict tests_list tests_namespaces tests_stub_async tests_stub_sync check_getdns getdns_query $(CHECK_EV_PROG) $(CHECK_EVENT_PROG) $(CHECK_UV_PROG) +LDFLAGS=-L.. +LDLIBS=../libgetdns.la +LIBCHECK_LDFLAGS=@LIBCHECK_LDFLAGS@ +LIBCHECK_LIBS=@LIBCHECK_LIBS@ + +PROGRAMS=tests_dict tests_list tests_namespaces tests_stub_async tests_stub_sync getdns_query $(CHECK_GETDNS) $(CHECK_EV_PROG) $(CHECK_EVENT_PROG) $(CHECK_UV_PROG) .SUFFIXES: .c .o .a .lo .h @@ -95,16 +103,16 @@ check_getdns_common: check_getdns_common.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns_common.lo check_getdns: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_selectloop.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -lpthread -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_selectloop.lo + $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $(LIBCHECK_LDFLAGS) $(LIBCHECK_LIBS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_selectloop.lo check_getdns_event: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libevent.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libevent.lo $(LDFLAGS) $(LDLIBS) -lpthread ../libgetdns_ext_event.la $(EXTENSION_LIBEVENT_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS) + $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libevent.lo $(LDFLAGS) $(LDLIBS) $(LIBCHECK_LDFLAGS) $(LIBCHECK_LIBS) $(EXTENSION_LIBEVENT_LIB) $(EXTENSION_LIBEVENT_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS) check_getdns_uv: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libuv.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libuv.lo $(LDFLAGS) $(LDLIBS) -lpthread ../libgetdns_ext_uv.la $(EXTENSION_LIBUV_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS) + $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libuv.lo $(LDFLAGS) $(LDLIBS) $(LIBCHECK_LDFLAGS) $(LIBCHECK_LIBS) $(EXTENSION_LIBUV_LIB) $(EXTENSION_LIBUV_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS) check_getdns_ev: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo $(LDFLAGS) $(LDLIBS) -lpthread ../libgetdns_ext_ev.la $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) + $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo $(LDFLAGS) $(LDLIBS) $(LIBCHECK_LDFLAGS) $(LIBCHECK_LIBS) $(EXTENSION_LIBEV_LIB) $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) getdns_query: getdns_query.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ getdns_query.lo $(LDFLAGS) $(LDLIBS) @@ -113,8 +121,17 @@ install: getdns_query $(INSTALL) -m 755 -d $(DESTDIR)$(bindir) $(LIBTOOL) --mode=install cp getdns_query $(DESTDIR)$(bindir) -test: all - ./check_getdns +nolibcheck: + @echo "***" + @echo "*** Cannot run unit tests, because they could not be compiled," + @echo "*** because libcheck was not found or usable at configure time." + @echo "*** To compile and run unit tests make sure libcheck is available" + @echo "*** and usable during configuration" + @echo "***" + @false + +test: all $(NOLIBCHECK) + ./$(CHECK_GETDNS) if test $(have_libevent) = 1 ; then ./$(CHECK_EVENT_PROG) ; fi if test $(have_libev) = 1 ; then ./$(CHECK_EV_PROG) ; fi if test $(have_libuv) = 1 ; then ./$(CHECK_UV_PROG) ; fi