2012-04-10 15:18:28 +00:00
|
|
|
#
|
2016-02-12 10:07:35 +00:00
|
|
|
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
2012-04-10 15:18:28 +00:00
|
|
|
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
#
|
|
|
|
# This code is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License version 2 only, as
|
|
|
|
# published by the Free Software Foundation. Oracle designates this
|
|
|
|
# particular file as subject to the "Classpath" exception as provided
|
|
|
|
# by Oracle in the LICENSE file that accompanied this code.
|
|
|
|
#
|
|
|
|
# This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
# version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
# accompanied this code).
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License version
|
|
|
|
# 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#
|
|
|
|
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
# or visit www.oracle.com if you need additional information or have any
|
|
|
|
# questions.
|
|
|
|
#
|
|
|
|
|
|
|
|
# When you read this source. Remember that $(sort ...) has the side effect
|
|
|
|
# of removing duplicates. It is actually this side effect that is
|
|
|
|
# desired whenever sort is used below!
|
|
|
|
|
2014-08-17 14:51:37 +00:00
|
|
|
ifndef _NATIVE_COMPILATION_GMK
|
|
|
|
_NATIVE_COMPILATION_GMK := 1
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifeq (,$(_MAKEBASE_GMK))
|
|
|
|
$(error You must include MakeBase.gmk prior to including NativeCompilation.gmk)
|
2012-04-10 15:18:28 +00:00
|
|
|
endif
|
|
|
|
|
2015-10-19 17:21:27 +00:00
|
|
|
################################################################################
|
|
|
|
# Create exported symbols file for static libraries
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# get the exported symbols from mapfiles and if there
|
|
|
|
# is no mapfile, get them from the archive
|
|
|
|
define GetSymbols
|
|
|
|
$(RM) $$(@D)/$$(basename $$(@F)).symbols; \
|
|
|
|
if [ ! -z $$($1_MAPFILE) -a -e $$($1_MAPFILE) ]; then \
|
|
|
|
$(ECHO) "Getting symbols from mapfile $$($1_MAPFILE)"; \
|
|
|
|
$(AWK) '/global:/','/local:/' $$($1_MAPFILE) | \
|
|
|
|
$(SED) -e 's/#.*//;s/global://;s/local://;s/\;//;s/^[ ]*/_/;/^_$$$$/d' | \
|
|
|
|
$(EGREP) -v "JNI_OnLoad|JNI_OnUnload|Agent_OnLoad|Agent_OnUnload|Agent_OnAttach" > \
|
|
|
|
$$(@D)/$$(basename $$(@F)).symbols || true; \
|
|
|
|
$(NM) $$($1_TARGET) | $(GREP) " T " | \
|
|
|
|
$(EGREP) "JNI_OnLoad|JNI_OnUnload|Agent_OnLoad|Agent_OnUnload|Agent_OnAttach" | \
|
|
|
|
$(CUT) -d ' ' -f 3 >> $$(@D)/$$(basename $$(@F)).symbols || true;\
|
|
|
|
else \
|
|
|
|
$(ECHO) "Getting symbols from nm"; \
|
|
|
|
$(NM) -m $$($1_TARGET) | $(GREP) "__TEXT" | \
|
|
|
|
$(EGREP) -v "non-external|private extern|__TEXT,__eh_frame" | \
|
|
|
|
$(SED) -e 's/.* //' > $$(@D)/$$(basename $$(@F)).symbols; \
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
2015-04-17 11:54:50 +00:00
|
|
|
################################################################################
|
|
|
|
# Define a native toolchain configuration that can be used by
|
|
|
|
# SetupNativeCompilation calls
|
|
|
|
#
|
|
|
|
# Parameter 1 is the name of the toolchain definition
|
|
|
|
#
|
|
|
|
# Remaining parameters are named arguments:
|
|
|
|
# EXTENDS - Optional parent definition to get defaults from
|
|
|
|
# CC - The C compiler
|
|
|
|
# CXX - The C++ compiler
|
|
|
|
# LD - The Linker
|
|
|
|
# AR - Static linker
|
|
|
|
# AS - Assembler
|
|
|
|
# MT - Windows MT tool
|
|
|
|
# RC - Windows RC tool
|
2016-03-17 19:03:53 +00:00
|
|
|
# OBJCOPY - The objcopy tool for debug symbol handling
|
2015-09-28 13:51:29 +00:00
|
|
|
# STRIP - The tool to use for stripping debug symbols
|
2015-04-17 11:54:50 +00:00
|
|
|
# SYSROOT_CFLAGS - Compiler flags for using the specific sysroot
|
|
|
|
# SYSROOT_LDFLAGS - Linker flags for using the specific sysroot
|
|
|
|
DefineNativeToolchain = $(NamedParamsMacroTemplate)
|
|
|
|
define DefineNativeToolchainBody
|
|
|
|
# If extending another definition, get default values from that,
|
|
|
|
# otherwise, nothing more needs to be done as variable assignments
|
|
|
|
# already happened in NamedParamsMacroTemplate.
|
|
|
|
ifneq ($$($1_EXTENDS), )
|
|
|
|
$$(call SetIfEmpty, $1_CC, $$($$($1_EXTENDS)_CC))
|
|
|
|
$$(call SetIfEmpty, $1_CXX, $$($$($1_EXTENDS)_CXX))
|
|
|
|
$$(call SetIfEmpty, $1_LD, $$($$($1_EXTENDS)_LD))
|
|
|
|
$$(call SetIfEmpty, $1_AR, $$($$($1_EXTENDS)_AR))
|
|
|
|
$$(call SetIfEmpty, $1_AS, $$($$($1_EXTENDS)_AS))
|
|
|
|
$$(call SetIfEmpty, $1_MT, $$($$($1_EXTENDS)_MT))
|
|
|
|
$$(call SetIfEmpty, $1_RC, $$($$($1_EXTENDS)_RC))
|
2016-03-17 19:03:53 +00:00
|
|
|
$$(call SetIfEmpty, $1_OBJCOPY, $$($$($1_EXTENDS)_OBJCOPY))
|
2015-09-28 13:51:29 +00:00
|
|
|
$$(call SetIfEmpty, $1_STRIP, $$($$($1_EXTENDS)_STRIP))
|
2015-04-17 11:54:50 +00:00
|
|
|
$$(call SetIfEmpty, $1_SYSROOT_CFLAGS, $$($$($1_EXTENDS)_SYSROOT_CFLAGS))
|
|
|
|
$$(call SetIfEmpty, $1_SYSROOT_LDFLAGS, $$($$($1_EXTENDS)_SYSROOT_LDFLAGS))
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Create a default toolchain with the main compiler and linker
|
|
|
|
$(eval $(call DefineNativeToolchain, TOOLCHAIN_DEFAULT, \
|
|
|
|
CC := $(CC), \
|
|
|
|
CXX := $(CXX), \
|
|
|
|
LD := $(LD), \
|
|
|
|
AR := $(AR), \
|
|
|
|
AS := $(AS), \
|
|
|
|
MT := $(MT), \
|
|
|
|
RC := $(RC), \
|
2016-03-17 19:03:53 +00:00
|
|
|
OBJCOPY := $(OBJCOPY), \
|
2015-09-28 13:51:29 +00:00
|
|
|
STRIP := $(STRIP), \
|
2015-04-17 11:54:50 +00:00
|
|
|
SYSROOT_CFLAGS := $(SYSROOT_CFLAGS), \
|
|
|
|
SYSROOT_LDFLAGS := $(SYSROOT_LDFLAGS), \
|
|
|
|
))
|
|
|
|
|
|
|
|
# Create a toolchain where linking is done with the C++ linker
|
|
|
|
$(eval $(call DefineNativeToolchain, TOOLCHAIN_LINK_CXX, \
|
|
|
|
EXTENDS := TOOLCHAIN_DEFAULT, \
|
|
|
|
LD := $(LDCXX), \
|
|
|
|
))
|
|
|
|
|
|
|
|
# Create a toolchain with the BUILD compiler, used for build tools that
|
|
|
|
# are to be run during the build.
|
|
|
|
$(eval $(call DefineNativeToolchain, TOOLCHAIN_BUILD, \
|
|
|
|
CC := $(BUILD_CC), \
|
2015-11-24 14:46:04 +00:00
|
|
|
CXX := $(BUILD_CXX), \
|
2015-04-17 11:54:50 +00:00
|
|
|
LD := $(BUILD_LD), \
|
2015-11-24 14:46:04 +00:00
|
|
|
AR := $(BUILD_AR), \
|
|
|
|
AS := $(BUILD_AS), \
|
2016-03-17 19:03:53 +00:00
|
|
|
OBJCOPY := $(BUILD_OBJCOPY), \
|
|
|
|
STRIP := $(BUILD_STRIP), \
|
2015-04-17 11:54:50 +00:00
|
|
|
SYSROOT_CFLAGS := $(BUILD_SYSROOT_CFLAGS), \
|
|
|
|
SYSROOT_LDFLAGS := $(BUILD_SYSROOT_LDFLAGS), \
|
|
|
|
))
|
|
|
|
|
2015-12-15 10:02:03 +00:00
|
|
|
# BUILD toolchain with the C++ linker
|
|
|
|
$(eval $(call DefineNativeToolchain, TOOLCHAIN_BUILD_LINK_CXX, \
|
|
|
|
EXTENDS := TOOLCHAIN_BUILD, \
|
|
|
|
LD := $(BUILD_LDCXX), \
|
|
|
|
))
|
|
|
|
|
2015-04-17 11:54:50 +00:00
|
|
|
################################################################################
|
|
|
|
|
2014-11-26 14:14:14 +00:00
|
|
|
# Extensions of files handled by this macro.
|
2016-02-02 14:02:55 +00:00
|
|
|
NATIVE_SOURCE_EXTENSIONS := %.s %.S %.c %.cpp %.cc %.m %.mm
|
2014-11-26 14:14:14 +00:00
|
|
|
|
|
|
|
# Replaces native source extensions with the object file extension in a string.
|
|
|
|
# Param 1: the string containing source file names with extensions
|
|
|
|
# The surrounding strip is needed to keep additional whitespace out
|
|
|
|
define replace_with_obj_extension
|
|
|
|
$(strip \
|
|
|
|
$(foreach extension, $(NATIVE_SOURCE_EXTENSIONS), \
|
|
|
|
$(patsubst $(extension),%$(OBJ_SUFFIX),$(filter $(extension),$1))) \
|
|
|
|
)
|
|
|
|
endef
|
2012-04-10 15:18:28 +00:00
|
|
|
|
2014-08-19 11:43:40 +00:00
|
|
|
ifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin)
|
|
|
|
UNIX_PATH_PREFIX := /cygdrive
|
|
|
|
else ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys)
|
|
|
|
UNIX_PATH_PREFIX :=
|
|
|
|
endif
|
|
|
|
|
2015-02-06 11:37:31 +00:00
|
|
|
# This pattern is used to transform the output of the microsoft CL compiler
|
|
|
|
# into a make syntax dependency file (.d)
|
2014-11-26 14:14:14 +00:00
|
|
|
WINDOWS_SHOWINCLUDE_SED_PATTERN := \
|
|
|
|
-e '/^Note: including file:/!d' \
|
|
|
|
-e 's|Note: including file: *||' \
|
|
|
|
-e 's|\\|/|g' \
|
|
|
|
-e 's|^\([a-zA-Z]\):|$(UNIX_PATH_PREFIX)/\1|g' \
|
2015-03-13 13:00:36 +00:00
|
|
|
-e '\|$(TOPDIR)|I !d' \
|
2014-11-26 14:14:14 +00:00
|
|
|
-e 's|$$$$| \\|g' \
|
|
|
|
#
|
|
|
|
|
2015-02-06 11:37:31 +00:00
|
|
|
# This pattern is used to transform a dependency file (.d) to a list
|
|
|
|
# of make targets for dependent files (.d.targets)
|
|
|
|
DEPENDENCY_TARGET_SED_PATTERN := \
|
|
|
|
-e 's/\#.*//' \
|
|
|
|
-e 's/^[^:]*: *//' \
|
|
|
|
-e 's/ *\\$$$$//' \
|
2015-04-14 12:22:10 +00:00
|
|
|
-e 's/^[ ]*//' \
|
2015-02-06 11:37:31 +00:00
|
|
|
-e '/^$$$$/ d' \
|
|
|
|
-e 's/$$$$/ :/' \
|
|
|
|
#
|
|
|
|
|
2012-04-10 15:18:28 +00:00
|
|
|
define add_native_source
|
2013-10-10 12:58:19 +00:00
|
|
|
# param 1 = BUILD_MYPACKAGE
|
|
|
|
# parma 2 = the source file name (..../alfa.c or .../beta.cpp)
|
|
|
|
# param 3 = the bin dir that stores all .o (.obj) and .d files.
|
|
|
|
# param 4 = the c flags to the compiler
|
|
|
|
# param 5 = the c compiler
|
|
|
|
# param 6 = the c++ flags to the compiler
|
|
|
|
# param 7 = the c++ compiler
|
2015-03-04 09:47:36 +00:00
|
|
|
# param 8 = the flags to the assembler
|
2016-02-12 10:07:35 +00:00
|
|
|
# param 9 = set to disable THIS_FILE
|
|
|
|
|
|
|
|
ifeq ($9, )
|
|
|
|
$1_$2_THIS_FILE = -DTHIS_FILE='"$$(<F)"'
|
|
|
|
endif
|
2013-10-10 12:58:19 +00:00
|
|
|
|
2016-04-08 11:14:23 +00:00
|
|
|
ifeq ($$($1_$(notdir $2)_OPTIMIZATION), )
|
|
|
|
$1_$(notdir $2)_OPT_CFLAGS := $$($1_OPT_CFLAGS)
|
|
|
|
$1_$(notdir $2)_OPT_CXXFLAGS := $$($1_OPT_CXXFLAGS)
|
|
|
|
else
|
|
|
|
ifeq (NONE, $$($1_$(notdir $2)_OPTIMIZATION))
|
|
|
|
$1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_NONE)
|
|
|
|
$1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_NONE)
|
|
|
|
else ifeq (LOW, $$($1_$(notdir $2)_OPTIMIZATION))
|
|
|
|
$1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_NORM)
|
|
|
|
$1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_NORM)
|
|
|
|
else ifeq (HIGH, $$($1_$(notdir $2)_OPTIMIZATION))
|
|
|
|
$1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_HI)
|
|
|
|
$1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_HI)
|
|
|
|
else ifeq (HIGHEST, $$($1_$(notdir $2)_OPTIMIZATION))
|
|
|
|
$1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_HIGHEST)
|
|
|
|
$1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST)
|
|
|
|
else ifeq (HIGHEST_JVM, $$($1_$(notdir $2)_OPTIMIZATION))
|
|
|
|
$1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_HIGHEST_JVM)
|
|
|
|
$1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST_JVM)
|
|
|
|
else ifeq (SIZE, $$($1_$(notdir $2)_OPTIMIZATION))
|
|
|
|
$1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_SIZE)
|
|
|
|
$1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_SIZE)
|
|
|
|
else
|
|
|
|
$$(error Unknown value for OPTIMIZATION: $$($1_$(notdir $2)_OPTIMIZATION))
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($$($1_PRECOMPILED_HEADER), )
|
|
|
|
ifeq ($$(filter $$(notdir $2), $$($1_PRECOMPILED_HEADER_EXCLUDE)), )
|
|
|
|
$1_$2_USE_PCH_FLAGS := $$($1_USE_PCH_FLAGS)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$$(filter %.c,$2))
|
|
|
|
# Compile as a C file
|
2016-04-08 11:14:23 +00:00
|
|
|
$1_$2_FLAGS=$(CFLAGS_CCACHE) $$($1_$2_USE_PCH_FLAGS) $4 \
|
|
|
|
$$($1_$(notdir $2)_OPT_CFLAGS) \
|
|
|
|
$$($1_$(notdir $2)_CFLAGS) $$($1_$2_THIS_FILE) -c
|
2013-10-10 12:58:19 +00:00
|
|
|
$1_$2_COMP=$5
|
|
|
|
$1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
|
|
|
|
else ifneq (,$$(filter %.m,$2))
|
2015-03-04 09:47:36 +00:00
|
|
|
# Compile as an Objective-C file
|
2016-04-08 11:14:23 +00:00
|
|
|
$1_$2_FLAGS=-x objective-c $(CFLAGS_CCACHE) $$($1_$2_USE_PCH_FLAGS) $4 \
|
|
|
|
$$($1_$(notdir $2)_OPT_CFLAGS) \
|
|
|
|
$$($1_$(notdir $2)_CFLAGS) $$($1_$2_THIS_FILE) -c
|
2015-03-04 09:47:36 +00:00
|
|
|
$1_$2_COMP=$5
|
2013-10-10 12:58:19 +00:00
|
|
|
$1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
|
2016-02-02 14:02:55 +00:00
|
|
|
else ifneq (,$$(filter %.s %.S,$2))
|
2013-10-10 12:58:19 +00:00
|
|
|
# Compile as assembler file
|
2016-02-12 10:07:35 +00:00
|
|
|
$1_$2_FLAGS=$8
|
2013-10-10 12:58:19 +00:00
|
|
|
$1_$2_COMP=$(AS)
|
|
|
|
$1_$2_DEP_FLAG:=
|
2015-09-14 17:56:55 +00:00
|
|
|
else ifneq (,$$(filter %.cpp,$2)$$(filter %.cc,$2)$$(filter %.mm,$2))
|
2015-03-04 09:47:36 +00:00
|
|
|
# Compile as a C++ or Objective-C++ file
|
2016-04-08 11:14:23 +00:00
|
|
|
$1_$2_FLAGS=$(CFLAGS_CCACHE) $$($1_$2_USE_PCH_FLAGS) $6 \
|
|
|
|
$$($1_$(notdir $2)_OPT_CXXFLAGS) \
|
|
|
|
$$($1_$(notdir $2)_CXXFLAGS) $$($1_$2_THIS_FILE) -c
|
2013-10-10 12:58:19 +00:00
|
|
|
$1_$2_COMP=$7
|
|
|
|
$1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS)
|
2014-11-26 14:14:14 +00:00
|
|
|
else
|
|
|
|
$$(error Internal error in NativeCompilation.gmk: no compiler for file $2)
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
|
|
|
# Generate the .o (.obj) file name and place it in the bin dir.
|
2014-11-26 14:14:14 +00:00
|
|
|
$1_$2_OBJ := $3/$$(call replace_with_obj_extension, $$(notdir $2))
|
2013-10-10 12:58:19 +00:00
|
|
|
# Only continue if this object file hasn't been processed already. This lets the first found
|
|
|
|
# source file override any other with the same name.
|
2015-12-15 10:02:03 +00:00
|
|
|
ifeq (,$$(findstring $$($1_$2_OBJ),$$($1_OBJS_SO_FAR)))
|
|
|
|
$1_OBJS_SO_FAR+=$$($1_$2_OBJ)
|
2016-02-02 14:02:55 +00:00
|
|
|
ifeq (,$$(filter %.s %.S,$2))
|
2013-10-10 12:58:19 +00:00
|
|
|
# And this is the dependency file for this obj file.
|
|
|
|
$1_$2_DEP:=$$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ))
|
2015-02-06 11:37:31 +00:00
|
|
|
# The dependency target file lists all dependencies as empty targets
|
|
|
|
# to avoid make error "No rule to make target" for removed files
|
|
|
|
$1_$2_DEP_TARGETS:=$$(patsubst %$(OBJ_SUFFIX),%.d.targets,$$($1_$2_OBJ))
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
# Include previously generated dependency information. (if it exists)
|
|
|
|
-include $$($1_$2_DEP)
|
2015-02-06 11:37:31 +00:00
|
|
|
-include $$($1_$2_DEP_TARGETS)
|
2013-10-10 12:58:19 +00:00
|
|
|
|
2014-02-24 11:16:58 +00:00
|
|
|
ifeq ($(TOOLCHAIN_TYPE), microsoft)
|
2016-03-14 11:00:24 +00:00
|
|
|
# To avoid name clashes between pdbs for objects and libs/execs, put
|
|
|
|
# object pdbs in a separate subdir.
|
|
|
|
$1_$2_DEBUG_OUT_FLAGS:=-Fd$$(strip $$(patsubst $$($1_OBJECT_DIR)/%, \
|
|
|
|
$$($1_OBJECT_DIR)/pdb/%, $$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ))))
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2016-04-08 11:14:23 +00:00
|
|
|
ifneq ($$(strip $$($1_$(notdir $2)_CFLAGS) $$($1_$(notdir $2)_CXXFLAGS) \
|
|
|
|
$$($1_$(notdir $2)_OPTIMIZATION)), )
|
|
|
|
$1_$2_VARDEPS := $$($1_$(notdir $2)_CFLAGS) $$($1_$(notdir $2)_CXXFLAGS) \
|
|
|
|
$$($1_$(notdir $2)_OPT_CFLAGS) $$($1_$(notdir $2)_OPT_CXXFLAGS)
|
2015-12-15 10:02:03 +00:00
|
|
|
$1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, \
|
|
|
|
$$(patsubst %$(OBJ_SUFFIX),%.vardeps,$$($1_$2_OBJ)))
|
|
|
|
endif
|
|
|
|
|
|
|
|
$$($1_$2_OBJ) : $2 $$($1_COMPILE_VARDEPS_FILE) $$($1_$2_VARDEPS_FILE) | $$($1_BUILD_INFO)
|
|
|
|
$$(call LogInfo, Compiling $$(notdir $2) (for $$(notdir $$($1_TARGET))))
|
2016-03-14 11:00:24 +00:00
|
|
|
$$(call MakeDir, $$(@D) $$(@D)/pdb)
|
2014-02-24 11:16:58 +00:00
|
|
|
ifneq ($(TOOLCHAIN_TYPE), microsoft)
|
|
|
|
ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s,$2), solstudio)
|
2015-09-03 09:05:49 +00:00
|
|
|
# The Solaris studio compiler doesn't output the full path to the object file in the
|
|
|
|
# generated deps files. Fixing it with sed. If compiling assembly, don't try this.
|
2016-02-02 14:02:55 +00:00
|
|
|
$$(call ExecuteWithLog, $$@, \
|
2015-09-03 09:05:49 +00:00
|
|
|
$$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP).tmp $(CC_OUT_OPTION)$$($1_$2_OBJ) $2)
|
2013-10-10 12:58:19 +00:00
|
|
|
$(SED) 's|^$$(@F):|$$@:|' $$($1_$2_DEP).tmp > $$($1_$2_DEP)
|
2013-05-02 13:56:39 +00:00
|
|
|
else
|
2016-02-02 14:02:55 +00:00
|
|
|
$$(call ExecuteWithLog, $$@, \
|
2015-09-03 09:05:49 +00:00
|
|
|
$$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2)
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
2015-09-28 09:39:13 +00:00
|
|
|
# Create a dependency target file from the dependency file.
|
|
|
|
# Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
|
|
|
|
ifneq ($$($1_$2_DEP),)
|
|
|
|
$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS)
|
|
|
|
endif
|
2015-09-03 09:05:49 +00:00
|
|
|
else
|
|
|
|
# The Visual Studio compiler lacks a feature for generating make dependencies, but by
|
|
|
|
# setting -showIncludes, all included files are printed. These are filtered out and
|
|
|
|
# parsed into make dependences.
|
2016-01-16 12:01:43 +00:00
|
|
|
# Keep as much as possible on one execution line for best performance on Windows.
|
|
|
|
# No need to save exit code from compilation since pipefail is always active on
|
|
|
|
# Windows.
|
2016-02-02 14:02:55 +00:00
|
|
|
$$(call ExecuteWithLog, $$@, \
|
2015-09-03 09:05:49 +00:00
|
|
|
$$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) \
|
2016-01-16 12:01:43 +00:00
|
|
|
$(CC_OUT_OPTION)$$($1_$2_OBJ) $2) \
|
|
|
|
| $(GREP) -v -e "^Note: including file:" \
|
2015-09-03 09:05:49 +00:00
|
|
|
-e "^$(notdir $2)$$$$" || test "$$$$?" = "1" ; \
|
2016-01-16 12:01:43 +00:00
|
|
|
$(ECHO) $$@: \\ > $$($1_$2_DEP) ; \
|
|
|
|
$(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_$2_OBJ).log \
|
|
|
|
| $(SORT) -u >> $$($1_$2_DEP) ; \
|
2015-02-06 11:37:31 +00:00
|
|
|
$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS)
|
|
|
|
endif
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
2012-04-10 15:18:28 +00:00
|
|
|
endef
|
|
|
|
|
2014-11-26 13:59:10 +00:00
|
|
|
# Setup make rules for creating a native binary (a shared library or an
|
|
|
|
# executable).
|
|
|
|
#
|
|
|
|
# Parameter 1 is the name of the rule. This name is used as variable prefix,
|
|
|
|
# and the targets generated are listed in a variable by that name.
|
|
|
|
#
|
|
|
|
# Remaining parameters are named arguments. These include:
|
2015-04-17 11:54:50 +00:00
|
|
|
# TOOLCHAIN Name of toolchain setup to use. Defaults to TOOLCHAIN_DEFAULT.
|
2014-11-26 13:59:10 +00:00
|
|
|
# SRC one or more directory roots to scan for C/C++ files.
|
|
|
|
# CFLAGS the compiler flags to be used, used both for C and C++.
|
|
|
|
# CXXFLAGS the compiler flags to be used for c++, if set overrides CFLAGS.
|
|
|
|
# LDFLAGS the linker flags to be used, used both for C and C++.
|
2015-10-29 15:30:02 +00:00
|
|
|
# LIBS the libraries to link to
|
2014-11-26 13:59:10 +00:00
|
|
|
# ARFLAGS the archiver flags to be used
|
|
|
|
# OBJECT_DIR the directory where we store the object files
|
|
|
|
# LIBRARY the resulting library file
|
|
|
|
# PROGRAM the resulting exec file
|
|
|
|
# INCLUDES only pick source from these directories
|
|
|
|
# EXCLUDES do not pick source from these directories
|
|
|
|
# INCLUDE_FILES only compile exactly these files!
|
|
|
|
# EXCLUDE_FILES with these names
|
2015-12-15 10:02:03 +00:00
|
|
|
# EXCLUDE_PATTERN exclude files matching any of these substrings
|
2014-11-26 13:59:10 +00:00
|
|
|
# EXTRA_FILES List of extra files not in any of the SRC dirs
|
2015-12-15 10:02:03 +00:00
|
|
|
# EXTRA_OBJECT_FILES List of extra object files to include when linking
|
2014-11-26 13:59:10 +00:00
|
|
|
# VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run
|
|
|
|
# RC_FLAGS flags for RC.
|
2016-02-12 10:07:35 +00:00
|
|
|
# EMBED_MANIFEST if true, embed manifest on Windows.
|
2014-11-26 13:59:10 +00:00
|
|
|
# MAPFILE mapfile
|
|
|
|
# REORDER reorder file
|
2016-02-12 10:07:35 +00:00
|
|
|
# USE_MAPFILE_FOR_SYMBOLS if true and this is a STATIC_BUILD, just copy the
|
|
|
|
# mapfile for the output symbols file
|
2014-11-26 13:59:10 +00:00
|
|
|
# CC the compiler to use, default is $(CC)
|
2015-04-17 11:54:50 +00:00
|
|
|
# LD the linker to use, default is $(LD)
|
2016-04-08 11:14:23 +00:00
|
|
|
# OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST, HIGHEST_JVM, SIZE
|
2015-03-09 09:39:16 +00:00
|
|
|
# DISABLED_WARNINGS_<toolchain> Disable the given warnings for the specified toolchain
|
2015-11-24 11:18:24 +00:00
|
|
|
# DISABLED_WARNINGS_C_<toolchain> Disable the given warnings for the specified toolchain
|
|
|
|
# when compiling C code
|
|
|
|
# DISABLED_WARNINGS_CXX_<toolchain> Disable the given warnings for the specified
|
|
|
|
# toolchain when compiling C++ code
|
2015-09-28 13:51:29 +00:00
|
|
|
# STRIP_SYMBOLS Set to true to strip the final binary if the toolchain allows for it
|
2016-02-02 14:02:55 +00:00
|
|
|
# DEBUG_SYMBOLS Set to false to disable generation of debug symbols
|
2016-05-03 20:49:27 +00:00
|
|
|
# COPY_DEBUG_SYMBOLS Set to false to override global setting of debug symbol copying
|
|
|
|
# ZIP_EXTERNAL_DEBUG_SYMBOLS Set to false to override global setting of debug symbol
|
|
|
|
# zipping
|
2016-04-08 11:14:23 +00:00
|
|
|
# CFLAGS_DEBUG_SYMBOLS Overrides the default cflags for enabling debug symbols
|
|
|
|
# CXXFLAGS_DEBUG_SYMBOLS Overrides the default cxxflags for enabling debug symbols
|
2015-09-28 13:51:29 +00:00
|
|
|
# STRIPFLAGS Optionally change the flags given to the strip command
|
2016-04-08 11:14:23 +00:00
|
|
|
# PRECOMPILED_HEADER Header file to use as precompiled header
|
|
|
|
# PRECOMPILED_HEADER_EXCLUDE List of source files that should not use PCH
|
2015-03-12 11:13:23 +00:00
|
|
|
SetupNativeCompilation = $(NamedParamsMacroTemplate)
|
|
|
|
define SetupNativeCompilationBody
|
2012-07-03 23:11:12 +00:00
|
|
|
|
2015-10-19 17:21:27 +00:00
|
|
|
# If we're doing a static build and producing a library
|
|
|
|
# force it to be a static library and remove the -l libraries
|
|
|
|
ifeq ($(STATIC_BUILD), true)
|
|
|
|
ifneq ($$($1_LIBRARY),)
|
|
|
|
$1_STATIC_LIBRARY := $$($1_LIBRARY)
|
|
|
|
$1_LIBRARY :=
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$$($1_BIN))
|
|
|
|
$$(error BIN has been replaced with OBJECT_DIR)
|
|
|
|
endif
|
2012-07-03 23:11:12 +00:00
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$$($1_LIB))
|
|
|
|
$$(error LIB has been replaced with LIBRARY)
|
|
|
|
endif
|
2012-07-03 23:11:12 +00:00
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$$($1_EXE))
|
|
|
|
$$(error EXE has been replaced with PROGRAM)
|
|
|
|
endif
|
2012-07-03 23:11:12 +00:00
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$$($1_LIBRARY))
|
|
|
|
ifeq (,$$($1_OUTPUT_DIR))
|
|
|
|
$$(error LIBRARY requires OUTPUT_DIR)
|
2012-07-03 23:11:12 +00:00
|
|
|
endif
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq ($$($1_LIBRARY),$(basename $$($1_LIBRARY)))
|
|
|
|
$$(error directory of LIBRARY should be specified using OUTPUT_DIR)
|
2012-07-03 23:11:12 +00:00
|
|
|
endif
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$(findstring $(SHARED_LIBRARY_SUFFIX),$$($1_LIBRARY)))
|
|
|
|
$$(error LIBRARY should be specified without SHARED_LIBRARY_SUFFIX: $(SHARED_LIBRARY_SUFFIX))
|
|
|
|
endif
|
2012-07-03 23:11:12 +00:00
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$(findstring $(LIBRARY_PREFIX),$$($1_LIBRARY)))
|
|
|
|
$$(error LIBRARY should be specified without LIBRARY_PREFIX: $(LIBRARY_PREFIX))
|
|
|
|
endif
|
2012-07-03 23:11:12 +00:00
|
|
|
|
2014-11-26 14:14:14 +00:00
|
|
|
ifeq ($$($1_SUFFIX), )
|
|
|
|
$1_SUFFIX := $(SHARED_LIBRARY_SUFFIX)
|
|
|
|
endif
|
|
|
|
|
|
|
|
$1_BASENAME:=$(LIBRARY_PREFIX)$$($1_LIBRARY)$$($1_SUFFIX)
|
2013-10-10 12:58:19 +00:00
|
|
|
$1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME)
|
2014-01-14 11:05:32 +00:00
|
|
|
$1_NOSUFFIX:=$(LIBRARY_PREFIX)$$($1_LIBRARY)
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
2012-07-03 23:11:12 +00:00
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$$($1_STATIC_LIBRARY))
|
|
|
|
ifeq (,$$($1_OUTPUT_DIR))
|
|
|
|
$$(error STATIC_LIBRARY requires OUTPUT_DIR)
|
2012-07-03 23:11:12 +00:00
|
|
|
endif
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq ($$($1_STATIC_LIBRARY),$(basename $$($1_STATIC_LIBRARY)))
|
|
|
|
$$(error directory of STATIC_LIBRARY should be specified using OUTPUT_DIR)
|
2012-07-03 23:11:12 +00:00
|
|
|
endif
|
2012-04-10 15:18:28 +00:00
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$(findstring $(STATIC_LIBRARY_SUFFIX),$$($1_STATIC_LIBRARY)))
|
|
|
|
$$(error STATIC_LIBRARY should be specified without STATIC_LIBRARY_SUFFIX: $(STATIC_LIBRARY_SUFFIX))
|
2012-04-10 15:18:28 +00:00
|
|
|
endif
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$(findstring $(LIBRARY_PREFIX),$$($1_STATIC_LIBRARY)))
|
|
|
|
$$(error STATIC_LIBRARY should be specified without LIBRARY_PREFIX: $(LIBRARY_PREFIX))
|
2012-07-03 23:11:12 +00:00
|
|
|
endif
|
|
|
|
|
2014-11-26 14:14:14 +00:00
|
|
|
ifeq ($$($1_SUFFIX), )
|
|
|
|
$1_SUFFIX := $(STATIC_LIBRARY_SUFFIX)
|
|
|
|
endif
|
|
|
|
|
|
|
|
$1_BASENAME:=$(LIBRARY_PREFIX)$$($1_STATIC_LIBRARY)$$($1_SUFFIX)
|
2013-10-10 12:58:19 +00:00
|
|
|
$1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME)
|
2014-01-14 11:05:32 +00:00
|
|
|
$1_NOSUFFIX:=$(LIBRARY_PREFIX)$$($1_STATIC_LIBRARY)
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
2012-04-10 15:18:28 +00:00
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$$($1_PROGRAM))
|
|
|
|
ifeq (,$$($1_OUTPUT_DIR))
|
|
|
|
$$(error PROGRAM requires OUTPUT_DIR)
|
2012-10-26 21:29:57 +00:00
|
|
|
endif
|
2012-04-10 15:18:28 +00:00
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq ($$($1_PROGRAM),$(basename $$($1_PROGRAM)))
|
|
|
|
$$(error directory of PROGRAM should be specified using OUTPUT_DIR)
|
2012-04-10 15:18:28 +00:00
|
|
|
endif
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$(findstring $(EXE_SUFFIX),$$($1_PROGRAM)))
|
|
|
|
$$(error PROGRAM should be specified without EXE_SUFFIX: $(EXE_SUFFIX))
|
2012-04-10 15:18:28 +00:00
|
|
|
endif
|
|
|
|
|
2014-11-26 14:14:14 +00:00
|
|
|
ifeq ($$($1_SUFFIX), )
|
|
|
|
$1_SUFFIX := $(EXE_SUFFIX)
|
|
|
|
endif
|
|
|
|
|
|
|
|
$1_BASENAME:=$$($1_PROGRAM)$$($1_SUFFIX)
|
2013-10-10 12:58:19 +00:00
|
|
|
$1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME)
|
2014-01-14 11:05:32 +00:00
|
|
|
$1_NOSUFFIX:=$$($1_PROGRAM)
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
2015-09-25 06:58:49 +00:00
|
|
|
$1_SAFE_NAME := $$(strip $$(subst /,_, $1))
|
2012-04-10 15:18:28 +00:00
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifeq (,$$($1_TARGET))
|
|
|
|
$$(error Neither PROGRAM, LIBRARY nor STATIC_LIBRARY has been specified for SetupNativeCompilation)
|
|
|
|
endif
|
2012-06-08 03:25:06 +00:00
|
|
|
|
2015-04-17 11:54:50 +00:00
|
|
|
# Setup the toolchain to be used
|
|
|
|
$$(call SetIfEmpty, $1_TOOLCHAIN, TOOLCHAIN_DEFAULT)
|
|
|
|
$$(call SetIfEmpty, $1_CC, $$($$($1_TOOLCHAIN)_CC))
|
|
|
|
$$(call SetIfEmpty, $1_CXX, $$($$($1_TOOLCHAIN)_CXX))
|
|
|
|
$$(call SetIfEmpty, $1_LD, $$($$($1_TOOLCHAIN)_LD))
|
|
|
|
$$(call SetIfEmpty, $1_AR, $$($$($1_TOOLCHAIN)_AR))
|
|
|
|
$$(call SetIfEmpty, $1_AS, $$($$($1_TOOLCHAIN)_AS))
|
|
|
|
$$(call SetIfEmpty, $1_MT, $$($$($1_TOOLCHAIN)_MT))
|
|
|
|
$$(call SetIfEmpty, $1_RC, $$($$($1_TOOLCHAIN)_RC))
|
2016-03-17 19:03:53 +00:00
|
|
|
$$(call SetIfEmpty, $1_OBJCOPY, $$($$($1_TOOLCHAIN)_OBJCOPY))
|
2015-09-28 13:51:29 +00:00
|
|
|
$$(call SetIfEmpty, $1_STRIP, $$($$($1_TOOLCHAIN)_STRIP))
|
2015-04-17 11:54:50 +00:00
|
|
|
$$(call SetIfEmpty, $1_SYSROOT_CFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_CFLAGS))
|
|
|
|
$$(call SetIfEmpty, $1_SYSROOT_LDFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_LDFLAGS))
|
2013-10-10 12:58:19 +00:00
|
|
|
|
2015-04-16 12:48:01 +00:00
|
|
|
ifneq ($$($1_MANIFEST), )
|
|
|
|
ifeq ($$($1_MANIFEST_VERSION), )
|
|
|
|
$$(error If MANIFEST is provided, then MANIFEST_VERSION is required in $1)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
# Make sure the dirs exist.
|
2015-01-26 09:28:53 +00:00
|
|
|
$$(call MakeDir,$$($1_OBJECT_DIR) $$($1_OUTPUT_DIR))
|
2015-04-17 11:54:50 +00:00
|
|
|
$$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),, \
|
|
|
|
$$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d)))
|
2013-10-10 12:58:19 +00:00
|
|
|
|
|
|
|
# Find all files in the source trees. Sort to remove duplicates.
|
2015-12-15 10:02:03 +00:00
|
|
|
$1_SRCS := $$(sort $$(call CacheFind,$$($1_SRC)))
|
|
|
|
$1_SRCS := $$(filter $$(NATIVE_SOURCE_EXTENSIONS), $$($1_SRCS))
|
2013-10-10 12:58:19 +00:00
|
|
|
# Extract the C/C++ files.
|
2015-12-15 10:02:03 +00:00
|
|
|
ifneq ($$($1_EXCLUDE_PATTERNS), )
|
|
|
|
# We must not match the exclude pattern against the src root(s).
|
|
|
|
$1_SRCS_WITHOUT_ROOTS := $$($1_SRCS)
|
|
|
|
$$(foreach i,$$($1_SRC),$$(eval $1_SRCS_WITHOUT_ROOTS := $$(patsubst \
|
|
|
|
$$i/%,%, $$($1_SRCS_WITHOUT_ROOTS))))
|
|
|
|
$1_ALL_EXCLUDE_FILES := $$(call containing, $$($1_EXCLUDE_PATTERNS), \
|
|
|
|
$$($1_SRCS_WITHOUT_ROOTS))
|
|
|
|
endif
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq ($$($1_EXCLUDE_FILES),)
|
2015-12-15 10:02:03 +00:00
|
|
|
$1_ALL_EXCLUDE_FILES += $$($1_EXCLUDE_FILES)
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
2015-12-15 10:02:03 +00:00
|
|
|
ifneq ($$($1_ALL_EXCLUDE_FILES),)
|
|
|
|
$1_EXCLUDE_FILES_PAT := $$($1_ALL_EXCLUDE_FILES) \
|
|
|
|
$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_ALL_EXCLUDE_FILES)))
|
|
|
|
$1_EXCLUDE_FILES_PAT := $$(addprefix %,$$($1_EXCLUDE_FILES_PAT))
|
|
|
|
$1_SRCS := $$(filter-out $$($1_EXCLUDE_FILES_PAT),$$($1_SRCS))
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
2015-12-15 10:02:03 +00:00
|
|
|
ifneq ($$($1_INCLUDE_FILES), )
|
|
|
|
$1_INCLUDE_FILES_PAT := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_INCLUDE_FILES)))
|
|
|
|
$1_SRCS := $$(filter $$($1_INCLUDE_FILES_PAT),$$($1_SRCS))
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
|
|
|
# There can be only a single bin dir root, no need to foreach over the roots.
|
|
|
|
$1_BINS := $$(wildcard $$($1_OBJECT_DIR)/*$(OBJ_SUFFIX))
|
|
|
|
# Now we have a list of all c/c++ files to compile: $$($1_SRCS)
|
|
|
|
# and we have a list of all existing object files: $$($1_BINS)
|
|
|
|
|
|
|
|
# Prepend the source/bin path to the filter expressions. Then do the filtering.
|
|
|
|
ifneq ($$($1_INCLUDES),)
|
|
|
|
$1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES))))
|
|
|
|
$1_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS))
|
|
|
|
endif
|
|
|
|
ifneq ($$($1_EXCLUDES),)
|
2014-08-17 14:51:37 +00:00
|
|
|
$1_SRC_EXCLUDES := $$(addsuffix /%,$$($1_EXCLUDES))
|
|
|
|
$1_SRC_EXCLUDES += $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES))))
|
2013-10-10 12:58:19 +00:00
|
|
|
$1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
|
|
|
|
endif
|
|
|
|
|
2014-11-26 14:14:14 +00:00
|
|
|
$1_SRCS += $$($1_EXTRA_FILES)
|
|
|
|
|
2015-09-25 06:58:49 +00:00
|
|
|
ifeq (,$$($1_SRCS))
|
|
|
|
$$(error No sources found for $1 when looking inside the dirs $$($1_SRC))
|
|
|
|
endif
|
|
|
|
|
2015-12-15 10:02:03 +00:00
|
|
|
# Calculate the expected output from compiling the sources
|
2014-11-26 14:14:14 +00:00
|
|
|
$1_EXPECTED_OBJS_FILENAMES := $$(call replace_with_obj_extension, $$(notdir $$($1_SRCS)))
|
2015-12-15 10:02:03 +00:00
|
|
|
$1_EXPECTED_OBJS := $$(addprefix $$($1_OBJECT_DIR)/,$$($1_EXPECTED_OBJS_FILENAMES))
|
2013-10-10 12:58:19 +00:00
|
|
|
# Are there too many object files on disk? Perhaps because some source file was removed?
|
|
|
|
$1_SUPERFLOUS_OBJS:=$$(sort $$(filter-out $$($1_EXPECTED_OBJS),$$($1_BINS)))
|
|
|
|
# Clean out the superfluous object files.
|
|
|
|
ifneq ($$($1_SUPERFLUOUS_OBJS),)
|
|
|
|
$$(shell $(RM) -f $$($1_SUPERFLUOUS_OBJS))
|
|
|
|
endif
|
2015-12-15 10:02:03 +00:00
|
|
|
# Sort to remove dupliates and provide a reproducable order on the input files to the linker.
|
|
|
|
$1_ALL_OBJS := $$(sort $$($1_EXPECTED_OBJS) $$($1_EXTRA_OBJECT_FILES))
|
2013-10-10 12:58:19 +00:00
|
|
|
|
2014-11-21 15:05:46 +00:00
|
|
|
# Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables for CFLAGS.
|
|
|
|
$1_EXTRA_CFLAGS:=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CFLAGS_$(OPENJDK_TARGET_OS))
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq ($(DEBUG_LEVEL),release)
|
|
|
|
# Pickup extra debug dependent variables for CFLAGS
|
|
|
|
$1_EXTRA_CFLAGS+=$$($1_CFLAGS_debug)
|
2014-11-21 15:05:46 +00:00
|
|
|
$1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug)
|
2013-10-10 12:58:19 +00:00
|
|
|
$1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_debug)
|
|
|
|
else
|
|
|
|
$1_EXTRA_CFLAGS+=$$($1_CFLAGS_release)
|
2014-11-21 15:05:46 +00:00
|
|
|
$1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release)
|
2013-10-10 12:58:19 +00:00
|
|
|
$1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_release)
|
|
|
|
endif
|
|
|
|
|
2014-11-21 15:05:46 +00:00
|
|
|
# Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables for CXXFLAGS.
|
|
|
|
$1_EXTRA_CXXFLAGS:=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS))
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq ($(DEBUG_LEVEL),release)
|
|
|
|
# Pickup extra debug dependent variables for CXXFLAGS
|
|
|
|
$1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_debug)
|
2014-11-21 15:05:46 +00:00
|
|
|
$1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug)
|
2013-10-10 12:58:19 +00:00
|
|
|
$1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_debug)
|
|
|
|
else
|
|
|
|
$1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_release)
|
2014-11-21 15:05:46 +00:00
|
|
|
$1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release)
|
2013-10-10 12:58:19 +00:00
|
|
|
$1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_release)
|
|
|
|
endif
|
|
|
|
|
2015-06-11 14:37:11 +00:00
|
|
|
# If no C++ flags are explicitly set, default to using the C flags.
|
|
|
|
# After that, we can set additional C++ flags that should not interfere
|
|
|
|
# with the mechanism for copying the C flags by default.
|
|
|
|
ifeq ($$($1_CXXFLAGS),)
|
|
|
|
$1_CXXFLAGS:=$$($1_CFLAGS)
|
|
|
|
endif
|
|
|
|
ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)),)
|
|
|
|
$1_EXTRA_CXXFLAGS:=$$($1_EXTRA_CFLAGS)
|
|
|
|
endif
|
|
|
|
|
2016-01-20 08:53:52 +00:00
|
|
|
ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true)
|
2016-04-08 11:14:23 +00:00
|
|
|
$$(call SetIfEmpty, $1_CFLAGS_DEBUG_SYMBOLS, $(CFLAGS_DEBUG_SYMBOLS))
|
|
|
|
$$(call SetIfEmpty, $1_CXXFLAGS_DEBUG_SYMBOLS, $(CXXFLAGS_DEBUG_SYMBOLS))
|
|
|
|
$1_EXTRA_CFLAGS += $$($1_CFLAGS_DEBUG_SYMBOLS)
|
|
|
|
$1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_DEBUG_SYMBOLS)
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (,$$($1_REORDER))
|
|
|
|
$1_EXTRA_CFLAGS += $$(C_FLAG_REORDER)
|
|
|
|
$1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER)
|
|
|
|
endif
|
|
|
|
|
2015-10-19 17:21:27 +00:00
|
|
|
# Pass the library name for static JNI library naming
|
|
|
|
ifneq ($$($1_STATIC_LIBRARY),)
|
|
|
|
$1_EXTRA_CFLAGS += -DLIBRARY_NAME=$$($1_STATIC_LIBRARY)
|
|
|
|
$1_EXTRA_CXXFLAGS += -DLIBRARY_NAME=$$($1_STATIC_LIBRARY)
|
|
|
|
endif
|
|
|
|
|
2015-03-17 15:01:05 +00:00
|
|
|
# Pick up disabled warnings, if possible on this platform.
|
|
|
|
ifneq ($(DISABLE_WARNING_PREFIX),)
|
2015-11-24 11:18:24 +00:00
|
|
|
$1_EXTRA_CFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), \
|
|
|
|
$$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)) \
|
|
|
|
$$($1_DISABLED_WARNINGS_C_$(TOOLCHAIN_TYPE)))
|
|
|
|
$1_EXTRA_CXXFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), \
|
|
|
|
$$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)) \
|
|
|
|
$$($1_DISABLED_WARNINGS_CXX_$(TOOLCHAIN_TYPE)))
|
2015-03-17 15:01:05 +00:00
|
|
|
endif
|
|
|
|
|
2015-05-08 08:37:13 +00:00
|
|
|
# Check if warnings should be considered errors.
|
|
|
|
# Pick first binary and toolchain specific, then binary specific, then general setting.
|
|
|
|
ifeq ($$($1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE)),)
|
|
|
|
ifeq ($$($1_WARNINGS_AS_ERRORS),)
|
|
|
|
$1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE) := $$(WARNINGS_AS_ERRORS)
|
|
|
|
else
|
|
|
|
$1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE) := $$($1_WARNINGS_AS_ERRORS)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($$($1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE)), true)
|
|
|
|
$1_EXTRA_CFLAGS += $(CFLAGS_WARNINGS_ARE_ERRORS)
|
|
|
|
$1_EXTRA_CXXFLAGS += $(CFLAGS_WARNINGS_ARE_ERRORS)
|
|
|
|
endif
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
ifeq (NONE, $$($1_OPTIMIZATION))
|
2016-04-08 11:14:23 +00:00
|
|
|
$1_OPT_CFLAGS := $(C_O_FLAG_NONE)
|
|
|
|
$1_OPT_CXXFLAGS := $(CXX_O_FLAG_NONE)
|
2013-10-10 12:58:19 +00:00
|
|
|
else ifeq (LOW, $$($1_OPTIMIZATION))
|
2016-04-08 11:14:23 +00:00
|
|
|
$1_OPT_CFLAGS := $(C_O_FLAG_NORM)
|
|
|
|
$1_OPT_CXXFLAGS := $(CXX_O_FLAG_NORM)
|
2013-10-10 12:58:19 +00:00
|
|
|
else ifeq (HIGH, $$($1_OPTIMIZATION))
|
2016-04-08 11:14:23 +00:00
|
|
|
$1_OPT_CFLAGS := $(C_O_FLAG_HI)
|
|
|
|
$1_OPT_CXXFLAGS := $(CXX_O_FLAG_HI)
|
2013-10-10 12:58:19 +00:00
|
|
|
else ifeq (HIGHEST, $$($1_OPTIMIZATION))
|
2016-04-08 11:14:23 +00:00
|
|
|
$1_OPT_CFLAGS := $(C_O_FLAG_HIGHEST)
|
|
|
|
$1_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST)
|
|
|
|
else ifeq (HIGHEST_JVM, $$($1_OPTIMIZATION))
|
|
|
|
$1_OPT_CFLAGS := $(C_O_FLAG_HIGHEST_JVM)
|
|
|
|
$1_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST_JVM)
|
|
|
|
else ifeq (SIZE, $$($1_OPTIMIZATION))
|
|
|
|
$1_OPT_CFLAGS := $(C_O_FLAG_SIZE)
|
|
|
|
$1_OPT_CXXFLAGS := $(CXX_O_FLAG_SIZE)
|
2013-10-10 12:58:19 +00:00
|
|
|
else ifneq (, $$($1_OPTIMIZATION))
|
|
|
|
$$(error Unknown value for OPTIMIZATION: $$($1_OPTIMIZATION))
|
|
|
|
endif
|
|
|
|
|
2014-11-26 14:14:14 +00:00
|
|
|
$1_BUILD_INFO := $$($1_OBJECT_DIR)/_build-info.marker
|
|
|
|
|
2015-01-26 09:28:53 +00:00
|
|
|
# Track variable changes for all variables that affect the compilation command
|
2015-02-06 11:37:31 +00:00
|
|
|
# lines for all object files in this setup. This includes at least all the
|
2015-01-26 09:28:53 +00:00
|
|
|
# variables used in the call to add_native_source below.
|
2015-04-17 11:54:50 +00:00
|
|
|
$1_COMPILE_VARDEPS := $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $$($1_SYSROOT_CFLAGS) \
|
2016-04-08 11:14:23 +00:00
|
|
|
$$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) $$($1_OPT_CFLAGS) $$($1_OPT_CXXFLAGS) \
|
2015-12-15 10:02:03 +00:00
|
|
|
$$($1_CC) $$($1_CXX) $$($1_AS) $$($1_ASFLAGS)
|
2015-01-26 09:28:53 +00:00
|
|
|
$1_COMPILE_VARDEPS_FILE := $$(call DependOnVariable, $1_COMPILE_VARDEPS, \
|
|
|
|
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).comp.vardeps)
|
2014-03-28 13:59:56 +00:00
|
|
|
|
2016-04-08 11:14:23 +00:00
|
|
|
ifneq ($$($1_PRECOMPILED_HEADER), )
|
|
|
|
ifeq ($(USE_PRECOMPILED_HEADER), 1)
|
|
|
|
ifeq ($(TOOLCHAIN_TYPE), microsoft)
|
|
|
|
$1_PCH_FILE := $$($1_OBJECT_DIR)/$1.pch
|
|
|
|
$1_GENERATED_PCH_SRC := $$($1_OBJECT_DIR)/$1_pch.cpp
|
|
|
|
$1_GENERATED_PCH_OBJ := $$($1_OBJECT_DIR)/$1_pch.obj
|
|
|
|
|
|
|
|
$$(eval $$(call add_native_source,$1,$$($1_GENERATED_PCH_SRC), \
|
|
|
|
$$($1_OBJECT_DIR),,, \
|
|
|
|
$$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) $$($1_SYSROOT_CFLAGS) \
|
|
|
|
-Fp$$($1_PCH_FILE) -Yc$$(notdir $$($1_PRECOMPILED_HEADER)), \
|
|
|
|
$$($1_CXX),,no_this_file))
|
|
|
|
|
|
|
|
$1_USE_PCH_FLAGS := \
|
|
|
|
-Fp$$($1_PCH_FILE) -Yu$$(notdir $$($1_PRECOMPILED_HEADER))
|
|
|
|
|
|
|
|
$$($1_ALL_OBJS): $$($1_GENERATED_PCH_OBJ)
|
|
|
|
|
|
|
|
# Explicitly add the pch obj file first to ease comparing to old
|
|
|
|
# hotspot build.
|
|
|
|
$1_ALL_OBJS := $$($1_GENERATED_PCH_OBJ) $$($1_ALL_OBJS)
|
|
|
|
|
|
|
|
$$($1_GENERATED_PCH_SRC):
|
|
|
|
$(ECHO) "#include \"$$(notdir $$($1_PRECOMPILED_HEADER))\"" > $$@
|
|
|
|
|
|
|
|
else ifneq ($(findstring $(TOOLCHAIN_TYPE), gcc clang), )
|
|
|
|
ifeq ($(TOOLCHAIN_TYPE), gcc)
|
|
|
|
$1_PCH_FILE := $$($1_OBJECT_DIR)/precompiled/$$(notdir $$($1_PRECOMPILED_HEADER)).gch
|
|
|
|
$1_USE_PCH_FLAGS := -I$$($1_OBJECT_DIR)/precompiled
|
|
|
|
else ifeq ($(TOOLCHAIN_TYPE), clang)
|
|
|
|
$1_PCH_FILE := $$($1_OBJECT_DIR)/precompiled/$$(notdir $$($1_PRECOMPILED_HEADER)).pch
|
|
|
|
$1_USE_PCH_FLAGS := -include-pch $$($1_PCH_FILE)
|
|
|
|
endif
|
|
|
|
$1_PCH_DEP := $$($1_PCH_FILE).d
|
|
|
|
$1_PCH_DEP_TARGETS := $$($1_PCH_FILE).d.targets
|
|
|
|
|
|
|
|
-include $$($1_PCH_DEP)
|
|
|
|
-include $$($1_PCH_DEP_TARGETS)
|
|
|
|
|
|
|
|
$$($1_PCH_FILE): $$($1_PRECOMPILED_HEADER) $$($1_COMPILE_VARDEPS_FILE)
|
|
|
|
$$(call LogInfo, Generating precompiled header)
|
|
|
|
$$(call MakeDir, $$(@D))
|
|
|
|
$$(call ExecuteWithLog, $$@, \
|
|
|
|
$$($1_CC) $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $$($1_SYSROOT_CFLAGS) \
|
|
|
|
$$($1_OPT_CFLAGS) \
|
|
|
|
-x c++-header -c $(C_FLAG_DEPS) $$($1_PCH_DEP) $$< -o $$@)
|
|
|
|
$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_PCH_DEP) > $$($1_PCH_DEP_TARGETS)
|
|
|
|
|
|
|
|
$$($1_ALL_OBJS): $$($1_PCH_FILE)
|
|
|
|
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
# Now call add_native_source for each source file we are going to compile.
|
|
|
|
$$(foreach p,$$($1_SRCS), \
|
|
|
|
$$(eval $$(call add_native_source,$1,$$p,$$($1_OBJECT_DIR), \
|
2015-04-17 11:54:50 +00:00
|
|
|
$$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $$($1_SYSROOT_CFLAGS), \
|
2015-01-15 11:09:04 +00:00
|
|
|
$$($1_CC), \
|
2015-04-17 11:54:50 +00:00
|
|
|
$$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) $$($1_SYSROOT_CFLAGS), \
|
2015-03-04 09:47:36 +00:00
|
|
|
$$($1_CXX), $$($1_ASFLAGS))))
|
2013-10-10 12:58:19 +00:00
|
|
|
|
2015-01-26 09:28:53 +00:00
|
|
|
# Setup rule for printing progress info when compiling source files.
|
|
|
|
# This is a rough heuristic and may not always print accurate information.
|
|
|
|
$$($1_BUILD_INFO): $$($1_SRCS) $$($1_COMPILE_VARDEPS_FILE)
|
|
|
|
ifeq ($$(wildcard $$($1_TARGET)),)
|
|
|
|
$(ECHO) 'Creating $$($1_BASENAME) from $$(words $$(filter-out %.vardeps, $$?)) file(s)'
|
|
|
|
else
|
2015-02-06 11:37:31 +00:00
|
|
|
$(ECHO) $$(strip 'Updating $$($1_BASENAME)' \
|
|
|
|
$$(if $$(filter-out %.vardeps, $$?), \
|
2015-09-25 06:58:49 +00:00
|
|
|
'due to $$(words $$(filter-out %.vardeps, $$?)) file(s)', \
|
|
|
|
$$(if $$(filter %.vardeps, $$?), 'due to makefile changes')))
|
2015-01-26 09:28:53 +00:00
|
|
|
endif
|
|
|
|
$(TOUCH) $$@
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
# On windows we need to create a resource file
|
|
|
|
ifeq ($(OPENJDK_TARGET_OS), windows)
|
|
|
|
ifneq (,$$($1_VERSIONINFO_RESOURCE))
|
|
|
|
$1_RES:=$$($1_OBJECT_DIR)/$$($1_BASENAME).res
|
2014-11-26 14:14:14 +00:00
|
|
|
$1_RES_DEP:=$$($1_RES).d
|
2015-02-06 11:37:31 +00:00
|
|
|
$1_RES_DEP_TARGETS:=$$($1_RES).d.targets
|
2014-11-26 14:14:14 +00:00
|
|
|
-include $$($1_RES_DEP)
|
2015-02-06 11:37:31 +00:00
|
|
|
-include $$($1_RES_DEP_TARGETS)
|
2015-01-26 09:28:53 +00:00
|
|
|
|
2015-04-17 11:54:50 +00:00
|
|
|
$1_RES_VARDEPS := $$($1_RC) $$($1_RC_FLAGS)
|
2015-01-26 09:28:53 +00:00
|
|
|
$1_RES_VARDEPS_FILE := $$(call DependOnVariable, $1_RES_VARDEPS, \
|
|
|
|
$$($1_RES).vardeps)
|
|
|
|
|
|
|
|
$$($1_RES): $$($1_VERSIONINFO_RESOURCE) $$($1_RES_VARDEPS_FILE)
|
2016-01-16 12:01:43 +00:00
|
|
|
$$(call LogInfo, Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$(notdir $$($1_TARGET))))
|
2016-02-22 10:22:55 +00:00
|
|
|
$$(call MakeDir, $$(@D) $$($1_OBJECT_DIR))
|
2016-02-12 10:07:35 +00:00
|
|
|
$$(call ExecuteWithLog, $$@, \
|
|
|
|
$$($1_RC) $$($1_RC_FLAGS) $$($1_SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \
|
|
|
|
$$($1_VERSIONINFO_RESOURCE))
|
2016-05-13 07:21:20 +00:00
|
|
|
# Windows RC compiler does not support -showIncludes, so we mis-use CL
|
|
|
|
# for this. Filter out RC specific arguments that are unknown to CL.
|
|
|
|
# For some unknown reason, in this case CL actually outputs the show
|
|
|
|
# includes to stderr so need to redirect it to hide the output from the
|
|
|
|
# main log.
|
2016-02-22 10:22:55 +00:00
|
|
|
$$(call ExecuteWithLog, $$($1_RES_DEP).obj, \
|
2016-05-13 07:21:20 +00:00
|
|
|
$$($1_CC) $$(filter-out -l%, $$($1_RC_FLAGS)) \
|
|
|
|
$$($1_SYSROOT_CFLAGS) -showIncludes -nologo -TC \
|
|
|
|
$(CC_OUT_OPTION)$$($1_RES_DEP).obj -P -Fi$$($1_RES_DEP).pp \
|
|
|
|
$$($1_VERSIONINFO_RESOURCE)) 2>&1 \
|
|
|
|
| $(GREP) -v -e "^Note: including file:" \
|
|
|
|
-e "^$$(notdir $$($1_VERSIONINFO_RESOURCE))$$$$" || test "$$$$?" = "1" ; \
|
2016-01-16 12:01:43 +00:00
|
|
|
$(ECHO) $$($1_RES): \\ > $$($1_RES_DEP) ; \
|
2016-05-13 07:21:20 +00:00
|
|
|
$(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_RES_DEP).obj.log >> $$($1_RES_DEP) ; \
|
2015-02-06 11:37:31 +00:00
|
|
|
$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_RES_DEP) > $$($1_RES_DEP_TARGETS)
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
|
|
|
endif
|
2012-06-08 03:25:06 +00:00
|
|
|
|
2016-02-12 10:07:35 +00:00
|
|
|
ifneq ($(DISABLE_MAPFILES),true)
|
|
|
|
$1_REAL_MAPFILE := $$($1_MAPFILE)
|
2012-07-03 23:11:12 +00:00
|
|
|
ifneq ($(OPENJDK_TARGET_OS),windows)
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$$($1_REORDER))
|
2016-02-12 10:07:35 +00:00
|
|
|
$1_REAL_MAPFILE := $$($1_OBJECT_DIR)/mapfile
|
2012-06-08 03:25:06 +00:00
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
$$($1_REAL_MAPFILE) : $$($1_MAPFILE) $$($1_REORDER)
|
2016-02-22 10:22:55 +00:00
|
|
|
$$(call MakeDir, $$(@D))
|
2012-06-08 03:25:06 +00:00
|
|
|
$$(CP) $$($1_MAPFILE) $$@.tmp
|
2012-07-03 23:11:12 +00:00
|
|
|
$$(SED) -e 's=OUTPUTDIR=$$($1_OBJECT_DIR)=' $$($1_REORDER) >> $$@.tmp
|
2012-06-08 03:25:06 +00:00
|
|
|
$$(MV) $$@.tmp $$@
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2014-11-21 15:05:46 +00:00
|
|
|
# Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables
|
2015-10-29 15:30:02 +00:00
|
|
|
# for LDFLAGS and LIBS
|
2014-11-21 15:05:46 +00:00
|
|
|
$1_EXTRA_LDFLAGS:=$$($1_LDFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS))
|
2015-10-29 15:30:02 +00:00
|
|
|
$1_EXTRA_LIBS:=$$($1_LIBS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LIBS_$(OPENJDK_TARGET_OS))
|
2013-10-10 12:58:19 +00:00
|
|
|
ifneq (,$$($1_REAL_MAPFILE))
|
|
|
|
$1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE))
|
|
|
|
endif
|
|
|
|
|
2014-01-14 11:05:32 +00:00
|
|
|
# Need to make sure TARGET is first on list
|
2013-10-10 12:58:19 +00:00
|
|
|
$1 := $$($1_TARGET)
|
2016-02-02 14:02:55 +00:00
|
|
|
|
2016-05-03 20:49:27 +00:00
|
|
|
ifneq ($$($1_COPY_DEBUG_SYMBOLS), false)
|
|
|
|
$1_COPY_DEBUG_SYMBOLS := $(COPY_DEBUG_SYMBOLS)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
|
|
|
|
$1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($$($1_COPY_DEBUG_SYMBOLS), true)
|
2016-02-02 14:02:55 +00:00
|
|
|
ifneq ($$($1_DEBUG_SYMBOLS), false)
|
|
|
|
# Only copy debug symbols for dynamic libraries and programs.
|
|
|
|
ifeq ($$($1_STATIC_LIBRARY), )
|
|
|
|
ifneq ($$($1_OUTPUT_DIR), $$($1_OBJECT_DIR))
|
|
|
|
# The dependency on TARGET is needed on windows for debuginfo files
|
|
|
|
# to be rebuilt properly.
|
|
|
|
$$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% $$($1_TARGET)
|
2016-02-12 10:07:35 +00:00
|
|
|
# Use cp -r since on macosx, the dSYM is a directory
|
|
|
|
$(CP) -r $$< $$@
|
2016-02-02 14:02:55 +00:00
|
|
|
endif
|
2013-10-10 12:58:19 +00:00
|
|
|
|
2016-02-02 14:02:55 +00:00
|
|
|
# Generate debuginfo files.
|
|
|
|
ifeq ($(OPENJDK_TARGET_OS), windows)
|
2016-03-14 11:00:24 +00:00
|
|
|
$1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \
|
2016-02-02 14:02:55 +00:00
|
|
|
"-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map"
|
|
|
|
$1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
|
|
|
|
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
|
|
|
|
# No separate command is needed for debuginfo on windows, instead
|
|
|
|
# touch target to make sure it has a later time stamp than the debug
|
|
|
|
# symbol files to avoid unnecessary relinking on rebuild.
|
|
|
|
$1_CREATE_DEBUGINFO_CMDS := $(TOUCH) $$($1_TARGET)
|
|
|
|
|
|
|
|
else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
|
|
|
|
$1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
|
|
|
|
# Setup the command line creating debuginfo files, to be run after linking.
|
|
|
|
# It cannot be run separately since it updates the original target file
|
|
|
|
$1_CREATE_DEBUGINFO_CMDS := \
|
2016-03-17 19:03:53 +00:00
|
|
|
$$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
|
|
|
|
$(CD) $$($1_OUTPUT_DIR) && \
|
|
|
|
$$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
|
2016-02-02 14:02:55 +00:00
|
|
|
|
|
|
|
else ifeq ($(OPENJDK_TARGET_OS), macosx)
|
|
|
|
$1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_BASENAME).dSYM
|
|
|
|
# On Macosx, the debuginfo generation doesn't touch the linked binary, but
|
|
|
|
# to avoid always relinking, touch it anyway to force a later timestamp than
|
|
|
|
# the dSYM files.
|
|
|
|
$1_CREATE_DEBUGINFO_CMDS := \
|
|
|
|
$(DSYMUTIL) --out $$($1_DEBUGINFO_FILES) $$($1_TARGET) $$(NEWLINE) \
|
|
|
|
$(TOUCH) $$($1_TARGET)
|
|
|
|
endif # OPENJDK_TARGET_OS
|
|
|
|
|
|
|
|
# This dependency dance ensures that debug info files get rebuilt
|
|
|
|
# properly if deleted.
|
|
|
|
$$($1_TARGET): $$($1_DEBUGINFO_FILES)
|
|
|
|
$$($1_DEBUGINFO_FILES): $$($1_ALL_OBJS)
|
|
|
|
|
2016-05-03 20:49:27 +00:00
|
|
|
ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
|
2016-02-02 14:02:55 +00:00
|
|
|
$1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz
|
|
|
|
$1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP))
|
|
|
|
|
|
|
|
# The dependency on TARGET is needed for debuginfo files
|
|
|
|
# to be rebuilt properly.
|
|
|
|
$$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
|
2013-10-10 12:58:19 +00:00
|
|
|
$(CD) $$($1_OBJECT_DIR) \
|
2016-01-20 08:53:52 +00:00
|
|
|
&& $(ZIP) -q -r $$@ $$(notdir $$($1_DEBUGINFO_FILES))
|
2014-01-14 11:05:32 +00:00
|
|
|
|
2016-02-02 14:02:55 +00:00
|
|
|
else
|
|
|
|
$1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_FILES))
|
|
|
|
endif
|
|
|
|
endif # !STATIC_LIBRARY
|
|
|
|
endif # $1_DEBUG_SYMBOLS != false
|
2016-01-20 08:53:52 +00:00
|
|
|
endif # COPY_DEBUG_SYMBOLS
|
2014-01-14 11:05:32 +00:00
|
|
|
|
2015-09-28 13:51:29 +00:00
|
|
|
ifeq ($$($1_STRIP_SYMBOLS), true)
|
|
|
|
ifneq ($$($1_STRIP), )
|
|
|
|
# Default to using the global STRIPFLAGS. Allow for overriding with an empty value
|
|
|
|
$1_STRIPFLAGS ?= $(STRIPFLAGS)
|
|
|
|
$1_STRIP_CMD := $$($1_STRIP) $$($1_STRIPFLAGS) $$($1_TARGET)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2014-01-14 11:05:32 +00:00
|
|
|
ifneq (,$$($1_LIBRARY))
|
|
|
|
# Generating a dynamic library.
|
2014-12-03 14:20:21 +00:00
|
|
|
$1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
|
2014-01-14 11:05:32 +00:00
|
|
|
ifeq ($(OPENJDK_TARGET_OS), windows)
|
2014-12-03 14:20:21 +00:00
|
|
|
$1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib"
|
2012-07-03 23:11:12 +00:00
|
|
|
endif
|
|
|
|
|
2016-02-22 10:27:09 +00:00
|
|
|
# Create loadmap on AIX. Helps in diagnosing some problems.
|
|
|
|
ifneq ($(COMPILER_BINDCMD_FILE_FLAG),)
|
|
|
|
$1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap
|
|
|
|
endif
|
|
|
|
|
2015-04-17 11:54:50 +00:00
|
|
|
$1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
|
2015-10-29 15:30:02 +00:00
|
|
|
$$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_CREATE_DEBUGINFO_CMDS) \
|
2015-09-28 13:51:29 +00:00
|
|
|
$$($1_STRIP_CMD)
|
2015-01-26 09:28:53 +00:00
|
|
|
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
|
|
|
|
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
|
|
|
|
|
2015-12-15 10:02:03 +00:00
|
|
|
$1_LD_OBJ_ARG := $$($1_ALL_OBJS)
|
|
|
|
|
2016-01-08 08:46:02 +00:00
|
|
|
# If there are many object files, use an @-file...
|
2015-12-15 10:02:03 +00:00
|
|
|
ifneq ($$(word 17, $$($1_ALL_OBJS)), )
|
|
|
|
$1_OBJ_FILE_LIST := $$($1_OBJECT_DIR)/_$1_objectfilenames.txt
|
2016-01-08 08:46:02 +00:00
|
|
|
ifneq ($(COMPILER_COMMAND_FILE_FLAG),)
|
2015-12-15 10:02:03 +00:00
|
|
|
$1_LD_OBJ_ARG := $(COMPILER_COMMAND_FILE_FLAG)$$($1_OBJ_FILE_LIST)
|
|
|
|
else
|
2016-01-08 08:46:02 +00:00
|
|
|
# ...except for toolchains which don't support them.
|
2015-12-15 10:02:03 +00:00
|
|
|
$1_LD_OBJ_ARG := `cat $$($1_OBJ_FILE_LIST)`
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
$$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) \
|
2015-09-11 08:05:49 +00:00
|
|
|
$$($1_VARDEPS_FILE)
|
2015-12-15 10:02:03 +00:00
|
|
|
ifneq ($$($1_OBJ_FILE_LIST), )
|
|
|
|
$$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST)))
|
|
|
|
endif
|
|
|
|
# Keep as much as possible on one execution line for best performance
|
|
|
|
# on Windows
|
2016-01-16 12:01:43 +00:00
|
|
|
$$(call LogInfo, Linking $$($1_BASENAME))
|
2016-01-30 09:25:15 +00:00
|
|
|
ifeq ($(OPENJDK_TARGET_OS), windows)
|
2016-02-02 14:02:55 +00:00
|
|
|
$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
|
2016-01-30 09:25:15 +00:00
|
|
|
$$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
|
|
|
|
$(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \
|
|
|
|
$$($1_EXTRA_LIBS)) \
|
|
|
|
| $(GREP) -v "^ Creating library .*\.lib and object .*\.exp" || \
|
|
|
|
test "$$$$?" = "1" ; \
|
|
|
|
$$($1_CREATE_DEBUGINFO_CMDS)
|
|
|
|
$$($1_STRIP_CMD)
|
|
|
|
else
|
2016-02-02 14:02:55 +00:00
|
|
|
$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
|
2016-01-30 09:25:15 +00:00
|
|
|
$$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
|
|
|
|
$(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \
|
|
|
|
$$($1_EXTRA_LIBS)) ; \
|
|
|
|
$$($1_CREATE_DEBUGINFO_CMDS)
|
|
|
|
$$($1_STRIP_CMD)
|
|
|
|
endif
|
2013-10-10 12:58:19 +00:00
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (,$$($1_STATIC_LIBRARY))
|
2015-10-29 15:30:02 +00:00
|
|
|
$1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \
|
|
|
|
$$($1_EXTRA_LIBS)
|
2015-01-26 09:28:53 +00:00
|
|
|
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
|
|
|
|
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
|
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
# Generating a static library, ie object file archive.
|
2016-02-12 10:07:35 +00:00
|
|
|
ifeq ($(STATIC_BUILD), true)
|
|
|
|
ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
|
|
|
|
STATIC_MAPFILE_DEP := $$($1_MAPFILE)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
$$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP)
|
2016-01-16 12:01:43 +00:00
|
|
|
$$(call LogInfo, Archiving $$($1_STATIC_LIBRARY))
|
2016-02-02 14:02:55 +00:00
|
|
|
$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
|
2015-12-15 10:02:03 +00:00
|
|
|
$$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \
|
2015-10-19 17:21:27 +00:00
|
|
|
$$($1_RES))
|
|
|
|
ifeq ($(STATIC_BUILD), true)
|
2016-02-12 10:07:35 +00:00
|
|
|
ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
|
|
|
|
$(CP) $$($1_MAPFILE) $$(@D)/$$(basename $$(@F)).symbols
|
|
|
|
else
|
|
|
|
$(GetSymbols)
|
|
|
|
endif
|
2015-10-19 17:21:27 +00:00
|
|
|
endif
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (,$$($1_PROGRAM))
|
|
|
|
# A executable binary has been specified, setup the target for it.
|
2015-04-17 11:54:50 +00:00
|
|
|
$1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
|
2015-10-29 15:30:02 +00:00
|
|
|
$$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \
|
2015-09-28 13:51:29 +00:00
|
|
|
$$($1_CODESIGN) $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \
|
|
|
|
$$($1_STRIP_CMD)
|
2015-01-26 09:28:53 +00:00
|
|
|
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
|
|
|
|
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
|
|
|
|
|
2016-02-12 10:07:35 +00:00
|
|
|
ifeq ($(OPENJDK_TARGET_OS), windows)
|
|
|
|
ifeq ($$($1_EMBED_MANIFEST), true)
|
|
|
|
$1_EXTRA_LDFLAGS += -manifest:embed
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2015-12-15 10:02:03 +00:00
|
|
|
$$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
|
2015-09-11 08:05:49 +00:00
|
|
|
$$($1_VARDEPS_FILE)
|
2016-01-16 12:01:43 +00:00
|
|
|
$$(call LogInfo, Linking executable $$($1_BASENAME))
|
2016-02-02 14:02:55 +00:00
|
|
|
$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
|
2015-09-03 09:05:49 +00:00
|
|
|
$$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
|
|
|
|
$(EXE_OUT_OPTION)$$($1_TARGET) \
|
2015-12-15 10:02:03 +00:00
|
|
|
$$($1_ALL_OBJS) $$($1_RES) \
|
2015-10-29 15:30:02 +00:00
|
|
|
$$($1_LIBS) $$($1_EXTRA_LIBS))
|
2015-04-16 12:48:01 +00:00
|
|
|
ifeq ($(OPENJDK_TARGET_OS), windows)
|
|
|
|
ifneq ($$($1_MANIFEST), )
|
2015-04-17 11:54:50 +00:00
|
|
|
$$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_PROGRAM).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1
|
2015-04-16 12:48:01 +00:00
|
|
|
endif
|
2014-12-03 14:20:21 +00:00
|
|
|
endif
|
|
|
|
# This only works if the openjdk_codesign identity is present on the system. Let
|
|
|
|
# silently fail otherwise.
|
|
|
|
ifneq (,$(CODESIGN))
|
|
|
|
ifneq (,$$($1_CODESIGN))
|
|
|
|
$(CODESIGN) -s openjdk_codesign $$@
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
$$($1_CREATE_DEBUGINFO_CMDS)
|
2015-09-28 13:51:29 +00:00
|
|
|
$$($1_STRIP_CMD)
|
2014-01-14 11:05:32 +00:00
|
|
|
|
2013-10-10 12:58:19 +00:00
|
|
|
endif
|
2012-04-10 15:18:28 +00:00
|
|
|
endef
|
2014-08-17 14:51:37 +00:00
|
|
|
|
|
|
|
endif # _NATIVE_COMPILATION_GMK
|