NewMakefile.gmk 8.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#
# 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.
#

# Utilities used in this Makefile
BASENAME=basename
CAT=cat
CD=cd
CMP=cmp
CP=cp
ECHO=echo
MKDIR=mkdir
O
ohair 已提交
34
PRINTF=printf
35
PWD=pwd
O
ohair 已提交
36
TAR=tar
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
ifeq ($(PLATFORM),windows)
  ZIP=zip
else
  # store symbolic links as the link
  ZIP=zip -y
endif
# 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

# Current root directory
CURRENT_DIRECTORY := $(shell $(PWD))

# Build directory root
BUILD_DIR_ROOT = $(CURRENT_DIRECTORY)/build

# All configured Makefiles to run
ALL_MAKEFILES = $(wildcard $(BUILD_DIR_ROOT)/*-*/Makefile)

# All bundles to create
ALL_IMAGE_DIRS = $(wildcard $(BUILD_DIR_ROOT)/*-*/images/*-image)

# Build all the standard 'all', 'images', and 'clean' targets
all images clean: checks
	@if [ "$(ALL_MAKEFILES)" = "" ] ; then \
	  $(ECHO) "ERROR: No configurations to build"; exit 1; \
	fi
	@for bdir in $(dir $(ALL_MAKEFILES)) ; do \
O
ohair 已提交
67 68
	  $(ECHO) "$(CD) $${bdir} && $(MAKE) $@" ; \
	  $(CD) $${bdir} && $(MAKE) $@ ; \
69 70
	done

O
ohair 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
# TBD: Deploy input
$(BUILD_DIR_ROOT)/.deploy_input:
	@if [ "$(ALL_MAKEFILES)" = "" ] ; then \
	  $(ECHO) "ERROR: No configurations to build"; exit 1; \
	fi
	@for bdir in $(dir $(ALL_MAKEFILES)) ; do \
	  if [ deploy/make/Makefile ] ; then \
	    echo "Attempting deploy build." ; \
	    ( \
	      $(RM) -r $${bdir}/deploy_input ; \
	      $(MKDIR) -p $${bdir}/deploy_input ; \
	      ( $(CD) $${bdir}/images && $(TAR) -cf - j2sdk-image j2re-image ) \
	        | ( $(CD) $${bdir}/deploy_input && $(TAR) -xf - ) ; \
	    ) ; \
	  fi; \
	done
	touch $@

# TBD: Deploy images
deploy: $(BUILD_DIR_ROOT)/.deploy_input
	@if [ "$(ALL_MAKEFILES)" = "" ] ; then \
	  $(ECHO) "ERROR: No configurations to build"; exit 1; \
	fi
	@for bdir in $(dir $(ALL_MAKEFILES)) ; do \
	  if [ deploy/make/Makefile ] ; then \
	    echo "Attempting deploy build." ; \
	    ( \
	      $(CD) deploy/make && \
	      $(MAKE) \
	        ABS_OUTPUTDIR=$${bdir}/deploy_input \
	        OUTPUTDIR=$${bdir}/deploy_input \
	    ) ; \
	  fi; \
	done

# TBD: Install bundles
install:

109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
# Bundle creation
bundles:
	@if [ "$(ALL_IMAGE_DIRS)" = "" ] ; then \
	  $(ECHO) "ERROR: No images to bundle"; exit 1; \
	fi
	@for i in $(ALL_IMAGE_DIRS) ; do \
          $(MKDIR) -p $${i}/../../bundles && \
          $(RM) $${i}/../../bundles/`$(BASENAME) $${i}`.zip && \
	  $(ECHO) "$(CD) $${i} && $(ZIP) -q -r ../../bundles/`$(BASENAME) $${i}`.zip ."  && \
	  $(CD) $${i} && $(ZIP) -q -r ../../bundles/`$(BASENAME) $${i}`.zip . ; \
	done

# Clobber all the built files
clobber::
	$(RM) -r $(BUILD_DIR_ROOT)

# Make various checks to insure the build will be successful
#   Possibilities:
#     * Check that if any closed repo is provided, they all must be.
#     * Check that all open repos exist, at least until we are ready for some
#       kind of partial build.
checks:
	@$(ECHO) "No checks yet"

O
ohair 已提交
133 134
# Keep track of user targets
USER_TARGETS += all deploy install images clean clobber checks
135 136 137 138 139 140 141 142 143

###########################################################################
# 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
bridgeBuild: bridge2configure images

# Bridge from old Makefile ALT settings to configure options
O
ohair 已提交
144 145
bridge2configure: $(BUILD_DIR_ROOT)/.bridge2configureOpts
	bash ./configure $(strip $(shell $(CAT) $<))
146 147

# Create a file with configure options created from old Makefile mechanisms.
O
ohair 已提交
148
$(BUILD_DIR_ROOT)/.bridge2configureOpts: $(BUILD_DIR_ROOT)/.bridge2configureOptsLatest
149 150 151 152
	$(RM) $@
	$(CP) $< $@

# Use this file to only change when obvious things have changed
O
ohair 已提交
153
$(BUILD_DIR_ROOT)/.bridge2configureOptsLatest: FRC
154
	$(RM) $@.tmp
O
ohair 已提交
155
	$(MKDIR) -p $(BUILD_DIR_ROOT)
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
	@$(ECHO) " --with-debug-level=$(if $(DEBUG_LEVEL),$(DEBUG_LEVEL),release) " >> $@.tmp
ifdef ARCH_DATA_MODEL
	@$(ECHO) " --with-target-bits=$(ARCH_DATA_MODEL) " >> $@.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
	@if [ -f $@ ] ; then \
          if ! $(CMP) $@ $@.tmp > /dev/null ; then \
            $(CP) $@.tmp $@ ; \
          fi ; \
        else \
          $(CP) $@.tmp $@ ; \
        fi
	$(RM) $@.tmp

# Clobber all the built files
clobber:: bridge2clobber
bridge2clobber::
O
ohair 已提交
184 185
	$(RM) $(BUILD_DIR_ROOT)/.bridge2*
	$(RM) $(BUILD_DIR_ROOT)/.deploy_input
186 187 188 189

# Keep track of phony targets
PHONY_LIST += bridge2configure bridgeBuild bridge2clobber

O
ohair 已提交
190 191 192 193 194 195 196 197 198
###########################################################################
# Sanity checks (history target)
#

sanity: checks

# Keep track of user targets
USER_TARGETS += sanity

199 200 201 202 203 204 205
###########################################################################
# Javadocs
#

javadocs:
	cd common/makefiles && $(MAKE) -f MakefileJavadoc.gmk

O
ohair 已提交
206 207
# Keep track of user targets
USER_TARGETS += javadocs
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238

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

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

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: $(JPRT_ARCHIVE_BUNDLE)

$(JPRT_ARCHIVE_BUNDLE): bridgeBuild bundles
	$(MKDIR) -p $(@D)
	$(RM) $@
	$(CP) $(BUILD_DIR_ROOT)/$(BUILD_DIRNAME)/bundles/j2sdk-image.zip $@

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

O
ohair 已提交
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
###########################################################################
# Help target

HELP_FORMAT=%12s%s\n

help:
	@$(PRINTF) "# JDK Makefile\n"
	@$(PRINTF) "#\n"
	@$(PRINTF) "# Usage: make [Target]\n"
	@$(PRINTF) "#\n"
	@$(PRINTF) "#   $(HELP_FORMAT)" "Target   " "Description"
	@$(PRINTF) "#   $(HELP_FORMAT)" "------   " "-----------"
	@for i in $(USER_TARGETS) ; do \
	  $(MAKE) help_$${i} ; \
	done
	@$(PRINTF) "#\n"

help_all:
	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
	"Build the entire jdk but not the images"
help_images:
	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
	"Create the jdk images for the builds"
help_deploy:
	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
	"Create the jdk deploy images from the jdk images"
help_install:
	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
	"Create the jdk install bundles from the deploy images"
help_clean:
	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
	"Clean and prepare for a fresh build from scratch"
help_clobber:
	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
	"Clean and also purge any hidden derived data"
help_checks:
	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
	"Perform various checks to make sure we can build"
help_sanity:
	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
	"Same as 'make checks'"
help_javadocs:
	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
	"Build the javadocs"
help_help:
	@$(PRINTF) "#   $(HELP_FORMAT)" "$(subst help_,,$@) - " \
	"Print out the help messages"

# Keep track of user targets
USER_TARGETS += help

290 291
###########################################################################
# Phony targets
O
ohair 已提交
292
.PHONY: $(PHONY_LIST) $(USER_TARGETS)
293 294 295

# Force target
FRC: