8011687: Support correct dependencies from header files on windows and solaris
authorerikj
Thu, 02 May 2013 15:56:39 +0200
changeset 16988 53de314b1c30
parent 16987 19305cbf4362
child 17041 1715c3d2919f
8011687: Support correct dependencies from header files on windows and solaris Reviewed-by: tbell
common/autoconf/generated-configure.sh
common/autoconf/spec.gmk.in
common/autoconf/toolchain.m4
common/makefiles/NativeCompilation.gmk
--- a/common/autoconf/generated-configure.sh	Thu May 02 15:46:38 2013 +0200
+++ b/common/autoconf/generated-configure.sh	Thu May 02 15:56:39 2013 +0200
@@ -681,6 +681,7 @@
 STATIC_LIBRARY
 SHARED_LIBRARY
 OBJ_SUFFIX
+COMPILER_NAME
 LIPO
 ac_ct_OBJDUMP
 OBJDUMP
@@ -3774,7 +3775,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1367502345
+DATE_WHEN_GENERATED=1367502949
 
 ###############################################################################
 #
@@ -28805,6 +28806,7 @@
 
 
 
+
 # The (cross) compiler is now configured, we can now test capabilities
 # of the target platform.
 
--- a/common/autoconf/spec.gmk.in	Thu May 02 15:46:38 2013 +0200
+++ b/common/autoconf/spec.gmk.in	Thu May 02 15:56:39 2013 +0200
@@ -300,6 +300,7 @@
 # CC is gcc and others behaving reasonably similar.
 # CL is cl.exe only.
 COMPILER_TYPE:=@COMPILER_TYPE@
+COMPILER_NAME:=@COMPILER_NAME@
 
 COMPILER_SUPPORTS_TARGET_BITS_FLAG=@COMPILER_SUPPORTS_TARGET_BITS_FLAG@
 
--- a/common/autoconf/toolchain.m4	Thu May 02 15:46:38 2013 +0200
+++ b/common/autoconf/toolchain.m4	Thu May 02 15:56:39 2013 +0200
@@ -573,6 +573,7 @@
     fi
 fi
 
+AC_SUBST(COMPILER_NAME)
 AC_SUBST(OBJ_SUFFIX)
 AC_SUBST(SHARED_LIBRARY)
 AC_SUBST(STATIC_LIBRARY)
--- a/common/makefiles/NativeCompilation.gmk	Thu May 02 15:46:38 2013 +0200
+++ b/common/makefiles/NativeCompilation.gmk	Thu May 02 15:56:39 2013 +0200
@@ -95,10 +95,28 @@
         $$($1_$2_OBJ) : $2
         ifeq ($(COMPILER_TYPE),CC)
 		$$(call COMPILING_MSG,$2,$$($1_TARGET))
+          # The Sun studio compiler doesn't output the full path to the object file in the
+          # generated deps files. Fixing it with sed. If compiling assembly, don't try this.
+          ifeq ($(COMPILER_NAME)$$(filter %.s,$2),ossc)
+		$$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP).tmp $(CC_OUT_OPTION)$$($1_$2_OBJ) $2
+		$(SED) 's|^$$(@F):|$$@:|' $$($1_$2_DEP).tmp > $$($1_$2_DEP)
+          else
 		$$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2
         endif
+        endif
+        # The Visual Studio compiler lacks a feature for generating make dependencies, but by
+        # setting -showIncludes, all included files are printed. These are filtered out and 
+        # parsed into make dependences.
         ifeq ($(COMPILER_TYPE),CL)
-		$$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEBUG_OUT_FLAGS) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2
+		$$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 | $(TEE) $$($1_$2_DEP).raw | $(GREP) -v "^Note: including file:"
+		($(ECHO) $$@: \\ \
+		 && $(SED) -e '/^Note: including file:/!d' \
+			-e 's|Note: including file: *||' \
+			-e 's|\\|/|g' \
+			-e 's|^\([a-zA-Z]\):|/cygdrive/\1|g' \
+			-e '/$(subst /,\/,$(TOPDIR))/!d' \
+			-e 's|$$$$| \\|g' \
+			$$($1_$2_DEP).raw) > $$($1_$2_DEP)
         endif
     endif
 endef