On Mon, 2022-01-24 at 21:27 +0100, Adam Tuja wrote: > SRCS = a.c b.c ../c-1up.c > OBJS = $(SRCS:.c=.o) > > .c.o: > $(CC) $(CFLAGS) -c -o $@ $< > > $(PROG): $(OBJS) > > Now, when I understand it, it works. It's not the same thing as > objects are placed beside source files but step forward nevertheless.
Did you mean to write something different in your last sentence? It IS the same thing as objects placed beside source files, unless I misunderstand what you mean by "beside". This makefile will always write the object files into the same directory as the source files. As long as you want to do that, then you can use suffix rules or pattern rules very easily. It's when you want object files to go into a different directory from source files that suffix rules won't work well (you can use VPATH to help somewhat).