Follow-up Comment #3, bug #14927 (project make): Following is a way to add objects in parallel with 3.80/81 The main idea - *- depend files are used as sentinels of the object files *- object files which do not have depend files are extracted from the library with their original modification date. #FILES - a given list of source files no extension (e.g. .cc) #L - The Archive #DEP_FILES - depend files #*_BASE - directories
DEP_FILES = $(patsubst %,$(DEP_BASE)/%.d,$(FILES)) vpath %.d $(DEP_BASE) #make a list of existing depend files existing_depend_files=$(if $(wildcard $L), \ $(foreach dep_file,$(FILES),$(wildcard $(DEP_BASE)/$(dep_file).d)),) #make a list of non-existing depend files non_existing_depend_files=$(filter-out $(existing_depend_files), \ $(patsubst %,$(DEP_BASE)/%.d,$(FILES))) #If depend file does not exist then first try to take out object with original modification time #Then just create the depend file define make_nonexisting_depend $(if $(wildcard $L),cd $(@D);$(AR) -xvo $(L) $*.o,) $(DEPEND.cc) $< -MT '$1 $(OBJ_BASE)/$*.o' -MP -MF $1 endef $(non_existing_depend_files): $(DEP_BASE)/%.d: %.cc $(call make_nonexisting_depend,$@) #If depend file exists compile as well. define make_existing_depend $(COMPILE.cc) $< -MM -MT '$1 $(OBJ_BASE)/$*.o' -MP -MF $1 -o $(OBJ_BASE)/$*.o endef $(existing_depend_files): $(DEP_BASE)/%.d: %.cc $(call make_existing_depend,$@) include $(patsubst %,$(DEP_BASE)/%.d,$(FILES)) #Library is made of: #object files created by the existing depend files target #object files from the non existing depend files list created by the object target itself #If all object were updated remove library first $L: $(existing_depend_files) $(patsubst $(DEP_BASE)/%.d,$(OBJ_BASE)/%.o,$(non_existing_depend_files)) $(if $(filter-out $?,$^),@$(RM) $@; echo $@ was removed,) $(AR) $(ARFLAGS) $@ $(patsubst %.d,%.o,$(filter %.d,$?)) $(filter %.o,$?) $(RM) $(OBJ_BASE)/*.o $(OBJ_FILES): $(OBJ_BASE)/%.o: %.cc $(COMPILE.cc) $< -o $@ /Alon _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?14927> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@gnu.org http://lists.gnu.org/mailman/listinfo/bug-make