I'm coping with an issue, probably due to my lack of knowledge of makefile possibilities. I'd like to set a rule similar to
$(OBJ_DIR)/%.o: %.c
@echo "Compiling...";
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
echo "Files compiled"
but with following target/prerequisites conditions:
targets: All targets at OBJ_DIR folder. Each one for each .c file I want to compile. prerequisites: a list of .c files that comes from a external file (or eventually listed at makefile itself) including folder path. Folders for .c files are different.
DIR1/FILE1.c
DIR2/FILE2.c
DIR3/FILE3.c
DIR4/FILE4.c
Each .o target only depends on its corresponding prerequisite. For instance,
FILE1.o <--> FILE1.c
FILE2.o <--> FILE2.c
FILE3.o <--> FILE3.c
FILE4.o <--> FILE4.c
Of course I can repeat the rules for each target/prerequiste, but I'd like to unify the rule in a single one, assuring that the dependencies are set one by one .o <---> .c, without involving crossed dependencies between prerequisites and targets with no real dependency.
Can you help in regards ?