annotate make/common/Library.gmk @ 795:6dce6ac0929e

6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll 6779412: VS2008 errors compiling jdk sources Summary: Update Makefiles to tolerate newer Visual Studio releases and runtimes. Reviewed-by: ohair
author tbell
date Wed, 14 Jan 2009 21:35:03 -0800
parents 14f50aee4989
children 9053bcc8eef0
rev   line source
duke@0 1 #
xdono@594 2 # Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 #
duke@0 5 # This code is free software; you can redistribute it and/or modify it
duke@0 6 # under the terms of the GNU General Public License version 2 only, as
duke@0 7 # published by the Free Software Foundation. Sun designates this
duke@0 8 # particular file as subject to the "Classpath" exception as provided
duke@0 9 # by Sun in the LICENSE file that accompanied this code.
duke@0 10 #
duke@0 11 # This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 14 # version 2 for more details (a copy is included in the LICENSE file that
duke@0 15 # accompanied this code).
duke@0 16 #
duke@0 17 # You should have received a copy of the GNU General Public License version
duke@0 18 # 2 along with this work; if not, write to the Free Software Foundation,
duke@0 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 20 #
duke@0 21 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 22 # CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 23 # have any questions.
duke@0 24 #
duke@0 25
duke@0 26 #
duke@0 27 # Generic makefile for building shared libraries.
duke@0 28 #
duke@0 29
duke@0 30 # WARNING: This file is shared with other workspaces.
duke@0 31 # So when it includes other files, it must use JDK_TOPDIR.
duke@0 32 #
duke@0 33
duke@0 34 include $(JDK_TOPDIR)/make/common/Classes.gmk
duke@0 35
duke@0 36 #
duke@0 37 # It is important to define these *after* including Classes.gmk
duke@0 38 # in order to override the values defined inthat makefile.
duke@0 39 #
duke@0 40
duke@0 41 ifeq ($(LIBRARY), fdlibm)
duke@0 42 ifeq ($(PLATFORM),windows)
duke@0 43 ACTUAL_LIBRARY_NAME = $(LIB_PREFIX)$(LIBRARY).$(FDDLIBM_SUFFIX)
duke@0 44 ACTUAL_LIBRARY_DIR = $(OBJDIR)
duke@0 45 else # PLATFORM
duke@0 46 ACTUAL_LIBRARY_NAME = $(LIB_PREFIX)$(LIBRARY).$(ARCH).$(FDDLIBM_SUFFIX)
duke@0 47 ACTUAL_LIBRARY_DIR = $(OBJDIR)
duke@0 48 endif #PLATFORM
duke@0 49 else # LIBRARY
duke@0 50 ACTUAL_LIBRARY_NAME = $(LIB_PREFIX)$(LIBRARY).$(LIBRARY_SUFFIX)
duke@0 51 ACTUAL_LIBRARY_DIR = $(LIB_LOCATION)
duke@0 52 endif
duke@0 53 ACTUAL_LIBRARY = $(ACTUAL_LIBRARY_DIR)/$(ACTUAL_LIBRARY_NAME)
duke@0 54
duke@0 55 library:: $(ACTUAL_LIBRARY)
duke@0 56
duke@0 57 FILES_o = $(patsubst %.c, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c))))
duke@0 58 FILES_o += $(patsubst %.s, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_s))))
duke@0 59 FILES_o += $(patsubst %.cpp, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_cpp))))
duke@0 60
duke@0 61 ifeq ($(INCREMENTAL_BUILD),true)
duke@0 62 FILES_d = $(patsubst %.c, %.$(DEPEND_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c))))
duke@0 63 FILES_d += $(patsubst %.cpp, %.$(DEPEND_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_cpp))))
duke@0 64 endif # INCREMENTAL_BUILD
duke@0 65
duke@0 66 ifeq ($(PLATFORM),solaris)
duke@0 67 # List of all lint files, one for each .c file (only for C)
duke@0 68 FILES_ln = $(patsubst %.c, %.$(LINT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c))))
duke@0 69 endif
duke@0 70
duke@0 71 #
duke@0 72 # C++ libraries must be linked with CC.
duke@0 73 #
duke@0 74 ifdef CPLUSPLUSLIBRARY
duke@0 75 LINKER=$(LINK.cc)
duke@0 76 else
duke@0 77 LINKER=$(LINK.c)
duke@0 78 endif
duke@0 79
duke@0 80 # FIXUP: unpack needs the zip .o files. So we must build zip?
duke@0 81 # or fix unpack makefile so it uses Program.gmk.
duke@0 82 ifneq ($(IMPORT_NATIVE_BINARIES),true)
duke@0 83 COMPILE_IT=true
duke@0 84 else
duke@0 85 ifeq ($(LIBRARY),zip)
duke@0 86 COMPILE_IT=true
duke@0 87 else
duke@0 88 COMPILE_IT=false
duke@0 89 endif
duke@0 90 endif
duke@0 91
duke@0 92 # If a Makefile has specified a pre-compiled closed src lib, just copy it.
duke@0 93 ifdef USE_BINARY_PLUG_LIBRARY
duke@0 94 COMPILE_IT=false
duke@0 95 endif
duke@0 96
duke@0 97 # We either need to import (copy) libraries in, or build them
duke@0 98 ifeq ($(COMPILE_IT),true)
duke@0 99
duke@0 100 $(ACTUAL_LIBRARY):: $(INIT) $(TEMPDIR) $(LIBDIR) $(BINDIR) $(EXTDIR) classheaders
duke@0 101
duke@0 102 #
duke@0 103 # COMPILE_APPROACH: Different approaches to compile up the native object
duke@0 104 # files as quickly as possible.
duke@0 105 # The setting of parallel works best on Unix, batch on Windows.
duke@0 106 #
duke@0 107
duke@0 108 COMPILE_FILES_o = $(OBJDIR)/.files_compiled
duke@0 109 $(COMPILE_FILES_o): $(FILES_d) $(FILES_o)
duke@0 110 @$(ECHO) "$<" >> $@
duke@0 111 clean::
duke@0 112 $(RM) $(COMPILE_FILES_o)
duke@0 113
duke@0 114 #
duke@0 115 # COMPILE_APPROACH=parallel: Will trigger compilations (just compilations) to
duke@0 116 # happen in parallel. Greatly decreases Unix build time, even on single CPU
duke@0 117 # machines, more so on multiple CPU machines. Default is 2 compiles
duke@0 118 # at a time, but can be adjusted with ALT_PARALLEL_COMPILE_JOBS.
duke@0 119 # Note that each .d file will also be dependent on it's .o file, see
duke@0 120 # Rules.gmk.
duke@0 121 # Note this does not depend on Rules.gmk to work like batch (below)
duke@0 122 # and this technique doesn't seem to help Windows build time nor does
duke@0 123 # it work very well, it's possible the Windows Visual Studio compilers
duke@0 124 # don't work well in a parallel situation, this needs investigation.
duke@0 125 #
duke@0 126
duke@0 127 ifeq ($(COMPILE_APPROACH),parallel)
duke@0 128
duke@0 129 .PHONY: library_parallel_compile
duke@0 130
duke@0 131 library_parallel_compile:
duke@0 132 @$(ECHO) "Begin parallel compiles: $(shell $(PWD))"
duke@0 133 @$(MAKE) -j $(PARALLEL_COMPILE_JOBS) $(COMPILE_FILES_o)
duke@0 134 @$(ECHO) "Done with parallel compiles: $(shell $(PWD))"
duke@0 135
duke@0 136 $(ACTUAL_LIBRARY):: library_parallel_compile
duke@0 137
duke@0 138 endif
duke@0 139
duke@0 140 #
duke@0 141 # COMPILE_APPROACH=batch: Will trigger compilations (just compilations) to
duke@0 142 # happen in batch mode. Greatly decreases Windows build time.
duke@0 143 # See logic in Rules.gmk for how compiles happen, the $(MAKE) in
duke@0 144 # library_batch_compile below triggers the actions in Rules.gmk.
duke@0 145 # Note that each .d file will also be dependent on it's .o file, see
duke@0 146 # Rules.gmk.
duke@0 147 #
duke@0 148 ifeq ($(COMPILE_APPROACH),batch)
duke@0 149
duke@0 150 .PHONY: library_batch_compile
duke@0 151
duke@0 152 library_batch_compile:
duke@0 153 @$(ECHO) "Begin BATCH compiles: $(shell $(PWD))"
duke@0 154 $(MAKE) $(COMPILE_FILES_o)
duke@0 155 $(MAKE) batch_compile
duke@0 156 @$(ECHO) "Done with BATCH compiles: $(shell $(PWD))"
duke@0 157 $(MAKE) COMPILE_APPROACH=normal $(COMPILE_FILES_o)
duke@0 158
duke@0 159 $(ACTUAL_LIBRARY):: library_batch_compile
duke@0 160
duke@0 161 endif
duke@0 162
duke@0 163 ifeq ($(PLATFORM), windows)
duke@0 164
duke@0 165 #
duke@0 166 # Library building rules.
duke@0 167 #
duke@0 168
duke@0 169 $(LIBRARY).lib:: $(OBJDIR)
duke@0 170
duke@0 171 ifeq ($(LIBRARY), fdlibm)
duke@0 172 $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lib
duke@0 173
duke@0 174 $(OBJDIR)/$(LIBRARY).lib:: $(OBJDIR)/$(LIBRARY).lcf
duke@0 175 @$(prep-target)
duke@0 176 $(LIBEXE) -NODEFAULTLIB:MSVCRT -out:$@ -nologo \
duke@0 177 @$(OBJDIR)/$(LIBRARY).lcf $(OTHER_LCF) $(LDLIBS_COMMON)
duke@0 178 else # LIBRARY
duke@0 179 # build it into $(OBJDIR) so that the other generated files get put
duke@0 180 # there, then copy just the DLL (and MAP file) to the requested directory.
duke@0 181 #
tbell@795 182 # In VS2005 or VS2008 the link command creates a .manifest file that we want
tbell@795 183 # to insert into the linked artifact so we do not need to track it separately.
tbell@795 184 # Use ";#2" for .dll and ";#1" for .exe in the MT command below:
duke@0 185 $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf
duke@0 186 @$(prep-target)
duke@0 187 @$(MKDIR) -p $(OBJDIR)
duke@0 188 $(LINK) -dll -out:$(OBJDIR)/$(@F) \
duke@0 189 -map:$(OBJDIR)/$(LIBRARY).map \
duke@0 190 $(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \
duke@0 191 $(OTHER_LCF) $(JAVALIB) $(LDLIBS)
tbell@795 192 ifdef MT
tbell@795 193 $(MT) /manifest $(OBJDIR)/$(@F).manifest /outputresource:$(OBJDIR)/$(@F);#2
tbell@795 194 endif
duke@0 195 $(CP) $(OBJDIR)/$(@F) $@
duke@0 196 $(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
duke@0 197 $(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
duke@0 198
duke@0 199 endif # LIBRARY
duke@0 200
duke@0 201 $(OBJDIR)/$(LIBRARY).lcf: $(OBJDIR)/$(LIBRARY).res $(COMPILE_FILES_o) $(FILES_m)
duke@0 202 @$(prep-target)
duke@0 203 @$(MKDIR) -p $(TEMPDIR)
duke@0 204 @$(ECHO) $(FILES_o) > $@
duke@0 205 ifndef LOCAL_RESOURCE_FILE
duke@0 206 @$(ECHO) $(OBJDIR)/$(LIBRARY).res >> $@
duke@0 207 endif
duke@0 208 @$(ECHO) Created $@
duke@0 209
duke@0 210 # J2SE name required here
duke@0 211 RC_FLAGS += /D "J2SE_FNAME=$(LIBRARY).dll" \
duke@0 212 /D "J2SE_INTERNAL_NAME=$(LIBRARY)" \
duke@0 213 /D "J2SE_FTYPE=0x2L"
duke@0 214
duke@0 215 $(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE)
duke@0 216 ifndef LOCAL_RESOURCE_FILE
duke@0 217 @$(prep-target)
duke@0 218 $(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE)
duke@0 219 endif
duke@0 220
duke@0 221 #
duke@0 222 # Install a .lib file if required.
duke@0 223 #
duke@0 224 ifeq ($(INSTALL_DOT_LIB), true)
duke@0 225 $(ACTUAL_LIBRARY):: $(LIBDIR)/$(LIBRARY).lib
duke@0 226
duke@0 227 clean::
duke@0 228 -$(RM) $(LIBDIR)/$(LIBRARY).lib
duke@0 229
duke@0 230 $(LIBDIR)/$(LIBRARY).lib:: $(OBJDIR)/$(LIBRARY).lib
duke@0 231 $(install-file)
duke@0 232
duke@0 233 $(LIBDIR)/$(LIBRARY).dll:: $(OBJDIR)/$(LIBRARY).dll
duke@0 234 $(install-file)
duke@0 235
duke@0 236 endif # INSTALL_DOT_LIB
duke@0 237
duke@0 238 else # PLATFORM
duke@0 239
duke@0 240 #
duke@0 241 # On Solaris, use mcs to write the version into the comment section of
duke@0 242 # the shared library. On other platforms set this to false at the
duke@0 243 # make command line.
duke@0 244 #
duke@0 245 $(ACTUAL_LIBRARY):: $(COMPILE_FILES_o) $(FILES_m) $(FILES_reorder)
duke@0 246 @$(prep-target)
ohair@460 247 @$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), OPTIMIZATION_LEVEL=$(OPTIMIZATION_LEVEL)"
duke@0 248 @$(ECHO) "Rebuilding $@ because of $?"
duke@0 249 ifeq ($(LIBRARY), fdlibm)
duke@0 250 $(AR) -r $@ $(FILES_o)
duke@0 251 else # LIBRARY
duke@0 252 $(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
duke@0 253 ifeq ($(WRITE_LIBVERSION),true)
duke@0 254 $(MCS) -d -a "$(FULL_VERSION)" $@
duke@0 255 endif # WRITE_LIBVERSION
duke@0 256 endif # LIBRARY
duke@0 257
duke@0 258 endif # PLATFORM
duke@0 259
duke@0 260 #
duke@0 261 # Cross check all linted files against each other
duke@0 262 #
duke@0 263 ifeq ($(PLATFORM),solaris)
duke@0 264 lint.errors : $(FILES_ln)
duke@0 265 $(LINT.c) $(FILES_ln) $(LDLIBS)
duke@0 266 endif
duke@0 267
duke@0 268 else # COMPILE_IT
duke@0 269
duke@0 270 # OpenJDK rule is first so any lib is preferentially copied from that location.
duke@0 271 ifndef USE_BINARY_PLUG_LIBRARY
duke@0 272
duke@0 273 # In this case we are just copying the file.
duke@0 274 ifneq ($(LIBRARY), fdlibm)
duke@0 275 # Copies in the file from the JDK_IMPORT_PATH area
duke@0 276 $(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/%
duke@0 277 $(install-import-file)
duke@0 278 $(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/native_threads/%
duke@0 279 $(install-import-file)
duke@0 280 $(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/headless/%
duke@0 281 $(install-import-file)
duke@0 282 $(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/xawt/%
duke@0 283 $(install-import-file)
duke@0 284 else # fdlibm
duke@0 285 $(ACTUAL_LIBRARY_DIR)/%:
duke@0 286 $(prep-target)
duke@0 287 endif # fdlibm
duke@0 288
duke@0 289 endif # USE_BINARY_PLUG_LIBRARY
duke@0 290
duke@0 291 endif # COMPILE_IT
duke@0 292
duke@0 293 #
duke@0 294 # Class libraries with JNI native methods get a include to the package.
duke@0 295 #
duke@0 296 ifdef PACKAGE
duke@0 297 vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)
duke@0 298 vpath %.c $(SHARE_SRC)/native/$(PKGDIR)
duke@0 299 OTHER_INCLUDES += -I$(SHARE_SRC)/native/common -I$(PLATFORM_SRC)/native/common
duke@0 300 OTHER_INCLUDES += -I$(SHARE_SRC)/native/$(PKGDIR) \
duke@0 301 -I$(PLATFORM_SRC)/native/$(PKGDIR)
duke@0 302 endif
duke@0 303
duke@0 304 #
duke@0 305 # Clean/clobber rules
duke@0 306 #
duke@0 307 clean::
duke@0 308 $(RM) -r $(ACTUAL_LIBRARY)
duke@0 309
duke@0 310 clobber:: clean
duke@0 311
duke@0 312 #
duke@0 313 # INCREMENTAL_BUILD means that this workspace will be built over and over
duke@0 314 # possibly incrementally. This means tracking the object file dependencies
duke@0 315 # on include files so that sources get re-compiled when the include files
duke@0 316 # change. When building from scratch and doing a one time build (like
duke@0 317 # release engineering or nightly builds) set INCREMENTAL_BUILD=false.
duke@0 318 #
duke@0 319
duke@0 320 ifeq ($(INCREMENTAL_BUILD),true)
duke@0 321
duke@0 322 #
duke@0 323 # Workaround: gnumake sometimes says files is empty when it shouldn't
duke@0 324 # was: files := $(foreach file, $(wildcard $(OBJDIR)/*.$(DEPEND_SUFFIX)), $(file))
duke@0 325 #
duke@0 326 files := $(shell $(LS) $(OBJDIR)/*.$(DEPEND_SUFFIX) 2>/dev/null)
duke@0 327
duke@0 328 #
duke@0 329 # Only include these files if we have any.
duke@0 330 #
duke@0 331 ifneq ($(strip $(files)),)
duke@0 332
duke@0 333 include $(files)
duke@0 334
duke@0 335 endif # files
duke@0 336
duke@0 337 endif # INCREMENTAL_BUILD
duke@0 338
duke@0 339 #
duke@0 340 # Default dependencies
duke@0 341 #
duke@0 342
duke@0 343 all: build
duke@0 344
duke@0 345 build: library
duke@0 346
duke@0 347 debug:
duke@0 348 $(MAKE) VARIANT=DBG build
duke@0 349
duke@0 350 fastdebug:
duke@0 351 $(MAKE) VARIANT=DBG FASTDEBUG=true build
duke@0 352
duke@0 353 openjdk:
duke@0 354 $(MAKE) OPENJDK=true build
duke@0 355
duke@0 356 .PHONY: all build debug fastdebug
duke@0 357