1 # 2 # Copyright (c) 1995, 2009, 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 # Common variables used by all the Java makefiles. This file should 28 # not contain rules. 29 # 30 31 # 32 # On Solaris, the 'make' utility from Sun will not work with these makefiles. 33 # This little rule is only understood by Sun's make, and is harmless 34 # when seen by the GNU make tool. If using Sun's make, this causes the 35 # make command to fail. 36 # 37 SUN_MAKE_TEST:sh = echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33 38 39 include $(BUILDDIR)/common/shared/Platform.gmk 40 41 TOPDIR=$(BUILDDIR)/.. 42 43 include $(TOPDIR)/make/common/CancelImplicits.gmk 44 45 # Historically PLATFORM_SRC used to be src/$(PLATFORM), but we switched it to 46 # src/solaris so if you want to build on Linux you didn't need a src/linux 47 # directory. In an ideal world it would be called src/genunix but we are not 48 # there yet. 49 # 50 ifndef SHARE_SRC 51 SHARE_SRC = $(TOPDIR)/src/share 52 endif 53 54 _OUTPUTDIR=$(TOPDIR)/build/$(PLATFORM)-$(ARCH) 55 56 # 57 # Get platform definitions 58 # 59 60 include $(TOPDIR)/make/common/Defs-$(PLATFORM).gmk 61 62 # 63 # Localizations for the different parts of the product beyond English 64 # 65 66 JRE_LOCALES = de es fr it ja ko sv zh_CN zh_TW zh_HK 67 PLUGIN_LOCALES = de es fr it ja ko sv zh_CN zh_TW zh_HK 68 JDK_LOCALES = ja zh_CN 69 70 # 71 # A list of locales we support but don't have resource files. 72 # This is defined to optimize the search of resource bundles. 73 # 74 JRE_NONEXIST_LOCALES = en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh 75 76 LIBDIR = $(OUTPUTDIR)/lib 77 ABS_LIBDIR = $(ABS_OUTPUTDIR)/lib 78 # for ext jre files 79 EXTDIR = $(LIBDIR)/ext 80 # for generated class files 81 CLASSBINDIR = $(OUTPUTDIR)/classes 82 DEMOCLASSDIR = $(OUTPUTDIR)/democlasses 83 # for generated tool class files 84 BUILDTOOLCLASSDIR = $(OUTPUTDIR)/btclasses 85 # for build tool jar files 86 BUILDTOOLJARDIR = $(OUTPUTDIR)/btjars 87 ABS_BUILDTOOLJARDIR = $(ABS_OUTPUTDIR)/btjars 88 # for generated java source files 89 GENSRCDIR = $(OUTPUTDIR)/gensrc 90 # for imported source files 91 IMPORTSRCDIR = $(OUTPUTDIR)/impsrc 92 # for imported documents 93 IMPORTDOCDIR = $(OUTPUTDIR)/impdoc 94 # for generated demo 95 DEMODIR = $(OUTPUTDIR)/demo 96 # for sample code 97 SAMPLEDIR = $(OUTPUTDIR)/sample 98 # for generated documentation 99 DOCSDIR = $(OUTPUTDIR)/docs$(DOCSDIRSUFFIX) 100 DOCSDIRSUFFIX = 101 102 # An attempt is made to generate unique enough directories for the 103 # generated files to not have name collisisons. Most build units 104 # defines PRODUCT (except Release.gmk), but then they may or may 105 # not define PACKAGE, THREADIR (only HPI uses this), PROGRAM, and 106 # LIBRARY. This code chunk attempts to generate a unique 107 # OBJDIR/CLASSHDRDIR for each build unit based on which of those 108 # values are set within each build unit. 109 110 UNIQUE_LOCATION_STRING = tmp 111 112 ifneq ($(PRODUCT),) 113 UNIQUE_LOCATION_STRING += /$(PRODUCT) 114 endif 115 116 ifneq ($(PACKAGE),) 117 UNIQUE_LOCATION_STRING += /$(PACKAGE) 118 endif 119 120 ifneq ($(PROGRAM),) 121 UNIQUE_LOCATION_STRING += /$(PROGRAM) 122 endif 123 124 ifneq ($(LIBRARY),) 125 ifneq ($(LIBRARY_OUTPUT),) 126 UNIQUE_LOCATION_STRING += /$(LIBRARY_OUTPUT) 127 else 128 UNIQUE_LOCATION_STRING += /$(LIBRARY) 129 endif 130 endif 131 132 ifneq ($(THREADDIR),) 133 UNIQUE_LOCATION_STRING += /$(THREADDIR) 134 endif 135 136 # the use of += above makes a space separated list which we need to 137 # remove for filespecs. 138 # 139 NULLSTRING := 140 ONESPACE := $(NULLSTRING) # space before this comment is required. 141 UNIQUE_PATH = $(subst $(ONESPACE),,$(UNIQUE_LOCATION_STRING)) 142 143 # TEMPDIR is a unique general purpose directory 144 # need to use 'override' because GNU Make on Linux exports the wrong 145 # value. 146 override TEMPDIR = $(OUTPUTDIR)/$(UNIQUE_PATH) 147 override ABS_TEMPDIR = $(ABS_OUTPUTDIR)/$(UNIQUE_PATH) 148 149 # This must be created right away for pattern rules in Sanity.gmk to work. 150 dummy1:=$(shell $(MKDIR) -p $(TEMPDIR)) 151 dummy2:=$(shell $(MKDIR) -p $(TEMP_DISK)) 152 153 # 154 # CLASSDESTDIR can be used to specify the directory where generated classes 155 # are to be placed. The default is CLASSBINDIR. 156 # 157 ifndef CLASSDESTDIR 158 CLASSDESTDIR = $(CLASSBINDIR) 159 endif 160 161 # 162 # vpaths. These are the default locations searched for source files. 163 # GNUmakefiles of individual areas often override the default settings. 164 # There are no longer default vpath entries for C and assembler files 165 # so we can ensure that libraries don't get their hands on JVM files. 166 # 167 # We define an intermediate variable for Java files because 168 # we use its value later to help define $SOURCEPATH 169 170 VPATH0.java = $(GENSRCDIR)$(CLASSPATH_SEPARATOR)$(PLATFORM_SRC)/classes$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/classes 171 VPATH.java = $(VPATH0.java) 172 vpath %.java $(VPATH.java) 173 vpath %.class $(CLASSBINDIR) 174 175 # 176 # Classpath seen by javac (different from the one seen by the VM 177 # running javac), and useful variables. 178 # 179 SOURCEPATH = $(VPATH.java) 180 PKG = $(shell $(EXPR) $(PACKAGE) : '\([a-z]*\)') 181 PKGDIR = $(subst .,/,$(PACKAGE)) 182 183 # 184 # The java/javac/jdk variables (JAVAC_CMD, JAVA_CMD, etc.) 185 # 186 include $(BUILDDIR)/common/shared/Defs-java.gmk 187 188 # 189 # Set opt level to ALT_OPT if set otherwise _OPT 190 # 191 POPT = $(_OPT$(ALT_OPT))$(ALT_OPT) 192 193 # 194 # Convenient macros 195 # 196 197 # Prepare $@ target, remove old one and making sure directory exists 198 define prep-target 199 $(MKDIR) -p $(@D) 200 $(RM) $@ 201 endef 202 203 # Simple install of $< file to $@ 204 define install-file 205 $(prep-target) 206 $(CP) $< $@ 207 endef 208 209 # Cleanup rule for after debug java run (hotspot.log file is left around) 210 # (This could be an old leftover file in a read-only area, use the @- prefix) 211 HOTSPOT_LOG_NAME = hotspot.log 212 define java-vm-cleanup 213 if [ -w $(HOTSPOT_LOG_NAME) ] ; then $(RM) $(HOTSPOT_LOG_NAME); fi 214 endef 215 216 # Default make settings for processing SUBDIRS with clobber or clean names 217 SUBDIRS_MAKEFLAGS-clobber = INCREMENTAL_BUILD=false 218 SUBDIRS_MAKEFLAGS-clean = INCREMENTAL_BUILD=false 219 220 # Given a SUBDIRS list, cd into them and make them 221 # SUBDIRS_MAKEFLAGS Make settings for a subdir make 222 # SUBDIRS_MAKEFLAGS-$@ Make settings specific to this target 223 define SUBDIRS-loop 224 @for i in DUMMY $(SUBDIRS) ; do \ 225 if [ "$$i" != "DUMMY" ] ; then \ 226 $(MAKE) -C $${i} $@ \ 227 $(SUBDIRS_MAKEFLAGS) \ 228 $(SUBDIRS_MAKEFLAGS-$@) \ 229 FULL_VERSION=$(FULL_VERSION) \ 230 RELEASE=$(RELEASE) || exit 1; \ 231 fi ; \ 232 done 233 endef 234 235 # Given a OTHERSUBDIRS list, cd into them and make them (extra loop define) 236 # OTHERSUBDIRS_MAKEFLAGS Make settings for a subdir make 237 define OTHERSUBDIRS-loop 238 @for i in DUMMY $(OTHERSUBDIRS) ; do \ 239 if [ "$$i" != "DUMMY" ] ; then \ 240 $(MAKE) -C $${i} $@ \ 241 $(OTHERSUBDIRS_MAKEFLAGS) \ 242 FULL_VERSION=$(FULL_VERSION) \ 243 RELEASE=$(RELEASE) || exit 1; \ 244 fi ; \ 245 done 246 endef 247 248 # Prevent the use of many default suffix rules we do not need 249 .SUFFIXES: 250 .SUFFIXES: .java .class 251 252 # Make sure we are all insane 253 ifdef INSANE 254 export INSANE 255 endif 256 257 # Make sure we have the current year 258 ifndef COPYRIGHT_YEAR 259 ifdef ALT_COPYRIGHT_YEAR 260 COPYRIGHT_YEAR := $(ALT_COPYRIGHT_YEAR) 261 else 262 COPYRIGHT_YEAR := $(shell $(DATE) '+%Y') 263 endif 264 export COPYRIGHT_YEAR 265 endif 266 267 # Install of imported file (JDK_IMPORT_PATH, or some other external location) 268 define install-import-file 269 @$(ECHO) "ASSEMBLY_IMPORT: $@" 270 $(install-file) 271 endef 272 273 .PHONY: all build clean clobber