In my system, a single makefile approach is used, which includes many makefiles. All targets (excluding phony targets) have an absolute path.
I have been using the following rules which work pretty well but I am not happy with this approach because it depends on parsing the output of make -p. If that output formatting ever changes, these rules will break.
I would like to know if there is a better way or how difficult would it be to add such a query feature to make, via command line options or any other tricks for accessing makes internal database directly.
Thanks.
# Makefile
.PHONY: FORCE $(CURDIR)/foo1: $(CURDIR)/foo2 $(CURDIR)/foo1: $(CURDIR)/foo3 $(CURDIR)/foo2: $(CURDIR)/foo3
$(CURDIR)/foo%:
@echo $@# echo the prerequisites of target /%
reqs./%: FORCE
@$(MAKE) -p /$* 2>/dev/null|sed -n -e 's%^/$(patsubst .,\.,$*): \(.*\)%\1%p' -e '\%^/$(patsubst .,\.,$*):.*%q'
# echo the dependents of target /%
deps./%: FORCE
@$(MAKE) -p /$* 2>/dev/null|sed -n 's%^\(/.*\):.* /$(patsubst .,\.,$*)\b.*%\1%p'
#eof
[EMAIL PROTECTED] junk]$ make reqs.$(pwd -P)/foo1
/usr/local/apache/htdocs/common/test/junk/foo2 /usr/local/apache/htdocs/common/test/junk/foo3
[EMAIL PROTECTED] junk]$ make reqs.$(pwd -P)/foo2
/usr/local/apache/htdocs/common/test/junk/foo3
[EMAIL PROTECTED] junk]$ make reqs.$(pwd -P)/foo3
[EMAIL PROTECTED] junk]$ make deps.$(pwd -P)/foo1
[EMAIL PROTECTED] junk]$ make deps.$(pwd -P)/foo2
/usr/local/apache/htdocs/common/test/junk/foo1
[EMAIL PROTECTED] junk]$ make deps.$(pwd -P)/foo3
/usr/local/apache/htdocs/common/test/junk/foo1
/usr/local/apache/htdocs/common/test/junk/foo2
[EMAIL PROTECTED] junk]$
- Greg Keraunen http://www.xmake.org
_______________________________________________ Help-make mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/help-make
