1 #
   2 # Copyright (c) 2012, 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 # This file is included by the root NewerMakefile and contains targets 
  27 # and utilities needed by JPRT.
  28 
  29 # Utilities used in this Makefile
  30 CAT=cat
  31 CMP=cmp
  32 CP=cp
  33 ECHO=echo
  34 MKDIR=mkdir
  35 PRINTF=printf
  36 PWD=pwd
  37 # Insure we have a path that looks like it came from pwd
  38 #   (This is mostly for Windows sake and drive letters)
  39 define UnixPath # path
  40 $(shell (cd "$1" && $(PWD)))
  41 endef
  42 
  43 BUILD_DIR_ROOT:=$(root_dir)/build
  44 
  45 # Appears to be an open build
  46 OPEN_BUILD := \
  47 $(shell \
  48   if [    -d $(root_dir)/jdk/src/closed      \
  49        -o -d $(root_dir)/jdk/make/closed     \
  50        -o -d $(root_dir)/jdk/test/closed     \
  51        -o -d $(root_dir)/hotspot/src/closed  \
  52        -o -d $(root_dir)/hotspot/make/closed \
  53        -o -d $(root_dir)/hotspot/test/closed ] ; then \
  54     echo "false"; \
  55   else \
  56     echo "true"; \
  57   fi \
  58  )
  59 ifdef OPENJDK
  60   OPEN_BUILD=true
  61 endif
  62 
  63 ###########################################################################
  64 # To help in adoption of the new configure&&make build process, a bridge
  65 #   build will use the old settings to run configure and do the build.
  66 
  67 # Build with the configure bridge. After running configure, restart make
  68 # to parse the new spec file.
  69 BRIDGE_TARGETS := all
  70 bridgeBuild: bridge2configure
  71         @cd $(root_dir) && $(MAKE) -f NewMakefile.gmk $(BRIDGE_TARGETS)
  72 
  73 # Bridge from old Makefile ALT settings to configure options
  74 bridge2configure: $(BUILD_DIR_ROOT)/.bridge2configureOpts
  75         bash ./configure $(strip $(shell $(CAT) $<))
  76 
  77 # Create a file with configure options created from old Makefile mechanisms.
  78 $(BUILD_DIR_ROOT)/.bridge2configureOpts: $(BUILD_DIR_ROOT)/.bridge2configureOptsLatest
  79         $(RM) $@
  80         $(CP) $< $@
  81 
  82 # Use this file to only change when obvious things have changed
  83 $(BUILD_DIR_ROOT)/.bridge2configureOptsLatest: FRC
  84         $(RM) $@.tmp
  85         $(MKDIR) -p $(BUILD_DIR_ROOT)
  86         @$(ECHO) " --with-debug-level=$(if $(DEBUG_LEVEL),$(DEBUG_LEVEL),release) " >> $@.tmp
  87 ifdef ARCH_DATA_MODEL
  88         @$(ECHO) " --with-target-bits=$(ARCH_DATA_MODEL) " >> $@.tmp
  89 endif
  90 ifeq ($(ARCH_DATA_MODEL),32)
  91         @$(ECHO) " --with-jvm-variants=client,server " >> $@.tmp
  92 endif
  93 ifdef ALT_PARALLEL_COMPILE_JOBS
  94         @$(ECHO) " --with-num-cores=$(ALT_PARALLEL_COMPILE_JOBS) " >> $@.tmp
  95 endif
  96 ifdef ALT_BOOTDIR
  97         @$(ECHO) " --with-boot-jdk=$(call UnixPath,$(ALT_BOOTDIR)) " >> $@.tmp
  98 endif
  99 ifdef ALT_CUPS_HEADERS_PATH
 100         @$(ECHO) " --with-cups-include=$(call UnixPath,$(ALT_CUPS_HEADERS_PATH)) " >> $@.tmp
 101 endif
 102 ifdef ALT_FREETYPE_HEADERS_PATH
 103         @$(ECHO) " --with-freetype=$(call UnixPath,$(ALT_FREETYPE_HEADERS_PATH)/..) " >> $@.tmp
 104 endif
 105 ifeq ($(OPEN_BUILD),true)
 106         @$(ECHO) " --enable-openjdk-only " >> $@.tmp
 107 else
 108   # Todo: move to closed?
 109   ifdef ALT_MOZILLA_HEADERS_PATH
 110         @$(ECHO) " --with-mozilla-headers=$(call UnixPath,$(ALT_MOZILLA_HEADERS_PATH)) " >> $@.tmp
 111   endif
 112   ifdef ALT_JUNIT_DIR
 113         @$(ECHO) " --with-junit-dir=$(call UnixPath,$(ALT_JUNIT_DIR)) " >> $@.tmp
 114   endif
 115   ifdef ANT_HOME
 116         @$(ECHO) " --with-ant-home=$(call UnixPath,$(ANT_HOME)) " >> $@.tmp
 117   endif
 118   ifdef ALT_JAVAFX_ZIP_DIR
 119         @$(ECHO) " --with-javafx-zip-dir=$(call UnixPath,$(ALT_JAVAFX_ZIP_DIR)) " >> $@.tmp
 120   endif
 121   ifdef ALT_WIXDIR
 122         @$(ECHO) " --with-wix=$(call UnixPath,$(ALT_WIXDIR)) " >> $@.tmp
 123   endif
 124   ifdef ALT_CCSS_SIGNING_DIR
 125         @$(ECHO) " --with-ccss-signing=$(call UnixPath,$(ALT_CCSS_SIGNING_DIR)) " >> $@.tmp
 126   endif
 127   ifdef ALT_SLASH_JAVA
 128         @$(ECHO) " --with-java-devtools=$(call UnixPath,$(ALT_SLASH_JAVA)/devtools) " >> $@.tmp
 129   endif
 130 endif
 131         @if [ -f $@ ] ; then \
 132           if ! $(CMP) $@ $@.tmp > /dev/null ; then \
 133             $(CP) $@.tmp $@ ; \
 134           fi ; \
 135         else \
 136           $(CP) $@.tmp $@ ; \
 137         fi
 138         $(RM) $@.tmp
 139 
 140 PHONY_LIST += bridge2configure bridgeBuild
 141 
 142 ###########################################################################
 143 # JPRT targets
 144 
 145 ifndef JPRT_ARCHIVE_BUNDLE
 146   JPRT_ARCHIVE_BUNDLE=/tmp/jprt_bundles/j2sdk-image.zip
 147 endif
 148 
 149 # These targets execute in a SPEC free context, before calling bridgeBuild
 150 # to generate the SPEC.
 151 jprt_build_product: DEBUG_LEVEL=release
 152 jprt_build_product: BUILD_DIRNAME=*-release
 153 jprt_build_product: jprt_build_generic
 154 
 155 jprt_build_fastdebug: DEBUG_LEVEL=fastdebug
 156 jprt_build_fastdebug: BUILD_DIRNAME=*-fastdebug
 157 jprt_build_fastdebug: jprt_build_generic
 158 
 159 jprt_build_debug: DEBUG_LEVEL=slowdebug
 160 jprt_build_debug: BUILD_DIRNAME=*-debug
 161 jprt_build_debug: jprt_build_generic
 162 
 163 jprt_build_generic: BRIDGE_TARGETS+=jprt_bundle
 164 jprt_build_generic: bridgeBuild
 165 
 166 # This target must be called in the context of a SPEC file
 167 jprt_bundle: $(JPRT_ARCHIVE_BUNDLE)
 168         @$(call CheckIfMakeAtEnd)
 169 
 170 # This target must be called in the context of a SPEC file
 171 $(JPRT_ARCHIVE_BUNDLE): bundles
 172         $(MKDIR) -p $(@D)
 173         $(RM) $@
 174         $(CP) $(BUILD_OUTPUT)/bundles/j2sdk-image.zip $@
 175 
 176 # This target must be called in the context of a SPEC file
 177 bundles: all
 178         @$(call TargetEnter)
 179         $(MKDIR) -p $(BUILD_OUTPUT)/bundles
 180         $(CD) $(IMAGES_OUTPUTDIR)/j2sdk-image && $(ZIP) -q -r $(BUILD_OUTPUT)/bundles/j2sdk-image.zip .
 181         $(CD) $(IMAGES_OUTPUTDIR)/j2re-image && $(ZIP) -q -r $(BUILD_OUTPUT)/bundles/j2re-image.zip .
 182         @$(call TargetExit)
 183 
 184 # Keep track of phony targets
 185 PHONY_LIST += jprt_build_product jprt_build_fastdebug jprt_build_debug \
 186               jprt_build_generic bundles jprt_bundle
 187 
 188 ###########################################################################
 189 # Phony targets
 190 .PHONY: $(PHONY_LIST)
 191 
 192 # Force target
 193 FRC: