aboutsummaryrefslogtreecommitdiff
path: root/mk/autodep.mk
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2011-05-01 20:18:52 +0000
committerGraydon Hoare <[email protected]>2011-05-01 20:20:25 +0000
commit40624e35d74e5d200ae689c02753f0d60924e668 (patch)
treee1e259098d5c49cd49844b40abd46ec35219d94a /mk/autodep.mk
parentrustc: Preserve dots in input path when using an implicit output path (diff)
downloadrust-40624e35d74e5d200ae689c02753f0d60924e668.tar.xz
rust-40624e35d74e5d200ae689c02753f0d60924e668.zip
Start splitting up Makefile.in
Diffstat (limited to 'mk/autodep.mk')
-rw-r--r--mk/autodep.mk86
1 files changed, 86 insertions, 0 deletions
diff --git a/mk/autodep.mk b/mk/autodep.mk
new file mode 100644
index 00000000..59f221d0
--- /dev/null
+++ b/mk/autodep.mk
@@ -0,0 +1,86 @@
+######################################################################
+# Auto-dependency
+######################################################################
+
+ML_DEPFILES := $(BOOT_MLS:%.ml=%.d)
+C_DEPFILES := $(RUNTIME_CS:%.cpp=%.d) $(RUSTLLVM_LIB_CS:%.cpp=%.d) \
+ $(RUSTLLVM_OBJS_CS:%.cpp=%.d)
+
+rt/%.d: rt/%.cpp $(MKFILES)
+ @$(call E, dep: $@)
+ $(Q)$(call CFG_DEPEND_C, $@ \
+ $(subst $(S)src/,,$(patsubst %.cpp, %.o, $<)), \
+ $(RUNTIME_INCS)) $< >[email protected]
+ $(Q)$(CFG_PATH_MUNGE) [email protected]
+ $(Q)rm -f [email protected]
+ $(Q)mv [email protected] $@
+
+rustllvm/%.d: rustllvm/%.cpp $(MKFILES)
+ @$(call E, dep: $@)
+ $(Q)$(call CFG_DEPEND_C, $@ \
+ $(subst $(S)src/,,$(patsubst %.cpp, %.o, $<)), \
+ $(CFG_LLVM_CXXFLAGS) $(RUSTLLVM_INCS)) $< >[email protected]
+ $(Q)$(CFG_PATH_MUNGE) [email protected]
+ $(Q)rm -f [email protected]
+ $(Q)mv [email protected] $@
+
+%.d: %.ml $(MKFILES)
+ @$(call E, dep: $@)
+ $(Q)ocamldep$(OPT) -slash $(BOOT_ML_DEP_INCS) $< >[email protected]
+ $(Q)$(CFG_PATH_MUNGE) [email protected]
+ $(Q)rm -f [email protected]
+ $(Q)perl -i.bak -pe "s@$(S)src/@@go" [email protected]
+ $(Q)rm -f [email protected]
+ $(Q)mv [email protected] $@
+
+%.d: %.mli $(MKFILES)
+ @$(call E, dep: $@)
+ $(Q)ocamldep$(OPT) -slash $(BOOT_ML_DEP_INCS) $< >[email protected]
+ $(Q)$(CFG_PATH_MUNGE) [email protected]
+ $(Q)rm -f [email protected]
+ $(Q)perl -i.bak -pe "s@$(S)src/@@go" [email protected]
+ $(Q)rm -f [email protected]
+ $(Q)mv [email protected] $@
+
+ifneq ($(MAKECMDGOALS),clean)
+-include $(ML_DEPFILES) $(C_DEPFILES)
+endif
+
+RUSTBOOT_PROBE := $(wildcard boot/rustboot$(X))
+
+ifneq ($(RUSTBOOT_PROBE),)
+CFG_INFO := $(info cfg: using built boot/rustboot$(X) for rust deps)
+CRATE_DEPFILES := $(subst $(S)src/,,$(ALL_TEST_CRATES:%.rc=%.d)) \
+ boot/$(CFG_STDLIB).d \
+ stage0/rustc$(X).d \
+ stage0/$(CFG_STDLIB).d
+
+boot/$(CFG_STDLIB).d: $(STDLIB_CRATE) $(STDLIB_INPUTS) \
+ $(MKFILES) boot/rustboot$(X)
+ @$(call E, dep: $@)
+ $(BOOT) -o $(patsubst %.d,%$(X),$@) -shared -rdeps $< >[email protected]
+ $(Q)$(CFG_PATH_MUNGE) [email protected]
+ $(Q)rm -f [email protected]
+ $(Q)mv [email protected] $@
+
+stage0/rustc$(X).d: $(COMPILER_CRATE) $(COMPILER_INPUTS) \
+ $(STDLIB_CRATE) $(MKFILES) boot/rustboot$(X)
+ @$(call E, dep: $@)
+ $(BOOT) -o $(patsubst %.d,%$(X),$@) -shared -rdeps $< >[email protected]
+ $(Q)$(CFG_PATH_MUNGE) [email protected]
+ $(Q)rm -f [email protected]
+ $(Q)mv [email protected] $@
+
+%.d: %.rc $(MKFILES) boot/rustboot$(X)
+ @$(call E, dep: $@)
+ $(BOOT) -o $(patsubst %.d,%$(X),$@) -rdeps $< >[email protected]
+ $(Q)$(CFG_PATH_MUNGE) [email protected]
+ $(Q)rm -f [email protected]
+ $(Q)mv [email protected] $@
+
+ifneq ($(MAKECMDGOALS),clean)
+-include $(CRATE_DEPFILES)
+endif
+endif
+
+depend: boot/rustboot$(X) $(CRATE_DEPFILES) $(ML_DEPFILES) $(C_DEPFILES)