Riccardo Manfrin <[email protected]> writes:

> and then mux their compiling process with rules like the following:
>
> %.o : %.cpp
>      $(COMPILE) -c  ... $< -o $@

Something like this?

$(OBJDIR)/%.o : %.cpp
        $(COMPILE) -c  ... $< -o $@

If subdirectories might not exist in OBJDIR, you can create them like
this:


.SECONDEXPANSION:               # to expand $$(@D)/.DIR

$(OBJDIR)/%.o : %.cpp | $$(@D)/.DIR
        $(COMPILE) -c  ... $< -o $@

%/.DIR :
        @mkdir -p $(@D)
        @touch $@


An alternative is to invoke make from the build directory and use VPATH
to locate the source files, but that looks less natural from what you've
shown.

_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to