On Mon, 2022-01-24 at 19:09 +0100, Adam Tuja wrote: > It doesn't matter how with many levels above current directory the > path has (../ ../../ ...), it's still the same.
Suffix rules are very limited: this is why pattern rules were invented. As long as you're happy with creating the object file in the current directory, AND you're happy with ensuring that no two directories ever have the same source file name, then it's possible to use suffix rules to build them. However you can see from the rule: .c.o: that there's nothing here to tell make where the source file will be, so clearly that cannot work by itself. A suffix rule is identical to the pattern rule: %.o : %.c so, the prefix of the target and prerequisite MUST be identical strings. The string "c-1up" is not identical to the string "../c-1up", and so this rule cannot match. You can use VPATH to give make a list of directories to use to search for source files. So, in your makefile if you add this: VPATH = .. ../.. when make wants to build c-1up.c it will look for ./c-1up.c, then ../c-1up.c, then ../../c-1up.c, and build the first one it finds. https://www.gnu.org/software/make/manual/html_node/Directory-Search.html > PS. > Not to mention that if I don't specify target (all) then it only > processes one file Make has to choose SOME target to build by default, if you don't specify one. Make always chooses the first target in the makefile by default. So, move your "all" target to the top so it's the first target and it will work as you expect. https://www.gnu.org/software/make/manual/html_node/Goals.html