Patch: automatic dependencies for gcc

Ralf Wildenhues Ralf.Wildenhues@gmx.de
Sat Mar 8 18:41:00 GMT 2008


* Ralf Wildenhues wrote on Sat, Mar 08, 2008 at 05:36:03PM CET:
> * Tom Tromey wrote on Sat, Mar 08, 2008 at 04:27:59PM CET:

> > Hmm, maybe I can fake a build forcing the use of depcomp even with
> > gcc.
> 
> That should be possible with passing
>   am_cv_CC_dependencies_compiler_type=gcc
> 
> to gcc/configure.

This reveals that depcomp relies on the fact that dependencies for
subdir/object.o go in subdir/$(DEPDIR)/object.Po.  Your patch puts
them in $(DEPDIR)/subdir/object.Po.

I'm currently testing this on top of your patch.

Cheers,
Ralf

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 9ee29d0..84799ef 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -850,10 +850,10 @@ INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
 
 COMPILE.base = $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS)
 ifeq ($(DEPMODE),depmode=gcc3)
-COMPILE = $(COMPILE.base) -o $@ -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Po
+COMPILE = $(COMPILE.base) -o $@ -MT $@ -MMD -MP -MF $(dir $*)/$(DEPDIR)/$(notdir $*).Po
 else
 COMPILE = source='$<' object='$@' libtool=no \
-    DEPDIR=$(DEPDIR) $(DEPMODE) $(depcomp) $(COMPILE.base)
+    DEPDIR=$(DEPDIR) $(DEPMODE) $(depcomp) $(COMPILE.base) -o $@
 endif
 
 %.o: %.c
@@ -1951,10 +1951,10 @@ s-gtype: build/gengtype$(build_exeext) $(filter-out [%], $(GTFILES)) \
 BUILDCOMPILE.base = $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS)
 ifeq ($(BUILD_DEPMODE),depmode=gcc3)
 BUILDCOMPILE = $(BUILDCOMPILE.base) -o $@ -MT $@ -MMD -MP \
-    -MF $(DEPDIR)/build/$*.Po
+    -MF build/$(DEPDIR)/$(notdir $*).Po
 else
 BUILDCOMPILE = source='$<' object='$@' libtool=no \
-    DEPDIR=$(DEPDIR)/build $(BUILD_DEPMODE) $(depcomp) $(BUILDCOMPILE.base)
+    DEPDIR=$(DEPDIR) $(BUILD_DEPMODE) $(depcomp) $(BUILDCOMPILE.base) -o $@
 endif
 
 ALL_BUILD_OBJS = $(BUILD_RTL) $(BUILD_ERRORS) \
@@ -2616,6 +2616,7 @@ distclean: clean lang.distclean
 	-rm -f gcov.pod
 # Delete po/*.gmo only if we are not building in the source directory.
 	-if [ ! -f po/exgettext ]; then rm -f po/*.gmo; fi
+	-rm -rf $(DEPDIR) */$(DEPDIR)
 	-rmdir ada cp f java objc intl po testsuite 2>/dev/null
 
 # Get rid of every file that's generated from some other file, except for `configure'.
@@ -3268,7 +3269,9 @@ gcc-options.o: options.c
 $(ALL_HOST_OBJS): | $(XGCC_GEN_HEADERS)
 
 # Include the auto-generated dependencies for all host objects.
--include $(patsubst %.o, $(DEPDIR)/%.Po, $(ALL_HOST_OBJS))
+DEPFILES = $(foreach obj, $(ALL_HOST_OBJS), \
+	     $(dir $(obj))$(DEPDIR)/$(patsubst %.o,%.Po,$(notdir $(obj))))
+-include $(DEPFILES)
 
 # Include the auto-generated dependencies for all build objects.
--include $(patsubst %.o, $(DEPDIR)/build/%.Po, $(ALL_BUILD_OBJS))
+-include $(patsubst %.o, build/$(DEPDIR)/%.Po, $(notdir $(ALL_BUILD_OBJS)))
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 9b169b2..8bd6f5c 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3666,10 +3666,10 @@ done
 
 ZW_CREATE_DEPDIR
 AC_CONFIG_COMMANDS([gccdepdir],[
-  ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs $DEPDIR/build
+  ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs build/$DEPDIR
   for lang in $subdirs
   do
-      ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs $DEPDIR/$lang
+      ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs $lang/$DEPDIR
   done], [subdirs="$subdirs" ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR])
 
 ZW_PROG_COMPILER_DEPENDENCIES([CC])



More information about the Gcc-patches mailing list