0N/A#
4915N/A# Copyright (c) 1995, 2012, 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
4632N/Aifeq ($(PLATFORM), macosx)
4632N/AFILES_o += $(patsubst %.m, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_objc))))
4632N/AFILES_o += $(patsubst %.mm, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_objcpp))))
4632N/A
4632N/A# MMM: why?
4632N/AINCREMENTAL_BUILD=false
4632N/A
4632N/Aendif # PLATFORM
4632N/A
4632N/A
4632N/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$(ACTUAL_LIBRARY):: $(INIT) $(TEMPDIR) $(LIBDIR) $(BINDIR) $(EXTDIR) classheaders
3867N/A @$(ECHO) Building lib:$(ACTUAL_LIBRARY)
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#
4915N/Aifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
4915N/A MAP_OPTION="-map:$(OBJDIR)/$(LIBRARY).map"
4915N/Aendif
4915N/A
0N/A$(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf
0N/A @$(prep-target)
0N/A @$(MKDIR) -p $(OBJDIR)
0N/A $(LINK) -dll -out:$(OBJDIR)/$(@F) \
4915N/A $(MAP_OPTION) \
0N/A $(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \
0N/A $(OTHER_LCF) $(JAVALIB) $(LDLIBS)
0N/A $(CP) $(OBJDIR)/$(@F) $@
3419N/A @$(call binary_file_verification,$@)
4915N/Aifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
4956N/A ifeq ($(ZIP_DEBUGINFO_FILES),1)
4956N/A (set -e ; \
4956N/A $(CD) $(OBJDIR) ; \
4956N/A $(ZIPEXE) -q $(LIBRARY).diz $(LIBRARY).map $(LIBRARY).pdb ; \
4956N/A )
4956N/A $(CP) $(OBJDIR)/$(LIBRARY).diz $(@D)
4956N/A $(RM) $(OBJDIR)/$(LIBRARY).map $(OBJDIR)/$(LIBRARY).pdb
4956N/A else
0N/A $(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
0N/A $(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
4956N/A endif
4915N/Aendif
0N/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#
4632N/A
4632N/Aifneq ($(PLATFORM), macosx)
4632N/A ARFLAGS = -r
4632N/Aendif
4632N/A
5036N/Aifeq ($(PLATFORM), solaris)
5036N/A ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
5036N/A$(ACTUAL_LIBRARY):: $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS)
5036N/A endif
5036N/Aendif
5036N/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)
4632N/A $(AR) $(ARFLAGS) $@ $(FILES_o)
0N/Aelse # LIBRARY
0N/A $(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
3419N/A @$(call binary_file_verification,$@)
0N/Aifeq ($(WRITE_LIBVERSION),true)
0N/A $(MCS) -d -a "$(FULL_VERSION)" $@
0N/Aendif # WRITE_LIBVERSION
4956N/A ifneq ($(PLATFORM), macosx)
4956N/A ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
4956N/A ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
5036N/A ifeq ($(PLATFORM), solaris)
5036N/A# gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
5036N/A# Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from
5036N/A# empty section headers until a fixed $(OBJCOPY) is available.
5036N/A# An empty section header has sh_addr == 0 and sh_size == 0.
5036N/A# This problem has only been seen on Solaris X64, but we call this tool
5036N/A# on all Solaris builds just in case.
5036N/A#
5036N/A# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
5036N/A# Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
4956N/A (set -e ; \
4956N/A $(CD) $(@D) ; \
5036N/A $(FIX_EMPTY_SEC_HDR_FLAGS) $(@F) ; \
5036N/A $(OBJCOPY) --only-keep-debug $(@F) $(LIB_PREFIX)$(LIBRARY).debuginfo ; \
5036N/A $(ADD_GNU_DEBUGLINK) $(LIB_PREFIX)$(LIBRARY).debuginfo $(@F) ; \
4956N/A )
5036N/A else # PLATFORM != solaris
5036N/A (set -e ; \
5036N/A $(CD) $(@D) ; \
5036N/A $(OBJCOPY) --only-keep-debug $(@F) $(LIB_PREFIX)$(LIBRARY).debuginfo ; \
5036N/A $(OBJCOPY) --add-gnu-debuglink=$(LIB_PREFIX)$(LIBRARY).debuginfo $(@F) ; \
5036N/A )
5036N/A endif # PLATFORM == solaris
4956N/A ifeq ($(STRIP_POLICY),all_strip)
4956N/A $(STRIP) $@
4956N/A else
4956N/A ifeq ($(STRIP_POLICY),min_strip)
4956N/A ifeq ($(PLATFORM), solaris)
4956N/A $(STRIP) -x $@
4956N/A else
4956N/A # assume Linux
4956N/A $(STRIP) -g $@
4956N/A endif
4956N/A # implied else here is no stripping at all
4956N/A endif
4956N/A endif
4956N/A ifeq ($(ZIP_DEBUGINFO_FILES),1)
4956N/A (set -e ; \
4956N/A $(CD) $(@D) ; \
5036N/A $(ZIPEXE) -q $(LIB_PREFIX)$(LIBRARY).diz $(LIB_PREFIX)$(LIBRARY).debuginfo ; \
5036N/A $(RM) $(LIB_PREFIX)$(LIBRARY).debuginfo ; \
4956N/A )
4956N/A endif
4956N/A endif # LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
4956N/A endif # ENABLE_FULL_DEBUG_SYMBOLS
4956N/A endif # PLATFORM-!macosx
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/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