"nedbrek" <nedb...@yahoo.com> wrote: > > Yes, I am also using some tricks I found on the web to support building > outside of the source tree. > > I currently have all the dependendcies in one file, and regenerate manually. > I have gotten auto-dependency generation to work with C++ (it is just a > matter of breaking the dependencies into separate files). >
If it is of interest, below is the makefile I have created for this purpose. It has the dependency generation built-in. The part I don't like about it is that the -deps option of dmd creates a very large file with all the dependencies, not just the one for the .d file being compiled. It is easy to filter out, but there is unnecessary IO (something you mentioned as being slow). ====== PHONY: all clean EXECUTABLE=foo SOURCE_DIR=source OUTPUT_DIR=output BINARY_DIR=$(OUTPUT_DIR)/bin BUILD_DIR=$(OUTPUT_DIR)/build DMD=/path/to/dmd DMD_FLAGS=-w -wi LINK_FLAGS=$(DMD_FLAGS) COMPILE_FLAGS=$(DMD_FLAGS) -I$(SOURCE_DIR) SOURCE_FILES=$(shell find $(SOURCE_DIR) -name "*.d") OBJECT_FILES=$(subst $(SOURCE_DIR), $(BUILD_DIR), \ $(SOURCE_FILES:%.d=%.o)) DEP_MAKEFILES=$(addsuffix .mk, $(OBJECT_FILES)) all: $(BINARY_DIR)/$(EXECUTABLE) $(BINARY_DIR)/$(EXECUTABLE): $(OBJECT_FILES) @echo "Linking '$@'..." @$(DMD) $(LINK_FLAGS) -of$@ $^ $(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.d @echo "Compiling '$<'..." @mkdir -p `dirname $@`; \ $(DMD) $(COMPILE_FLAGS) -c -deps=$@.dep -of$@ $< && \ cat $@.dep | grep "^[^(]*($<" | \ sed 's;^.*(.*).*(\(.*\)).*;$@ : \1;' > $@.mk clean: rm -fr $(OUTPUT_DIR) -include $(DEP_MAKEFILES)