NativeCompilation.gmk revision 1315:32470a815f99
1250199Sgrehan# 2298446Ssephe# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 3250199Sgrehan# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4250199Sgrehan# 5250199Sgrehan# This code is free software; you can redistribute it and/or modify it 6250199Sgrehan# under the terms of the GNU General Public License version 2 only, as 7250199Sgrehan# published by the Free Software Foundation. Oracle designates this 8250199Sgrehan# particular file as subject to the "Classpath" exception as provided 9250199Sgrehan# by Oracle in the LICENSE file that accompanied this code. 10250199Sgrehan# 11250199Sgrehan# This code is distributed in the hope that it will be useful, but WITHOUT 12250199Sgrehan# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13250199Sgrehan# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14250199Sgrehan# version 2 for more details (a copy is included in the LICENSE file that 15250199Sgrehan# accompanied this code). 16250199Sgrehan# 17250199Sgrehan# You should have received a copy of the GNU General Public License version 18250199Sgrehan# 2 along with this work; if not, write to the Free Software Foundation, 19250199Sgrehan# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20250199Sgrehan# 21250199Sgrehan# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22250199Sgrehan# or visit www.oracle.com if you need additional information or have any 23250199Sgrehan# questions. 24250199Sgrehan# 25250199Sgrehan 26250199Sgrehan# When you read this source. Remember that $(sort ...) has the side effect 27250199Sgrehan# of removing duplicates. It is actually this side effect that is 28250199Sgrehan# desired whenever sort is used below! 29256276Sdim 30256276Sdimifndef _NATIVE_COMPILATION_GMK 31256276Sdim_NATIVE_COMPILATION_GMK := 1 32250199Sgrehan 33296028Ssepheifeq (,$(_MAKEBASE_GMK)) 34250199Sgrehan $(error You must include MakeBase.gmk prior to including NativeCompilation.gmk) 35250199Sgrehanendif 36250199Sgrehan 37250199Sgrehan# Extensions of files handled by this macro. 38250199SgrehanNATIVE_SOURCE_EXTENSIONS := %.s %.c %.cpp %.m %.mm 39296181Ssephe 40301588Ssephe# Replaces native source extensions with the object file extension in a string. 41301588Ssephe# Param 1: the string containing source file names with extensions 42250199Sgrehan# The surrounding strip is needed to keep additional whitespace out 43301588Ssephedefine replace_with_obj_extension 44250199Sgrehan$(strip \ 45250199Sgrehan $(foreach extension, $(NATIVE_SOURCE_EXTENSIONS), \ 46250199Sgrehan $(patsubst $(extension),%$(OBJ_SUFFIX),$(filter $(extension),$1))) \ 47250199Sgrehan) 48300102Ssepheendef 49302619Ssephe 50301588Ssepheifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin) 51300102Ssephe UNIX_PATH_PREFIX := /cygdrive 52250199Sgrehanelse ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys) 53302731Ssephe UNIX_PATH_PREFIX := 54302692Ssepheendif 55302692Ssephe 56302864SsepheWINDOWS_SHOWINCLUDE_SED_PATTERN := \ 57302713Ssephe -e '/^Note: including file:/!d' \ 58302713Ssephe -e 's|Note: including file: *||' \ 59302864Ssephe -e 's|\\|/|g' \ 60250199Sgrehan -e 's|^\([a-zA-Z]\):|$(UNIX_PATH_PREFIX)/\1|g' \ 61302864Ssephe -e '/$(subst /,\/,$(TOPDIR))/!d' \ 62302864Ssephe -e 's|$$$$| \\|g' \ 63302864Ssephe # 64302864Ssephe 65302864Ssephedefine add_native_source 66302864Ssephe # param 1 = BUILD_MYPACKAGE 67302864Ssephe # parma 2 = the source file name (..../alfa.c or .../beta.cpp) 68302864Ssephe # param 3 = the bin dir that stores all .o (.obj) and .d files. 69302864Ssephe # param 4 = the c flags to the compiler 70302864Ssephe # param 5 = the c compiler 71302864Ssephe # param 6 = the c++ flags to the compiler 72302864Ssephe # param 7 = the c++ compiler 73302864Ssephe # param 8 = the objc compiler 74302864Ssephe # param 9 = the flags to the assembler 75302864Ssephe 76302864Ssephe ifneq (,$$(filter %.c,$2)) 77302864Ssephe # Compile as a C file 78302864Ssephe $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c 79250199Sgrehan $1_$2_COMP=$5 80250199Sgrehan $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) 81250199Sgrehan else ifneq (,$$(filter %.m,$2)) 82250199Sgrehan # Compile as a objective-c file 83302731Ssephe $1_$2_FLAGS=-x objective-c $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c 84250199Sgrehan $1_$2_COMP=$8 85302618Ssephe $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) 86302693Ssephe else ifneq (,$$(filter %.s,$2)) 87302618Ssephe # Compile as assembler file 88302618Ssephe $1_$2_FLAGS=$9 -DTHIS_FILE='"$$(<F)"' 89302618Ssephe $1_$2_COMP=$(AS) 90302618Ssephe $1_$2_DEP_FLAG:= 91302695Ssephe else ifneq (,$$(filter %.cpp,$2)$$(filter %.mm,$2)) 92302731Ssephe # Compile as a C++ file 93302731Ssephe $1_$2_FLAGS=$6 $$($1_$(notdir $2)_CXXFLAGS) -DTHIS_FILE='"$$(<F)"' -c 94302731Ssephe $1_$2_COMP=$7 95250199Sgrehan $1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS) 96302726Ssephe else 97250199Sgrehan $$(error Internal error in NativeCompilation.gmk: no compiler for file $2) 98250199Sgrehan endif 99250199Sgrehan # Generate the .o (.obj) file name and place it in the bin dir. 100296289Ssephe $1_$2_OBJ := $3/$$(call replace_with_obj_extension, $$(notdir $2)) 101296289Ssephe # Only continue if this object file hasn't been processed already. This lets the first found 102296289Ssephe # source file override any other with the same name. 103296289Ssephe ifeq (,$$(findstring $$($1_$2_OBJ),$$($1_ALL_OBJS))) 104296289Ssephe $1_ALL_OBJS+=$$($1_$2_OBJ) 105296289Ssephe ifeq (,$$(filter %.s,$2)) 106302695Ssephe # And this is the dependency file for this obj file. 107296289Ssephe $1_$2_DEP:=$$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ)) 108296289Ssephe # Include previously generated dependency information. (if it exists) 109296289Ssephe -include $$($1_$2_DEP) 110296289Ssephe 111296181Ssephe ifeq ($(TOOLCHAIN_TYPE), microsoft) 112296290Ssephe $1_$2_DEBUG_OUT_FLAGS:=-Fd$$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ)) \ 113296181Ssephe -Fm$$(patsubst %$(OBJ_SUFFIX),%.map,$$($1_$2_OBJ)) 114296181Ssephe endif 115296181Ssephe endif 116296181Ssephe 117296181Ssephe $$($1_$2_OBJ) : $2 $$($1_COMPILE_VARDEPS_FILE) | $$($1_BUILD_INFO) 118296181Ssephe $(ECHO) $(LOG_INFO) "Compiling $$(notdir $2) (for $$(notdir $$($1_TARGET)))" 119296181Ssephe ifneq ($(TOOLCHAIN_TYPE), microsoft) 120296181Ssephe # The Solaris studio compiler doesn't output the full path to the object file in the 121296181Ssephe # generated deps files. Fixing it with sed. If compiling assembly, don't try this. 122296181Ssephe ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s,$2), solstudio) 123302819Ssephe $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP).tmp $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 124296181Ssephe $(SED) 's|^$$(@F):|$$@:|' $$($1_$2_DEP).tmp > $$($1_$2_DEP) 125296181Ssephe else 126302706Ssephe $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 127302693Ssephe endif 128296181Ssephe endif 129302706Ssephe # The Visual Studio compiler lacks a feature for generating make dependencies, but by 130302693Ssephe # setting -showIncludes, all included files are printed. These are filtered out and 131302694Ssephe # parsed into make dependences. 132296181Ssephe ifeq ($(TOOLCHAIN_TYPE), microsoft) 133302633Ssephe ($$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) \ 134302633Ssephe $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 ; echo $$$$? > $$($1_$2_DEP).exitvalue) \ 135296181Ssephe | $(TEE) $$($1_$2_DEP).raw | $(GREP) -v -e "^Note: including file:" \ 136296181Ssephe -e "^$(notdir $2)$$$$" || test "$$$$?" = "1" ; \ 137296181Ssephe exit `cat $$($1_$2_DEP).exitvalue` 138298693Ssephe $(RM) $$($1_$2_DEP).exitvalue 139296181Ssephe ($(ECHO) $$@: \\ \ 140296181Ssephe && $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_$2_DEP).raw) > $$($1_$2_DEP) 141296181Ssephe endif 142296181Ssephe endif 143298693Ssepheendef 144296181Ssephe 145296181Ssephe# Setup make rules for creating a native binary (a shared library or an 146296181Ssephe# executable). 147296181Ssephe# 148298693Ssephe# Parameter 1 is the name of the rule. This name is used as variable prefix, 149296181Ssephe# and the targets generated are listed in a variable by that name. 150296181Ssephe# 151296181Ssephe# Remaining parameters are named arguments. These include: 152298693Ssephe# SRC one or more directory roots to scan for C/C++ files. 153296188Ssephe# LANG C or C++ 154296188Ssephe# CFLAGS the compiler flags to be used, used both for C and C++. 155296188Ssephe# CXXFLAGS the compiler flags to be used for c++, if set overrides CFLAGS. 156302693Ssephe# LDFLAGS the linker flags to be used, used both for C and C++. 157296181Ssephe# LDFLAGS_SUFFIX the linker flags to be added last on the commandline 158296188Ssephe# typically the libraries linked to. 159296188Ssephe# ARFLAGS the archiver flags to be used 160296289Ssephe# OBJECT_DIR the directory where we store the object files 161298693Ssephe# LIBRARY the resulting library file 162298693Ssephe# PROGRAM the resulting exec file 163296289Ssephe# INCLUDES only pick source from these directories 164296188Ssephe# EXCLUDES do not pick source from these directories 165296181Ssephe# INCLUDE_FILES only compile exactly these files! 166296181Ssephe# EXCLUDE_FILES with these names 167296181Ssephe# EXTRA_FILES List of extra files not in any of the SRC dirs 168296181Ssephe# VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run 169298693Ssephe# RC_FLAGS flags for RC. 170296181Ssephe# MAPFILE mapfile 171296181Ssephe# REORDER reorder file 172296181Ssephe# DEBUG_SYMBOLS add debug symbols (if configured on) 173296181Ssephe# CC the compiler to use, default is $(CC) 174298693Ssephe# LDEXE the linker to use for linking executables, default is $(LDEXE) 175296181Ssephe# OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST 176296181Ssephedefine SetupNativeCompilation 177296181Ssephe $(if $(27),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk)) 178296181Ssephe $(call EvalDebugWrapper,$(strip $1),$(call SetupNativeCompilationInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15),$(16),$(17),$(18),$(19),$(20),$(21),$(22),$(23),$(24),$(25),$(26))) 179296181Ssepheendef 180296181Ssephe 181296181Ssephedefine SetupNativeCompilationInner 182296181Ssephe $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) 183296181Ssephe $(call LogSetupMacroEntry,SetupNativeCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15),$(16),$(17),$(18),$(19),$(20),$(21),$(22),$(23),$(24),$(25),$(26)) 184296290Ssephe $(if $(27),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk)) 185250199Sgrehan 186250199Sgrehan ifneq (,$$($1_BIN)) 187250199Sgrehan $$(error BIN has been replaced with OBJECT_DIR) 188250199Sgrehan endif 189250199Sgrehan 190250199Sgrehan ifneq (,$$($1_LIB)) 191250199Sgrehan $$(error LIB has been replaced with LIBRARY) 192250199Sgrehan endif 193250199Sgrehan 194250199Sgrehan ifneq (,$$($1_EXE)) 195250199Sgrehan $$(error EXE has been replaced with PROGRAM) 196250199Sgrehan endif 197250199Sgrehan 198302607Ssephe ifneq (,$$($1_LIBRARY)) 199302607Ssephe ifeq (,$$($1_OUTPUT_DIR)) 200302607Ssephe $$(error LIBRARY requires OUTPUT_DIR) 201302607Ssephe endif 202302607Ssephe 203302607Ssephe ifneq ($$($1_LIBRARY),$(basename $$($1_LIBRARY))) 204250199Sgrehan $$(error directory of LIBRARY should be specified using OUTPUT_DIR) 205250199Sgrehan endif 206250199Sgrehan 207302607Ssephe ifneq (,$(findstring $(SHARED_LIBRARY_SUFFIX),$$($1_LIBRARY))) 208302607Ssephe $$(error LIBRARY should be specified without SHARED_LIBRARY_SUFFIX: $(SHARED_LIBRARY_SUFFIX)) 209302607Ssephe endif 210302693Ssephe 211302607Ssephe ifneq (,$(findstring $(LIBRARY_PREFIX),$$($1_LIBRARY))) 212302607Ssephe $$(error LIBRARY should be specified without LIBRARY_PREFIX: $(LIBRARY_PREFIX)) 213302607Ssephe endif 214302812Ssephe 215302812Ssephe ifeq ($$($1_SUFFIX), ) 216302812Ssephe $1_SUFFIX := $(SHARED_LIBRARY_SUFFIX) 217282212Swhu endif 218250199Sgrehan 219250199Sgrehan $1_BASENAME:=$(LIBRARY_PREFIX)$$($1_LIBRARY)$$($1_SUFFIX) 220250199Sgrehan $1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME) 221302692Ssephe $1_NOSUFFIX:=$(LIBRARY_PREFIX)$$($1_LIBRARY) 222300102Ssephe endif 223302557Ssephe 224300646Ssephe ifneq (,$$($1_STATIC_LIBRARY)) 225302713Ssephe ifeq (,$$($1_OUTPUT_DIR)) 226302713Ssephe $$(error STATIC_LIBRARY requires OUTPUT_DIR) 227302713Ssephe endif 228302713Ssephe 229302713Ssephe ifneq ($$($1_STATIC_LIBRARY),$(basename $$($1_STATIC_LIBRARY))) 230302713Ssephe $$(error directory of STATIC_LIBRARY should be specified using OUTPUT_DIR) 231302713Ssephe endif 232294886Ssephe 233250199Sgrehan ifneq (,$(findstring $(STATIC_LIBRARY_SUFFIX),$$($1_STATIC_LIBRARY))) 234250199Sgrehan $$(error STATIC_LIBRARY should be specified without STATIC_LIBRARY_SUFFIX: $(STATIC_LIBRARY_SUFFIX)) 235256350Sgrehan endif 236250199Sgrehan 237250199Sgrehan ifneq (,$(findstring $(LIBRARY_PREFIX),$$($1_STATIC_LIBRARY))) 238302812Ssephe $$(error STATIC_LIBRARY should be specified without LIBRARY_PREFIX: $(LIBRARY_PREFIX)) 239302812Ssephe endif 240302812Ssephe 241302812Ssephe ifeq ($$($1_SUFFIX), ) 242250199Sgrehan $1_SUFFIX := $(STATIC_LIBRARY_SUFFIX) 243250199Sgrehan endif 244250199Sgrehan 245250199Sgrehan $1_BASENAME:=$(LIBRARY_PREFIX)$$($1_STATIC_LIBRARY)$$($1_SUFFIX) 246256350Sgrehan $1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME) 247256350Sgrehan $1_NOSUFFIX:=$(LIBRARY_PREFIX)$$($1_STATIC_LIBRARY) 248256350Sgrehan endif 249256350Sgrehan 250250199Sgrehan ifneq (,$$($1_PROGRAM)) 251250199Sgrehan ifeq (,$$($1_OUTPUT_DIR)) 252250199Sgrehan $$(error PROGRAM requires OUTPUT_DIR) 253250199Sgrehan endif 254250199Sgrehan 255250199Sgrehan ifneq ($$($1_PROGRAM),$(basename $$($1_PROGRAM))) 256250199Sgrehan $$(error directory of PROGRAM should be specified using OUTPUT_DIR) 257250199Sgrehan endif 258250199Sgrehan 259250199Sgrehan ifneq (,$(findstring $(EXE_SUFFIX),$$($1_PROGRAM))) 260250199Sgrehan $$(error PROGRAM should be specified without EXE_SUFFIX: $(EXE_SUFFIX)) 261296290Ssephe endif 262296290Ssephe 263296181Ssephe ifeq ($$($1_SUFFIX), ) 264250199Sgrehan $1_SUFFIX := $(EXE_SUFFIX) 265250199Sgrehan endif 266250199Sgrehan 267250199Sgrehan $1_BASENAME:=$$($1_PROGRAM)$$($1_SUFFIX) 268250199Sgrehan $1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME) 269250199Sgrehan $1_NOSUFFIX:=$$($1_PROGRAM) 270250199Sgrehan endif 271250199Sgrehan 272250199Sgrehan ifeq (,$$($1_TARGET)) 273250199Sgrehan $$(error Neither PROGRAM, LIBRARY nor STATIC_LIBRARY has been specified for SetupNativeCompilation) 274302607Ssephe endif 275302607Ssephe 276250199Sgrehan ifeq (,$$($1_LANG)) 277302607Ssephe $$(error You have to specify LANG for native compilation $1) 278302607Ssephe endif 279302607Ssephe ifeq (C,$$($1_LANG)) 280302607Ssephe ifeq ($$($1_LDEXE),) 281302693Ssephe $1_LDEXE:=$(LDEXE) 282302812Ssephe endif 283302812Ssephe ifeq ($$($1_LD),) 284302607Ssephe $1_LD:=$(LD) 285250199Sgrehan endif 286302607Ssephe else 287302607Ssephe ifeq (C++,$$($1_LANG)) 288302693Ssephe ifeq ($$($1_LD),) 289302693Ssephe $1_LD:=$(LDCXX) 290302607Ssephe endif 291302607Ssephe ifeq ($$($1_LDEXE),) 292302607Ssephe $1_LDEXE:=$(LDEXECXX) 293250199Sgrehan endif 294302607Ssephe else 295250199Sgrehan $$(error Unknown native language $$($1_LANG) for $1) 296302607Ssephe endif 297302607Ssephe endif 298302607Ssephe 299302607Ssephe ifeq ($$($1_CC),) 300302693Ssephe $1_CC:=$(CC) 301302607Ssephe endif 302302812Ssephe ifeq ($$($1_CXX),) 303302607Ssephe $1_CXX:=$(CXX) 304250199Sgrehan endif 305302607Ssephe ifeq ($$($1_OBJC),) 306302607Ssephe $1_OBJC:=$(OBJC) 307302607Ssephe endif 308250199Sgrehan 309302607Ssephe # Make sure the dirs exist. 310250199Sgrehan $$(call MakeDir,$$($1_OBJECT_DIR) $$($1_OUTPUT_DIR)) 311302607Ssephe $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d))) 312302607Ssephe 313302607Ssephe # Find all files in the source trees. Sort to remove duplicates. 314302693Ssephe $1_ALL_SRCS := $$(sort $$(call CacheFind,$$($1_SRC))) 315302607Ssephe # Extract the C/C++ files. 316302812Ssephe $1_EXCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_EXCLUDE_FILES))) 317250199Sgrehan $1_INCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_INCLUDE_FILES))) 318302812Ssephe ifneq ($$($1_EXCLUDE_FILES),) 319302812Ssephe $1_EXCLUDE_FILES:=$$(addprefix %,$$($1_EXCLUDE_FILES)) 320302812Ssephe endif 321302812Ssephe $1_SRCS := $$(filter-out $$($1_EXCLUDE_FILES),$$(filter $$(NATIVE_SOURCE_EXTENSIONS),$$($1_ALL_SRCS))) 322302812Ssephe ifneq (,$$(strip $$($1_INCLUDE_FILES))) 323302812Ssephe $1_SRCS := $$(filter $$($1_INCLUDE_FILES),$$($1_SRCS)) 324302812Ssephe endif 325302812Ssephe ifeq (,$$($1_SRCS)) 326250199Sgrehan $$(error No sources found for $1 when looking inside the dirs $$($1_SRC)) 327250199Sgrehan endif 328250199Sgrehan # There can be only a single bin dir root, no need to foreach over the roots. 329302609Ssephe $1_BINS := $$(wildcard $$($1_OBJECT_DIR)/*$(OBJ_SUFFIX)) 330250199Sgrehan # Now we have a list of all c/c++ files to compile: $$($1_SRCS) 331302609Ssephe # and we have a list of all existing object files: $$($1_BINS) 332302609Ssephe 333302871Ssephe # Prepend the source/bin path to the filter expressions. Then do the filtering. 334250199Sgrehan ifneq ($$($1_INCLUDES),) 335302871Ssephe $1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES)))) 336302871Ssephe $1_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS)) 337302871Ssephe endif 338302871Ssephe ifneq ($$($1_EXCLUDES),) 339302871Ssephe $1_SRC_EXCLUDES := $$(addsuffix /%,$$($1_EXCLUDES)) 340302871Ssephe $1_SRC_EXCLUDES += $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES)))) 341302871Ssephe $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS)) 342302871Ssephe endif 343302871Ssephe 344302609Ssephe $1_SRCS += $$($1_EXTRA_FILES) 345302609Ssephe 346302609Ssephe # Calculate the expected output from compiling the sources (sort to remove duplicates. Also provides 347302609Ssephe # a reproducable order on the input files to the linker). 348302609Ssephe $1_EXPECTED_OBJS_FILENAMES := $$(call replace_with_obj_extension, $$(notdir $$($1_SRCS))) 349302609Ssephe $1_EXPECTED_OBJS:=$$(sort $$(addprefix $$($1_OBJECT_DIR)/,$$($1_EXPECTED_OBJS_FILENAMES))) 350302871Ssephe # Are there too many object files on disk? Perhaps because some source file was removed? 351250199Sgrehan $1_SUPERFLOUS_OBJS:=$$(sort $$(filter-out $$($1_EXPECTED_OBJS),$$($1_BINS))) 352302609Ssephe # Clean out the superfluous object files. 353302609Ssephe ifneq ($$($1_SUPERFLUOUS_OBJS),) 354302609Ssephe $$(shell $(RM) -f $$($1_SUPERFLUOUS_OBJS)) 355250199Sgrehan endif 356302609Ssephe 357302871Ssephe # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables for CFLAGS. 358250199Sgrehan $1_EXTRA_CFLAGS:=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CFLAGS_$(OPENJDK_TARGET_OS)) 359250199Sgrehan ifneq ($(DEBUG_LEVEL),release) 360302609Ssephe # Pickup extra debug dependent variables for CFLAGS 361302609Ssephe $1_EXTRA_CFLAGS+=$$($1_CFLAGS_debug) 362302609Ssephe $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug) 363250199Sgrehan $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_debug) 364302609Ssephe else 365302609Ssephe $1_EXTRA_CFLAGS+=$$($1_CFLAGS_release) 366302609Ssephe $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release) 367302609Ssephe $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_release) 368302609Ssephe endif 369302609Ssephe 370302609Ssephe # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables for CXXFLAGS. 371302609Ssephe $1_EXTRA_CXXFLAGS:=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)) 372250199Sgrehan ifneq ($(DEBUG_LEVEL),release) 373250199Sgrehan # Pickup extra debug dependent variables for CXXFLAGS 374302609Ssephe $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_debug) 375302609Ssephe $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug) 376302609Ssephe $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_debug) 377302630Ssephe else 378302609Ssephe $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_release) 379250199Sgrehan $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release) 380302609Ssephe $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_release) 381302609Ssephe endif 382302609Ssephe 383302609Ssephe ifeq ($$($1_DEBUG_SYMBOLS), true) 384302609Ssephe ifeq ($(ENABLE_DEBUG_SYMBOLS), true) 385302609Ssephe ifdef OPENJDK 386302609Ssephe # Always add debug symbols 387302609Ssephe $1_EXTRA_CFLAGS+=$(CFLAGS_DEBUG_SYMBOLS) 388302609Ssephe $1_EXTRA_CXXFLAGS+=$(CXXFLAGS_DEBUG_SYMBOLS) 389302609Ssephe else 390302609Ssephe # Programs don't get the debug symbols added in the old build. It's not clear if 391302609Ssephe # this is intentional. 392302609Ssephe ifeq ($$($1_PROGRAM),) 393250199Sgrehan $1_EXTRA_CFLAGS+=$(CFLAGS_DEBUG_SYMBOLS) 394302609Ssephe $1_EXTRA_CXXFLAGS+=$(CXXFLAGS_DEBUG_SYMBOLS) 395302609Ssephe endif 396302609Ssephe endif 397302609Ssephe endif 398302609Ssephe endif 399302609Ssephe 400302871Ssephe ifeq ($$($1_CXXFLAGS),) 401302609Ssephe $1_CXXFLAGS:=$$($1_CFLAGS) 402250199Sgrehan endif 403250199Sgrehan ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)),) 404302609Ssephe $1_EXTRA_CXXFLAGS:=$$($1_EXTRA_CFLAGS) 405302609Ssephe endif 406302871Ssephe 407302609Ssephe ifneq (,$$($1_REORDER)) 408302609Ssephe $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER) 409302609Ssephe $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER) 410302609Ssephe endif 411302609Ssephe 412302609Ssephe ifeq (NONE, $$($1_OPTIMIZATION)) 413302609Ssephe $1_EXTRA_CFLAGS += $(C_O_FLAG_NONE) 414250199Sgrehan $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_NONE) 415302609Ssephe else ifeq (LOW, $$($1_OPTIMIZATION)) 416302609Ssephe $1_EXTRA_CFLAGS += $(C_O_FLAG_NORM) 417302609Ssephe $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_NORM) 418302609Ssephe else ifeq (HIGH, $$($1_OPTIMIZATION)) 419302871Ssephe $1_EXTRA_CFLAGS += $(C_O_FLAG_HI) 420302609Ssephe $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_HI) 421302609Ssephe else ifeq (HIGHEST, $$($1_OPTIMIZATION)) 422302609Ssephe $1_EXTRA_CFLAGS += $(C_O_FLAG_HIGHEST) 423250199Sgrehan $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_HIGHEST) 424302609Ssephe else ifneq (, $$($1_OPTIMIZATION)) 425302609Ssephe $$(error Unknown value for OPTIMIZATION: $$($1_OPTIMIZATION)) 426250199Sgrehan endif 427302609Ssephe 428302609Ssephe $1_BUILD_INFO := $$($1_OBJECT_DIR)/_build-info.marker 429302609Ssephe 430302609Ssephe # Track variable changes for all variables that affect the compilation command 431302609Ssephe # lines for all object files in this setup. This includes at least all the 432250199Sgrehan # variables used in the call to add_native_source below. 433302609Ssephe $1_COMPILE_VARDEPS := $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $(SYSROOT_CFLAGS) \ 434302609Ssephe $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) \ 435302609Ssephe $$($1_CC) $$($1_CXX) $$($1_OBJC) $$($1_ASFLAGS) \ 436250199Sgrehan $$(foreach s, $$($1_SRCS), \ 437302609Ssephe $$($1_$$(notdir $$s)_CFLAGS) $$($1_$$(notdir $$s)_CXXFLAGS)) 438302609Ssephe $1_COMPILE_VARDEPS_FILE := $$(call DependOnVariable, $1_COMPILE_VARDEPS, \ 439302609Ssephe $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).comp.vardeps) 440302609Ssephe 441302609Ssephe # Now call add_native_source for each source file we are going to compile. 442250199Sgrehan $$(foreach p,$$($1_SRCS), \ 443302609Ssephe $$(eval $$(call add_native_source,$1,$$p,$$($1_OBJECT_DIR), \ 444250199Sgrehan $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $(SYSROOT_CFLAGS), \ 445302609Ssephe $$($1_CC), \ 446250199Sgrehan $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) $(SYSROOT_CFLAGS), \ 447302609Ssephe $$($1_CXX),$$($1_OBJC),$$($1_ASFLAGS)))) 448302609Ssephe 449302609Ssephe # Setup rule for printing progress info when compiling source files. 450250199Sgrehan # This is a rough heuristic and may not always print accurate information. 451302609Ssephe $$($1_BUILD_INFO): $$($1_SRCS) $$($1_COMPILE_VARDEPS_FILE) 452250199Sgrehan ifeq ($$(wildcard $$($1_TARGET)),) 453302609Ssephe $(ECHO) 'Creating $$($1_BASENAME) from $$(words $$(filter-out %.vardeps, $$?)) file(s)' 454302609Ssephe else 455302871Ssephe $(ECHO) 'Updating $$($1_BASENAME) from $$(words $$(filter-out %.vardeps, $$?)) file(s)' 456302609Ssephe endif 457302632Ssephe $(TOUCH) $$@ 458302632Ssephe 459302632Ssephe # On windows we need to create a resource file 460302871Ssephe ifeq ($(OPENJDK_TARGET_OS), windows) 461302632Ssephe ifneq (,$$($1_VERSIONINFO_RESOURCE)) 462302609Ssephe $1_RES:=$$($1_OBJECT_DIR)/$$($1_BASENAME).res 463302609Ssephe $1_RES_DEP:=$$($1_RES).d 464250199Sgrehan -include $$($1_RES_DEP) 465250199Sgrehan 466302611Ssephe $1_RES_VARDEPS := $(RC) $$($1_RC_FLAGS) 467302611Ssephe $1_RES_VARDEPS_FILE := $$(call DependOnVariable, $1_RES_VARDEPS, \ 468250199Sgrehan $$($1_RES).vardeps) 469250199Sgrehan 470302611Ssephe $$($1_RES): $$($1_VERSIONINFO_RESOURCE) $$($1_RES_VARDEPS_FILE) 471250199Sgrehan $(ECHO) $(LOG_INFO) "Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$(notdir $$($1_TARGET)))" 472302611Ssephe $(RC) $$($1_RC_FLAGS) $(SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \ 473302611Ssephe $$($1_VERSIONINFO_RESOURCE) 474302611Ssephe # Windows RC compiler does not support -showIncludes, so we mis-use CL for this. 475302611Ssephe $(CC) $$($1_RC_FLAGS) $(SYSROOT_CFLAGS) -showIncludes -nologo -TC \ 476250199Sgrehan $(CC_OUT_OPTION)$$($1_RES_DEP).obj $$($1_VERSIONINFO_RESOURCE) > $$($1_RES_DEP).raw 2>&1 || exit 0 477302611Ssephe ($(ECHO) $$($1_RES): \\ \ 478302611Ssephe && $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_RES_DEP).raw) > $$($1_RES_DEP) 479302611Ssephe endif 480302611Ssephe ifneq (,$$($1_MANIFEST)) 481302693Ssephe $1_GEN_MANIFEST:=$$($1_OBJECT_DIR)/$$($1_PROGRAM).manifest 482302611Ssephe IMVERSIONVALUE:=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VERSION).$(COOKED_BUILD_NUMBER) 483250199Sgrehan $1_MANIFEST_VARDEPS_FILE := $$(call DependOnVariable, IMVERSIONVALUE, \ 484250199Sgrehan $$($1_GEN_MANIFEST).vardeps) 485302611Ssephe $$($1_GEN_MANIFEST): $$($1_MANIFEST) $$($1_MANIFEST_VARDEPS_FILE) 486302611Ssephe $(SED) 's%IMVERSION%$$(IMVERSIONVALUE)%g;s%PROGRAM%$$($1_PROGRAM)%g' $$< > $$@ 487302693Ssephe endif 488302611Ssephe endif 489250199Sgrehan 490302611Ssephe # mapfile doesnt seem to be implemented on macosx (yet??) 491302611Ssephe ifneq ($(OPENJDK_TARGET_OS),macosx) 492302611Ssephe ifneq ($(OPENJDK_TARGET_OS),windows) 493302611Ssephe $1_REAL_MAPFILE:=$$($1_MAPFILE) 494302693Ssephe ifneq (,$$($1_REORDER)) 495302611Ssephe $1_REAL_MAPFILE:=$$($1_OBJECT_DIR)/mapfile 496302611Ssephe 497302611Ssephe $$($1_REAL_MAPFILE) : $$($1_MAPFILE) $$($1_REORDER) 498250199Sgrehan $$(MKDIR) -p $$(@D) 499302611Ssephe $$(CP) $$($1_MAPFILE) $$@.tmp 500302611Ssephe $$(SED) -e 's=OUTPUTDIR=$$($1_OBJECT_DIR)=' $$($1_REORDER) >> $$@.tmp 501302611Ssephe $$(MV) $$@.tmp $$@ 502250199Sgrehan endif 503302611Ssephe endif 504250199Sgrehan endif 505250199Sgrehan 506282212Swhu # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables 507282212Swhu # for LDFLAGS and LDFLAGS_SUFFIX 508250199Sgrehan $1_EXTRA_LDFLAGS:=$$($1_LDFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS)) 509302610Ssephe $1_EXTRA_LDFLAGS_SUFFIX:=$$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS)) 510302610Ssephe ifneq (,$$($1_REAL_MAPFILE)) 511302610Ssephe $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE)) 512294886Ssephe endif 513302610Ssephe 514250199Sgrehan # Need to make sure TARGET is first on list 515302812Ssephe $1 := $$($1_TARGET) 516302812Ssephe ifeq ($$($1_STATIC_LIBRARY),) 517302812Ssephe ifeq ($$($1_DEBUG_SYMBOLS), true) 518302633Ssephe ifeq ($(ENABLE_DEBUG_SYMBOLS), true) 519282212Swhu ifneq ($(OPENJDK_TARGET_OS), macosx) # no MacOS X support yet 520282212Swhu ifneq ($$($1_OUTPUT_DIR),$$($1_OBJECT_DIR)) 521294886Ssephe # The dependency on TARGET is needed on windows for debuginfo files 522294886Ssephe # to be rebuilt properly. 523294886Ssephe $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% $$($1_TARGET) 524294886Ssephe $(CP) $$< $$@ 525250199Sgrehan endif 526250199Sgrehan 527250199Sgrehan # Generate debuginfo files. 528250199Sgrehan ifeq ($(OPENJDK_TARGET_OS), windows) 529250199Sgrehan $1_EXTRA_LDFLAGS += "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \ 530250199Sgrehan "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map" 531302610Ssephe $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \ 532302610Ssephe $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map 533302610Ssephe 534302610Ssephe else ifeq ($(OPENJDK_TARGET_OS), solaris) 535302693Ssephe $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo 536302610Ssephe # Setup the command line creating debuginfo files, to be run after linking. 537302610Ssephe # It cannot be run separately since it updates the original target file 538250199Sgrehan # 539302610Ssephe # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. 540302610Ssephe # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from 541302693Ssephe # empty section headers until a fixed $(OBJCOPY) is available. 542250199Sgrehan # An empty section header has sh_addr == 0 and sh_size == 0. 543302610Ssephe # This problem has only been seen on Solaris X64, but we call this tool 544302610Ssephe # on all Solaris builds just in case. 545302610Ssephe # 546302610Ssephe # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. 547302610Ssephe # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. 548302610Ssephe $1_CREATE_DEBUGINFO_CMDS := \ 549302693Ssephe $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$($1_TARGET) $$(NEWLINE) \ 550302610Ssephe $(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \ 551302610Ssephe $(CD) $$($1_OUTPUT_DIR) && \ 552302610Ssephe $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$($1_DEBUGINFO_FILES) $$($1_TARGET) 553302693Ssephe $1_DEBUGINFO_EXTRA_DEPS := $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) 554302610Ssephe 555302610Ssephe else ifeq ($(OPENJDK_TARGET_OS), linux) 556250199Sgrehan $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo 557250199Sgrehan # Setup the command line creating debuginfo files, to be run after linking. 558250199Sgrehan # It cannot be run separately since it updates the original target file 559250199Sgrehan $1_CREATE_DEBUGINFO_CMDS := \ 560250199Sgrehan $(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \ 561250199Sgrehan $(CD) $$($1_OUTPUT_DIR) && \ 562250199Sgrehan $(OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET) 563250199Sgrehan 564250199Sgrehan endif # No MacOS X support 565250199Sgrehan 566250199Sgrehan # This dependency dance ensures that debug info files get rebuilt 567250199Sgrehan # properly if deleted. 568256350Sgrehan $$($1_TARGET): $$($1_DEBUGINFO_FILES) 569256350Sgrehan $$($1_DEBUGINFO_FILES): $$($1_EXPECTED_OBJS) 570282212Swhu 571250199Sgrehan ifeq ($(ZIP_DEBUGINFO_FILES), true) 572302818Ssephe $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz 573302818Ssephe $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP)) 574302818Ssephe 575302818Ssephe # The dependency on TARGET is needed for debuginfo files 576282212Swhu # to be rebuilt properly. 577282212Swhu $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET) 578302818Ssephe $(CD) $$($1_OBJECT_DIR) \ 579282212Swhu && $(ZIP) -q $$@ $$(notdir $$($1_DEBUGINFO_FILES)) 580302818Ssephe 581282212Swhu else 582302818Ssephe $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_FILES)) 583282212Swhu endif 584302818Ssephe endif 585302818Ssephe endif # !MacOS X 586282212Swhu endif # $1_DEBUG_SYMBOLS 587282212Swhu endif # !STATIC_LIBRARY 588282212Swhu 589282212Swhu ifneq (,$$($1_LIBRARY)) 590250199Sgrehan # Generating a dynamic library. 591302818Ssephe $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME)) 592250199Sgrehan ifeq ($(OPENJDK_TARGET_OS), windows) 593302819Ssephe $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib" 594302818Ssephe endif 595302818Ssephe 596302818Ssephe $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX) 597302818Ssephe 598302818Ssephe $1_VARDEPS := $$($1_LD) $(SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \ 599302818Ssephe $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) 600302818Ssephe $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ 601302818Ssephe $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) 602250199Sgrehan 603302818Ssephe $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) \ 604302818Ssephe $$($1_DEBUGINFO_EXTRA_DEPS) $$($1_VARDEPS_FILE) 605302818Ssephe $(ECHO) $(LOG_INFO) "Linking $$($1_BASENAME)" 606250199Sgrehan $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(SYSROOT_LDFLAGS) \ 607250199Sgrehan $(LD_OUT_OPTION)$$@ \ 608250199Sgrehan $$($1_EXPECTED_OBJS) $$($1_RES) \ 609250199Sgrehan $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) 610250199Sgrehan $$($1_CREATE_DEBUGINFO_CMDS) 611250199Sgrehan # Touch target to make sure it has a later time stamp than the debug 612250199Sgrehan # symbol files to avoid unnecessary relinking on rebuild. 613250199Sgrehan ifeq ($(OPENJDK_TARGET_OS), windows) 614250199Sgrehan $(TOUCH) $$@ 615250199Sgrehan endif 616250199Sgrehan 617250199Sgrehan endif 618250199Sgrehan 619250199Sgrehan ifneq (,$$($1_STATIC_LIBRARY)) 620250199Sgrehan $1_VARDEPS := $(AR) $$($1_ARFLAGS) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) 621250199Sgrehan $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ 622250199Sgrehan $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) 623250199Sgrehan 624250199Sgrehan # Generating a static library, ie object file archive. 625282212Swhu $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) 626302870Ssephe $(ECHO) $(LOG_INFO) "Archiving $$($1_STATIC_LIBRARY)" 627250199Sgrehan $(AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_EXPECTED_OBJS) \ 628250199Sgrehan $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) 629250199Sgrehan endif 630250199Sgrehan 631250199Sgrehan ifneq (,$$($1_PROGRAM)) 632250199Sgrehan # A executable binary has been specified, setup the target for it. 633250199Sgrehan $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX) 634250199Sgrehan 635250199Sgrehan $1_VARDEPS := $$($1_LDEXE) $(SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \ 636250199Sgrehan $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) 637250199Sgrehan $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ 638250199Sgrehan $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) 639250199Sgrehan 640302870Ssephe $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_GEN_MANIFEST) \ 641302870Ssephe $$($1_DEBUGINFO_EXTRA_DEPS) $$($1_VARDEPS_FILE) 642250199Sgrehan $(ECHO) $(LOG_INFO) "Linking executable $$($1_BASENAME)" 643302870Ssephe $$($1_LDEXE) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(SYSROOT_LDFLAGS) \ 644302870Ssephe $(EXE_OUT_OPTION)$$($1_TARGET) \ 645250199Sgrehan $$($1_EXPECTED_OBJS) $$($1_RES) \ 646302870Ssephe $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) 647302870Ssephe ifneq (,$$($1_GEN_MANIFEST)) 648250199Sgrehan $(MT) -nologo -manifest $$($1_GEN_MANIFEST) -outputresource:$$@;#1 649302870Ssephe endif 650250199Sgrehan # This only works if the openjdk_codesign identity is present on the system. Let 651250199Sgrehan # silently fail otherwise. 652302731Ssephe ifneq (,$(CODESIGN)) 653302731Ssephe ifneq (,$$($1_CODESIGN)) 654250199Sgrehan $(CODESIGN) -s openjdk_codesign $$@ 655250199Sgrehan endif 656250199Sgrehan endif 657250199Sgrehan $$($1_CREATE_DEBUGINFO_CMDS) 658250199Sgrehan # Touch target to make sure it has a later time stamp than the debug 659250199Sgrehan # symbol files to avoid unnecessary relinking on rebuild. 660250199Sgrehan ifeq ($(OPENJDK_TARGET_OS), windows) 661250199Sgrehan $(TOUCH) $$@ 662250199Sgrehan endif 663250199Sgrehan 664250199Sgrehan endif 665250199Sgrehanendef 666250199Sgrehan 667250199Sgrehanendif # _NATIVE_COMPILATION_GMK 668250199Sgrehan