make/common/NativeCompilation.gmk
changeset 41260 4f71f07b30d1
parent 37969 2203863bfe3e
child 41651 38f26302650f
--- a/make/common/NativeCompilation.gmk	Wed Jul 05 22:17:45 2017 +0200
+++ b/make/common/NativeCompilation.gmk	Wed Oct 05 10:49:21 2016 +0200
@@ -346,6 +346,7 @@
 #   LIBS the libraries to link to
 #   ARFLAGS the archiver flags to be used
 #   OBJECT_DIR the directory where we store the object files
+#   OUTPUT_DIR the directory where the resulting binary is put
 #   LIBRARY the resulting library file
 #   PROGRAM the resulting exec file
 #   INCLUDES only pick source from these directories
@@ -829,67 +830,58 @@
     ifneq ($$($1_DEBUG_SYMBOLS), false)
       # Only copy debug symbols for dynamic libraries and programs.
       ifeq ($$($1_STATIC_LIBRARY), )
-        ifneq ($$($1_OUTPUT_DIR), $$($1_OBJECT_DIR))
-          # The dependency on TARGET is needed on windows for debuginfo files
-          # to be rebuilt properly.
-          $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% $$($1_TARGET)
-                # Use cp -r since on macosx, the dSYM is a directory
-		$(CP) -r $$< $$@
-        endif
-
         # Generate debuginfo files.
         ifeq ($(OPENJDK_TARGET_OS), windows)
-          $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \
-              "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map"
-          $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
-              $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
+          $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \
+              "-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map"
+          $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \
+              $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map
           # No separate command is needed for debuginfo on windows, instead
           # touch target to make sure it has a later time stamp than the debug
           # symbol files to avoid unnecessary relinking on rebuild.
           $1_CREATE_DEBUGINFO_CMDS := $(TOUCH) $$($1_TARGET)
 
         else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
-          $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
+          $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo
           # Setup the command line creating debuginfo files, to be run after linking.
           # It cannot be run separately since it updates the original target file
           $1_CREATE_DEBUGINFO_CMDS := \
-            $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
-            $(CD) $$($1_OUTPUT_DIR) && \
-                $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
+              $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
+              $(CD) $$($1_OUTPUT_DIR) && \
+                  $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
 
         else ifeq ($(OPENJDK_TARGET_OS), macosx)
-          $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_BASENAME).dSYM
+          $1_DEBUGINFO_FILES := \
+              $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
+              $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
           # On Macosx, the debuginfo generation doesn't touch the linked binary, but
           # to avoid always relinking, touch it anyway to force a later timestamp than
           # the dSYM files.
           $1_CREATE_DEBUGINFO_CMDS := \
-              $(DSYMUTIL) --out $$($1_DEBUGINFO_FILES) $$($1_TARGET) $$(NEWLINE) \
+              $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET) $$(NEWLINE) \
               $(TOUCH) $$($1_TARGET)
         endif # OPENJDK_TARGET_OS
 
-        # This dependency dance ensures that debug info files get rebuilt
-        # properly if deleted.
-        $$($1_TARGET): $$($1_DEBUGINFO_FILES)
-        $$($1_DEBUGINFO_FILES): $$($1_ALL_OBJS)
+        $$($1_DEBUGINFO_FILES): $$($1_TARGET)
+
+        $1 += $$($1_DEBUGINFO_FILES)
 
         ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
-          $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz
-          $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP))
+          $1_DEBUGINFO_ZIP := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).diz
+          $1 += $$($1_DEBUGINFO_ZIP)
 
           # The dependency on TARGET is needed for debuginfo files
           # to be rebuilt properly.
           $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
-		$(CD) $$($1_OBJECT_DIR) \
-		&& $(ZIP) -q -r $$@ $$(notdir $$($1_DEBUGINFO_FILES))
+		$(CD) $$($1_OUTPUT_DIR) && \
+		    $(ZIP) -q -r $$@ $$(subst $$($1_OUTPUT_DIR)/,, $$($1_DEBUGINFO_FILES))
 
-        else
-          $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_FILES))
         endif
-      endif # !STATIC_LIBRARY
+       endif # !STATIC_LIBRARY
     endif # $1_DEBUG_SYMBOLS != false
   endif # COPY_DEBUG_SYMBOLS
 
-  ifeq ($$($1_STRIP_SYMBOLS), true)
+  ifneq ($$($1_STRIP_SYMBOLS), false)
     ifneq ($$($1_STRIP), )
       # Default to using the global STRIPFLAGS. Allow for overriding with an empty value
       $1_STRIPFLAGS ?= $(STRIPFLAGS)
@@ -902,6 +894,8 @@
     $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
     ifeq ($(OPENJDK_TARGET_OS), windows)
       $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib"
+      # Create a rule for the import lib so that other rules may depend on it
+      $$($1_OBJECT_DIR)/$$($1_LIBRARY).lib: $$($1_TARGET)
     endif
 
     # Create loadmap on AIX. Helps in diagnosing some problems.