Skip to content

Commit

Permalink
Merge pull request networkupstools#2595 from jimklimov/fightwarn-libg…
Browse files Browse the repository at this point in the history
…d-cibuild

CI: libgd, ci_build.sh, SYSTEMD_VERSION
  • Loading branch information
jimklimov authored Aug 19, 2024
2 parents 0b1c6fe + 0cf8e3f commit a682eae
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Makefile.in
/ChangeLog.adoc
/config.guess
/config.log
/config.log.inplace-outer
/config.status
/config.sub
/config.h
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
89 changes: 42 additions & 47 deletions ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down Expand Up @@ -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])
Expand All @@ -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
])
Expand Down Expand Up @@ -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}'])
Expand Down
4 changes: 3 additions & 1 deletion m4/nut_check_libgd.m4
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ if test -z "${nut_have_libgd_seen}"; then
AX_RUN_OR_LINK_IFELSE([AC_LANG_PROGRAM([
#include <gd.h>
#include <gdfontmb.h>
#include <stdio.h>
],
[
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])
Expand Down
32 changes: 26 additions & 6 deletions m4/nut_check_libsystemd.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down

0 comments on commit a682eae

Please sign in to comment.