Skip to content

Commit

Permalink
Add 'tree' make target to build whole subtree
Browse files Browse the repository at this point in the history
- added 'tree' alias
- improved implementation of tree_$(d) targets: no need to have all of
  them listed in every target, it is more optimal to rely on
  dependencies between them
  • Loading branch information
aostruszka committed Apr 23, 2012
1 parent e486147 commit 50b724b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ MK := $(TOP)/mk

.PHONY: all clean clean_all clean_tree

# By default build only targets from this directory (and its dependencies)
.DEFAULT_GOAL := dir_$(RUNDIR)
# A shortcut to build whole subtree
tree : tree_$(RUNDIR)

clean : clean_$(RUNDIR)
clean_tree : clean_tree_$(RUNDIR)

Expand Down
10 changes: 7 additions & 3 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,13 @@ to the directory where Rules.mk is).
In addition to those each dir has "it's own" targets. These are:

1) dir_<directory_path>
which builds all targets in given directory
2) clean_<directory_path>
which builds all targets in given directory plus its dependencies
2) tree_<directory_path>
which builds all targets in subtree starting at directory given
3) clean_<directory_path>
which removes all "products" from the $(OBJDIR) subdirectory of
current directory
3) clean_tree_<directory_path>
4) clean_tree_<directory_path>
which does clean_<directory_path> and the same for each its
subdirectory

Expand All @@ -304,6 +306,8 @@ Then:
several subdirectories in one directory) then simple 'make' in this
directory - instead of doing nothing - will build targets of all its
subdirectories.
* 'make tree' (same as 'make tree_$(pwd)')
rebuilds everything in given subtree
* 'make clean' (same as 'make clean_$(pwd)')
removes everything from Dir_1/obj/
* 'make clean_tree (same as 'make clean_tree_$(pwd)')
Expand Down
2 changes: 1 addition & 1 deletion mk/footer.mk
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ $(foreach tgt,$(filter-out $(AUTO_TGTS),$(TARGETS_$(d))),$(eval $(call tgt_rule,

# Way to build all targets in given subtree (not just current dir as via
# dir_$(d) - see below)
tree_$(d) : $(call subtree_tgts,$(d))
tree_$(d) : $(TARGETS_$(d)) $(foreach sd,$(SUBDIRS_$(d)),tree_$(sd))

# If the directory is just for grouping its targets will be targets from
# all subdirectories
Expand Down

0 comments on commit 50b724b

Please sign in to comment.