1 #
2 # Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation. Oracle designates this
8 # particular file as subject to the "Classpath" exception as provided
9 # by Oracle in the LICENSE file that accompanied this code.
10 #
11 # This code is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # version 2 for more details (a copy is included in the LICENSE file that
15 # accompanied this code).
16 #
17 # You should have received a copy of the GNU General Public License version
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
528 else \
529 if [ -L '$(call DecodeSpace, $<)' ]; then \
530 $(ECHO) "Source file is a symlink and target is in the same directory: $< $@" ; \
531 exit 1; \
532 fi; \
533 $(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \
534 fi
535 endef
536 else ifeq ($(OPENJDK_TARGET_OS),macosx)
537 # On mac, extended attributes sometimes creep into the source files, which may later
538 # cause the creation of ._* files which confuses testing. Clear these with xattr if
539 # set. Some files get their write permissions removed after being copied to the
540 # output dir. When these are copied again to images, xattr would fail. By only clearing
541 # attributes when they are present, failing on this is avoided.
542 #
543 # If copying a soft link to a directory, need to delete the target first to avoid
544 # weird errors.
545 define install-file
546 $(call MakeTargetDir)
547 $(RM) '$(call DecodeSpace, $@)'
548 $(CP) -fRP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
549 if [ -n "`$(XATTR) -ls '$(call DecodeSpace, $@)'`" ]; then $(XATTR) -cs '$(call DecodeSpace, $@)'; fi
550 endef
551 else
552 define install-file
553 $(call MakeTargetDir)
554 $(CP) -fP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
555 endef
556 endif
557
558 # Variant of install file that does not preserve symlinks
559 define install-file-nolink
560 $(call MakeTargetDir)
561 $(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
562 endef
563
564 ################################################################################
565 # Take two paths and return the path of the last common directory.
566 # Ex: /foo/bar/baz, /foo/bar/banan -> /foo/bar
567 # foo/bar/baz, /foo/bar -> <empty>
568 #
569 # The x prefix is used to preserve the presence of the initial slash
983 else
984 LogCmdlines =
985 endif
986
987 ################################################################################
988 # ExecuteWithLog will run a command and log the output appropriately. This is
989 # meant to be used by commands that do "real" work, like a compilation.
990 # The output is stored in a specified log file, which is displayed at the end
991 # of the build in case of failure. The command line itself is stored in a file,
992 # and also logged to stdout if the LOG=cmdlines option has been given.
993 #
994 # NOTE: If the command redirects stdout, the caller needs to wrap it in a
995 # subshell (by adding parentheses around it), otherwise the redirect to the
996 # subshell tee process will create a race condition where the target file may
997 # not be fully written when the make recipe is done.
998 #
999 # Param 1 - The path to base the name of the log file / command line file on
1000 # Param 2 - The command to run
1001 ExecuteWithLog = \
1002 $(call LogCmdlines, Exececuting: [$(strip $2)]) \
1003 $(call WriteFile, $2, $(strip $1).cmdline) \
1004 ( $(strip $2) > >($(TEE) $(strip $1).log) 2> >($(TEE) $(strip $1).log >&2) || \
1005 ( exitcode=$(DOLLAR)? && \
1006 $(CP) $(strip $1).log $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(OUTPUTDIR)/%,%,$(strip $1))).log && \
1007 $(CP) $(strip $1).cmdline $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(OUTPUTDIR)/%,%,$(strip $1))).cmdline && \
1008 exit $(DOLLAR)exitcode ) )
1009
1010 ################################################################################
1011 # Find lib dir for module
1012 # Param 1 - module name
1013 FindLibDirForModule = \
1014 $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
1015
1016 ################################################################################
1017 # Return a string suitable for use after a -classpath or --module-path option. It
1018 # will be correct and safe to use on all platforms. Arguments are given as space
1019 # separate classpath entries. Safe for multiple nested calls.
1020 # param 1 : A space separated list of classpath entries
1021 # The surrounding strip is needed to keep additional whitespace out
1022 PathList = \
|
1 #
2 # Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation. Oracle designates this
8 # particular file as subject to the "Classpath" exception as provided
9 # by Oracle in the LICENSE file that accompanied this code.
10 #
11 # This code is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # version 2 for more details (a copy is included in the LICENSE file that
15 # accompanied this code).
16 #
17 # You should have received a copy of the GNU General Public License version
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
528 else \
529 if [ -L '$(call DecodeSpace, $<)' ]; then \
530 $(ECHO) "Source file is a symlink and target is in the same directory: $< $@" ; \
531 exit 1; \
532 fi; \
533 $(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \
534 fi
535 endef
536 else ifeq ($(OPENJDK_TARGET_OS),macosx)
537 # On mac, extended attributes sometimes creep into the source files, which may later
538 # cause the creation of ._* files which confuses testing. Clear these with xattr if
539 # set. Some files get their write permissions removed after being copied to the
540 # output dir. When these are copied again to images, xattr would fail. By only clearing
541 # attributes when they are present, failing on this is avoided.
542 #
543 # If copying a soft link to a directory, need to delete the target first to avoid
544 # weird errors.
545 define install-file
546 $(call MakeTargetDir)
547 $(RM) '$(call DecodeSpace, $@)'
548 # Work around a weirdness with cp on Macosx. When coying a symlink, if
549 # the target of the link is write protected (e.g. 444), cp will add
550 # write permission for the user on the target file (644). Avoid this by
551 # using ln to create a new link instead.
552 if [ -h '$(call DecodeSpace, $<)' ]; then \
553 $(LN) -s "`$(READLINK) '$(call DecodeSpace, $<)'`" '$(call DecodeSpace, $@)'; \
554 else \
555 $(CP) -fRP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \
556 fi
557 if [ -n "`$(XATTR) -ls '$(call DecodeSpace, $@)'`" ]; then \
558 $(XATTR) -cs '$(call DecodeSpace, $@)'; \
559 fi
560 endef
561 else
562 define install-file
563 $(call MakeTargetDir)
564 $(CP) -fP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
565 endef
566 endif
567
568 # Variant of install file that does not preserve symlinks
569 define install-file-nolink
570 $(call MakeTargetDir)
571 $(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
572 endef
573
574 ################################################################################
575 # Take two paths and return the path of the last common directory.
576 # Ex: /foo/bar/baz, /foo/bar/banan -> /foo/bar
577 # foo/bar/baz, /foo/bar -> <empty>
578 #
579 # The x prefix is used to preserve the presence of the initial slash
993 else
994 LogCmdlines =
995 endif
996
997 ################################################################################
998 # ExecuteWithLog will run a command and log the output appropriately. This is
999 # meant to be used by commands that do "real" work, like a compilation.
1000 # The output is stored in a specified log file, which is displayed at the end
1001 # of the build in case of failure. The command line itself is stored in a file,
1002 # and also logged to stdout if the LOG=cmdlines option has been given.
1003 #
1004 # NOTE: If the command redirects stdout, the caller needs to wrap it in a
1005 # subshell (by adding parentheses around it), otherwise the redirect to the
1006 # subshell tee process will create a race condition where the target file may
1007 # not be fully written when the make recipe is done.
1008 #
1009 # Param 1 - The path to base the name of the log file / command line file on
1010 # Param 2 - The command to run
1011 ExecuteWithLog = \
1012 $(call LogCmdlines, Exececuting: [$(strip $2)]) \
1013 $(call MakeDir, $(dir $(strip $1))) \
1014 $(call WriteFile, $2, $(strip $1).cmdline) \
1015 ( $(strip $2) > >($(TEE) $(strip $1).log) 2> >($(TEE) $(strip $1).log >&2) || \
1016 ( exitcode=$(DOLLAR)? && \
1017 $(CP) $(strip $1).log $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(OUTPUTDIR)/%,%,$(strip $1))).log && \
1018 $(CP) $(strip $1).cmdline $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(OUTPUTDIR)/%,%,$(strip $1))).cmdline && \
1019 exit $(DOLLAR)exitcode ) )
1020
1021 ################################################################################
1022 # Find lib dir for module
1023 # Param 1 - module name
1024 FindLibDirForModule = \
1025 $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
1026
1027 ################################################################################
1028 # Return a string suitable for use after a -classpath or --module-path option. It
1029 # will be correct and safe to use on all platforms. Arguments are given as space
1030 # separate classpath entries. Safe for multiple nested calls.
1031 # param 1 : A space separated list of classpath entries
1032 # The surrounding strip is needed to keep additional whitespace out
1033 PathList = \
|