make/StripBinaries.gmk
author ccheung
Tue, 07 Jun 2016 00:06:17 +0000
changeset 39211 8e8b396a42e9
parent 36506 17612cee3530
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27560
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     1
#
35747
aeaa6d0101a8 8149647: Incremental enhancements from build-infra
ihse
parents: 35008
diff changeset
     2
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
27560
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     4
#
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    10
#
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    15
# accompanied this code).
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    16
#
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    20
#
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    23
# questions.
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    24
#
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    25
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    26
default: all
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    27
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    28
include $(SPEC)
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    29
include MakeBase.gmk
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    30
31310
481585782338 8081814: Modularize the deploy build
erikj
parents: 30853
diff changeset
    31
# Hook to include the corresponding custom file, if present.
481585782338 8081814: Modularize the deploy build
erikj
parents: 30853
diff changeset
    32
$(eval $(call IncludeCustomExtension, , StripBinaries.gmk))
481585782338 8081814: Modularize the deploy build
erikj
parents: 30853
diff changeset
    33
27560
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    34
################################################################################
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    35
# Copy native libraries and executables to a secondary location to strip them
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    36
# and filter out files that shouldn't go into the image.
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    37
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    38
MODULES_CMDS_STRIPPED := $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    39
MODULES_LIBS_STRIPPED := $(SUPPORT_OUTPUTDIR)/modules_libs-stripped
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    40
32811
df82db312e58 8135060: Stop building Xcode projects in install build
erikj
parents: 31312
diff changeset
    41
ifneq ($(STRIP), )
27560
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    42
  define StripRecipe
35008
ef0cd710989f 8146403: Windows build can be faster
erikj
parents: 32811
diff changeset
    43
	$(call LogInfo, Stripping $(patsubst $(OUTPUT_ROOT)/%,%,$<))
ef0cd710989f 8146403: Windows build can be faster
erikj
parents: 32811
diff changeset
    44
	$(call MakeDir, $(@D))
27560
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    45
	$(CP) $< $@.tmp
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    46
	$(CHMOD) u+w $@.tmp
32811
df82db312e58 8135060: Stop building Xcode projects in install build
erikj
parents: 31312
diff changeset
    47
	$(STRIP) $(STRIPFLAGS) $@.tmp
27560
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    48
	$(CHMOD) go-w $@.tmp
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    49
	$(MV) $@.tmp $@
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    50
  endef
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    51
else
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    52
  define StripRecipe
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    53
    $(call install-file)
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    54
  endef
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    55
endif
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    56
31310
481585782338 8081814: Modularize the deploy build
erikj
parents: 30853
diff changeset
    57
NO_STRIP_CMDS_FILTER += %.cgi
481585782338 8081814: Modularize the deploy build
erikj
parents: 30853
diff changeset
    58
27560
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    59
# Don't include debug info for executables.
36506
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    60
ifneq ($(wildcard $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)), )
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    61
  # OS X stores symbol information in a .dylib file inside a .dSYM directory -
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    62
  # that file should not be stripped, so we prune the tree at the .dSYM directory.
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    63
  ALL_CMDS_SRC := $(filter-out %.bc %.debuginfo %.diz %.map %.pdb, \
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    64
      $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE) \( -type f -o -type l \) \
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    65
      -print -o -name "*.dSYM" -prune))
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    66
  COPY_CMDS_SRC := $(filter $(NO_STRIP_CMDS_FILTER), $(ALL_CMDS_SRC))
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    67
  STRIP_CMDS_SRC := $(filter-out $(NO_STRIP_CMDS_FILTER), $(ALL_CMDS_SRC))
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    68
endif
27560
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    69
36506
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    70
ifneq ($(wildcard $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)), )
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    71
  # OS X stores symbol information in a .dylib file inside a .dSYM directory -
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    72
  # that file should not be stripped, so we prune the tree at the .dSYM directory.
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    73
  # Example: support/modules_libs/java.base/libjsig.dylib.dSYM/Contents/Resources/DWARF/libjsig.dylib
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    74
  STRIP_LIBS_SRC := \
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    75
      $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE) \
30853
0384273d840d 8066757: Can't build 'images' with --disable-zip-debug-info on OS X after jigsaw m2 merge
sla
parents: 30096
diff changeset
    76
        -name '*$(SHARED_LIBRARY_SUFFIX)' -type f -print -o -name "*.dSYM" -prune)
36506
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    77
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    78
  # Make sure symbolic links are copied and not stripped.
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    79
  COPY_LIBS_SRC := \
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    80
      $(filter-out $(STRIP_LIBS_SRC), \
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    81
      $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE) -type f -o -type l))
17612cee3530 8142968: Module System implementation
alanb
parents: 35747
diff changeset
    82
endif
27560
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    83
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    84
$(eval $(call SetupCopyFiles,STRIP_MODULES_CMDS, \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    85
    SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds, \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    86
    DEST := $(MODULES_CMDS_STRIPPED), \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    87
    FILES := $(STRIP_CMDS_SRC), \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    88
    MACRO := StripRecipe))
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    89
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    90
$(eval $(call SetupCopyFiles,COPY_MODULES_CMDS, \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    91
    SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds, \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    92
    DEST := $(MODULES_CMDS_STRIPPED), \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    93
    FILES := $(COPY_CMDS_SRC)))
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    94
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    95
$(eval $(call SetupCopyFiles,STRIP_MODULES_LIBS, \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    96
    SRC := $(SUPPORT_OUTPUTDIR)/modules_libs, \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    97
    DEST := $(MODULES_LIBS_STRIPPED), \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    98
    FILES := $(STRIP_LIBS_SRC), \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    99
    MACRO := StripRecipe))
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   100
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   101
$(eval $(call SetupCopyFiles,COPY_MODULES_LIBS, \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   102
    SRC := $(SUPPORT_OUTPUTDIR)/modules_libs, \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   103
    DEST := $(MODULES_LIBS_STRIPPED), \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   104
    FILES := $(COPY_LIBS_SRC)))
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   105
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   106
TARGETS += $(STRIP_MODULES_CMDS) $(COPY_MODULES_CMDS) \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   107
    $(STRIP_MODULES_LIBS) $(COPY_MODULES_LIBS)
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   108
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   109
all: $(TARGETS)