1 #
   2 # Copyright (c) 2011, 2016, 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 $(eval $(call FillCacheFind, $(wildcard $(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 applet demos.
  73 
  74 # Setup make rules for building a demo applet.
  75 #
  76 # Parameter 1 is the name of the rule. This name is used as variable prefix,
  77 # and the targets generated are listed in a variable by that name. It is also
  78 # used to locate the name of the applet subdir, and to determine the name
  79 # of the output directory.
  80 #
  81 # Remaining parameters are named arguments. These include:
  82 # SRC_DIR   Alternative source directory to use for the demos.
  83 # DISABLE_SJAVAC   Passed to SetupJavaCompilation
  84 
  85 SetupBuildAppletDemo = $(NamedParamsMacroTemplate)
  86 define SetupBuildAppletDemoBody
  87   ifeq ($$($1_SRC_DIR), )
  88     $1_SRC_DIR := $(DEMO_SHARE_SRC)/applets
  89   endif
  90 
  91   $$(eval $$(call SetupJavaCompilation, BUILD_DEMO_APPLET_$1, \
  92       SETUP := GENERATE_USINGJDKBYTECODE, \
  93       SRC := $$($1_SRC_DIR)/$1, \
  94       BIN := $(SUPPORT_OUTPUTDIR)/demos/image/applets/$1, \
  95       COPY := .html .java .xyz .obj .au .gif, \
  96       DISABLE_SJAVAC := $$($1_DISABLE_SJAVAC), \
  97   ))
  98 
  99   $1 := $$(BUILD_DEMO_APPLET_$1)
 100 
 101   TARGETS += $$($1)
 102 endef
 103 
 104 ifneq ($(OPENJDK_TARGET_OS), solaris)
 105   $(eval $(call SetupBuildAppletDemo, ArcTest))
 106   $(eval $(call SetupBuildAppletDemo, BarChart))
 107   $(eval $(call SetupBuildAppletDemo, Blink))
 108   $(eval $(call SetupBuildAppletDemo, CardTest))
 109   $(eval $(call SetupBuildAppletDemo, Clock))
 110   $(eval $(call SetupBuildAppletDemo, DitherTest))
 111   $(eval $(call SetupBuildAppletDemo, DrawTest))
 112   $(eval $(call SetupBuildAppletDemo, Fractal))
 113   $(eval $(call SetupBuildAppletDemo, GraphicsTest))
 114   $(eval $(call SetupBuildAppletDemo, NervousText))
 115   $(eval $(call SetupBuildAppletDemo, SimpleGraph))
 116   $(eval $(call SetupBuildAppletDemo, SortDemo))
 117   $(eval $(call SetupBuildAppletDemo, SpreadSheet))
 118 endif
 119 
 120 ################################################################################
 121 # Build normal demos.
 122 
 123 COPY_TO_JAR := .html .txt .properties .js .gif .jpg .theme .data .opt .c .h \
 124     .png .ttf .xyz .obj README COPYRIGHT
 125 
 126 COPY_TO_IMAGE := *.html *.txt *.png *.xml README*
 127 
 128 # Setup make rules for building a demo.
 129 #
 130 # Parameter 1 is the name of the rule. This name is used as variable prefix,
 131 # and the targets generated are listed in a variable by that name.
 132 #
 133 # Remaining parameters are named arguments. These include:
 134 # DEMO_SUBDIR   The name of the subdir of the demo, below the demo top dir.
 135 # EXTRA_SRC_DIR   Additional source directory.
 136 # SRC_SUB_DIR   Optional subdir to locate source code in
 137 # SRC_DIR   Alternative source directory to use for the demos.
 138 # EXCLUDE_FILES   Exclude file list
 139 # JAR_NAME   Base name of jar file. Defaults to $1.
 140 # MAIN_CLASS   The main class for the jar. Defaults to $1.
 141 # EXTRA_COPY_TO_JAR   Additional files to copy to jar (as patterns)
 142 # EXTRA_COPY_TO_IMAGE   Additional files to copy to images (as wildcards)
 143 # EXTRA_MANIFEST_ATTR   Extra manifest attribute
 144 # SKIP_COMPILATION   Skip Java compilation iff true
 145 # DISABLE_SJAVAC   Passed to SetupJavaCompilation
 146 SetupBuildDemo = $(NamedParamsMacroTemplate)
 147 define SetupBuildDemoBody
 148   ifeq ($$($1_SRC_DIR), )
 149     $1_SRC_DIR := $(DEMO_SHARE_SRC)
 150   endif
 151 
 152   $1_SRC_BASE := $$($1_SRC_DIR)/$$($1_DEMO_SUBDIR)/$1
 153 
 154   # In some demos the source is found in a subdir
 155   ifneq ($$($1_SRC_SUB_DIR), )
 156     $1_MAIN_SRC := $$($1_SRC_BASE)/$$($1_SRC_SUB_DIR)
 157   else
 158     # for allmost all
 159     $1_MAIN_SRC := $$($1_SRC_BASE)
 160   endif
 161 
 162   # Default is to use demo name as jar file name.
 163   ifeq ($$($1_JAR_NAME), )
 164     $1_JAR_NAME := $1
 165   endif
 166 
 167   # Default is to use demo name as jar main class.
 168   ifeq ($$($1_MAIN_CLASS), )
 169     $1_MAIN_CLASS := $1
 170   else ifeq ($$($1_MAIN_CLASS), NONE)
 171     $1_MAIN_CLASS :=
 172     $1_EXTRA_MANIFEST_ATTR += Main-Class: \n
 173   endif
 174 
 175   ifneq ($$($1_SKIP_COMPILATION), true)
 176     $$(eval $$(call SetupJavaCompilation, BUILD_DEMO_$1, \
 177         SETUP := GENERATE_USINGJDKBYTECODE, \
 178         SRC := $$($1_MAIN_SRC) $$($1_EXTRA_SRC_DIR), \
 179         BIN := $(SUPPORT_OUTPUTDIR)/demos/classes/$$($1_DEMO_SUBDIR)/$1, \
 180         COPY := $(COPY_TO_JAR) $$($1_EXTRA_COPY_TO_JAR), \
 181         JAR := $(SUPPORT_OUTPUTDIR)/demos/image/$$($1_DEMO_SUBDIR)/$1/$$($1_JAR_NAME).jar, \
 182         JARMAIN := $$($1_MAIN_CLASS), \
 183         MANIFEST := $(DEMO_MANIFEST), \
 184         EXTRA_MANIFEST_ATTR := $$($1_EXTRA_MANIFEST_ATTR), \
 185         SRCZIP := $(SUPPORT_OUTPUTDIR)/demos/image/$$($1_DEMO_SUBDIR)/$1/src.zip, \
 186         EXCLUDE_FILES := $$($1_EXCLUDE_FILES), \
 187         DISABLE_SJAVAC := $$($1_DISABLE_SJAVAC), \
 188     ))
 189 
 190     $1 += $$(BUILD_DEMO_$1)
 191   endif
 192 
 193   # Copy files. Sort is needed to remove duplicates.
 194   $1_COPY_FILES := $$(sort $$(wildcard $$(addprefix $$($1_SRC_BASE)/, \
 195       $(COPY_TO_IMAGE) $$($1_EXTRA_COPY_TO_IMAGE))))
 196   $$(eval $$(call SetupCopyFiles, COPY_DEMO_$1, \
 197       SRC :=  $$($1_SRC_BASE), \
 198       DEST := $(SUPPORT_OUTPUTDIR)/demos/image/$$($1_DEMO_SUBDIR)/$1, \
 199       FILES := $$($1_COPY_FILES), \
 200   ))
 201 
 202   $1 += $$(COPY_DEMO_$1)
 203 
 204   TARGETS += $$($1)
 205 endef
 206 
 207 CODEPOINT_SERVICE := java.awt.im.spi.InputMethodDescriptor
 208 CODEPOINT_METAINF_SERVICE_FILE := \
 209     $(SUPPORT_OUTPUTDIR)/demos/classes/jfc/CodePointIM/META-INF/services/$(CODEPOINT_SERVICE)
 210 
 211 $(eval $(call SetupBuildDemo, CodePointIM, \
 212     DEMO_SUBDIR := jfc, \
 213     EXTRA_COPY_TO_JAR := $(CODEPOINT_SERVICE), \
 214 ))
 215 
 216 # We also need to copy the CODEPOINT_SERVICE file to the META-INF/services
 217 # location, and make sure the jar depends on that file to get it included.
 218 $(CODEPOINT_METAINF_SERVICE_FILE): $(DEMO_SHARE_SRC)/jfc/CodePointIM/$(CODEPOINT_SERVICE)
 219         $(call install-file)
 220 
 221 $(BUILD_DEMO_CodePointIM_JAR): $(CODEPOINT_METAINF_SERVICE_FILE)
 222 
 223 ifneq ($(OPENJDK_TARGET_OS), solaris)
 224   $(eval $(call SetupBuildDemo, MoleculeViewer, \
 225       DEMO_SUBDIR := applets, \
 226       MAIN_CLASS := XYZChemModel, \
 227       EXTRA_COPY_TO_IMAGE := *.java, \
 228   ))
 229 
 230   $(eval $(call SetupBuildDemo, WireFrame, \
 231       DEMO_SUBDIR := applets, \
 232       MAIN_CLASS := ThreeD, \
 233       EXTRA_COPY_TO_IMAGE := *.java, \
 234   ))
 235 
 236   $(eval $(call SetupBuildDemo, SwingApplet, \
 237       DEMO_SUBDIR := jfc, \
 238   ))
 239 endif
 240 
 241 $(eval $(call SetupBuildDemo, FileChooserDemo, \
 242     DEMO_SUBDIR := jfc, \
 243 ))
 244 
 245 $(eval $(call SetupBuildDemo, SwingSet2, \
 246     DEMO_SUBDIR := jfc, \
 247     EXTRA_COPY_TO_JAR := .java, \
 248     EXTRA_MANIFEST_ATTR := SplashScreen-Image: resources/images/splash.png, \
 249     DISABLE_SJAVAC := true, \
 250 ))
 251 
 252 $(eval $(call SetupBuildDemo, Font2DTest, \
 253     DEMO_SUBDIR := jfc, \
 254 ))
 255 
 256 $(eval $(call SetupBuildDemo, J2Ddemo, \
 257     DEMO_SUBDIR := jfc, \
 258     MAIN_CLASS := java2d.J2Ddemo, \
 259     JAR_NAME := J2Ddemo, \
 260 ))
 261 
 262 $(eval $(call SetupBuildDemo, Metalworks, \
 263     DEMO_SUBDIR := jfc, \
 264 ))
 265 
 266 $(eval $(call SetupBuildDemo, Notepad, \
 267     DEMO_SUBDIR := jfc, \
 268 ))
 269 
 270 $(eval $(call SetupBuildDemo, SampleTree, \
 271     DEMO_SUBDIR := jfc, \
 272 ))
 273 
 274 $(eval $(call SetupBuildDemo, TableExample, \
 275     DEMO_SUBDIR := jfc, \
 276 ))
 277 
 278 $(eval $(call SetupBuildDemo, TransparentRuler, \
 279     DEMO_SUBDIR := jfc, \
 280     MAIN_CLASS := transparentruler.Ruler, \
 281 ))
 282 
 283 ################################################################################
 284 # Copy html and README files.
 285 
 286 $(SUPPORT_OUTPUTDIR)/demos/image/README: $(DEMO_SHARE_SRC)/README
 287         $(call install-file)
 288 
 289 TARGETS += $(SUPPORT_OUTPUTDIR)/demos/image/README
 290 
 291 ################################################################################
 292 # Copy netbeans project files.
 293 
 294 $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%: $(DEMO_SHARE_SRC)/nbproject/%
 295         $(call install-file)
 296         $(CHMOD) -f ug+w $@
 297 
 298 ifeq ($(OPENJDK_TARGET_OS), solaris)
 299   TARGETS += $(patsubst $(DEMO_SHARE_SRC)/nbproject/%, \
 300     $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%, \
 301     $(filter-out $(DEMO_SHARE_SRC)/nbproject/jfc/SwingApplet%, \
 302     $(call CacheFind, $(DEMO_SHARE_SRC)/nbproject)))
 303 else
 304   TARGETS += $(patsubst $(DEMO_SHARE_SRC)/nbproject/%, \
 305     $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%, \
 306     $(call CacheFind, $(DEMO_SHARE_SRC)/nbproject))
 307 endif
 308 
 309 ################################################################################
 310 
 311 ifneq ($(filter images, $(MAKECMDGOALS)), )
 312   $(eval $(call SetupCopyFiles, COPY_TO_TEST_IMAGE, \
 313       SRC := $(SUPPORT_OUTPUTDIR)/demos/image, \
 314       DEST := $(TEST_IMAGE_DIR)/jdk/demos, \
 315       FILES := $(call CacheFind, $(SUPPORT_OUTPUTDIR)/demos/image), \
 316   ))
 317 
 318   IMAGES_TARGETS := $(COPY_TO_TEST_IMAGE)
 319 endif
 320 
 321 ################################################################################
 322 # Hook to include the corresponding custom file, if present.
 323 $(eval $(call IncludeCustomExtension, CompileDemos-post.gmk))
 324 
 325 all: $(TARGETS)
 326 images: $(IMAGES_TARGETS)
 327 
 328 .PHONY: all