--- old/make/CopyImportModules.gmk 2016-09-30 11:47:21.952528311 +0200 +++ new/make/CopyImportModules.gmk 2016-09-30 11:47:21.868524787 +0200 @@ -59,9 +59,24 @@ $(eval $(call SetupCopyFiles, COPY_LIBS, \ SRC := $(LIBS_DIR), \ DEST := $(JDK_OUTPUTDIR)/lib, \ - FILES := $(call CacheFind, $(LIBS_DIR)), \ + FILES := $(filter %$(SHARED_LIBRARY_SUFFIX), $(call CacheFind, $(LIBS_DIR))), \ )) - TARGETS += $(COPY_LIBS) + + # Use relative links if the import dir is inside the OUTPUT_ROOT, otherwise + # copy to avoid having automated systems following symlinks when deleting files, + # or risk invalidating the build output from external changes. + ifeq ($(filter $(OUTPUT_ROOT)/%, $(LIBS_DIR)), ) + LINK_MACRO := install-file + else + LINK_MACRO := link-file-relative + endif + $(eval $(call SetupCopyFiles, LINK_LIBS, \ + SRC := $(LIBS_DIR), \ + DEST := $(JDK_OUTPUTDIR)/lib, \ + FILES := $(filter-out %$(SHARED_LIBRARY_SUFFIX), $(call CacheFind, $(LIBS_DIR))), \ + MACRO := $(LINK_MACRO), \ + )) + TARGETS += $(COPY_LIBS) $(LINK_LIBS) endif endif