Comments (6)
Looks like the problem was that SUBDIRS_TGTS would only be included if there wasn't a TARGETS specified for the current directory. The patch below solved the problem for me. I'm not sure if it will break anything else, though.
diff --git a/mk/footer.mk b/mk/footer.mk
index ad6cdae..1aec6c7 100644
--- a/mk/footer.mk
+++ b/mk/footer.mk
@@ -73,11 +73,8 @@ $(foreach tgt,$(filter-out $(AUTO_TGTS),$(TARGETS_$(d))),$(eval $(call tgt_rule,
# dir_$(d) - see below)
tree_$(d) : $(call subtree_tgts,$(d))
-# If the directory is just for grouping its targets will be targets from
-# all subdirectories
-ifeq ($(strip $(TARGETS_$(d))),)
-TARGETS_$(d) := $(SUBDIRS_TGTS)
-endif
+# Include targets from all subdirectories
+TARGETS_$(d) := $(SUBDIRS_TGTS) $(TARGETS_$(d))
# This is a default rule - see Makefile
dir_$(d) : $(TARGETS_$(d))
from nonrec-make.
This is by "design".
By default simple make should build only targets from directory where it was invoked - any targets from subdirectories should be built only if they are dependencies of targets from this directory.
To build all subtree targets as of now you can run in shell: "make tree_$(pwd)"
This should build all targets from given subtree even if they are not dependencies. However your comment caused me to check this and I will change current implementation since it can be done better as the clean_tree is. Moreover I will add a shortcut in Makefile so that simple "make tree" will be enough for what you need.
Best regards
Andrzej
PS. The part that you have changed is for the case where you split code over couple subdirectories. Then in the parent you can have Rules.mk with only "SUBDIRS ..." line and targets of this parent will be all targets from its subdirs.
from nonrec-make.
Thanks for explaining, Andrzej. I was assuming the SUBDIRS were being used as a means to collect all of the Rules.mk and targets to be built.
This brings up another question: If I wanted to explicitly call out goodbye as a build target (but keep the same directory layout), what would you recommend? This seems a bit tricky since TARGETS need to be relative to the OBJDIR, right? I tried adding ../goodbye/$(OBJDIR)/goodbye
to ex3\Rules.mk's TARGETS, but I get an error because ex3/obj/../goodbye/obj/goodbye
and ex3/goodbye/obj/goodbye
aren't the same to make. The cleanest way I can think of is to put ex3/goodbye
in the SUBDIRS of the parent directory's Rules (Rules.top in this case).
from nonrec-make.
If you want to call out compilation of only 'goodbye' then there are basically two choices. BTW I intended to point you to wiki pages on that, but ... it turns out that some part of [[Basic Concepts]] got lost when I moved from google to github. It is fixed now (points 5&6) and you might want to read it again.
- "make /full/path/to/goodbye/including/objdirs" - not very convenient unless you define in shell some variable that will hold the full path. However this will not survive beyond your current shell instance so my preference would be to ...
- Add an alias in Rules.mk in ex3 directory
- e.g. "tests : dir_$(d)"
- or "goodbye : $(OBJPATH)/goodbye"
Since you've indicated that this was meant to be some unit test the first case would cause "make tests" to build all targets from ex3 directory. Second case is just an alias for one particular test and with it you can just issue "make goodbye".
HTH
Andrzej
PS. I've uploaded new commit (50b724b) with this "tree" target, so I'm closing this "issue" :)
from nonrec-make.
Xulfir
I just thought that my answer might not be what you were looking for.
It depends on what you've meant by "I wanted to explicitly call out goodbye as a build target".
If by "call out" you've meant having ability to specify goodbye as a target during make invocation then the above answer should help. However if by "call out" you've meant using goodbye as e.g. some dependency inside Rules.mk then if this is in parents directory Rules.mk simple SUBDIRS_TGTS
or TARGETS_$(subdir)
should work. However if you want to refer to just one of the targets or using full path is inconvenient then using alias should be sufficient e.g. in ex3/Rules.mk just have
GB := $(OBJPATH)/goodbye
and you can use this variable.
This has some gotchas though so let me know if this answers your needs.
Best regards
Andrzej
from nonrec-make.
Thanks again, Andrzej. This has been very helpful. It is clear you've put a lot of thought into this project. I'm very glad you have shared it.
Cheers,
Xulfir
from nonrec-make.
Related Issues (19)
- How to shorten OBJPATH when doing out-of-tree builds HOT 6
- Extending functionality without touching the source of nonrec-make HOT 2
- Overwriting system defined compilers HOT 2
- not a layer?socute HOT 15
- make dist_clean and custom OBJDIRs HOT 3
- In xxx.d files .I think it should be like xxx.o xxx.d:xxx.c x1.h x2.h \n xxx.c x1.h x2.h: HOT 2
- Uppercase and lowercase for same word mixed together HOT 3
- Can't figure out how to use SUBDIRS_TGTS for more than one level of subdirectories. HOT 4
- Autogenerated / Installed source and dependencies HOT 4
- Build vs. target targets HOT 8
- Bug in the config-default.mk file HOT 1
- Can I compile exe and so in one directory hierarchy both? HOT 2
- Install example HOT 8
- License HOT 2
- Is it possible to make it even simplier? HOT 3
- Suggestion: Include targets in default clean rule HOT 2
- Idea: Use order-only prerequisites for $(OBJPATH) HOT 4
- tgt_rule changes order of dependencies HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nonrec-make.