make/CreateJmods.gmk
author duke
Wed, 05 Jul 2017 22:22:33 +0200
changeset 41643 df0e03e3ca0e
parent 41532 76dffc133464
child 41874 07c3c4f1eb63
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37770
9f040cf69078 8150044: Generate classlists at build-time
redestad
parents: 37765
diff changeset
     1
39929
f6828731baa8 8160334: Building --with-parfait= fails with No rule to make target 'PARFAIT_NATIVEJMOD
erikj
parents: 38848
diff changeset
     2
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
36506
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     4
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    10
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    15
# accompanied this code).
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    16
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    20
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    23
# questions.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    24
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    25
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    26
default: all
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    27
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    28
include $(SPEC)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    29
include MakeBase.gmk
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    30
include Modules.gmk
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    31
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    32
ifeq ($(MODULE), )
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    33
  $(error MODULE must be set when calling CreateJmods.gmk)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    34
endif
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    35
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    36
################################################################################
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    37
37770
9f040cf69078 8150044: Generate classlists at build-time
redestad
parents: 37765
diff changeset
    38
JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
9f040cf69078 8150044: Generate classlists at build-time
redestad
parents: 37765
diff changeset
    39
36506
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    40
LIBS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
41260
4f71f07b30d1 8150736: Excessive disk space used by build system
erikj
parents: 40782
diff changeset
    41
    $(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
36506
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    42
CMDS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
41260
4f71f07b30d1 8150736: Excessive disk space used by build system
erikj
parents: 40782
diff changeset
    43
    $(SUPPORT_OUTPUTDIR)/modules_cmds $(IMPORT_MODULES_CMDS))))
36506
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    44
CONF_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    45
    $(SUPPORT_OUTPUTDIR)/modules_conf $(IMPORT_MODULES_CONF))))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    46
CLASSES_DIR := $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE))
41532
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
    47
INCLUDE_HEADERS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
    48
    $(SUPPORT_OUTPUTDIR)/modules_include $(IMPORT_MODULES_INCLUDE_HEADERS))))
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
    49
MAN_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
    50
    $(SUPPORT_OUTPUTDIR)/modules_man $(IMPORT_MODULES_MAN))))
36506
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    51
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    52
$(eval $(call FillCacheFind, \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    53
    $(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR) $(CLASSES_DIR) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    54
))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    55
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    56
ifneq ($(LIBS_DIR), )
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    57
  JMOD_FLAGS += --libs $(LIBS_DIR)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    58
  DEPS += $(call CacheFind, $(LIBS_DIR))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    59
endif
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    60
ifneq ($(CMDS_DIR), )
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    61
  JMOD_FLAGS += --cmds $(CMDS_DIR)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    62
  DEPS += $(call CacheFind, $(CMDS_DIR))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    63
endif
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    64
ifneq ($(CONF_DIR), )
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    65
  JMOD_FLAGS += --config $(CONF_DIR)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    66
  DEPS += $(call CacheFind, $(CONF_DIR))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    67
endif
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    68
ifneq ($(CLASSES_DIR), )
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    69
  JMOD_FLAGS += --class-path $(CLASSES_DIR)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    70
  DEPS += $(call CacheFind, $(CLASSES_DIR))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    71
endif
41532
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
    72
ifneq ($(INCLUDE_HEADERS_DIR), )
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
    73
  JMOD_FLAGS += --header-files $(INCLUDE_HEADERS_DIR)
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
    74
  DEPS += $(call CacheFind, $(INCLUDE_HEADERS_DIR))
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
    75
endif
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
    76
ifneq ($(MAN_DIR), )
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
    77
  JMOD_FLAGS += --man-pages $(MAN_DIR)
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
    78
  DEPS += $(call CacheFind, $(MAN_DIR))
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
    79
endif
36506
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    80
37764
63e0379dd186 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36506
diff changeset
    81
# Add dependencies on other jmod files. Only java.base needs access to other
63e0379dd186 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36506
diff changeset
    82
# jmods.
63e0379dd186 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36506
diff changeset
    83
ifeq ($(MODULE), java.base)
37975
551c5d86de79 8155786: Determine modules depending on upgradeable modules directly and indirectly
erikj
parents: 37770
diff changeset
    84
  ALL_UPGRADEABLE_MODULES = $(call FindAllUpgradeableModules)
37770
9f040cf69078 8150044: Generate classlists at build-time
redestad
parents: 37765
diff changeset
    85
  # When creating a BUILDJDK, we don't need to add hashes to java.base
