common/makefiles/Jprt.gmk
author erikj
Fri, 28 Dec 2012 09:51:15 +0100
changeset 15053 64278cb83950
child 15058 61c4ac49cbda
permissions -rw-r--r--
8005549: build-infra: Merge NewMakefile.gmk and common/makefiles/Makefile Reviewed-by: ohair, tbell

#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

# This file is included by the root NewerMakefile and contains targets 
# and utilities needed by JPRT.

# Utilities used in this Makefile
CAT=cat
CMP=cmp
CP=cp
ECHO=echo
MKDIR=mkdir
PRINTF=printf
PWD=pwd
# Insure we have a path that looks like it came from pwd
#   (This is mostly for Windows sake and drive letters)
define UnixPath # path
$(shell (cd "$1" && $(PWD)))
endef

BUILD_DIR_ROOT:=$(root_dir)/build

###########################################################################
# To help in adoption of the new configure&&make build process, a bridge
#   build will use the old settings to run configure and do the build.

# Build with the configure bridge. After running configure, restart make
# to parse the new spec file.
BRIDGE_TARGETS := all
bridgeBuild: bridge2configure
	@cd $(root_dir) && $(MAKE) -f NewMakefile.gmk $(BRIDGE_TARGETS)

# Bridge from old Makefile ALT settings to configure options
bridge2configure: $(BUILD_DIR_ROOT)/.bridge2configureOpts
	bash ./configure $(strip $(shell $(CAT) $<))

# Create a file with configure options created from old Makefile mechanisms.
$(BUILD_DIR_ROOT)/.bridge2configureOpts: $(BUILD_DIR_ROOT)/.bridge2configureOptsLatest
	$(RM) $@
	$(CP) $< $@

# Use this file to only change when obvious things have changed
$(BUILD_DIR_ROOT)/.bridge2configureOptsLatest: FRC
	$(RM) $@.tmp
	$(MKDIR) -p $(BUILD_DIR_ROOT)
	@$(ECHO) " --with-debug-level=$(if $(DEBUG_LEVEL),$(DEBUG_LEVEL),release) " >> $@.tmp
ifdef ARCH_DATA_MODEL
	@$(ECHO) " --with-target-bits=$(ARCH_DATA_MODEL) " >> $@.tmp
endif
ifeq ($(ARCH_DATA_MODEL),32)
	@$(ECHO) " --with-jvm-variants=client,server " >> $@.tmp
endif
ifdef ALT_PARALLEL_COMPILE_JOBS
	@$(ECHO) " --with-num-cores=$(ALT_PARALLEL_COMPILE_JOBS) " >> $@.tmp
endif
ifdef ALT_BOOTDIR
	@$(ECHO) " --with-boot-jdk=$(call UnixPath,$(ALT_BOOTDIR)) " >> $@.tmp
endif
ifdef ALT_CUPS_HEADERS_PATH
	@$(ECHO) " --with-cups-include=$(call UnixPath,$(ALT_CUPS_HEADERS_PATH)) " >> $@.tmp
endif
ifdef ALT_FREETYPE_HEADERS_PATH
	@$(ECHO) " --with-freetype=$(call UnixPath,$(ALT_FREETYPE_HEADERS_PATH)/..) " >> $@.tmp
endif
ifdef OPENJDK
	@$(ECHO) " --enable-openjdk-only " >> $@.tmp
endif
# Todo: move to closed?
ifdef ALT_MOZILLA_HEADERS_PATH
	@$(ECHO) " --with-mozilla-headers=$(call UnixPath,$(ALT_MOZILLA_HEADERS_PATH)) " >> $@.tmp
endif
ifdef ALT_JUNIT_DIR
	@$(ECHO) " --with-junit-dir=$(call UnixPath,$(ALT_JUNIT_DIR)) " >> $@.tmp
endif
ifdef ANT_HOME
	@$(ECHO) " --with-ant-home=$(call UnixPath,$(ANT_HOME)) " >> $@.tmp
endif
ifdef ALT_SLASH_JAVA
	@$(ECHO) " --with-java-devtools=$(call UnixPath,$(ALT_SLASH_JAVA)/devtools) " >> $@.tmp
endif
	@if [ -f $@ ] ; then \
          if ! $(CMP) $@ $@.tmp > /dev/null ; then \
            $(CP) $@.tmp $@ ; \
          fi ; \
        else \
          $(CP) $@.tmp $@ ; \
        fi
	$(RM) $@.tmp

PHONY_LIST += bridge2configure bridgeBuild

###########################################################################
# JPRT targets

ifndef JPRT_ARCHIVE_BUNDLE
  JPRT_ARCHIVE_BUNDLE=/tmp/jprt_bundles/j2sdk-image.zip
endif

# These targets execute in a SPEC free context, before calling bridgeBuild
# to generate the SPEC.
jprt_build_product: DEBUG_LEVEL=release
jprt_build_product: BUILD_DIRNAME=*-release
jprt_build_product: jprt_build_generic

jprt_build_fastdebug: DEBUG_LEVEL=fastdebug
jprt_build_fastdebug: BUILD_DIRNAME=*-fastdebug
jprt_build_fastdebug: jprt_build_generic

jprt_build_debug: DEBUG_LEVEL=slowdebug
jprt_build_debug: BUILD_DIRNAME=*-debug
jprt_build_debug: jprt_build_generic

jprt_build_generic: BRIDGE_TARGETS+=jprt_bundle
jprt_build_generic: bridgeBuild

# This target must be called in the context of a SPEC file
jprt_bundle: $(JPRT_ARCHIVE_BUNDLE)
	@$(call CheckIfMakeAtEnd)

# This target must be called in the context of a SPEC file
$(JPRT_ARCHIVE_BUNDLE): bundles
	$(MKDIR) -p $(@D)
	$(RM) $@
	$(CP) $(BUILD_OUTPUT)/bundles/j2sdk-image.zip $@

# This target must be called in the context of a SPEC file
bundles: all
	@$(call TargetEnter)
	$(MKDIR) -p $(BUILD_OUTPUT)/bundles
	$(CD) $(IMAGES_OUTPUTDIR)/j2sdk-image && $(ZIP) -q -r $(BUILD_OUTPUT)/bundles/j2sdk-image.zip .
	$(CD) $(IMAGES_OUTPUTDIR)/j2re-image && $(ZIP) -q -r $(BUILD_OUTPUT)/bundles/j2re-image.zip .
	@$(call TargetExit)

# Keep track of phony targets
PHONY_LIST += jprt_build_product jprt_build_fastdebug jprt_build_debug \
              jprt_build_generic bundles jprt_bundle

###########################################################################
# Phony targets
.PHONY: $(PHONY_LIST)

# Force target
FRC: