Library.gmk revision 2362
0N/A#
2362N/A# Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A#
0N/A# This code is free software; you can redistribute it and/or modify it
0N/A# under the terms of the GNU General Public License version 2 only, as
2362N/A# published by the Free Software Foundation. Oracle designates this
0N/A# particular file as subject to the "Classpath" exception as provided
2362N/A# by Oracle in the LICENSE file that accompanied this code.
0N/A#
0N/A# This code is distributed in the hope that it will be useful, but WITHOUT
0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A# version 2 for more details (a copy is included in the LICENSE file that
0N/A# accompanied this code).
0N/A#
0N/A# You should have received a copy of the GNU General Public License version
0N/A# 2 along with this work; if not, write to the Free Software Foundation,
0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A#
2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A# or visit www.oracle.com if you need additional information or have any
2362N/A# questions.
0N/A#
0N/A
0N/A#
0N/A# Generic makefile for building shared libraries.
0N/A#
0N/A
0N/A# WARNING: This file is shared with other workspaces.
0N/A# So when it includes other files, it must use JDK_TOPDIR.
0N/A#
0N/A
0N/Ainclude $(JDK_TOPDIR)/make/common/Classes.gmk
0N/A
0N/A#
0N/A# It is important to define these *after* including Classes.gmk
0N/A# in order to override the values defined inthat makefile.
0N/A#
0N/A
0N/Aifeq ($(LIBRARY), fdlibm)
0N/Aifeq ($(PLATFORM),windows)
0N/AACTUAL_LIBRARY_NAME = $(LIB_PREFIX)$(LIBRARY).$(FDDLIBM_SUFFIX)
0N/AACTUAL_LIBRARY_DIR = $(OBJDIR)
0N/Aelse # PLATFORM
0N/AACTUAL_LIBRARY_NAME = $(LIB_PREFIX)$(LIBRARY).$(ARCH).$(FDDLIBM_SUFFIX)
0N/AACTUAL_LIBRARY_DIR = $(OBJDIR)
0N/Aendif #PLATFORM
0N/Aelse # LIBRARY
0N/AACTUAL_LIBRARY_NAME = $(LIB_PREFIX)$(LIBRARY).$(LIBRARY_SUFFIX)
0N/AACTUAL_LIBRARY_DIR = $(LIB_LOCATION)
0N/Aendif
0N/AACTUAL_LIBRARY = $(ACTUAL_LIBRARY_DIR)/$(ACTUAL_LIBRARY_NAME)
0N/A
0N/Alibrary:: $(ACTUAL_LIBRARY)
0N/A
0N/AFILES_o = $(patsubst %.c, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c))))
0N/AFILES_o += $(patsubst %.s, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_s))))
0N/AFILES_o += $(patsubst %.cpp, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_cpp))))
0N/A
0N/Aifeq ($(INCREMENTAL_BUILD),true)
0N/AFILES_d = $(patsubst %.c, %.$(DEPEND_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c))))
0N/AFILES_d += $(patsubst %.cpp, %.$(DEPEND_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_cpp))))
0N/Aendif # INCREMENTAL_BUILD
0N/A
0N/Aifeq ($(PLATFORM),solaris)
0N/A# List of all lint files, one for each .c file (only for C)
0N/AFILES_ln = $(patsubst %.c, %.$(LINT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c))))
0N/Aendif
0N/A
0N/A#
0N/A# C++ libraries must be linked with CC.
0N/A#
0N/Aifdef CPLUSPLUSLIBRARY
0N/ALINKER=$(LINK.cc)
0N/Aelse
0N/ALINKER=$(LINK.c)
0N/Aendif
0N/A
0N/A# FIXUP: unpack needs the zip .o files. So we must build zip?
0N/A# or fix unpack makefile so it uses Program.gmk.
0N/Aifneq ($(IMPORT_NATIVE_BINARIES),true)
0N/A COMPILE_IT=true
0N/Aelse
0N/A ifeq ($(LIBRARY),zip)
0N/A COMPILE_IT=true
0N/A else
0N/A COMPILE_IT=false
0N/A endif
0N/Aendif
0N/A
0N/A# If a Makefile has specified a pre-compiled closed src lib, just copy it.
0N/Aifdef USE_BINARY_PLUG_LIBRARY
0N/A COMPILE_IT=false
0N/Aendif
0N/A
0N/A# We either need to import (copy) libraries in, or build them
0N/Aifeq ($(COMPILE_IT),true)
0N/A
0N/A$(ACTUAL_LIBRARY):: $(INIT) $(TEMPDIR) $(LIBDIR) $(BINDIR) $(EXTDIR) classheaders
0N/A
0N/A#
0N/A# COMPILE_APPROACH: Different approaches to compile up the native object
0N/A# files as quickly as possible.
0N/A# The setting of parallel works best on Unix, batch on Windows.
0N/A#
0N/A
0N/ACOMPILE_FILES_o = $(OBJDIR)/.files_compiled
0N/A$(COMPILE_FILES_o): $(FILES_d) $(FILES_o)
0N/A @$(ECHO) "$<" >> $@
0N/Aclean::
0N/A $(RM) $(COMPILE_FILES_o)
0N/A
0N/A#
0N/A# COMPILE_APPROACH=parallel: Will trigger compilations (just compilations) to
0N/A# happen in parallel. Greatly decreases Unix build time, even on single CPU
0N/A# machines, more so on multiple CPU machines. Default is 2 compiles
0N/A# at a time, but can be adjusted with ALT_PARALLEL_COMPILE_JOBS.
0N/A# Note that each .d file will also be dependent on it's .o file, see
0N/A# Rules.gmk.
0N/A# Note this does not depend on Rules.gmk to work like batch (below)
0N/A# and this technique doesn't seem to help Windows build time nor does
0N/A# it work very well, it's possible the Windows Visual Studio compilers
0N/A# don't work well in a parallel situation, this needs investigation.
0N/A#
0N/A
0N/Aifeq ($(COMPILE_APPROACH),parallel)
0N/A
0N/A.PHONY: library_parallel_compile
0N/A
0N/Alibrary_parallel_compile:
0N/A @$(ECHO) "Begin parallel compiles: $(shell $(PWD))"
0N/A @$(MAKE) -j $(PARALLEL_COMPILE_JOBS) $(COMPILE_FILES_o)
0N/A @$(ECHO) "Done with parallel compiles: $(shell $(PWD))"
0N/A
0N/A$(ACTUAL_LIBRARY):: library_parallel_compile
0N/A
0N/Aendif
0N/A
0N/A#
0N/A# COMPILE_APPROACH=batch: Will trigger compilations (just compilations) to
0N/A# happen in batch mode. Greatly decreases Windows build time.
0N/A# See logic in Rules.gmk for how compiles happen, the $(MAKE) in
0N/A# library_batch_compile below triggers the actions in Rules.gmk.
0N/A# Note that each .d file will also be dependent on it's .o file, see
0N/A# Rules.gmk.
0N/A#
0N/Aifeq ($(COMPILE_APPROACH),batch)
0N/A
0N/A.PHONY: library_batch_compile
0N/A
0N/Alibrary_batch_compile:
0N/A @$(ECHO) "Begin BATCH compiles: $(shell $(PWD))"
0N/A $(MAKE) $(COMPILE_FILES_o)
0N/A $(MAKE) batch_compile
0N/A @$(ECHO) "Done with BATCH compiles: $(shell $(PWD))"
0N/A $(MAKE) COMPILE_APPROACH=normal $(COMPILE_FILES_o)
0N/A
0N/A$(ACTUAL_LIBRARY):: library_batch_compile
0N/A
0N/Aendif
0N/A
0N/Aifeq ($(PLATFORM), windows)
0N/A
0N/A#
0N/A# Library building rules.
0N/A#
0N/A
0N/A$(LIBRARY).lib:: $(OBJDIR)
0N/A
0N/Aifeq ($(LIBRARY), fdlibm)
0N/A$(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lib
0N/A
0N/A$(OBJDIR)/$(LIBRARY).lib:: $(OBJDIR)/$(LIBRARY).lcf
0N/A @$(prep-target)
0N/A $(LIBEXE) -NODEFAULTLIB:MSVCRT -out:$@ -nologo \
0N/A @$(OBJDIR)/$(LIBRARY).lcf $(OTHER_LCF) $(LDLIBS_COMMON)
0N/Aelse # LIBRARY
0N/A# build it into $(OBJDIR) so that the other generated files get put
0N/A# there, then copy just the DLL (and MAP file) to the requested directory.
0N/A#
795N/A# In VS2005 or VS2008 the link command creates a .manifest file that we want
795N/A# to insert into the linked artifact so we do not need to track it separately.
795N/A# Use ";#2" for .dll and ";#1" for .exe in the MT command below:
0N/A$(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf
0N/A @$(prep-target)
0N/A @$(MKDIR) -p $(OBJDIR)
0N/A $(LINK) -dll -out:$(OBJDIR)/$(@F) \
0N/A -map:$(OBJDIR)/$(LIBRARY).map \
0N/A $(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \
0N/A $(OTHER_LCF) $(JAVALIB) $(LDLIBS)
795N/Aifdef MT
795N/A $(MT) /manifest $(OBJDIR)/$(@F).manifest /outputresource:$(OBJDIR)/$(@F);#2
795N/Aendif
0N/A $(CP) $(OBJDIR)/$(@F) $@
2080N/A $(install-module-file)
0N/A $(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
0N/A $(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
0N/A
2080N/A$(ACTUAL_LIBRARY):: $(ACTUAL_LIBRARY_DIR)/$(LIBRARY).map $(ACTUAL_LIBRARY_DIR)/$(LIBRARY).pdb
2080N/A
2080N/A$(ACTUAL_LIBRARY_DIR)/%.map: FORCE
2080N/A $(install-module-file)
2080N/A
2080N/A$(ACTUAL_LIBRARY_DIR)/%.pdb: FORCE
2080N/A $(install-module-file)
2080N/A
0N/Aendif # LIBRARY
0N/A
0N/A$(OBJDIR)/$(LIBRARY).lcf: $(OBJDIR)/$(LIBRARY).res $(COMPILE_FILES_o) $(FILES_m)
0N/A @$(prep-target)
0N/A @$(MKDIR) -p $(TEMPDIR)
0N/A @$(ECHO) $(FILES_o) > $@
0N/Aifndef LOCAL_RESOURCE_FILE
0N/A @$(ECHO) $(OBJDIR)/$(LIBRARY).res >> $@
0N/Aendif
0N/A @$(ECHO) Created $@
0N/A
1365N/A# JDK name required here
1365N/ARC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
1365N/A /D "JDK_INTERNAL_NAME=$(LIBRARY)" \
1365N/A /D "JDK_FTYPE=0x2L"
0N/A
0N/A$(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE)
0N/Aifndef LOCAL_RESOURCE_FILE
0N/A @$(prep-target)
0N/A $(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE)
0N/Aendif
0N/A
0N/A#
0N/A# Install a .lib file if required.
0N/A#
0N/Aifeq ($(INSTALL_DOT_LIB), true)
0N/A$(ACTUAL_LIBRARY):: $(LIBDIR)/$(LIBRARY).lib
0N/A
0N/Aclean::
0N/A -$(RM) $(LIBDIR)/$(LIBRARY).lib
0N/A
0N/A$(LIBDIR)/$(LIBRARY).lib:: $(OBJDIR)/$(LIBRARY).lib
0N/A $(install-file)
0N/A
0N/A$(LIBDIR)/$(LIBRARY).dll:: $(OBJDIR)/$(LIBRARY).dll
0N/A $(install-file)
0N/A
0N/Aendif # INSTALL_DOT_LIB
0N/A
0N/Aelse # PLATFORM
0N/A
0N/A#
0N/A# On Solaris, use mcs to write the version into the comment section of
0N/A# the shared library. On other platforms set this to false at the
0N/A# make command line.
0N/A#
0N/A$(ACTUAL_LIBRARY):: $(COMPILE_FILES_o) $(FILES_m) $(FILES_reorder)
0N/A @$(prep-target)
460N/A @$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), OPTIMIZATION_LEVEL=$(OPTIMIZATION_LEVEL)"
0N/A @$(ECHO) "Rebuilding $@ because of $?"
0N/Aifeq ($(LIBRARY), fdlibm)
0N/A $(AR) -r $@ $(FILES_o)
0N/Aelse # LIBRARY
0N/A $(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
2080N/A $(install-module-file)
0N/Aifeq ($(WRITE_LIBVERSION),true)
0N/A $(MCS) -d -a "$(FULL_VERSION)" $@
0N/Aendif # WRITE_LIBVERSION
0N/Aendif # LIBRARY
0N/A
0N/Aendif # PLATFORM
0N/A
0N/A#
0N/A# Cross check all linted files against each other
0N/A#
0N/Aifeq ($(PLATFORM),solaris)
0N/Alint.errors : $(FILES_ln)
0N/A $(LINT.c) $(FILES_ln) $(LDLIBS)
0N/Aendif
0N/A
0N/Aelse # COMPILE_IT
0N/A
0N/A# OpenJDK rule is first so any lib is preferentially copied from that location.
0N/Aifndef USE_BINARY_PLUG_LIBRARY
0N/A
0N/A# In this case we are just copying the file.
0N/Aifneq ($(LIBRARY), fdlibm)
0N/A# Copies in the file from the JDK_IMPORT_PATH area
0N/A$(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/%
0N/A $(install-import-file)
0N/A$(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/native_threads/%
0N/A $(install-import-file)
0N/A$(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/headless/%
0N/A $(install-import-file)
0N/A$(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/xawt/%
0N/A $(install-import-file)
0N/Aelse # fdlibm
0N/A$(ACTUAL_LIBRARY_DIR)/%:
0N/A $(prep-target)
0N/Aendif # fdlibm
0N/A
0N/Aendif # USE_BINARY_PLUG_LIBRARY
0N/A
0N/Aendif # COMPILE_IT
0N/A
0N/A#
0N/A# Class libraries with JNI native methods get a include to the package.
0N/A#
0N/Aifdef PACKAGE
0N/Avpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)
0N/Avpath %.c $(SHARE_SRC)/native/$(PKGDIR)
0N/AOTHER_INCLUDES += -I$(SHARE_SRC)/native/common -I$(PLATFORM_SRC)/native/common
0N/AOTHER_INCLUDES += -I$(SHARE_SRC)/native/$(PKGDIR) \
0N/A -I$(PLATFORM_SRC)/native/$(PKGDIR)
0N/Aendif
0N/A
0N/A#
0N/A# Clean/clobber rules
0N/A#
0N/Aclean::
0N/A $(RM) -r $(ACTUAL_LIBRARY)
0N/A
0N/Aclobber:: clean
0N/A
0N/A#
0N/A# INCREMENTAL_BUILD means that this workspace will be built over and over
0N/A# possibly incrementally. This means tracking the object file dependencies
0N/A# on include files so that sources get re-compiled when the include files
0N/A# change. When building from scratch and doing a one time build (like
0N/A# release engineering or nightly builds) set INCREMENTAL_BUILD=false.
0N/A#
0N/A
0N/Aifeq ($(INCREMENTAL_BUILD),true)
0N/A
0N/A#
0N/A# Workaround: gnumake sometimes says files is empty when it shouldn't
0N/A# was: files := $(foreach file, $(wildcard $(OBJDIR)/*.$(DEPEND_SUFFIX)), $(file))
0N/A#
0N/Afiles := $(shell $(LS) $(OBJDIR)/*.$(DEPEND_SUFFIX) 2>/dev/null)
0N/A
0N/A#
0N/A# Only include these files if we have any.
0N/A#
0N/Aifneq ($(strip $(files)),)
0N/A
0N/Ainclude $(files)
0N/A
0N/Aendif # files
0N/A
0N/Aendif # INCREMENTAL_BUILD
0N/A
0N/A#
0N/A# Default dependencies
0N/A#
0N/A
0N/Aall: build
0N/A
0N/Abuild: library
0N/A
0N/Adebug:
0N/A $(MAKE) VARIANT=DBG build
0N/A
0N/Afastdebug:
0N/A $(MAKE) VARIANT=DBG FASTDEBUG=true build
0N/A
0N/Aopenjdk:
0N/A $(MAKE) OPENJDK=true build
0N/A
2080N/AFORCE:
2080N/A
0N/A.PHONY: all build debug fastdebug
0N/A