1 # 2 # Copyright (c) 2011, 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 ################################################################################ 27 # Build demos for the JDK into $(SUPPORT_OUTPUTDIR)/demos/image. 28 ################################################################################ 29 30 default: all 31 32 include $(SPEC) 33 include MakeBase.gmk 34 include JavaCompilation.gmk 35 include NativeCompilation.gmk 36 include SetupJavaCompilers.gmk 37 include TextFileProcessing.gmk 38 include ZipArchive.gmk 39 40 # Hook to include the corresponding custom file, if present. 41 $(eval $(call IncludeCustomExtension, CompileDemos-pre.gmk)) 42 43 # Prepare the find cache. 44 DEMO_SRC_DIRS += $(TOPDIR)/src/demo 45 46 $(call FillFindCache, $(DEMO_SRC_DIRS)) 47 48 # Append demo goals to this variable. 49 TARGETS = 50 51 # The demo structure and contents should really be cleaned up. 52 # Now every other demo has its own quirks where to put the 53 # READMEs and other files. 54 55 DEMO_SHARE_SRC := $(TOPDIR)/src/demo/share 56 GLOBAL_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/common/version.rc 57 58 DEMO_MANIFEST := $(SUPPORT_OUTPUTDIR)/demos/java-main-manifest.mf 59 60 # This rule will be depended on due to the MANIFEST line in SetupBuildDemo 61 # and SetupBuildJvmtiDemo. 62 $(eval $(call SetupTextFileProcessing, BUILD_JAVA_MANIFEST, \ 63 SOURCE_FILES := $(TOPDIR)/make/data/mainmanifest/manifest.mf, \ 64 OUTPUT_FILE := $(DEMO_MANIFEST), \ 65 REPLACEMENTS := \ 66 @@VERSION_SPECIFICATION@@ => $(VERSION_SPECIFICATION) ; \ 67 @@VERSION_SHORT@@ => $(VERSION_SHORT) ; \ 68 @@COMPANY_NAME@@ => $(COMPANY_NAME) , \ 69 )) 70 71 ################################################################################ 72 # Build normal demos. 73 74 COPY_TO_JAR := .html .txt .properties .js .gif .jpg .theme .data .opt .c .h \ 75 .png .ttf .xyz .obj README COPYRIGHT 76 77 COPY_TO_IMAGE := *.html *.txt *.png *.xml README* 78 79 # Setup make rules for building a demo. 80 # 81 # Parameter 1 is the name of the rule. This name is used as variable prefix, 82 # and the targets generated are listed in a variable by that name. 83 # 84 # Remaining parameters are named arguments. These include: 85 # DEMO_SUBDIR The name of the subdir of the demo, below the demo top dir. 86 # EXTRA_SRC_DIR Additional source directory. 87 # SRC_SUB_DIR Optional subdir to locate source code in 88 # SRC_DIR Alternative source directory to use for the demos. 89 # EXCLUDE_FILES Exclude file list 90 # JAR_NAME Base name of jar file. Defaults to $1. 91 # MAIN_CLASS The main class for the jar. Defaults to $1. 92 # EXTRA_COPY_TO_JAR Additional files to copy to jar (as patterns) 93 # EXTRA_COPY_TO_IMAGE Additional files to copy to images (as wildcards) 94 # EXTRA_MANIFEST_ATTR Extra manifest attribute 95 # SKIP_COMPILATION Skip Java compilation iff true 96 # DISABLE_SJAVAC Passed to SetupJavaCompilation 97 SetupBuildDemo = $(NamedParamsMacroTemplate) 98 define SetupBuildDemoBody 99 ifeq ($$($1_SRC_DIR), ) 100 $1_SRC_DIR := $(DEMO_SHARE_SRC) 101 endif 102 103 $1_SRC_BASE := $$($1_SRC_DIR)/$$($1_DEMO_SUBDIR)/$1 104 105 # In some demos the source is found in a subdir 106 ifneq ($$($1_SRC_SUB_DIR), ) 107 $1_MAIN_SRC := $$($1_SRC_BASE)/$$($1_SRC_SUB_DIR) 108 else 109 # for allmost all 110 $1_MAIN_SRC := $$($1_SRC_BASE) 111 endif 112 113 # Default is to use demo name as jar file name. 114 ifeq ($$($1_JAR_NAME), ) 115 $1_JAR_NAME := $1 116 endif 117 118 # Default is to use demo name as jar main class. 119 ifeq ($$($1_MAIN_CLASS), ) 120 $1_MAIN_CLASS := $1 121 else ifeq ($$($1_MAIN_CLASS), NONE) 122 $1_MAIN_CLASS := 123 $1_EXTRA_MANIFEST_ATTR += Main-Class: \n 124 endif 125 126 ifneq ($$($1_SKIP_COMPILATION), true) 127 $$(eval $$(call SetupJavaCompilation, BUILD_DEMO_$1, \ 128 SETUP := GENERATE_USINGJDKBYTECODE, \ 129 SRC := $$($1_MAIN_SRC) $$($1_EXTRA_SRC_DIR), \ 130 BIN := $(SUPPORT_OUTPUTDIR)/demos/classes/$$($1_DEMO_SUBDIR)/$1, \ 131 COPY := $(COPY_TO_JAR) $$($1_EXTRA_COPY_TO_JAR), \ 132 JAR := $(SUPPORT_OUTPUTDIR)/demos/image/$$($1_DEMO_SUBDIR)/$1/$$($1_JAR_NAME).jar, \ 133 JARMAIN := $$($1_MAIN_CLASS), \ 134 MANIFEST := $(DEMO_MANIFEST), \ 135 EXTRA_MANIFEST_ATTR := $$($1_EXTRA_MANIFEST_ATTR), \ 136 SRCZIP := $(SUPPORT_OUTPUTDIR)/demos/image/$$($1_DEMO_SUBDIR)/$1/src.zip, \ 137 EXCLUDE_FILES := $$($1_EXCLUDE_FILES), \ 138 DISABLE_SJAVAC := $$($1_DISABLE_SJAVAC), \ 139 )) 140 141 $1 += $$(BUILD_DEMO_$1) 142 endif 143 144 # Copy files. Sort is needed to remove duplicates. 145 $1_COPY_FILES := $$(sort $$(wildcard $$(addprefix $$($1_SRC_BASE)/, \ 146 $(COPY_TO_IMAGE) $$($1_EXTRA_COPY_TO_IMAGE)))) 147 $$(eval $$(call SetupCopyFiles, COPY_DEMO_$1, \ 148 SRC := $$($1_SRC_BASE), \ 149 DEST := $(SUPPORT_OUTPUTDIR)/demos/image/$$($1_DEMO_SUBDIR)/$1, \ 150 FILES := $$($1_COPY_FILES), \ 151 )) 152 153 $1 += $$(COPY_DEMO_$1) 154 155 TARGETS += $$($1) 156 endef 157 158 CODEPOINT_SERVICE := java.awt.im.spi.InputMethodDescriptor 159 CODEPOINT_METAINF_SERVICE_FILE := \ 160 $(SUPPORT_OUTPUTDIR)/demos/classes/jfc/CodePointIM/META-INF/services/$(CODEPOINT_SERVICE) 161 162 $(eval $(call SetupBuildDemo, CodePointIM, \ 163 DEMO_SUBDIR := jfc, \ 164 EXTRA_COPY_TO_JAR := $(CODEPOINT_SERVICE), \ 165 )) 166 167 # We also need to copy the CODEPOINT_SERVICE file to the META-INF/services 168 # location, and make sure the jar depends on that file to get it included. 169 $(CODEPOINT_METAINF_SERVICE_FILE): $(DEMO_SHARE_SRC)/jfc/CodePointIM/$(CODEPOINT_SERVICE) 170 $(call install-file) 171 172 $(BUILD_DEMO_CodePointIM_JAR): $(CODEPOINT_METAINF_SERVICE_FILE) 173 174 $(eval $(call SetupBuildDemo, FileChooserDemo, \ 175 DEMO_SUBDIR := jfc, \ 176 )) 177 178 $(eval $(call SetupBuildDemo, SwingSet2, \ 179 DEMO_SUBDIR := jfc, \ 180 EXTRA_COPY_TO_JAR := .java, \ 181 EXTRA_MANIFEST_ATTR := SplashScreen-Image: resources/images/splash.png, \ 182 DISABLE_SJAVAC := true, \ 183 )) 184 185 $(eval $(call SetupBuildDemo, Font2DTest, \ 186 DEMO_SUBDIR := jfc, \ 187 )) 188 189 $(eval $(call SetupBuildDemo, J2Ddemo, \ 190 DEMO_SUBDIR := jfc, \ 191 MAIN_CLASS := java2d.J2Ddemo, \ 192 JAR_NAME := J2Ddemo, \ 193 )) 194 195 $(eval $(call SetupBuildDemo, Metalworks, \ 196 DEMO_SUBDIR := jfc, \ 197 )) 198 199 $(eval $(call SetupBuildDemo, Notepad, \ 200 DEMO_SUBDIR := jfc, \ 201 )) 202 203 $(eval $(call SetupBuildDemo, Stylepad, \ 204 DEMO_SUBDIR := jfc, \ 205 EXTRA_SRC_DIR := $(DEMO_SHARE_SRC)/jfc/Notepad, \ 206 EXCLUDE_FILES := $(DEMO_SHARE_SRC)/jfc/Notepad/README.txt, \ 207 )) 208 209 $(eval $(call SetupBuildDemo, SampleTree, \ 210 DEMO_SUBDIR := jfc, \ 211 )) 212 213 $(eval $(call SetupBuildDemo, TableExample, \ 214 DEMO_SUBDIR := jfc, \ 215 )) 216 217 $(eval $(call SetupBuildDemo, TransparentRuler, \ 218 DEMO_SUBDIR := jfc, \ 219 MAIN_CLASS := transparentruler.Ruler, \ 220 )) 221 222 ################################################################################ 223 # Copy html and README files. 224 225 $(SUPPORT_OUTPUTDIR)/demos/image/README: $(DEMO_SHARE_SRC)/README 226 $(call install-file) 227 228 TARGETS += $(SUPPORT_OUTPUTDIR)/demos/image/README 229 230 ################################################################################ 231 # Copy netbeans project files. 232 233 $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%: $(DEMO_SHARE_SRC)/nbproject/% 234 $(call install-file) 235 $(CHMOD) -f ug+w $@ 236 237 ifeq ($(call isTargetOs, solaris), true) 238 TARGETS += $(patsubst $(DEMO_SHARE_SRC)/nbproject/%, \ 239 $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%, \ 240 $(call FindFiles, $(DEMO_SHARE_SRC)/nbproject)) 241 else 242 TARGETS += $(patsubst $(DEMO_SHARE_SRC)/nbproject/%, \ 243 $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%, \ 244 $(call FindFiles, $(DEMO_SHARE_SRC)/nbproject)) 245 endif 246 247 ################################################################################ 248 249 ifneq ($(filter images, $(MAKECMDGOALS)), ) 250 $(eval $(call SetupCopyFiles, COPY_TO_TEST_IMAGE, \ 251 SRC := $(SUPPORT_OUTPUTDIR)/demos/image, \ 252 DEST := $(TEST_IMAGE_DIR)/jdk/demos, \ 253 FILES := $(call FindFiles, $(SUPPORT_OUTPUTDIR)/demos/image), \ 254 )) 255 256 IMAGES_TARGETS := $(COPY_TO_TEST_IMAGE) 257 endif 258 259 ################################################################################ 260 # Hook to include the corresponding custom file, if present. 261 $(eval $(call IncludeCustomExtension, CompileDemos-post.gmk)) 262 263 all: $(TARGETS) 264 images: $(IMAGES_TARGETS) 265 266 .PHONY: all