diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java index f6c03a02f55..ab2d934bfe9 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java @@ -331,9 +331,33 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { String depFile = relativePath + resourceName + DOT + DEP_EXT; getDependencyMakefiles().add(depFile); } + + /* + * fix for PR 70491 + * We need to check if the current resource is LINKED, because + * the default CDT doesn't handle this properly. If it IS linked, + * then we must get the actual location of the resource, rather + * than the relative path. + */ + IPath resourceLocation = resource.getLocation(); + String projectLocation = project.getLocation().toString(); + String resourcePath = null; + String buildRule = null; + // figure out path to use to resource + if(!resourceLocation.toString().startsWith(projectLocation)) { + // it IS linked, so use the actual location + resourcePath = resourceLocation.toString(); + // Need a hardcoded rule, not a pattern rule, as a linked file + // can reside in any path + buildRule = relativePath + resourceName + DOT + outputExtension + COLON + WHITESPACE + resourcePath; + } else { + // use the relative path (not really needed to store per se but in the future someone may want this) + resourcePath = relativePath; + // The rule and command to add to the makefile + buildRule = relativePath + WILDCARD + DOT + outputExtension + COLON + WHITESPACE + ROOT + SEPARATOR + resourcePath + WILDCARD + DOT + inputExtension; + } // end fix for PR 70491 - // Add the rule and command to the makefile - String buildRule = relativePath + WILDCARD + DOT + outputExtension + COLON + WHITESPACE + ROOT + SEPARATOR + relativePath + WILDCARD + DOT + inputExtension; + // No duplicates in a makefile if (getRuleList().contains(buildRule)) { return; }