9f040cf69078 8150044: Generate classlists at build-time
redestad
parents: 37765
diff changeset
    86
  ifneq ($(CREATING_BUILDJDK), true)
9f040cf69078 8150044: Generate classlists at build-time
redestad
parents: 37765
diff changeset
    87
    DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \
37975
551c5d86de79 8155786: Determine modules depending on upgradeable modules directly and indirectly
erikj
parents: 37770
diff changeset
    88
        $(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules)))
37764
63e0379dd186 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36506
diff changeset
    89
37975
551c5d86de79 8155786: Determine modules depending on upgradeable modules directly and indirectly
erikj
parents: 37770
diff changeset
    90
    EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(ALL_UPGRADEABLE_MODULES))))
37764
63e0379dd186 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36506
diff changeset
    91
40241
59abac94e4f2 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39929
diff changeset
    92
    JMOD_FLAGS += --module-path $(JMODS_DIR) \
37770
9f040cf69078 8150044: Generate classlists at build-time
redestad
parents: 37765
diff changeset
    93
        --hash-modules '^(?!$(EXCLUDE_PATTERN))'
9f040cf69078 8150044: Generate classlists at build-time
redestad
parents: 37765
diff changeset
    94
  endif
37764
63e0379dd186 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36506
diff changeset
    95
endif
36506
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    96
39929
f6828731baa8 8160334: Building --with-parfait= fails with No rule to make target 'PARFAIT_NATIVEJMOD
erikj
parents: 38848
diff changeset
    97
# Changes to the jmod tool itself should also trigger a rebuild of all jmods.
f6828731baa8 8160334: Building --with-parfait= fails with No rule to make target 'PARFAIT_NATIVEJMOD
erikj
parents: 38848
diff changeset
    98
# The variable JMOD_CMD could contain an environment variable assignment before
f6828731baa8 8160334: Building --with-parfait= fails with No rule to make target 'PARFAIT_NATIVEJMOD
erikj
parents: 38848
diff changeset
    99
# the actual command. Filter that out using wildcard before adding to DEPS.
f6828731baa8 8160334: Building --with-parfait= fails with No rule to make target 'PARFAIT_NATIVEJMOD
erikj
parents: 38848
diff changeset
   100
DEPS += $(wildcard $(JMOD_CMD))
38848
0bc7ed792590 8144911: Consider having modifications to jdk.jlink trigger recreation of all jmods
erikj
parents: 37975
diff changeset
   101
ifeq ($(EXTERNAL_BUILDJDK), false)
0bc7ed792590 8144911: Consider having modifications to jdk.jlink trigger recreation of all jmods
erikj
parents: 37975
diff changeset
   102
  DEPS += $(call CacheFind, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod)
0bc7ed792590 8144911: Consider having modifications to jdk.jlink trigger recreation of all jmods
erikj
parents: 37975
diff changeset
   103
endif
0bc7ed792590 8144911: Consider having modifications to jdk.jlink trigger recreation of all jmods
erikj
parents: 37975
diff changeset
   104
36506
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   105
# TODO: What about headers?
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   106
# Create jmods in a temp dir and then move them into place to keep the
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   107
# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
37770
9f040cf69078 8150044: Generate classlists at build-time
redestad
parents: 37765
diff changeset
   108
$(JMODS_DIR)/$(MODULE).jmod: $(DEPS)
9f040cf69078 8150044: Generate classlists at build-time
redestad
parents: 37765
diff changeset
   109
	$(call LogWarn, Creating $(patsubst $(OUTPUT_ROOT)/%, %, $@))
36506
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   110
	$(call MakeDir, $(@D) $(SUPPORT_OUTPUTDIR)/jmods)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   111
	$(RM) $@ $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   112
	$(JMOD) create \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   113
            --module-version $(VERSION_SHORT) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   114
            --os-name $(REQUIRED_OS_NAME) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   115
            --os-arch $(OPENJDK_TARGET_CPU_LEGACY) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   116
            --os-version $(REQUIRED_OS_VERSION) \
40241
59abac94e4f2 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39929
diff changeset
   117
            --module-path $(JMODS_DIR) \
41532
76dffc133464 8167558: Add new JMOD section for header files and man pages
mchung
parents: 41260
diff changeset
   118
	    --exclude '**{_the.*,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \
36506
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   119
	    $(JMOD_FLAGS) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   120
	$(MV) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@) $@
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   121
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   122
TARGETS += $(IMAGES_OUTPUTDIR)/jmods/$(MODULE).jmod
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   123
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   124
################################################################################
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   125
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   126
all: $(TARGETS)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   127
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   128
################################################################################