make/common/Library.gmk

changeset 196
0a91416c1402
parent 189
3821536d79ab
parent 195
d6297db2b9dd
child 197
ae60f98d2f42
     1.1 --- a/make/common/Library.gmk	Tue Sep 07 15:16:24 2010 -0700
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,275 +0,0 @@
     1.4 -#
     1.5 -# Copyright (c) 1995, 2009, Oracle and/or its affiliates. All rights reserved.
     1.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 -#
     1.8 -# This code is free software; you can redistribute it and/or modify it
     1.9 -# under the terms of the GNU General Public License version 2 only, as
    1.10 -# published by the Free Software Foundation.  Oracle designates this
    1.11 -# particular file as subject to the "Classpath" exception as provided
    1.12 -# by Oracle in the LICENSE file that accompanied this code.
    1.13 -#
    1.14 -# This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 -# version 2 for more details (a copy is included in the LICENSE file that
    1.18 -# accompanied this code).
    1.19 -#
    1.20 -# You should have received a copy of the GNU General Public License version
    1.21 -# 2 along with this work; if not, write to the Free Software Foundation,
    1.22 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 -#
    1.24 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 -# or visit www.oracle.com if you need additional information or have any
    1.26 -# questions.
    1.27 -#
    1.28 -
    1.29 -#
    1.30 -# Generic makefile for building shared libraries.
    1.31 -#
    1.32 -
    1.33 -include $(TOPDIR)/make/common/Classes.gmk
    1.34 -
    1.35 -#
    1.36 -# It is important to define these *after* including Classes.gmk
    1.37 -# in order to override the values defined inthat makefile.
    1.38 -#
    1.39 -
    1.40 -ACTUAL_LIBRARY_NAME = $(LIB_PREFIX)$(LIBRARY).$(LIBRARY_SUFFIX)
    1.41 -ACTUAL_LIBRARY_DIR = $(LIB_LOCATION)
    1.42 -ACTUAL_LIBRARY = $(ACTUAL_LIBRARY_DIR)/$(ACTUAL_LIBRARY_NAME)
    1.43 -
    1.44 -library:: $(ACTUAL_LIBRARY)
    1.45 -
    1.46 -FILES_o   = $(patsubst %.c,   %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c))))
    1.47 -FILES_o  += $(patsubst %.s,   %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_s))))
    1.48 -FILES_o  += $(patsubst %.cpp, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_cpp))))
    1.49 -
    1.50 -ifeq ($(INCREMENTAL_BUILD),true)
    1.51 -FILES_d   = $(patsubst %.c,   %.$(DEPEND_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c))))
    1.52 -FILES_d  += $(patsubst %.cpp, %.$(DEPEND_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_cpp))))
    1.53 -endif # INCREMENTAL_BUILD
    1.54 -
    1.55 -ifeq ($(PLATFORM),solaris)
    1.56 -# List of all lint files, one for each .c file (only for C)
    1.57 -FILES_ln   = $(patsubst %.c,   %.$(LINT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c))))
    1.58 -endif
    1.59 -
    1.60 -#
    1.61 -# C++ libraries must be linked with CC.
    1.62 -#
    1.63 -ifdef CPLUSPLUSLIBRARY
    1.64 -LINKER=$(LINK.cc)
    1.65 -else
    1.66 -LINKER=$(LINK.c)
    1.67 -endif
    1.68 -
    1.69 -# We either need to import (copy) libraries in, or build them
    1.70 -$(ACTUAL_LIBRARY):: $(INIT) $(TEMPDIR) $(LIBDIR) $(BINDIR) $(EXTDIR) classheaders
    1.71 -
    1.72 -#
    1.73 -# COMPILE_APPROACH: Different approaches to compile up the native object
    1.74 -#   files as quickly as possible.
    1.75 -#   The setting of parallel works best on Unix, batch on Windows.
    1.76 -#
    1.77 -
    1.78 -COMPILE_FILES_o = $(OBJDIR)/.files_compiled
    1.79 -$(COMPILE_FILES_o): $(FILES_d) $(FILES_o)
    1.80 -	@$(ECHO) "$<" >> $@
    1.81 -clean::
    1.82 -	$(RM) $(COMPILE_FILES_o)
    1.83 -
    1.84 -#
    1.85 -# COMPILE_APPROACH=parallel: Will trigger compilations (just compilations) to
    1.86 -#   happen in parallel. Greatly decreases Unix build time, even on single CPU
    1.87 -#   machines, more so on multiple CPU machines. Default is 2 compiles
    1.88 -#   at a time, but can be adjusted with ALT_PARALLEL_COMPILE_JOBS.
    1.89 -#   Note that each .d file will also be dependent on it's .o file, see
    1.90 -#   Rules.gmk.
    1.91 -#   Note this does not depend on Rules.gmk to work like batch (below)
    1.92 -#   and this technique doesn't seem to help Windows build time nor does
    1.93 -#   it work very well, it's possible the Windows Visual Studio compilers
    1.94 -#   don't work well in a parallel situation, this needs investigation.
    1.95 -#
    1.96 -
    1.97 -ifeq ($(COMPILE_APPROACH),parallel)
    1.98 -
    1.99 -.PHONY: library_parallel_compile
   1.100 -
   1.101 -library_parallel_compile:
   1.102 -	@$(ECHO) "Begin parallel compiles: $(shell $(PWD))"
   1.103 -	@$(MAKE) -j $(PARALLEL_COMPILE_JOBS) $(COMPILE_FILES_o)
   1.104 -	@$(ECHO) "Done with parallel compiles: $(shell $(PWD))"
   1.105 -
   1.106 -$(ACTUAL_LIBRARY):: library_parallel_compile
   1.107 -
   1.108 -endif
   1.109 -
   1.110 -#
   1.111 -# COMPILE_APPROACH=batch: Will trigger compilations (just compilations) to
   1.112 -#   happen in batch mode. Greatly decreases Windows build time.
   1.113 -#   See logic in Rules.gmk for how compiles happen, the $(MAKE) in
   1.114 -#   library_batch_compile below triggers the actions in Rules.gmk.
   1.115 -#   Note that each .d file will also be dependent on it's .o file, see
   1.116 -#   Rules.gmk.
   1.117 -#
   1.118 -ifeq ($(COMPILE_APPROACH),batch)
   1.119 -
   1.120 -.PHONY: library_batch_compile
   1.121 -
   1.122 -library_batch_compile:
   1.123 -	@$(ECHO) "Begin BATCH compiles: $(shell $(PWD))"
   1.124 -	$(MAKE) $(COMPILE_FILES_o)
   1.125 -	$(MAKE) batch_compile
   1.126 -	@$(ECHO) "Done with BATCH compiles: $(shell $(PWD))"
   1.127 -	$(MAKE) COMPILE_APPROACH=normal $(COMPILE_FILES_o)
   1.128 -
   1.129 -$(ACTUAL_LIBRARY):: library_batch_compile
   1.130 -
   1.131 -endif
   1.132 -
   1.133 -ifeq ($(PLATFORM), windows)
   1.134 -
   1.135 -#
   1.136 -# Library building rules.
   1.137 -#
   1.138 -
   1.139 -$(LIBRARY).lib:: $(OBJDIR)
   1.140 -
   1.141 -# build it into $(OBJDIR) so that the other generated files get put 
   1.142 -# there, then copy just the DLL (and MAP file) to the requested directory.
   1.143 -#
   1.144 -$(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf
   1.145 -	@$(prep-target)
   1.146 -	@$(MKDIR) -p $(OBJDIR)
   1.147 -	$(LINK) -dll -out:$(OBJDIR)/$(@F) \
   1.148 -	  -map:$(OBJDIR)/$(LIBRARY).map \
   1.149 -	  $(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \
   1.150 -	  $(OTHER_LCF) $(JAVALIB) $(LDLIBS)
   1.151 -	$(CP) $(OBJDIR)/$(@F) $@
   1.152 -	$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
   1.153 -	$(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
   1.154 -
   1.155 -$(OBJDIR)/$(LIBRARY).lcf: $(OBJDIR)/$(LIBRARY).res $(COMPILE_FILES_o) $(FILES_m)
   1.156 -	@$(prep-target)
   1.157 -	@$(MKDIR) -p $(TEMPDIR)
   1.158 -	@$(ECHO) $(FILES_o) > $@ 
   1.159 -ifndef LOCAL_RESOURCE_FILE
   1.160 -	@$(ECHO) $(OBJDIR)/$(LIBRARY).res >> $@
   1.161 -endif
   1.162 -	@$(ECHO) Created $@ 
   1.163 -
   1.164 -RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
   1.165 -            /D "JDK_INTERNAL_NAME=$(LIBRARY)" \
   1.166 -            /D "JDK_FTYPE=0x2L"
   1.167 -
   1.168 -$(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE)
   1.169 -ifndef LOCAL_RESOURCE_FILE
   1.170 -	@$(prep-target)
   1.171 -	$(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE)
   1.172 -endif
   1.173 -
   1.174 -#
   1.175 -# Install a .lib file if required.
   1.176 -#
   1.177 -ifeq ($(INSTALL_DOT_LIB), true)
   1.178 -$(ACTUAL_LIBRARY):: $(LIBDIR)/$(LIBRARY).lib
   1.179 -
   1.180 -clean:: 
   1.181 -	-$(RM) $(LIBDIR)/$(LIBRARY).lib
   1.182 -
   1.183 -$(LIBDIR)/$(LIBRARY).lib:: $(OBJDIR)/$(LIBRARY).lib
   1.184 -	$(install-file)
   1.185 -
   1.186 -$(LIBDIR)/$(LIBRARY).dll:: $(OBJDIR)/$(LIBRARY).dll
   1.187 -	$(install-file)
   1.188 -
   1.189 -endif # INSTALL_DOT_LIB
   1.190 -
   1.191 -else # PLATFORM
   1.192 -
   1.193 -#
   1.194 -# On Solaris, use mcs to write the version into the comment section of
   1.195 -# the shared library.  On other platforms set this to false at the
   1.196 -# make command line.
   1.197 -#
   1.198 -$(ACTUAL_LIBRARY):: $(COMPILE_FILES_o) $(FILES_m) $(FILES_reorder)
   1.199 -	@$(prep-target)
   1.200 -	@$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), _OPT=$(_OPT)"
   1.201 -	@$(ECHO) "Rebuilding $@ because of $?"
   1.202 -	$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
   1.203 -ifeq ($(WRITE_LIBVERSION),true)
   1.204 -	$(MCS) -d -a "$(FULL_VERSION)" $@
   1.205 -endif # WRITE_LIBVERSION
   1.206 -
   1.207 -endif # PLATFORM
   1.208 -
   1.209 -#
   1.210 -# Cross check all linted files against each other
   1.211 -#
   1.212 -ifeq ($(PLATFORM),solaris)
   1.213 -lint.errors : $(FILES_ln)
   1.214 -	$(LINT.c) $(FILES_ln) $(LDLIBS) 
   1.215 -endif
   1.216 -
   1.217 -#
   1.218 -# Class libraries with JNI native methods get a include to the package.
   1.219 -#
   1.220 -ifdef PACKAGE
   1.221 -vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)
   1.222 -vpath %.c $(SHARE_SRC)/native/$(PKGDIR)
   1.223 -OTHER_INCLUDES += -I$(SHARE_SRC)/native/common -I$(PLATFORM_SRC)/native/common
   1.224 -OTHER_INCLUDES += -I$(SHARE_SRC)/native/$(PKGDIR) \
   1.225 -		  -I$(PLATFORM_SRC)/native/$(PKGDIR)
   1.226 -endif
   1.227 -
   1.228 -#
   1.229 -# Clean/clobber rules
   1.230 -#
   1.231 -clean::
   1.232 -	$(RM) -r $(ACTUAL_LIBRARY)
   1.233 -
   1.234 -clobber:: clean
   1.235 -
   1.236 -#
   1.237 -# INCREMENTAL_BUILD means that this workspace will be built over and over
   1.238 -#   possibly incrementally. This means tracking the object file dependencies
   1.239 -#   on include files so that sources get re-compiled when the include files
   1.240 -#   change. When building from scratch and doing a one time build (like
   1.241 -#   release engineering or nightly builds) set INCREMENTAL_BUILD=false.
   1.242 -#
   1.243 -
   1.244 -ifeq ($(INCREMENTAL_BUILD),true)
   1.245 -
   1.246 -#
   1.247 -# Workaround: gnumake sometimes says files is empty when it shouldn't
   1.248 -#    was:  files := $(foreach file, $(wildcard $(OBJDIR)/*.$(DEPEND_SUFFIX)), $(file))
   1.249 -#
   1.250 -files := $(shell $(LS) $(OBJDIR)/*.$(DEPEND_SUFFIX) 2>/dev/null)
   1.251 -
   1.252 -#
   1.253 -# Only include these files if we have any.
   1.254 -#
   1.255 -ifneq ($(strip $(files)),)
   1.256 -
   1.257 -include $(files)
   1.258 -
   1.259 -endif # files
   1.260 -
   1.261 -endif # INCREMENTAL_BUILD
   1.262 -
   1.263 -#
   1.264 -# Default dependencies
   1.265 -#
   1.266 -
   1.267 -all: build
   1.268 -
   1.269 -build: library
   1.270 -
   1.271 -debug:
   1.272 -	$(MAKE) VARIANT=DBG build
   1.273 -
   1.274 -fastdebug:
   1.275 -	$(MAKE) VARIANT=DBG FASTDEBUG=true build
   1.276 -
   1.277 -.PHONY: all build debug fastdebug
   1.278 -

mercurial