jdk-24/make/StripBinaries.gmk
Alan Bateman cc661dd1c6 8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282

Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: Chris Hegarty <chris.hegarty@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: alanb, mchung, tbell
2016-03-17 19:03:53 +00:00

110 lines
4.2 KiB
Plaintext

#
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
default: all
include $(SPEC)
include MakeBase.gmk
# Hook to include the corresponding custom file, if present.
$(eval $(call IncludeCustomExtension, , StripBinaries.gmk))
################################################################################
# Copy native libraries and executables to a secondary location to strip them
# and filter out files that shouldn't go into the image.
MODULES_CMDS_STRIPPED := $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped
MODULES_LIBS_STRIPPED := $(SUPPORT_OUTPUTDIR)/modules_libs-stripped
ifneq ($(STRIP), )
define StripRecipe
$(call LogInfo, Stripping $(patsubst $(OUTPUT_ROOT)/%,%,$<))
$(call MakeDir, $(@D))
$(CP) $< $@.tmp
$(CHMOD) u+w $@.tmp
$(STRIP) $(STRIPFLAGS) $@.tmp
$(CHMOD) go-w $@.tmp
$(MV) $@.tmp $@
endef
else
define StripRecipe
$(call install-file)
endef
endif
NO_STRIP_CMDS_FILTER += %.cgi
# Don't include debug info for executables.
ifneq ($(wildcard $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)), )
# OS X stores symbol information in a .dylib file inside a .dSYM directory -
# that file should not be stripped, so we prune the tree at the .dSYM directory.
ALL_CMDS_SRC := $(filter-out %.bc %.debuginfo %.diz %.map %.pdb, \
$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE) \( -type f -o -type l \) \
-print -o -name "*.dSYM" -prune))
COPY_CMDS_SRC := $(filter $(NO_STRIP_CMDS_FILTER), $(ALL_CMDS_SRC))
STRIP_CMDS_SRC := $(filter-out $(NO_STRIP_CMDS_FILTER), $(ALL_CMDS_SRC))
endif
ifneq ($(wildcard $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)), )
# OS X stores symbol information in a .dylib file inside a .dSYM directory -
# that file should not be stripped, so we prune the tree at the .dSYM directory.
# Example: support/modules_libs/java.base/libjsig.dylib.dSYM/Contents/Resources/DWARF/libjsig.dylib
STRIP_LIBS_SRC := \
$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE) \
-name '*$(SHARED_LIBRARY_SUFFIX)' -type f -print -o -name "*.dSYM" -prune)
# Make sure symbolic links are copied and not stripped.
COPY_LIBS_SRC := \
$(filter-out $(STRIP_LIBS_SRC), \
$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE) -type f -o -type l))
endif
$(eval $(call SetupCopyFiles,STRIP_MODULES_CMDS, \
SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds, \
DEST := $(MODULES_CMDS_STRIPPED), \
FILES := $(STRIP_CMDS_SRC), \
MACRO := StripRecipe))
$(eval $(call SetupCopyFiles,COPY_MODULES_CMDS, \
SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds, \
DEST := $(MODULES_CMDS_STRIPPED), \
FILES := $(COPY_CMDS_SRC)))
$(eval $(call SetupCopyFiles,STRIP_MODULES_LIBS, \
SRC := $(SUPPORT_OUTPUTDIR)/modules_libs, \
DEST := $(MODULES_LIBS_STRIPPED), \
FILES := $(STRIP_LIBS_SRC), \
MACRO := StripRecipe))
$(eval $(call SetupCopyFiles,COPY_MODULES_LIBS, \
SRC := $(SUPPORT_OUTPUTDIR)/modules_libs, \
DEST := $(MODULES_LIBS_STRIPPED), \
FILES := $(COPY_LIBS_SRC)))
TARGETS += $(STRIP_MODULES_CMDS) $(COPY_MODULES_CMDS) \
$(STRIP_MODULES_LIBS) $(COPY_MODULES_LIBS)
all: $(TARGETS)