-# All the source files that have coverage counters.
-COVERAGE_FILES = \
- lib/dpif.c \
- lib/flow.c \
- lib/lockfile.c \
- lib/hmap.c \
- lib/mac-learning.c \
- lib/netdev.c \
- lib/netdev-linux.c \
- lib/netlink.c \
- lib/odp-util.c \
- lib/poll-loop.c \
- lib/process.c \
- lib/rconn.c \
- lib/rtnetlink.c \
- lib/stream.c \
- lib/timeval.c \
- lib/unixctl.c \
- lib/util.c \
- lib/vconn.c \
- ofproto/ofproto.c \
- ofproto/pktbuf.c \
- vswitchd/bridge.c \
- vswitchd/ovs-brcompatd.c
-lib/coverage-counters.c: $(COVERAGE_FILES) lib/coverage-scan.pl
- (cd $(srcdir) && $(PERL) lib/coverage-scan.pl $(COVERAGE_FILES)) > $@.tmp
- mv $@.tmp $@
-EXTRA_DIST += lib/coverage-scan.pl
+if !USE_LINKER_SECTIONS
+# All distributed sources, with names adjust properly for referencing
+# from $(builddir).
+all_sources = \
+ `for file in $(DIST_SOURCES); do \
+ if test -f $$file; then \
+ echo $$file; \
+ else \
+ echo $(VPATH)/$$file; \
+ fi; \
+ done`
+
+lib/coverage.$(OBJEXT): lib/coverage.def
+lib/coverage.def: $(DIST_SOURCES)
+ sed -n 's|^COVERAGE_DEFINE(\([_a-zA-Z0-9]\{1,\}\)).*$$|COVERAGE_COUNTER(\1)|p' $(all_sources) | LC_ALL=C sort -u > $@
+CLEANFILES += lib/coverage.def
+
+lib/stress.$(OBJEXT): lib/stress.def
+lib/stress.def: $(DIST_SOURCES)
+ sed -n '/^STRESS_OPTION(/,/);$$/{s/);$$/)/;p}' $(all_sources) > $@
+CLEANFILES += lib/stress.def
+
+lib/vlog.$(OBJEXT): lib/vlog-modules.def
+lib/vlog-modules.def: $(DIST_SOURCES)
+ sed -n 's|^VLOG_DEFINE_\(THIS_\)\{0,1\}MODULE(\([_a-zA-Z0-9]\{1,\}\)).*$$|VLOG_MODULE(\2)|p' $(all_sources) | LC_ALL=C sort -u > $@
+CLEANFILES += lib/vlog-modules.def
+endif