I'm trying to do good logic in Makefile for my project. Let's assume i have a Makefile with rules:
...
NAME := prog_name
...
all: subsystem
subsystem:
@$(MAKE) -sC $(D_LIB)
@$(MAKE) -s $(NAME)
$(D_OBJ):
@mkdir -p $(D_OBJ)
$(NAME): $(D_OBJ) $(OBJ) $(H) $(LIB)
$(CC) ... -o $(NAME)
$(D_OBJ)%.o: $(D_SRC)%.c $(H) $(LIB)
@$(CC) ... -c $< -o $@
.PHONY: all subsystem
When i run command:
make (make all)
It check $(D_LIB) for any changes, then run make for $(NAME) rule. And if there were changes in the library or program files my program recompiles.
But if i run command:
make prog_name
It would not run subsystem rule and i will not know about the changes in the library in any way. Accordingly, the program won't be rebuilt. So I am tormented by the question of how to make it interconnected. If i run command make (all)
or run command make prog_name
, i should check every dependies for my programm and re-build it if necessary.