更新时间:2023-02-05 19:22:26
我建议您有两个目录用于目标文件,一个目录用于标准对象,一个目录用于可重定位的对象.像这样:
I suggest you have two directories for object files, one for standard objects and one for relocatable objects. Something like this:
$(STANDARD_OBJS) = $(addprefix $(STANDARD_OBJS_DIR)/, $(OBJS))
$(RELOC_OBJS) = $(addprefix $(RELOC_OBJS_DIR)/, $(OBJS))
$(RELOC_OBJS_DIR)/%.o: CCFLAGS += -fPic
$(RELOC_OBJS_DIR)/%.o $(STANDARD_OBJS_DIR)/%.o: $(SRC)/%.cc
g++ $< -o $@
(还有一些更复杂的版本,但这可以帮助您入门.)
(There are more sophisticated variations, but this will get you started.)