1 # 2 # Copyright (c) 2014, 2019, 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 23 # questions. 24 # 25 26 default: all 27 28 include $(SPEC) 29 include MakeBase.gmk 30 include JavaCompilation.gmk 31 include Modules.gmk 32 33 SRC_ZIP_WORK_DIR := $(SUPPORT_OUTPUTDIR)/src 34 35 # Hook to include the corresponding custom file, if present. 36 $(eval $(call IncludeCustomExtension, ZipSource.gmk)) 37 38 ################################################################################ 39 # Create the directory structure for src.zip using symlinks. 40 # <module>/<package>/<file>.java 41 42 # Find extra source dirs for a module that are not part of normal compilation 43 # but should be included in src.zip. 44 # $1: Module to find dirs for 45 ExtraSrcDirs = \ 46 $(wildcard $(SUPPORT_OUTPUTDIR)/rmic/$(strip $1)) 47 48 ALL_MODULES := $(FindAllModules) 49 50 # Generate the src dirs in the first make invocation and then call this makefile 51 # again to create src.zip. 52 $(foreach m, $(ALL_MODULES), \ 53 $(foreach d, $(call FindModuleSrcDirs, $m) $(call ExtraSrcDirs, $m), \ 54 $(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(TOPDIR)/%,%,$d)/$m) \ 55 $(if $(SRC_GENERATED), , \ 56 $(eval $$($d_TARGET): $d ; \ 57 $$(if $(filter $(TOPDIR)/%, $d), $$(link-file-relative), $$(link-file-absolute)) \ 58 ) \ 59 ) \ 60 $(eval SRC_ZIP_SRCS += $$($d_TARGET)) \ 61 $(eval SRC_ZIP_SRCS_$m += $$($d_TARGET)) \ 62 ) \ 63 ) 64 65 TARGETS += $(SRC_ZIP_SRCS) 66 67 ################################################################################ 68 # Only evaluate the creation of src.zip in a sub make call when the symlinked 69 # src directory structure has been generated. 70 ifeq ($(SRC_GENERATED), true) 71 72 # Rewrite the EXCLUDE_TRANSLATIONS locales as exclude patters for java files 73 TRANSLATIONS_PATTERN := $(addprefix %_, $(addsuffix .java, $(EXCLUDE_TRANSLATIONS))) 74 75 # Add excludes for translations for all modules except jdk.localedata 76 $(foreach s, $(SRC_ZIP_SRCS), \ 77 $(if $(filter $(notdir $s), jdk.localedata), , \ 78 $(eval BUILD_SRC_ZIP_EXCLUDE_PATTERNS_$(dir $s) := $$(TRANSLATIONS_PATTERN)) \ 79 ) \ 80 ) 81 82 $(eval $(call SetupZipArchive, BUILD_SRC_ZIP, \ 83 SRC := $(dir $(SRC_ZIP_SRCS)), \ 84 INCLUDES := $(SRC_ZIP_INCLUDES), \ 85 INCLUDE_FILES := $(SRC_ZIP_INCLUDE_FILES), \ 86 EXCLUDES := $(SRC_ZIP_EXCLUDES), \ 87 EXCLUDE_FILES := $(SRC_ZIP_EXCLUDE_FILES), \ 88 SUFFIXES := .java, \ 89 ZIP := $(SUPPORT_OUTPUTDIR)/src.zip, \ 90 FOLLOW_SYMLINKS := true, \ 91 )) 92 93 do-zip: $(BUILD_SRC_ZIP) 94 95 .PHONY: do-zip 96 endif 97 98 zip: $(SRC_ZIP_SRCS) 99 +$(MAKE) $(MAKE_ARGS) -f ZipSource.gmk do-zip SRC_GENERATED=true 100 101 TARGETS += zip 102 103 ################################################################################ 104 105 all: $(TARGETS) 106 107 .PHONY: default all zip