3 ms·
Sorry, I don't follow. I am doing out-of-tree builds? The problem is that there is no way to generate multiple files from one rule. If you write: $(OBJDIR
by david-given 11y ago
Sorry, I don't follow. I am doing out-of-tree builds?
The problem is that there is no way to generate multiple files from one rule. If you write:
$(OBJDIR)/foo.o: src/foo.c
...you get one rule, which will build one object file. If you want to generate two object files with two different settings, you have to have two rules.
$(OBJDIR1)/foo.o: src/foo.c
$(OBJDIR2)/foo.o: src/foo.c
There is no way round this. Target-specific variables look like they solve this, but they basically don't work for anything useful. There are only three options here: (1) hardcode multiple rules; (2) use make macros to generate multiple rules; (3) invoke the makefile multiple times with different settings. All of these options are horrible.
- enqk 11y agoYour flags should be encoded in the OBJDIR name indeed. It is most likely more correct anyway, as you can't always assume you can mix two objects which were compiled with different flags. An example is C++, where often standard libraries don't allow mixing debug and release code.
- the_why_of_y 11y ago> (3) invoke the makefile multiple times with different settings This is what I mean, more or less. Your build directory contains a generated configuration state (generated by GNU autoconf, for example), and a wrapper Makefile that reads the configuration and builds everything (maybe by invoking a "real" Makefile in the source directory if you're lucky, maybe by having a bunch of ugly Makefiles generated in the build directory too, as GNU automake does). And (provided you avoid automake) I don't find it horrible at all.