annotate make/common/Library.gmk @ 3419:006c683ead1a

6975326: Problem in install/make/rebase/Makefile, grep on empty pattern 6413588: Add 'ldd -r' and 'dump -Lv' checks to all .so files delivered in the JDK 7000995: Add check in makefiles to verify that msvcp100.dll is NOT used Reviewed-by: mduigou
author ohair
date Wed, 05 Jan 2011 14:28:58 -0800
parents a06412e13bf7
children f08682e23279
rev   line source
duke@0 1 #
ohair@3261 2 # Copyright (c) 1995, 2010, Oracle and/or its affiliates. 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
ohair@2362 7 # published by the Free Software Foundation. Oracle designates this
duke@0 8 # particular file as subject to the "Classpath" exception as provided
ohair@2362 9 # by Oracle 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 #
ohair@2362 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@2362 22 # or visit www.oracle.com if you need additional information or have any
ohair@2362 23 # 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 $(ACTUAL_LIBRARY):: $(INIT) $(TEMPDIR) $(LIBDIR) $(BINDIR) $(EXTDIR) classheaders
duke@0 81
duke@0 82 #
duke@0 83 # COMPILE_APPROACH: Different approaches to compile up the native object
duke@0 84 # files as quickly as possible.
duke@0 85 # The setting of parallel works best on Unix, batch on Windows.
duke@0 86 #
duke@0 87
duke@0 88 COMPILE_FILES_o = $(OBJDIR)/.files_compiled
duke@0 89 $(COMPILE_FILES_o): $(FILES_d) $(FILES_o)
duke@0 90 @$(ECHO) "$<" >> $@
duke@0 91 clean::
duke@0 92 $(RM) $(COMPILE_FILES_o)
duke@0 93
duke@0 94 #
duke@0 95 # COMPILE_APPROACH=parallel: Will trigger compilations (just compilations) to
duke@0 96 # happen in parallel. Greatly decreases Unix build time, even on single CPU
duke@0 97 # machines, more so on multiple CPU machines. Default is 2 compiles
duke@0 98 # at a time, but can be adjusted with ALT_PARALLEL_COMPILE_JOBS.
duke@0 99 # Note that each .d file will also be dependent on it's .o file, see
duke@0 100 # Rules.gmk.
duke@0 101 # Note this does not depend on Rules.gmk to work like batch (below)
duke@0 102 # and this technique doesn't seem to help Windows build time nor does
duke@0 103 # it work very well, it's possible the Windows Visual Studio compilers
duke@0 104 # don't work well in a parallel situation, this needs investigation.
duke@0 105 #
duke@0 106
duke@0 107 ifeq ($(COMPILE_APPROACH),parallel)
duke@0 108
duke@0 109 .PHONY: library_parallel_compile
duke@0 110
duke@0 111 library_parallel_compile:
duke@0 112 @$(ECHO) "Begin parallel compiles: $(shell $(PWD))"
duke@0 113 @$(MAKE) -j $(PARALLEL_COMPILE_JOBS) $(COMPILE_FILES_o)
duke@0 114 @$(ECHO) "Done with parallel compiles: $(shell $(PWD))"
duke@0 115
duke@0 116 $(ACTUAL_LIBRARY):: library_parallel_compile
duke@0 117
duke@0 118 endif
duke@0 119
duke@0 120 #
duke@0 121 # COMPILE_APPROACH=batch: Will trigger compilations (just compilations) to
duke@0 122 # happen in batch mode. Greatly decreases Windows build time.
duke@0 123 # See logic in Rules.gmk for how compiles happen, the $(MAKE) in
duke@0 124 # library_batch_compile below triggers the actions in Rules.gmk.
duke@0 125 # Note that each .d file will also be dependent on it's .o file, see
duke@0 126 # Rules.gmk.
duke@0 127 #
duke@0 128 ifeq ($(COMPILE_APPROACH),batch)
duke@0 129
duke@0 130 .PHONY: library_batch_compile
duke@0 131
duke@0 132 library_batch_compile:
duke@0 133 @$(ECHO) "Begin BATCH compiles: $(shell $(PWD))"
duke@0 134 $(MAKE) $(COMPILE_FILES_o)
duke@0 135 $(MAKE) batch_compile
duke@0 136 @$(ECHO) "Done with BATCH compiles: $(shell $(PWD))"
duke@0 137 $(MAKE) COMPILE_APPROACH=normal $(COMPILE_FILES_o)
duke@0 138
duke@0 139 $(ACTUAL_LIBRARY):: library_batch_compile
duke@0 140
duke@0 141 endif
duke@0 142
duke@0 143 ifeq ($(PLATFORM), windows)
duke@0 144
duke@0 145 #
duke@0 146 # Library building rules.
duke@0 147 #
duke@0 148
duke@0 149 $(LIBRARY).lib:: $(OBJDIR)
duke@0 150
duke@0 151 ifeq ($(LIBRARY), fdlibm)
duke@0 152 $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lib
duke@0 153
duke@0 154 $(OBJDIR)/$(LIBRARY).lib:: $(OBJDIR)/$(LIBRARY).lcf
duke@0 155 @$(prep-target)
duke@0 156 $(LIBEXE) -NODEFAULTLIB:MSVCRT -out:$@ -nologo \
duke@0 157 @$(OBJDIR)/$(LIBRARY).lcf $(OTHER_LCF) $(LDLIBS_COMMON)
duke@0 158 else # LIBRARY
duke@0 159 # build it into $(OBJDIR) so that the other generated files get put
duke@0 160 # there, then copy just the DLL (and MAP file) to the requested directory.
duke@0 161 #
tbell@795 162 # In VS2005 or VS2008 the link command creates a .manifest file that we want
tbell@795 163 # to insert into the linked artifact so we do not need to track it separately.
tbell@795 164 # Use ";#2" for .dll and ";#1" for .exe in the MT command below:
duke@0 165 $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf
duke@0 166 @$(prep-target)
duke@0 167 @$(MKDIR) -p $(OBJDIR)
duke@0 168 $(LINK) -dll -out:$(OBJDIR)/$(@F) \
duke@0 169 -map:$(OBJDIR)/$(LIBRARY).map \
duke@0 170 $(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \
duke@0 171 $(OTHER_LCF) $(JAVALIB) $(LDLIBS)
tbell@795 172 ifdef MT
tbell@795 173 $(MT) /manifest $(OBJDIR)/$(@F).manifest /outputresource:$(OBJDIR)/$(@F);#2
tbell@795 174 endif
duke@0 175 $(CP) $(OBJDIR)/$(@F) $@
ohair@3419 176 @$(call binary_file_verification,$@)
mchung@2080 177 $(install-module-file)
duke@0 178 $(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
duke@0 179 $(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
duke@0 180
mchung@2080 181 $(ACTUAL_LIBRARY):: $(ACTUAL_LIBRARY_DIR)/$(LIBRARY).map $(ACTUAL_LIBRARY_DIR)/$(LIBRARY).pdb
mchung@2080 182
mchung@2080 183 $(ACTUAL_LIBRARY_DIR)/%.map: FORCE
mchung@2080 184 $(install-module-file)
mchung@2080 185
mchung@2080 186 $(ACTUAL_LIBRARY_DIR)/%.pdb: FORCE
mchung@2080 187 $(install-module-file)
mchung@2080 188
duke@0 189 endif # LIBRARY
duke@0 190
duke@0 191 $(OBJDIR)/$(LIBRARY).lcf: $(OBJDIR)/$(LIBRARY).res $(COMPILE_FILES_o) $(FILES_m)
duke@0 192 @$(prep-target)
duke@0 193 @$(MKDIR) -p $(TEMPDIR)
duke@0 194 @$(ECHO) $(FILES_o) > $@
duke@0 195 ifndef LOCAL_RESOURCE_FILE
duke@0 196 @$(ECHO) $(OBJDIR)/$(LIBRARY).res >> $@
duke@0 197 endif
duke@0 198 @$(ECHO) Created $@
duke@0 199
herrick@1365 200 # JDK name required here
herrick@1365 201 RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
herrick@1365 202 /D "JDK_INTERNAL_NAME=$(LIBRARY)" \
herrick@1365 203 /D "JDK_FTYPE=0x2L"
duke@0 204
duke@0 205 $(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE)
duke@0 206 ifndef LOCAL_RESOURCE_FILE
duke@0 207 @$(prep-target)
duke@0 208 $(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE)
duke@0 209 endif
duke@0 210
duke@0 211 #
duke@0 212 # Install a .lib file if required.
duke@0 213 #
duke@0 214 ifeq ($(INSTALL_DOT_LIB), true)
duke@0 215 $(ACTUAL_LIBRARY):: $(LIBDIR)/$(LIBRARY).lib
duke@0 216
duke@0 217 clean::
duke@0 218 -$(RM) $(LIBDIR)/$(LIBRARY).lib
duke@0 219
duke@0 220 $(LIBDIR)/$(LIBRARY).lib:: $(OBJDIR)/$(LIBRARY).lib
duke@0 221 $(install-file)
duke@0 222
duke@0 223 $(LIBDIR)/$(LIBRARY).dll:: $(OBJDIR)/$(LIBRARY).dll
duke@0 224 $(install-file)
duke@0 225
duke@0 226 endif # INSTALL_DOT_LIB
duke@0 227
duke@0 228 else # PLATFORM
duke@0 229
duke@0 230 #
duke@0 231 # On Solaris, use mcs to write the version into the comment section of
duke@0 232 # the shared library. On other platforms set this to false at the
duke@0 233 # make command line.
duke@0 234 #
duke@0 235 $(ACTUAL_LIBRARY):: $(COMPILE_FILES_o) $(FILES_m) $(FILES_reorder)
duke@0 236 @$(prep-target)
ohair@460 237 @$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), OPTIMIZATION_LEVEL=$(OPTIMIZATION_LEVEL)"
duke@0 238 @$(ECHO) "Rebuilding $@ because of $?"
duke@0 239 ifeq ($(LIBRARY), fdlibm)
duke@0 240 $(AR) -r $@ $(FILES_o)
duke@0 241 else # LIBRARY
duke@0 242 $(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
ohair@3419 243 @$(call binary_file_verification,$@)
mchung@2080 244 $(install-module-file)
duke@0 245 ifeq ($(WRITE_LIBVERSION),true)
duke@0 246 $(MCS) -d -a "$(FULL_VERSION)" $@
duke@0 247 endif # WRITE_LIBVERSION
duke@0 248 endif # LIBRARY
duke@0 249
duke@0 250 endif # PLATFORM
duke@0 251
duke@0 252 #
duke@0 253 # Cross check all linted files against each other
duke@0 254 #
duke@0 255 ifeq ($(PLATFORM),solaris)
duke@0 256 lint.errors : $(FILES_ln)
duke@0 257 $(LINT.c) $(FILES_ln) $(LDLIBS)
duke@0 258 endif
duke@0 259
duke@0 260 #
duke@0 261 # Class libraries with JNI native methods get a include to the package.
duke@0 262 #
duke@0 263 ifdef PACKAGE
duke@0 264 vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)
duke@0 265 vpath %.c $(SHARE_SRC)/native/$(PKGDIR)
duke@0 266 OTHER_INCLUDES += -I$(SHARE_SRC)/native/common -I$(PLATFORM_SRC)/native/common
duke@0 267 OTHER_INCLUDES += -I$(SHARE_SRC)/native/$(PKGDIR) \
duke@0 268 -I$(PLATFORM_SRC)/native/$(PKGDIR)
duke@0 269 endif
duke@0 270
duke@0 271 #
duke@0 272 # Clean/clobber rules
duke@0 273 #
duke@0 274 clean::
duke@0 275 $(RM) -r $(ACTUAL_LIBRARY)
duke@0 276
duke@0 277 clobber:: clean
duke@0 278
duke@0 279 #
duke@0 280 # INCREMENTAL_BUILD means that this workspace will be built over and over
duke@0 281 # possibly incrementally. This means tracking the object file dependencies
duke@0 282 # on include files so that sources get re-compiled when the include files
duke@0 283 # change. When building from scratch and doing a one time build (like
duke@0 284 # release engineering or nightly builds) set INCREMENTAL_BUILD=false.
duke@0 285 #
duke@0 286
duke@0 287 ifeq ($(INCREMENTAL_BUILD),true)
duke@0 288
duke@0 289 #
duke@0 290 # Workaround: gnumake sometimes says files is empty when it shouldn't
duke@0 291 # was: files := $(foreach file, $(wildcard $(OBJDIR)/*.$(DEPEND_SUFFIX)), $(file))
duke@0 292 #
duke@0 293 files := $(shell $(LS) $(OBJDIR)/*.$(DEPEND_SUFFIX) 2>/dev/null)
duke@0 294
duke@0 295 #
duke@0 296 # Only include these files if we have any.
duke@0 297 #
duke@0 298 ifneq ($(strip $(files)),)
duke@0 299
duke@0 300 include $(files)
duke@0 301
duke@0 302 endif # files
duke@0 303
duke@0 304 endif # INCREMENTAL_BUILD
duke@0 305
duke@0 306 #
duke@0 307 # Default dependencies
duke@0 308 #
duke@0 309
duke@0 310 all: build
duke@0 311
duke@0 312 build: library
duke@0 313
duke@0 314 debug:
duke@0 315 $(MAKE) VARIANT=DBG build
duke@0 316
duke@0 317 fastdebug:
duke@0 318 $(MAKE) VARIANT=DBG FASTDEBUG=true build
duke@0 319
duke@0 320 openjdk:
duke@0 321 $(MAKE) OPENJDK=true build
duke@0 322
mchung@2080 323 FORCE:
mchung@2080 324
duke@0 325 .PHONY: all build debug fastdebug
duke@0 326