Skip to content

Commit b790e02

Browse files
authored
Squash automake warning when conditionally adding prerequisites to a target (#720)
1 parent 878e2d7 commit b790e02

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

Makefile.am

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ ACLOCAL_AMFLAGS = -I m4
77

88
AM_CPPFLAGS="-I$(srcdir)/src"
99

10+
## Set some variables to accumulate conditionally-set Automake targets.
11+
12+
CLEAN_LOCAL_TARGETS=
13+
DISTCLEAN_LOCAL_TARGETS=
14+
PHONY_TARGETS=
15+
1016
## Specify the documentation files that are distributed.
1117

1218
dist_doc_DATA = \
@@ -851,13 +857,14 @@ CLEANFILES += \
851857
testtrygrep \
852858
testNinputgrep
853859

854-
clean-local: testoutput-clean
855-
.PHONY: testoutput-clean
856860
testoutput-clean:
857861
-rm -rf testoutput8 testoutput8-jit testoutput8-dfa
858862
-rm -rf testoutput16 testoutput16-jit testoutput16-dfa
859863
-rm -rf testoutput32 testoutput32-jit testoutput32-dfa
860864

865+
CLEAN_LOCAL_TARGETS += testoutput-clean
866+
PHONY_TARGETS += testoutput-clean
867+
861868
## ------------ End of testing -------------
862869

863870

@@ -964,24 +971,27 @@ coverage-clean: coverage-reset coverage-clean-report coverage-clean-data
964971
coverage-distclean: coverage-clean
965972

966973
coverage: coverage-reset coverage-baseline coverage-check coverage-report
967-
clean-local: coverage-clean
968-
distclean-local: coverage-distclean
969974

970-
.PHONY: coverage coverage-baseline coverage-check coverage-report coverage-reset coverage-clean-report coverage-clean-data coverage-clean coverage-distclean
971-
972-
# Without coverage support, still arrange for 'make distclean' to get rid of
973-
# any coverage files that may have been left from a different configuration.
975+
CLEAN_LOCAL_TARGETS += coverage-clean
976+
DISTCLEAN_LOCAL_TARGETS += coverage-distclean
977+
PHONY_TARGETS += coverage coverage-baseline coverage-check coverage-report coverage-reset coverage-clean-report coverage-clean-data coverage-clean coverage-distclean
974978

975979
else
976980

977981
coverage:
978982
@echo "Configuring with --enable-coverage is required to generate code coverage report."
979983

984+
# Without coverage support, still arrange for 'make distclean' to get rid of
985+
# any coverage files that may have been left from a different configuration.
986+
980987
DISTCLEANFILES += src/*.gcda src/*.gcno
981988

982-
distclean-local:
989+
coverage-distclean:
983990
rm -rf $(PACKAGE)-$(VERSION)-coverage*
984991

992+
DISTCLEAN_LOCAL_TARGETS += coverage-distclean
993+
PHONY_TARGETS += coverage-distclean
994+
985995
endif # WITH_GCOV
986996

987997
## CMake support
@@ -995,4 +1005,14 @@ EXTRA_DIST += \
9951005
src/config-cmake.h.in \
9961006
CMakeLists.txt
9971007

1008+
## Set the special make and Automake targets. We could very easily simply
1009+
## redefine these targets to append prerequisites to them, rather than
1010+
## collecting the prerequisites in variables. However, there is an annoying
1011+
## Automake behaviour where it emits a warning if a target has prerequisites
1012+
## appended in a conditional block.
1013+
1014+
clean-local: $(CLEAN_LOCAL_TARGETS)
1015+
distclean-local: $(DISTCLEAN_LOCAL_TARGETS)
1016+
.PHONY: $(PHONY_TARGETS)
1017+
9981018
## end Makefile.am

0 commit comments

Comments
 (0)