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