does the target of a makefile have to be a file name?
Jul 12, 2020 at 7:28pm UTC
Hi
I have a makefile which includes the following rule/recipe
1 2
bin/test.exe: $(TEST_OBJ_FILES) $(LIB_DIR)/$(LIB_NAME) | $(BIN_DIR)
$(CC) $(FLAGS_E) $(TEST_OBJ_FILES) $(LIB_DIR)/$(LIB_NAME) -o $@
This works exactly as intended. However, I'd like to change the target name to something more user friendly like 'tests' so I changed the rule to:
1 2
tests: $(TEST_OBJ_FILES) $(LIB_DIR)/$(LIB_NAME) | $(BIN_DIR)
$(CC) $(FLAGS_E) $(TEST_OBJ_FILES) $(LIB_DIR)/$(LIB_NAME) -o bin/test.exe
This works fine except that makefile executes every single time (even when nothing has changed). I just wondered why this might be? I thought that the target name could be anything and didn't have to be a file?
Thanks
Jul 12, 2020 at 7:35pm UTC
If the target is not a file then there is no time stamp to check if it's changed.
Jul 12, 2020 at 9:45pm UTC
tests: bin/test.exe
bin/test.exe: $(TEST_OBJ_FILES) $(LIB_DIR)/$(LIB_NAME) | $(BIN_DIR)
$(CC) $(FLAGS_E) $(TEST_OBJ_FILES) $(LIB_DIR)/$(LIB_NAME) -o $@
Topic archived. No new replies allowed.