--- nut/configure.in +++ b/configure.in @@ -194,7 +194,6 @@ NUT_CHECK_LIBNETSNMP NUT_CHECK_LIBUSB -NUT_CHECK_LIBHAL NUT_CHECK_LIBNEON dnl ---------------------------------------------------------------------- @@ -238,22 +237,29 @@ dnl ${nut_with_ssl}: any value except "yes" or "no" is treated as "auto". if test "${nut_with_ssl}" != "no"; then dnl check for libssl compiler flags - NUT_CHECK_LIBSSL -fi - -if test "${nut_with_ssl}" = "yes" -a "${nut_have_libssl}" != "yes"; then - AC_MSG_ERROR(["OpenSSL not found, required for SSL support"]) -fi - -if test "${nut_with_ssl}" != "no"; then + + if test -z "${nut_have_libssl_seen}"; then + nut_have_libssl_seen=yes + + PKG_CHECK_MODULES(SSL, [libssl], + nut_have_libssl=yes, + nut_have_libssl=no) + fi + + if test "${nut_with_ssl}" = "yes" -a "${nut_have_libssl}" != "yes"; then + AC_MSG_ERROR(["OpenSSL not found, required for SSL support"]) + fi + nut_with_ssl="${nut_have_libssl}" -fi - -if test "${nut_with_ssl}" = "yes"; then - AC_DEFINE(HAVE_SSL, 1, [Define to enable SSL development code]) -fi - + + if test "${nut_with_ssl}" = "yes"; then + AC_DEFINE(HAVE_SSL, 1, [Define to enable SSL development code]) + fi +fi AM_CONDITIONAL(WITH_SSL, test "${nut_with_ssl}" = "yes") +AC_SUBST(SSL_CFLAGS) +AC_SUBST(SSL_LIBS) + NUT_REPORT_FEATURE([enable SSL development code], [${nut_with_ssl}]) @@ -383,6 +389,7 @@ dnl ---------------------------------------------------------------------- dnl checks related to --with-hal +NUT_CHECK_LIBHAL dnl ${nut_with_hal}: any value except "yes" or "no" is treated as "auto". if test "${nut_with_hal}" = "yes" -a "${nut_have_libhal}" != "yes"; then @@ -402,6 +409,12 @@ fi AM_CONDITIONAL(WITH_HAL, test "${nut_with_hal}" = "yes") +AC_SUBST(HAL_CFLAGS) +AC_SUBST(HAL_LIBS) +AC_SUBST(HAL_USER) +AC_SUBST(HAL_FDI_PATH) +AC_SUBST(HAL_CALLOUTS_PATH) + NUT_REPORT_FEATURE([enable HAL support], [${nut_with_hal}]) dnl ---------------------------------------------------------------------- @@ -764,8 +777,6 @@ AC_DEFINE_UNQUOTED(DATADIR, "${conftemp}", [Default path for data files]) -AC_SUBST(LIBSSL_CFLAGS) -AC_SUBST(LIBSSL_LDFLAGS) AC_SUBST(LIBGD_CFLAGS) AC_SUBST(LIBGD_LDFLAGS) AC_SUBST(LIBNETSNMP_CFLAGS) @@ -774,11 +785,6 @@ AC_SUBST(LIBUSB_LDFLAGS) AC_SUBST(LIBNEON_CFLAGS) AC_SUBST(LIBNEON_LDFLAGS) -AC_SUBST(HAL_USER) -AC_SUBST(HAL_FDI_PATH) -AC_SUBST(HAL_CALLOUTS_PATH) -AC_SUBST(LIBHAL_CFLAGS) -AC_SUBST(LIBHAL_LDFLAGS) AC_SUBST(DRIVER_BUILD_LIST) AC_SUBST(DRIVER_MAN_LIST) AC_SUBST(DRIVER_INSTALL_TARGET) --- nut/server/Makefile.am +++ b/server/Makefile.am @@ -5,12 +5,12 @@ # but only add them if we really use the target. AM_CFLAGS = -I$(top_srcdir)/include if WITH_SSL - AM_CFLAGS += $(LIBSSL_CFLAGS) + AM_CFLAGS += $(SSL_CFLAGS) endif LDADD = ../common/libcommon.a ../common/state.o ../common/upsconf.o \ ../common/parseconf.o $(NETLIBS) if WITH_SSL - LDADD += $(LIBSSL_LDFLAGS) + LDADD += $(SSL_LIBS) endif sbin_PROGRAMS = upsd --- nut/m4/nut_check_libssl.m4 +++ b/m4/nut_check_libssl.m4 @@ -1,5 +1,5 @@ dnl Check for LIBSSL compiler flags. On success, set nut_have_libssl="yes" -dnl and set LIBSSL_CFLAGS and LIBSSL_LDFLAGS. On failure, set +dnl and set LIBSSL_CFLAGS and LIBSSL_LIBS. On failure, set dnl nut_have_libssl="no". This macro can be run multiple times, but will dnl do the checking only once. @@ -10,55 +10,13 @@ AC_MSG_CHECKING(for SSL library availability) - dnl save CFLAGS and LDFLAGS - CFLAGS_ORIG="${CFLAGS}" - LDFLAGS_ORIG="${LDFLAGS}" - - CFLAGS="" - LDFLAGS="-lssl -lcrypto" - - AC_TRY_LINK([#include ], [SSL_library_init()], - nut_have_libssl=yes, - nut_have_libssl=no) - - if test "${nut_have_libssl}" != "yes"; then - CFLAGS="-I/usr/kerberos/include" - LDFLAGS="-lssl -lcrypto" - - AC_TRY_LINK([#include ], [SSL_library_init], - nut_have_libssl=yes, - nut_have_libssl=no) - fi - - if test "${nut_have_libssl}" != "yes"; then - CFLAGS="-I/usr/local/ssl/include" - LDFLAGS="-L/usr/local/ssl/lib -lssl -lcrypto" - - AC_TRY_LINK([#include ], [SSL_library_init], - nut_have_libssl=yes, - nut_have_libssl=no) - fi - - if test "${nut_have_libssl}" != "yes"; then - CFLAGS="-I/usr/local/ssl/include -I/usr/kerberos/include" - LDFLAGS="-L/usr/local/ssl/lib -lssl -lcrypto" - - AC_TRY_LINK([#include ], [SSL_library_init], - nut_have_libssl=yes, - nut_have_libssl=no) - fi - - if test "${nut_have_libssl}" = "yes"; then - LIBSSL_CFLAGS="${CFLAGS}" - LIBSSL_LDFLAGS="${LDFLAGS}" - fi - - dnl restore original CFLAGS and LDFLAGS - CFLAGS="${CFLAGS_ORIG}" - LDFLAGS="${LDFLAGS_ORIG}" + PKG_CHECK_MODULES(LIBSSL, [libssl], + nut_have_libssl=yes, + nut_have_libssl=no) + AC_SUBST(LIBSSL_CFLAGS) + AC_SUBST(LIBSSL_LIBS) AC_MSG_RESULT([${nut_have_libssl}]) - fi ]) --- nut/m4/nut_check_libhal.m4 +++ b/m4/nut_check_libhal.m4 @@ -1,5 +1,5 @@ -dnl Check for LIBHAL compiler flags. On success, set nut_have_libhal="yes" -dnl and set LIBHAL_CFLAGS and LIBHAL_LDFLAGS. On failure, set +dnl Check for HAL compiler flags. On success, set nut_have_libhal="yes" +dnl and set HAL_CFLAGS and HAL_LIBS. On failure, set dnl nut_have_libhal="no". This macro can be run multiple times, but will dnl do the checking only once. dnl NUT requires HAL version 0.5.8 at least @@ -11,7 +11,7 @@ CFLAGS_ORIG="${CFLAGS}" CPPFLAGS_ORIG="${CPPFLAGS}" - LDFLAGS_ORIG="${LDFLAGS}" + LIBS_ORIG="${LIBS}" nut_have_libhal=yes AC_MSG_CHECKING(for libhal version via pkg-config (0.5.8 minimum required)) @@ -38,13 +38,13 @@ dnl also get libs from glib-2.0 to workaround a bug in dbus-glib AC_MSG_CHECKING(for libhal ldflags via pkg-config) - LDFLAGS=`pkg-config --silence-errors --libs hal dbus-glib-1` + LIBS=`pkg-config --silence-errors --libs hal dbus-glib-1` if (test "$?" != "0") then AC_MSG_RESULT(not found) nut_have_libhal=no else - AC_MSG_RESULT(${LDFLAGS}) + AC_MSG_RESULT(${LIBS}) fi dnl this will only work as of HAL 0.5.9 @@ -98,22 +98,22 @@ CFLAGS="-DDBUS_API_SUBJECT_TO_CHANGE -I/usr/include/hal -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include" CPPFLAGS="${CFLAGS}" - LDFLAGS="-lhal -ldbus-1 -lpthread" + LIBS="-lhal -ldbus-1 -lpthread" AC_CHECK_HEADER(libhal.h, , [nut_have_libhal=no]) AC_CHECK_LIB(hal, libhal_device_new_changeset, [nut_have_libhal=yes], [nut_have_libhal=no], - ${LDFLAGS}) + ${LIBS}) fi if test "${nut_have_libhal}" = "yes"; then - LIBHAL_CFLAGS="${CFLAGS}" - LIBHAL_LDFLAGS="${LDFLAGS}" + HAL_CFLAGS="${CFLAGS}" + HAL_LIBS="${LIBS}" fi CFLAGS="${CFLAGS_ORIG}" CPPFLAGS="${CPPFLAGS_ORIG}" - LDFLAGS="${LDFLAGS_ORIG}" + LIBS="${LIBS_ORIG}" fi ]) --- nut/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -15,7 +15,7 @@ # but only add them if we really use the target. AM_CFLAGS = -I$(top_srcdir)/include if WITH_HAL - AM_CFLAGS += $(LIBHAL_CFLAGS) + AM_CFLAGS += $(HAL_CFLAGS) endif if WITH_USB if HAVE_LIBUSB @@ -26,7 +26,7 @@ AM_CFLAGS += $(LIBNETSNMP_CFLAGS) endif if WITH_SNMP - AM_CFLAGS += $(LIBSSL_CFLAGS) + AM_CFLAGS += $(SSL_CFLAGS) endif if WITH_NEONXML AM_CFLAGS += $(LIBNEON_CFLAGS) @@ -146,7 +146,7 @@ $(USBHID_UPS_SUBDRIVERS) usbhid_ups_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LDFLAGS) if WITH_SSL - usbhid_ups_LDADD += $(LIBSSL_LDFLAGS) + usbhid_ups_LDADD += $(SSL_LIBS) endif energizerups_SOURCES = energizerups.c @@ -175,17 +175,17 @@ # HAL hald_addon_usbhid_ups_SOURCES = usbhid-ups.c libhid.c libusb.c hidparser.c \ $(USBHID_UPS_SUBDRIVERS) -hald_addon_usbhid_ups_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(LIBHAL_LDFLAGS) $(LIBSSL_LDFLAGS) +hald_addon_usbhid_ups_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(HAL_LIBS) $(SSL_LIBS) hald_addon_tripplite_usb_SOURCES = tripplite_usb.c libusb.c -hald_addon_tripplite_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(LIBHAL_LDFLAGS) -lm +hald_addon_tripplite_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(HAL_LIBS) -lm hald_addon_bcmxcp_usb_SOURCES = bcmxcp_usb.c bcmxcp.c nut_usb.c -hald_addon_bcmxcp_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(LIBHAL_LDFLAGS) +hald_addon_bcmxcp_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(HAL_LIBS) hald_addon_megatec_usb_SOURCES = megatec.c megatec_usb.c libusb.c hald_addon_megatec_usb_CFLAGS = $(AM_CFLAGS) -DMEGATEC_SUBDRV -hald_addon_megatec_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(LIBHAL_LDFLAGS) +hald_addon_megatec_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(HAL_LIBS) # NEON XML/HTTP netxml_ups_SOURCES = netxml-ups.c mge-xml.c --- nut/clients/Makefile.am +++ b/clients/Makefile.am @@ -3,7 +3,7 @@ # by default, link programs in this directory with libcommon.a LDADD = ../common/libcommon.a libupsclient.la $(NETLIBS) if WITH_SSL - LDADD += $(LIBSSL_LDFLAGS) + LDADD += $(SSL_LIBS) endif # Avoid per-target CFLAGS, because this will prevent re-use of object @@ -11,7 +11,7 @@ # but only add them if we really use the target. AM_CFLAGS = -I$(top_srcdir)/include if WITH_SSL - AM_CFLAGS += $(LIBSSL_CFLAGS) + AM_CFLAGS += $(SSL_CFLAGS) endif if WITH_CGI AM_CFLAGS += $(LIBGD_CFLAGS) @@ -47,7 +47,10 @@ # not LDADD. libupsclient_la_SOURCES = upsclient.c upsclient.h libupsclient_la_LIBADD = ../common/parseconf.lo -libupsclient_la_LDFLAGS = -version-info 1:0:0 +if WITH_SSL + libupsclient_la_LIBADD += $(SSL_LIBS) +endif +libupsclient_la_LDFLAGS = -version-info 1:0:0 -export-dynamic # rules for cross-directory targets ../common/libcommon.a: FORCE