diff --git a/Makefile.am b/Makefile.am index ed5ec42138..9c5bfa5356 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,9 +51,48 @@ memcheck distcheck-valgrind: distcleancheck: @: -clean-local: - rm -f *-spellchecked - rm -f cppcheck*.xml +# Quick alias for root dir recipe: +realclean: maintainer-clean + +# Files made by our targets: +CLEANFILES = *-spellchecked cppcheck*.xml +DISTCLEANFILES = ChangeLog + +# Most of the files generated by custom rules in the configure script +# or by autogen.sh are cleaned by the Makefile.am in their directories. +# Files below are re-created by running `configure` script and may be +# wiped by a `make distclean`: +DISTCLEANFILES += config.log configure~ +#???# configure.ac~ +DISTCLEANFILES += include/config.h.in~ + +# Files made by autotools and common rituals of the configure script, +# these are needed to run the configure script itself so are not wiped +# by a mere `make distclean`; most of these are copied by autotools +# from their installation, or made by `automake` etc. on the system +# which generates `configure`; rebuilding NUT after deleting these +# requires `autogen.sh` script to be re-run (and tools available): +MAINTAINERCLEANFILES = INSTALL +MAINTAINERCLEANFILES += aclocal.m4 config.guess config.sub +MAINTAINERCLEANFILES += configure +MAINTAINERCLEANFILES += depcomp install-sh ltmain.sh missing test-driver +MAINTAINERCLEANFILES += m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 +MAINTAINERCLEANFILES += Makefile.in include/config.h.in + +# Do not let $SUBDIRS/Makefile rules delete their local .deps because +# this breaks our ability to clean up (e.g. some common/.../*.Plo files +# are included by generated Makefiles from other subdirectories, so they +# should be available during their clean-up). Just in case, we make sure +# here that their sub-distcleans complete first. +distclean-local: + @for DIR in $(SUBDIRS) ; do \ + if test -f "$${DIR}/Makefile" ; then \ + echo " DISTCLEAN in $${DIR}" >&2 ; \ + ( cd "$${DIR}" && $(MAKE) -s distclean ) || exit ; \ + fi ; \ + done + rm -rf .inst tmp autom4te.cache + find "$(builddir)" -type d -name '.deps' | while read DIR ; do rm -rf "$${DIR}" ; done # Hook the documentation building and validating recipes # Note: these are optionally available (as determined during configure runs) @@ -122,7 +161,7 @@ endif !HAVE_CPPCHECK # ---------------------------------------------------------------------- # Automatically generate the ChangeLog from Git logs: -MAINTAINERCLEAN_FILES = ChangeLog +MAINTAINERCLEANFILES += ChangeLog # Older boundary of the ChangeLog commits range # It can be a tag ('v2.2.0'), a commit hash, a date, ... @@ -141,6 +180,9 @@ ChangeLog: tools/gitlog2changelog.py dummy-stamp nut_version.h include/nut_version.h: cd $(abs_top_builddir)/include && $(MAKE) nut_version.h +tools/gitlog2changelog.py: tools/gitlog2changelog.py.in + cd $(@D) && $(MAKE) -s $(@F) + # ---------------------------------------------------------------------- # Maintainers targets: distribution signature and hashes dist-sig: @@ -206,6 +248,23 @@ snmp build-snmp install-snmp install-snmp-mgr install-snmp-man: setver: @echo "Error: 'make setver' no longer exists." @echo "Edit configure.ac to set version number." + +# Clean the dist tarball and packages +MAINTAINERCLEANFILES_DISTBALL = nut-*.tar.gz +# HP-UX: +MAINTAINERCLEANFILES_PACKAGES = NUT_HPUX_package@PACKAGE_VERSION@.depot +# AIX as below, and RedHat-compatible (cover binary and source packages): +MAINTAINERCLEANFILES_PACKAGES += nut*rpm +# Debian-compatible (cover binary and source packages): +MAINTAINERCLEANFILES_PACKAGES += nut*deb +# Solaris SVR4 package archives: +MAINTAINERCLEANFILES_PACKAGES += NUT_solaris_*_package@PACKAGE_VERSION@.local.gz +# Newer Solaris IPS (aka "pkg(5)" format archives) +MAINTAINERCLEANFILES_PACKAGES += *.p5p + +MAINTAINERCLEANFILES += $(MAINTAINERCLEANFILES_DISTBALL) +MAINTAINERCLEANFILES += $(MAINTAINERCLEANFILES_PACKAGES) + package: DESTDIR="$(abs_builddir)/_install_pkgprotodir" ; export DESTDIR; \ rm -rf "$$DESTDIR"; \ diff --git a/ci_build.sh b/ci_build.sh index 8f29b81626..904a662e9a 100755 --- a/ci_build.sh +++ b/ci_build.sh @@ -220,6 +220,19 @@ configure_nut() { CONFIGURE_SCRIPT=./configure.bat fi + if [ ! -s "$CONFIGURE_SCRIPT" ]; then + # 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 [ "$CI_OS_NAME" = "windows" ] ; then + $CI_TIME ./autogen.sh || true + else + $CI_TIME ./autogen.sh ### 2>/dev/null + fi || exit + fi + # Help copy-pasting build setups from CI logs to terminal: local CONFIG_OPTS_STR="`for F in "${CONFIG_OPTS[@]}" ; do echo "'$F' " ; done`" ### | tr '\n' ' '`" echo "=== CONFIGURING NUT: $CONFIGURE_SCRIPT ${CONFIG_OPTS_STR}" @@ -252,6 +265,29 @@ build_to_only_catch_errors() { return 0 } +optional_maintainer_clean_check() { + if [ "${DO_MAINTAINER_CLEAN_CHECK-}" = "no" ] ; then + echo "Skipping maintainer-clean check because recipe/developer said so" + else + [ -z "$CI_TIME" ] || echo "`date`: Starting maintainer-clean check of currently tested project..." + + # Note: currently Makefile.am has just a dummy "distcleancheck" rule + $CI_TIME $MAKE VERBOSE=1 DISTCHECK_FLAGS="$DISTCHECK_FLAGS" $PARMAKE_FLAGS maintainer-clean || return + + echo "=== Are GitIgnores good after '$MAKE maintainer-clean'? (should have no output below)" + git status --ignored -s || true + echo "===" + + if [ -n "`git status --ignored -s`" ] && [ "$CI_REQUIRE_GOOD_GITIGNORE" != false ]; then + echo "FATAL: There are changes in some files listed above - tracked sources should be updated in the PR, and build products should be added to a .gitignore file, everything made should be cleaned and no tracked files should be removed!" >&2 + git diff || true + echo "===" + return 1 + fi + fi + return 0 +} + echo "Processing BUILD_TYPE='${BUILD_TYPE}' ..." echo "Build host settings:" @@ -642,7 +678,7 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp else $CI_TIME ./autogen.sh ### 2>/dev/null fi - if [ "$NO_PKG_CONFIG" == "true" ] && [ "$CI_OS_NAME" = "linux" ] ; then + if [ "$NO_PKG_CONFIG" == "true" ] && [ "$CI_OS_NAME" = "linux" ] && (command -v dpkg) ; then echo "NO_PKG_CONFIG==true : BUTCHER pkg-config for this test case" >&2 sudo dpkg -r --force all pkg-config fi @@ -678,6 +714,9 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp echo "CCache stats after build:" ccache -s fi + + optional_maintainer_clean_check || exit + echo "=== Exiting after the custom-build target '$MAKE $BUILD_TGT' succeeded OK" exit 0 ;; @@ -777,6 +816,11 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp RES=$? FAILED="${FAILED} NUT_SSL_VARIANT=${NUT_SSL_VARIANT}[build]" } + + optional_maintainer_clean_check || { + RES=$? + FAILED="${FAILED} NUT_SSL_VARIANT=${NUT_SSL_VARIANT}[maintainer_clean]" + } done # TODO: Similar loops for other variations like TESTING, # MGE SHUT vs other serial protocols, libusb version... @@ -827,9 +871,18 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp echo "=== Are GitIgnores good after '$MAKE distcheck'? (should have no output below)" git status -s || true echo "===" + + if [ -n "`git status -s`" ] && [ "$CI_REQUIRE_GOOD_GITIGNORE" != false ]; then + echo "FATAL: There are changes in some files listed above - tracked sources should be updated in the PR, and build products should be added to a .gitignore file!" >&2 + git diff || true + echo "===" + exit 1 + fi ) fi + optional_maintainer_clean_check || exit + if [ "$HAVE_CCACHE" = yes ]; then echo "CCache stats after build:" ccache -s diff --git a/clients/Makefile.am b/clients/Makefile.am index d77db3f765..25a2c7e93c 100644 --- a/clients/Makefile.am +++ b/clients/Makefile.am @@ -94,3 +94,10 @@ libnutclientstub_la_LIBADD = libnutclient.la else EXTRA_DIST += nutclientmem.h nutclientmem.cpp endif + +MAINTAINERCLEANFILES = Makefile.in + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps diff --git a/common/Makefile.am b/common/Makefile.am index 3917a80039..1d00e38123 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -20,3 +20,10 @@ libcommonclient_la_SOURCES = common.c state.c str.c # using LTLIBOBJS. Refer to configure.in/.ac -> AC_REPLACE_FUNCS libcommon_la_LIBADD = libparseconf.la @LTLIBOBJS@ libcommonclient_la_LIBADD = libparseconf.la @LTLIBOBJS@ + +MAINTAINERCLEANFILES = Makefile.in + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps diff --git a/conf/Makefile.am b/conf/Makefile.am index 2d5947dd5d..220265312b 100644 --- a/conf/Makefile.am +++ b/conf/Makefile.am @@ -19,9 +19,6 @@ nodist_sysconf_DATA = upssched.conf.sample upsmon.conf.sample SPELLCHECK_SRC = $(dist_sysconf_DATA) \ upssched.conf.sample.in upsmon.conf.sample.in -clean-local: - rm -f *.pdf *.html *-spellchecked - # NOTE: Due to portability, we do not use a GNU percent-wildcard extension: #%-spellchecked: % Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) # $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ @@ -38,3 +35,7 @@ clean-local: spellcheck spellcheck-interactive spellcheck-sortdict: $(MAKE) -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC="$(SPELLCHECK_SRC)" SPELLCHECK_DIR="$(srcdir)" $@ + + +MAINTAINERCLEANFILES = Makefile.in +CLEANFILES = *.pdf *.html *-spellchecked diff --git a/data/Makefile.am b/data/Makefile.am index d5a694a182..23d7b8098c 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -6,9 +6,6 @@ dist_data_DATA = cmdvartab nodist_data_DATA = driver.list EXTRA_DIST = evolution500.seq epdu-managed.dev -clean-local: - rm -f *.pdf *.html *-spellchecked - # NOTE: Due to portability, we do not use a GNU percent-wildcard extension: #%-spellchecked: % Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) # $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ @@ -18,3 +15,6 @@ cmdvartab-spellchecked: cmdvartab Makefile.am $(top_srcdir)/docs/Makefile.am $(a spellcheck spellcheck-interactive spellcheck-sortdict: $(MAKE) -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC="cmdvartab" SPELLCHECK_DIR="$(srcdir)" $@ + +MAINTAINERCLEANFILES = Makefile.in +CLEANFILES = *.pdf *.html *-spellchecked diff --git a/data/html/Makefile.am b/data/html/Makefile.am index 956e66b884..823f18a9bc 100644 --- a/data/html/Makefile.am +++ b/data/html/Makefile.am @@ -1,7 +1,11 @@ -# Network UPS Tools: data/html +# Network UPS Tools: data/html # install these only if configured --with-cgi if WITH_CGI dist_html_DATA = index.html bottom.html nut-banner.png nodist_html_DATA = header.html endif EXTRA_DIST = README + +MAINTAINERCLEANFILES = Makefile.in +# Generated by configure script: +DISTCLEANFILES = header.html diff --git a/docs/Makefile.am b/docs/Makefile.am index a02c850f46..fe2032861e 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -1,4 +1,4 @@ -DISTCLEANFILES = +MAINTAINERCLEANFILES = Makefile.in EXTRA_DIST = # Is "egrep == grep -E" always valid? (maybe all a job for configure.ac) @@ -136,8 +136,10 @@ check-man: man: cd $(top_builddir)/docs/man/ && $(MAKE) -f Makefile all +CLEANFILES = *.xml *.html *.pdf *-spellchecked docbook-xsl.css + +# Dirs to clean clean-local: - rm -f *.pdf *.html *-spellchecked docbook-xsl.css rm -rf *.chunked *.bak tmp ### TODO: automatic dependency generation @@ -368,7 +370,7 @@ $(abs_builddir)/$(NUT_SPELL_DICT).sorted: $(abs_srcdir)/$(NUT_SPELL_DICT) cp -f "$(abs_builddir)/$(NUT_SPELL_DICT).bak-pre-sorting" "$(abs_srcdir)/" || true ; \ fi -DISTCLEANFILES += $(NUT_SPELL_DICT).bak-pre-sorting .$(NUT_SPELL_DICT).sorted $(NUT_SPELL_DICT).sorted +DISTCLEANFILES = $(NUT_SPELL_DICT).bak-pre-sorting .$(NUT_SPELL_DICT).sorted $(NUT_SPELL_DICT).sorted spellcheck-interactive: @FAILED="" ; for docsrc in $(SPELLCHECK_SRC); do \ diff --git a/docs/cables/Makefile.am b/docs/cables/Makefile.am index 1431357241..ee269a84c4 100644 --- a/docs/cables/Makefile.am +++ b/docs/cables/Makefile.am @@ -1,2 +1,2 @@ -clean-local: - rm -f *-spellchecked +CLEANFILES = *-spellchecked +MAINTAINERCLEANFILES = Makefile.in diff --git a/docs/man/Makefile.am b/docs/man/Makefile.am index 3a4e460ec2..43f326f468 100644 --- a/docs/man/Makefile.am +++ b/docs/man/Makefile.am @@ -790,7 +790,7 @@ check-man-txt: $(SRC_ALL_PAGES) echo "FAILED man-source sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \ fi; echo "PASSED man-source sanity check (checked $$CHECKED files)"; exit 0 -CLEANFILES = *.xml *.html +CLEANFILES = *-spellchecked SUFFIXES = .txt .html .1 .3 .5 .8 @@ -806,6 +806,8 @@ endif if HAVE_ASCIIDOC +CLEANFILES += *.1 *.3 *.5 *.8 *.xml *.html *.pdf + # Working around a2x not friendly to parallelized runs. # See more details in the main NUT docs/Makefile.am DOCBUILD_BEGIN = { \ @@ -931,11 +933,6 @@ else !HAVE_ASCIIDOC endif !HAVE_ASCIIDOC -clean-local: - rm -f *.pdf *.html *-spellchecked - rm -f *.1 *.3 *.5 *.8 - rm -rf tmp - # NOTE: Due to portability, we do not use a GNU percent-wildcard extension: #%-spellchecked: % Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) # $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ @@ -948,3 +945,8 @@ clean-local: spellcheck spellcheck-interactive spellcheck-sortdict: $(MAKE) -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC="$(SRC_ALL_PAGES)" SPELLCHECK_DIR="$(srcdir)" $@ + +MAINTAINERCLEANFILES = Makefile.in + +clean-local: + rm -rf tmp diff --git a/drivers/Makefile.am b/drivers/Makefile.am index c4a045d959..3bebfc7562 100644 --- a/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -54,7 +54,9 @@ MODBUS_DRIVERLIST = phoenixcontact_modbus generic_modbus LINUX_I2C_DRIVERLIST = asem pijuice # distribute all drivers, even ones that are not built by default -EXTRA_PROGRAMS = $(SERIAL_DRIVERLIST) $(SNMP_DRIVERLIST) $(USB_DRIVERLIST) $(SERIAL_USB_DRIVERLIST) $(NEONXML_DRIVERLIST) $(MACOSX_DRIVERLIST) +EXTRA_PROGRAMS = $(SERIAL_DRIVERLIST) $(USB_DRIVERLIST) $(SERIAL_USB_DRIVERLIST) +EXTRA_PROGRAMS += $(SNMP_DRIVERLIST) $(NEONXML_DRIVERLIST) $(MACOSX_DRIVERLIST) +EXTRA_PROGRAMS += $(LINUX_I2C_DRIVERLIST) # construct the list of drivers to build if SOME_DRIVERS @@ -325,3 +327,11 @@ libdummy_la_SOURCES = main.c dstate.c libdummy_la_LDFLAGS = -no-undefined -static libdummy_serial_la_SOURCES = serial.c libdummy_serial_la_LDFLAGS = -no-undefined -static + +CLEANFILES = $(EXTRA_LTLIBRARIES) $(EXTRA_PROGRAMS) +MAINTAINERCLEANFILES = Makefile.in + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps diff --git a/include/Makefile.am b/include/Makefile.am index 59bbfcfc57..385e32eb61 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -4,6 +4,7 @@ dist_noinst_HEADERS = attribute.h common.h extstate.h parseconf.h proto.h \ # http://www.gnu.org/software/automake/manual/automake.html#Clean BUILT_SOURCES = nut_version.h CLEANFILES = nut_version.h +MAINTAINERCLEANFILES = Makefile.in # magic to include Git version information in NUT version string # (for builds not made from the tagged commit in a Git workspace) @@ -32,7 +33,7 @@ nut_version.h: FORCE FORCE: # counter part of BUILT_SOURCES: since nut_version is not a direct -# deps of a local target, we must clean it by ourself before the +# deps of a local target, we must clean it by ourselves before the # distribution dist-hook: rm -f $(distdir)/nut_version.h diff --git a/lib/Makefile.am b/lib/Makefile.am index 856d0db728..8256a9ad6b 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -8,5 +8,5 @@ else endif endif -clean-local: - rm -f *-spellchecked +CLEANFILES = *-spellchecked +MAINTAINERCLEANFILES = Makefile.in diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 17b1dd28fb..bb076ece15 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -26,3 +26,5 @@ EXTRA_DIST = README \ Windows/Makefile SUBDIRS = augeas devd hotplug python systemd udev ufw Solaris upsdrvsvcctl + +MAINTAINERCLEANFILES = Makefile.in diff --git a/scripts/Solaris/Makefile.am b/scripts/Solaris/Makefile.am index b9651ef114..5a76433188 100644 --- a/scripts/Solaris/Makefile.am +++ b/scripts/Solaris/Makefile.am @@ -84,3 +84,5 @@ check-local-solaris-smf: $(SOLARIS_SMF_MANIFESTS) echo " SVCCFG-VALIDATE $$F"; \ /usr/sbin/svccfg validate "$$F" || RES=$$? ; \ done; exit $$RES + +MAINTAINERCLEANFILES = Makefile.in diff --git a/scripts/augeas/Makefile.am b/scripts/augeas/Makefile.am index b9a6774df9..ae667f9c53 100644 --- a/scripts/augeas/Makefile.am +++ b/scripts/augeas/Makefile.am @@ -37,5 +37,13 @@ if WITH_AUGLENS nutnutconf.aug nutupsdconf.aug nutupsmonconf.aug nutupssetconf.aug endif -clean-local: - rm -f *-spellchecked +MAINTAINERCLEANFILES = Makefile.in +CLEANFILES = *-spellchecked + +# Can be re-generated by configure script and/or make: +DISTCLEANFILES = gen-nutupsconf-aug.py + +# Generated by autogen.sh and needed to run the configure script: +MAINTAINERCLEANFILES += nutupsconf.aug.in + +DISTCLEANFILES += *.aug diff --git a/scripts/devd/Makefile.am b/scripts/devd/Makefile.am index e5a9bbcce9..f809a999b9 100644 --- a/scripts/devd/Makefile.am +++ b/scripts/devd/Makefile.am @@ -9,6 +9,16 @@ endif EXTRA_DIST = README +MAINTAINERCLEANFILES = Makefile.in + +# Generated by configure script: DISTCLEANFILES = nut-usb.conf + # we should never remove this one, apart from a distclean-check #MAINTAINERCLEANFILES = nut-usbups.rules.in + +# Generated by autogen.sh and needed to run the configure script +# (technically, generated by tools/nut-usbinfo.pl script among +# GENERATED_USB_OS_FILES): +MAINTAINERCLEANFILES += nut-usbups.rules.in +MAINTAINERCLEANFILES += nut-usb.conf.in diff --git a/scripts/hotplug/Makefile.am b/scripts/hotplug/Makefile.am index c36cd7dad1..9ba1d22f5f 100644 --- a/scripts/hotplug/Makefile.am +++ b/scripts/hotplug/Makefile.am @@ -6,6 +6,16 @@ if WITH_HOTPLUG endif EXTRA_DIST = README + +MAINTAINERCLEANFILES = Makefile.in + +# Generated by configure script: DISTCLEANFILES = libhidups + # we should never remove this one, apart from a distclean-check #MAINTAINERCLEANFILES = libhid.usermap + +# Generated by autogen.sh and needed to run the configure script +# (technically, generated by tools/nut-usbinfo.pl script among +# GENERATED_USB_OS_FILES): +MAINTAINERCLEANFILES += libhid.usermap diff --git a/scripts/python/Makefile.am b/scripts/python/Makefile.am index 8ab6bf6ff0..ce23b825fb 100644 --- a/scripts/python/Makefile.am +++ b/scripts/python/Makefile.am @@ -20,3 +20,4 @@ EXTRA_DIST = README \ module/PyNUT.py.in \ module/test_nutclient.py.in +MAINTAINERCLEANFILES = Makefile.in diff --git a/scripts/systemd/Makefile.am b/scripts/systemd/Makefile.am index dfd93959bd..594ee9de6c 100644 --- a/scripts/systemd/Makefile.am +++ b/scripts/systemd/Makefile.am @@ -31,3 +31,7 @@ EXTRA_DIST += \ # NOTE: Do not EXTRA_DIST nut-common.tmpfiles.in - it is generated per build endif +MAINTAINERCLEANFILES = Makefile.in + +# Generated by autogen.sh and needed to run the configure script: +MAINTAINERCLEANFILES += nut-common.tmpfiles.in diff --git a/scripts/udev/Makefile.am b/scripts/udev/Makefile.am index 1973ccf89b..5977f8eca2 100644 --- a/scripts/udev/Makefile.am +++ b/scripts/udev/Makefile.am @@ -18,7 +18,17 @@ EXTRA_DIST = README 52-nut-ipmipsu.rules: nut-ipmipsu.rules cp nut-ipmipsu.rules $@ +MAINTAINERCLEANFILES = Makefile.in + +# Generated by configure script: DISTCLEANFILES = nut-usbups.rules nut-ipmipsu.rules + CLEANFILES = 62-nut-usbups.rules 52-nut-ipmipsu.rules + # we should never remove this one, apart from a distclean-check #MAINTAINERCLEANFILES = nut-usbups.rules.in + +# Generated by autogen.sh and needed to run the configure script +# (technically, generated by tools/nut-usbinfo.pl script among +# GENERATED_USB_OS_FILES): +MAINTAINERCLEANFILES += nut-usbups.rules.in diff --git a/scripts/ufw/Makefile.am b/scripts/ufw/Makefile.am index 1431357241..7793f24713 100644 --- a/scripts/ufw/Makefile.am +++ b/scripts/ufw/Makefile.am @@ -1,2 +1,2 @@ -clean-local: - rm -f *-spellchecked +MAINTAINERCLEANFILES = Makefile.in +CLEANFILES = *-spellchecked diff --git a/scripts/upsdrvsvcctl/Makefile.am b/scripts/upsdrvsvcctl/Makefile.am index 7d7a0f235e..2af566cfea 100644 --- a/scripts/upsdrvsvcctl/Makefile.am +++ b/scripts/upsdrvsvcctl/Makefile.am @@ -10,3 +10,4 @@ endif EXTRA_DIST += nut-driver-enumerator.sh.in upsdrvsvcctl.in +MAINTAINERCLEANFILES = Makefile.in diff --git a/server/Makefile.am b/server/Makefile.am index 76f15e6c7a..0d1b933560 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -33,3 +33,10 @@ upsd_SOURCES = upsd.c user.c conf.c netssl.c sstate.c desc.c \ upstype.h user-data.h user.h sockdebug_SOURCES = sockdebug.c + +MAINTAINERCLEANFILES = Makefile.in + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps diff --git a/tests/Makefile.am b/tests/Makefile.am index dd2b60f11b..095b1d838d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,6 +5,7 @@ all: $(TESTS) EXTRA_DIST = nut-driver-enumerator-test.sh nut-driver-enumerator-test--ups.conf TESTS = nutlogtest getvaluetest +CLEANFILES = *.trs *.log AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/drivers AM_CXXFLAGS = -I$(top_srcdir)/include @@ -14,7 +15,16 @@ check_PROGRAMS = $(TESTS) nutlogtest_SOURCES = nutlogtest.c nutlogtest_LDADD = $(top_builddir)/common/libcommon.la -getvaluetest_SOURCES = getvaluetest.c $(top_srcdir)/drivers/hidparser.c +# Separate the .deps of other dirs from this one +LINKED_SOURCE_FILES = $(builddir)/hidparser.c + +# NOTE: Not using "$<" due to a legacy Sun/illumos dmake bug with resolver +# of dynamic vars, see e.g. https://man.omnios.org/man1/make#BUGS +$(builddir)/hidparser.c: $(top_srcdir)/drivers/hidparser.c + test -s "$@" || ln -s -f "$(top_srcdir)/drivers/hidparser.c" "$@" + +getvaluetest_SOURCES = getvaluetest.c +nodist_getvaluetest_SOURCES = $(builddir)/hidparser.c getvaluetest_LDADD = $(top_builddir)/common/libcommon.la # Make sure out-of-dir dependencies exist (especially when dev-building parts): @@ -27,12 +37,14 @@ CPPUNITTESTSRC = example.cpp nutclienttest.cpp # The test driver which orchestrates running those tests above CPPUNITTESTERSRC = cpputest.cpp +TESTS_CXX11 = cppunittest + if HAVE_CXX11 if HAVE_CPPUNIT # Note: per configure script this "SHOULD" also assume # that we HAVE_CXX11 - but better have it explicit -TESTS += cppunittest +TESTS += $(TESTS_CXX11) if WITH_VALGRIND check-local: $(check_PROGRAMS) @@ -65,3 +77,13 @@ else !HAVE_CXX11 EXTRA_DIST += example.cpp cpputest.cpp endif !HAVE_CXX11 + +BUILT_SOURCES = $(LINKED_SOURCE_FILES) +CLEANFILES += $(LINKED_SOURCE_FILES) +CLEANFILES += $(TESTS) $(TESTS_CXX11) +MAINTAINERCLEANFILES = Makefile.in + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps diff --git a/tools/Makefile.am b/tools/Makefile.am index 17c2252f1e..5a2bb7fc67 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -32,6 +32,10 @@ GENERATED_USB_OS_FILES += ../scripts/devd/nut-usb.conf.in # UPower output file GENERATED_USB_OS_FILES += ../scripts/upower/95-upower-hid.rules +CLEANFILES = $(GENERATED_SNMP_FILES) $(GENERATED_USB_FILES) +# We do not clean away these files, some are even tracked in Git: +#CLEANFILES += $(GENERATED_USB_OS_FILES) + all: nut-scanner-deps $(GENERATED_USB_OS_FILES) # This target is called from the making of nut-scanner to ensure its bits @@ -105,4 +109,11 @@ dist-hook: @$(distdir)/driver-list-format.sh; +MAINTAINERCLEANFILES = Makefile.in + +# Can be recreated by `make` or `configure`, +# impacted by choice of PYTHON version: +DISTCLEANFILES = gitlog2changelog.py +DISTCLEANFILES += nut-snmpinfo.py + .PHONY: nut-scanner-deps nut-scanner-snmp-deps nut-scanner-usb-deps diff --git a/tools/nut-scanner/Makefile.am b/tools/nut-scanner/Makefile.am index 680703eb85..938ad32cf3 100644 --- a/tools/nut-scanner/Makefile.am +++ b/tools/nut-scanner/Makefile.am @@ -7,6 +7,7 @@ NUT_SCANNER_DEPS_C = NUT_SCANNER_DEPS = $(NUT_SCANNER_DEPS_H) $(NUT_SCANNER_DEPS_C) BUILT_SOURCES = $(NUT_SCANNER_DEPS) +CLEANFILES = $(BUILT_SOURCES) # Make sure we have the freshest files (no-op if built earlier and then # no driver sources and other dependencies were edited by a developer) @@ -21,7 +22,31 @@ $(top_builddir)/common/libcommon.la: # 'dist', and is only required for actual build, in which case # BUILT_SOURCES (in ../include) will ensure nut_version.h will # be built before anything else -$(top_srcdir)/common/common.c nut-scanner.c: $(top_builddir)/include/nut_version.h +common.c nut-scanner.c: $(top_builddir)/include/nut_version.h + +LINKED_SOURCE_FILES = + +# Separate the .deps of other dirs from this one +# NOTE: Not using "$<" due to a legacy Sun/illumos dmake bug with resolver +# of dynamic vars, see e.g. https://man.omnios.org/man1/make#BUGS +LINKED_SOURCE_FILES += $(builddir)/serial.c +$(builddir)/serial.c: $(top_srcdir)/drivers/serial.c + test -s "$@" || ln -s -f "$(top_srcdir)/drivers/serial.c" "$@" + +LINKED_SOURCE_FILES += $(builddir)/bcmxcp_ser.c +$(builddir)/bcmxcp_ser.c: $(top_srcdir)/drivers/bcmxcp_ser.c + test -s "$@" || ln -s -f "$(top_srcdir)/drivers/bcmxcp_ser.c" "$@" + +LINKED_SOURCE_FILES += $(builddir)/common.c +$(builddir)/common.c: $(top_srcdir)/common/common.c + test -s "$@" || ln -s -f "$(top_srcdir)/common/common.c" "$@" + +LINKED_SOURCE_FILES += $(builddir)/str.c +$(builddir)/str.c: $(top_srcdir)/common/str.c + test -s "$@" || ln -s -f "$(top_srcdir)/common/str.c" "$@" + +CLEANFILES += $(LINKED_SOURCE_FILES) +BUILT_SOURCES += $(LINKED_SOURCE_FILES) $(top_builddir)/include/nut_version.h: @cd $(@D) && $(MAKE) -s $(@F) @@ -34,10 +59,8 @@ endif libnutscan_la_SOURCES = scan_nut.c scan_ipmi.c \ nutscan-device.c nutscan-ip.c nutscan-display.c \ nutscan-init.c scan_usb.c scan_snmp.c scan_xml_http.c \ - scan_avahi.c scan_eaton_serial.c nutscan-serial.c \ - $(top_srcdir)/drivers/serial.c \ - $(top_srcdir)/drivers/bcmxcp_ser.c \ - $(top_srcdir)/common/common.c $(top_srcdir)/common/str.c + scan_avahi.c scan_eaton_serial.c nutscan-serial.c +nodist_libnutscan_la_SOURCES = $(LINKED_SOURCE_FILES) libnutscan_la_LIBADD = $(NETLIBS) $(LIBLTDL_LIBS) # # Below we set API versions of public libraries @@ -82,7 +105,10 @@ else dist_noinst_HEADERS += nut-scan.h nutscan-device.h nutscan-ip.h nutscan-init.h nutscan-serial.h endif -CLEANFILES = $(BUILT_SOURCES) +CLEANFILES += *-spellchecked +MAINTAINERCLEANFILES = Makefile.in -clean-local: - rm -f *-spellchecked +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps