diff --git a/.gitignore b/.gitignore index c7292d334f..fd04ce4e58 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ Makefile.in /ChangeLog.adoc /config.guess /config.log +/config.log.inplace-outer /config.status /config.sub /config.h diff --git a/Makefile.am b/Makefile.am index 0ebaa573cd..abf9c1ada2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -111,7 +111,7 @@ distcleancheck: realclean: maintainer-clean # Files made by our targets: -CLEANFILES = *-spellchecked *.adoc-parsed cppcheck*.xml +CLEANFILES = *-spellchecked *.adoc-parsed cppcheck*.xml config.log.inplace-outer DISTCLEANFILES = ChangeLog # Most of the files generated by custom rules in the configure script diff --git a/ci_build.sh b/ci_build.sh index cf28f9b2d8..12cec3a01b 100755 --- a/ci_build.sh +++ b/ci_build.sh @@ -709,6 +709,45 @@ check_gitignore() { return 0 } +consider_cleanup_shortcut() { + # Note: modern auto(re)conf requires pkg-config to generate the configure + # script, so to stage the situation of building without one (as if on an + # older system) we have to remove it when we already have the script. + # This matches the use-case of distro-building from release tarballs that + # include all needed pre-generated files to rely less on OS facilities. + DO_REGENERATE=false + if [ x"${CI_REGENERATE}" = xtrue ] ; then + echo "=== Starting initial clean-up (from old build products): TAKING SHORTCUT because CI_REGENERATE='${CI_REGENERATE}'" + DO_REGENERATE=true + fi + + if [ -s Makefile ]; then + if [ -n "`find "${SCRIPTDIR}" -name configure.ac -newer "${CI_BUILDDIR}"/configure`" ] \ + || [ -n "`find "${SCRIPTDIR}" -name '*.m4' -newer "${CI_BUILDDIR}"/configure`" ] \ + || [ -n "`find "${SCRIPTDIR}" -name Makefile.am -newer "${CI_BUILDDIR}"/Makefile`" ] \ + || [ -n "`find "${SCRIPTDIR}" -name Makefile.in -newer "${CI_BUILDDIR}"/Makefile`" ] \ + || [ -n "`find "${SCRIPTDIR}" -name Makefile.am -newer "${CI_BUILDDIR}"/Makefile.in`" ] \ + ; then + # Avoid reconfiguring just for the sake of distclean + echo "=== Starting initial clean-up (from old build products): TAKING SHORTCUT because recipes changed" + DO_REGENERATE=true + fi + fi + + # When itertating configure.ac or m4 sources, we can end up with an + # existing but useless scropt file - nuke it and restart from scratch! + if [ -s "${CI_BUILDDIR}"/configure ] ; then + if ! sh -n "${CI_BUILDDIR}"/configure 2>/dev/null ; then + echo "=== Starting initial clean-up (from old build products): TAKING SHORTCUT because current configure script syntax is broken" + DO_REGENERATE=true + fi + fi + + if $DO_REGENERATE ; then + rm -f "${CI_BUILDDIR}"/Makefile "${CI_BUILDDIR}"/configure "${CI_BUILDDIR}"/include/config.h "${CI_BUILDDIR}"/include/config.h.in "${CI_BUILDDIR}"'/include/config.h.in~' + fi +} + can_clean_check() { if [ "${DO_CLEAN_CHECK-}" = "no" ] ; then # NOTE: Not handling here particular DO_MAINTAINER_CLEAN_CHECK or DO_DIST_CLEAN_CHECK @@ -1442,38 +1481,13 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp CONFIG_OPTS+=("--with-debuginfo=${BUILD_DEBUGINFO}") fi - # Note: modern auto(re)conf requires pkg-config to generate the configure - # script, so to stage the situation of building without one (as if on an - # older system) we have to remove it when we already have the script. - # This matches the use-case of distro-building from release tarballs that - # include all needed pre-generated files to rely less on OS facilities. - if [ -s Makefile ]; then - if [ -n "`find "${SCRIPTDIR}" -name configure.ac -newer "${CI_BUILDDIR}"/configure`" ] \ - || [ -n "`find "${SCRIPTDIR}" -name '*.m4' -newer "${CI_BUILDDIR}"/configure`" ] \ - || [ -n "`find "${SCRIPTDIR}" -name Makefile.am -newer "${CI_BUILDDIR}"/Makefile`" ] \ - || [ -n "`find "${SCRIPTDIR}" -name Makefile.in -newer "${CI_BUILDDIR}"/Makefile`" ] \ - || [ -n "`find "${SCRIPTDIR}" -name Makefile.am -newer "${CI_BUILDDIR}"/Makefile.in`" ] \ - ; then - # Avoid reconfiguring for the sake of distclean - echo "=== Starting initial clean-up (from old build products): TAKING SHORTCUT because recipes changed" - rm -f "${CI_BUILDDIR}"/Makefile "${CI_BUILDDIR}"/configure - fi - fi - - # When itertating configure.ac or m4 sources, we can end up with an - # existing but useless scropt file - nuke it and restart from scratch! - if [ -s "${CI_BUILDDIR}"/configure ] ; then - if ! sh -n "${CI_BUILDDIR}"/configure 2>/dev/null ; then - echo "=== Starting initial clean-up (from old build products): TAKING SHORTCUT because current configure script syntax is broken" - rm -f "${CI_BUILDDIR}"/Makefile "${CI_BUILDDIR}"/configure - fi - fi + consider_cleanup_shortcut if [ -s Makefile ]; then # Let initial clean-up be at default verbosity # Handle Ctrl+C with helpful suggestions: - trap 'echo "!!! If clean-up looped remaking the configure script for maintainer-clean, try to:"; echo " rm -f Makefile configure ; $0 $SCRIPT_ARGS"' 2 + trap 'echo "!!! If clean-up looped remaking the configure script for maintainer-clean, try to:"; echo " rm -f Makefile configure include/config.h* ; $0 $SCRIPT_ARGS"' 2 echo "=== Starting initial clean-up (from old build products)" case "$MAKE_FLAGS $MAKE_FLAGS_CLEAN" in @@ -2068,27 +2082,8 @@ bindings) fi cd "${SCRIPTDIR}" - if [ -s Makefile ]; then - if [ -n "`find "${SCRIPTDIR}" -name configure.ac -newer "${CI_BUILDDIR}"/configure`" ] \ - || [ -n "`find "${SCRIPTDIR}" -name '*.m4' -newer "${CI_BUILDDIR}"/configure`" ] \ - || [ -n "`find "${SCRIPTDIR}" -name Makefile.am -newer "${CI_BUILDDIR}"/Makefile`" ] \ - || [ -n "`find "${SCRIPTDIR}" -name Makefile.in -newer "${CI_BUILDDIR}"/Makefile`" ] \ - || [ -n "`find "${SCRIPTDIR}" -name Makefile.am -newer "${CI_BUILDDIR}"/Makefile.in`" ] \ - ; then - # Avoid reconfiguring for the sake of distclean - echo "=== Starting initial clean-up (from old build products): TAKING SHORTCUT because recipes changed" - rm -f "${CI_BUILDDIR}"/Makefile "${CI_BUILDDIR}"/configure - fi - fi - # When itertating configure.ac or m4 sources, we can end up with an - # existing but useless scropt file - nuke it and restart from scratch! - if [ -s "${CI_BUILDDIR}"/configure ] ; then - if ! sh -n "${CI_BUILDDIR}"/configure 2>/dev/null ; then - echo "=== Starting initial clean-up (from old build products): TAKING SHORTCUT because current configure script syntax is broken" - rm -f "${CI_BUILDDIR}"/Makefile "${CI_BUILDDIR}"/configure - fi - fi + consider_cleanup_shortcut if [ -s Makefile ]; then # Help developers debug: diff --git a/configure.ac b/configure.ac index 13cf303e59..807f293c6d 100644 --- a/configure.ac +++ b/configure.ac @@ -235,6 +235,8 @@ dnl # not configure time. dnl AC_DEFINE_UNQUOTED(UPS_VERSION, "${PACKAGE_VERSION}", [NUT version]) dnl However, automatically define the tree version (mostly for AC_SUBST) +dnl FIXME: This just picks first 3 chars, assuming single-digit components +dnl separated by a dot: TREE_VERSION="`echo ${PACKAGE_VERSION} | awk '{ print substr($0,1,3) }'`" AC_DEFINE_UNQUOTED(TREE_VERSION, "${TREE_VERSION}", [NUT tree version]) @@ -675,6 +677,10 @@ AS_IF([test x"$nut_enable_inplace_runtime" = xyes -a x"${NUT_VERSION_DEPLOYED-}" test -n "${CONFIG_CXXFLAGS-}" || CONFIG_CXXFLAGS=" " export CONFIG_CFLAGS export CONFIG_CXXFLAGS + + AC_MSG_NOTICE([Moving config.log of the original invocation to config.log.inplace-outer just before exec...]) + mv -f config.log config.log.inplace-outer || true + eval exec "$0" $CONFIG_FLAGS_DEPLOYED $CONFIG_FLAGS --disable-inplace-runtime ],[ AC_MSG_NOTICE([No CONFIG_FLAGS were reported or discovered from existing NUT deployment (if any); restarting script for a clean run]) @@ -685,6 +691,10 @@ AS_IF([test x"$nut_enable_inplace_runtime" = xyes -a x"${NUT_VERSION_DEPLOYED-}" test -n "${CONFIG_CXXFLAGS-}" || CONFIG_CXXFLAGS=" " export CONFIG_CFLAGS export CONFIG_CXXFLAGS + + AC_MSG_NOTICE([Moving config.log of the original invocation to config.log.inplace-outer just before exec...]) + mv -f config.log config.log.inplace-outer || true + AC_MSG_NOTICE([exec "$0" $CONFIG_FLAGS --disable-inplace-runtime]) eval exec "$0" $CONFIG_FLAGS --disable-inplace-runtime ]) @@ -1298,6 +1308,8 @@ if test "$as_ln_s" = "ln -s" ; then if test x"${_abs_srcdir}" = x"${_abs_builddir}" ; then LN_S_R="ln" else + dnl NOTE: Here we check equality of the file systems by the + dnl devices they are mounted from (first column in df output): _fs_srcdir="`df "${_abs_srcdir}" | tail -1 | awk '{print $1}'`" || fs_srcdir="XXXs" _fs_builddir="`df "${_abs_builddir}" | tail -1 | awk '{print $1}'`" || fs_builddir="XXXb" dnl AC_MSG_NOTICE([_fs_srcdir='${_fs_srcdir}' _fs_builddir='${_fs_builddir}']) diff --git a/m4/nut_check_libgd.m4 b/m4/nut_check_libgd.m4 index f4a025dccc..b2b56666aa 100644 --- a/m4/nut_check_libgd.m4 +++ b/m4/nut_check_libgd.m4 @@ -147,13 +147,15 @@ if test -z "${nut_have_libgd_seen}"; then AX_RUN_OR_LINK_IFELSE([AC_LANG_PROGRAM([ #include #include +#include ], [ +FILE *tmpf = tmpfile(); gdImagePtr im = gdImageCreate(64, 128); int back_color = gdImageColorAllocate(im, 255, 128, 32); gdImageFilledRectangle(im, 0, 0, 64, 128, back_color); gdImageColorTransparent(im, back_color); -gdImagePng(im, stdout); +gdImagePng(im, tmpf ? tmpf : stderr); gdImageDestroy(im); ] )], [], [nut_have_libgd=no]) diff --git a/m4/nut_check_libsystemd.m4 b/m4/nut_check_libsystemd.m4 index 155add4423..f8e702e920 100644 --- a/m4/nut_check_libsystemd.m4 +++ b/m4/nut_check_libsystemd.m4 @@ -13,22 +13,42 @@ if test -z "${nut_have_libsystemd_seen}"; then CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" + SYSTEMD_VERSION="none" + + AC_CHECK_TOOL(SYSTEMCTL, systemctl, none) + AS_IF([test x"$have_PKG_CONFIG" = xyes], [dnl See which version of the systemd library (if any) is installed dnl FIXME : Support detection of cflags/ldflags below by legacy dnl discovery if pkgconfig is not there AC_MSG_CHECKING(for libsystemd version via pkg-config) SYSTEMD_VERSION="`$PKG_CONFIG --silence-errors --modversion libsystemd 2>/dev/null`" - if test "$?" != "0" -o -z "${SYSTEMD_VERSION}"; then - SYSTEMD_VERSION="none" - fi + AS_IF([test "$?" != "0" -o -z "${SYSTEMD_VERSION}"], [ + SYSTEMD_VERSION="none" + ]) AC_MSG_RESULT(${SYSTEMD_VERSION} found) - ], - [SYSTEMD_VERSION="none" - AC_MSG_NOTICE([can not check libsystemd settings via pkg-config]) ] ) + AS_IF([test x"${SYSTEMD_VERSION}" = xnone], [ + AS_IF([test x"${SYSTEMCTL}" != xnone], [ + AC_MSG_CHECKING(for libsystemd version via systemctl) + dnl NOTE: Unlike the configure.ac file, in a "pure" + dnl m4 script like this one, we have to escape the + dnl dollar-number references (in awk below) lest they + dnl get seen as m4 function positional parameters. + SYSTEMD_VERSION="`LANG=C LC_ALL=C ${SYSTEMCTL} --version | grep -E '^systemd@<:@ \t@:>@*@<:@0-9@:>@@<:@0-9@:>@*' | awk '{print ''$''2}'`" \ + && test -n "${SYSTEMD_VERSION}" \ + || SYSTEMD_VERSION="none" + AC_MSG_RESULT(${SYSTEMD_VERSION} found) + ]) + ] + ) + + AS_IF([test x"${SYSTEMD_VERSION}" = xnone], [ + AC_MSG_NOTICE([can not check libsystemd settings via pkg-config nor systemctl]) + ]) + AC_MSG_CHECKING(for libsystemd cflags) AC_ARG_WITH(libsystemd-includes, AS_HELP_STRING([@<:@--with-libsystemd-includes=CFLAGS@:>@], [include flags for the systemd library]),