make/common/NativeCompilation.gmk
branchihse-nativecompilation-branch
changeset 56723 d927981eeb64
parent 56198 89aab97c5335
parent 50128 ea4e6d3dbf60
equal deleted inserted replaced
56198:89aab97c5335 56723:d927981eeb64
   148 # Param 1: the string containing source file names with extensions
   148 # Param 1: the string containing source file names with extensions
   149 # The surrounding strip is needed to keep additional whitespace out
   149 # The surrounding strip is needed to keep additional whitespace out
   150 define replace_with_obj_extension
   150 define replace_with_obj_extension
   151 $(strip \
   151 $(strip \
   152   $(foreach extension, $(NATIVE_SOURCE_EXTENSIONS), \
   152   $(foreach extension, $(NATIVE_SOURCE_EXTENSIONS), \
   153       $(patsubst $(extension),%$(OBJ_SUFFIX),$(filter $(extension),$1))) \
   153       $(patsubst $(extension),%$(OBJ_SUFFIX), $(filter $(extension), $1))) \
   154 )
   154 )
   155 endef
   155 endef
   156 
   156 
   157 ifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin)
   157 ifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin)
   158   UNIX_PATH_PREFIX := /cygdrive
   158   UNIX_PATH_PREFIX := /cygdrive
   181     -e 's/^[	 ]*//' \
   181     -e 's/^[	 ]*//' \
   182     -e '/^$$$$/ d' \
   182     -e '/^$$$$/ d' \
   183     -e 's/$$$$/ :/' \
   183     -e 's/$$$$/ :/' \
   184     #
   184     #
   185 
   185 
   186 define add_native_source
   186 ################################################################################
   187   # param 1 = BUILD_MYPACKAGE
   187 # Create the recipe needed to compile a single native source file.
   188   # parma 2 = the source file name (..../alfa.c or .../beta.cpp)
   188 #
   189   # param 3 = the bin dir that stores all .o (.obj) and .d files.
   189 # Parameter 1 is the name of the rule, based on the name of the library/
   190   # param 4 = the c flags to the compiler
   190 # program being build and the name of the source code file, e.g.
   191   # param 5 = the c compiler
   191 # BUILD_LIBFOO_fooMain.cpp.
   192   # param 6 = the c++ flags to the compiler
   192 #
   193   # param 7 = the c++ compiler
   193 # Remaining parameters are named arguments:
   194   # param 8 = the flags to the assembler
   194 #   FILE - The full path of the source file to compiler
   195   # param 9 = set to disable THIS_FILE
   195 #   BASE - The name of the rule for the entire binary to build ($1)
   196 
   196 #   DISABLE_THIS_FILE_DEFINE - Set to true to disable the THIS_FILE define.
   197   ifeq ($9, )
   197 #
   198     $1_$2_THIS_FILE = -DTHIS_FILE='"$$(<F)"'
   198 SetupCompileNativeFile = $(NamedParamsMacroTemplate)
   199   endif
   199 define SetupCompileNativeFileBody
   200 
   200   $1_FILENAME := $$(notdir $$($1_FILE))
   201   ifeq ($$($1_$(notdir $2)_OPTIMIZATION), )
   201 
   202     $1_$(notdir $2)_OPT_CFLAGS := $$($1_OPT_CFLAGS)
   202   # The target file to be generated.
   203     $1_$(notdir $2)_OPT_CXXFLAGS := $$($1_OPT_CXXFLAGS)
   203   $1_OBJ := $$($$($1_BASE)_OBJECT_DIR)/$$(call replace_with_obj_extension, \
   204   else
   204       $$($1_FILENAME))
   205     ifeq (NONE, $$($1_$(notdir $2)_OPTIMIZATION))
   205 
   206       $1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_NONE)
   206   # Only continue if this object file hasn't been processed already. This lets
   207       $1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_NONE)
   207   # the first found source file override any other with the same name.
   208     else ifeq (LOW, $$($1_$(notdir $2)_OPTIMIZATION))
   208   ifeq ($$(findstring $$($1_OBJ), $$($$($1_BASE)_OBJS_SO_FAR)), )
   209       $1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_NORM)
   209     $$($1_BASE)_OBJS_SO_FAR += $$($1_OBJ)
   210       $1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_NORM)
   210     # This is the definite source file to use for $1_FILENAME.
   211     else ifeq (HIGH, $$($1_$(notdir $2)_OPTIMIZATION))
   211     $1_SRC_FILE := $$($1_FILE)
   212       $1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_HI)
   212 
   213       $1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_HI)
   213     ifneq ($$($1_DISABLE_THIS_FILE_DEFINE), true)
   214     else ifeq (HIGHEST, $$($1_$(notdir $2)_OPTIMIZATION))
   214       $1_THIS_FILE = -DTHIS_FILE='"$$(<F)"'
   215       $1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_HIGHEST)
   215     endif
   216       $1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST)
   216 
   217     else ifeq (HIGHEST_JVM, $$($1_$(notdir $2)_OPTIMIZATION))
   217     ifeq ($$($1_OPTIMIZATION), )
   218       $1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_HIGHEST_JVM)
   218       $1_OPT_CFLAGS := $$($$($1_BASE)_OPT_CFLAGS)
   219       $1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST_JVM)
   219       $1_OPT_CXXFLAGS := $$($$($1_BASE)_OPT_CXXFLAGS)
   220     else ifeq (SIZE, $$($1_$(notdir $2)_OPTIMIZATION))
       
   221       $1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_SIZE)
       
   222       $1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_SIZE)
       
   223     else
   220     else
   224       $$(error Unknown value for OPTIMIZATION: $$($1_$(notdir $2)_OPTIMIZATION))
   221       ifeq ($$($1_OPTIMIZATION), NONE)
   225     endif
   222         $1_OPT_CFLAGS := $(C_O_FLAG_NONE)
   226   endif
   223         $1_OPT_CXXFLAGS := $(CXX_O_FLAG_NONE)
   227 
   224       else ifeq ($$($1_OPTIMIZATION), LOW)
   228   ifneq ($$($1_PRECOMPILED_HEADER), )
   225         $1_OPT_CFLAGS := $(C_O_FLAG_NORM)
   229     ifeq ($$(filter $$(notdir $2), $$($1_PRECOMPILED_HEADER_EXCLUDE)), )
   226         $1_OPT_CXXFLAGS := $(CXX_O_FLAG_NORM)
   230       $1_$2_USE_PCH_FLAGS := $$($1_USE_PCH_FLAGS)
   227       else ifeq ($$($1_OPTIMIZATION), HIGH)
   231     endif
   228         $1_OPT_CFLAGS := $(C_O_FLAG_HI)
   232   endif
   229         $1_OPT_CXXFLAGS := $(CXX_O_FLAG_HI)
   233 
   230       else ifeq ($$($1_OPTIMIZATION), HIGHEST)
   234   ifneq ($$(filter %.c, $2), )
   231         $1_OPT_CFLAGS := $(C_O_FLAG_HIGHEST)
   235     # Compile as a C file
   232         $1_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST)
   236     $1_$2_FLAGS := $(CFLAGS_CCACHE) $$($1_$2_USE_PCH_FLAGS) $4 \
   233       else ifeq ($$($1_OPTIMIZATION), HIGHEST_JVM)
   237         $$($1_$(notdir $2)_OPT_CFLAGS) \
   234         $1_OPT_CFLAGS := $(C_O_FLAG_HIGHEST_JVM)
   238         $$($1_$(notdir $2)_CFLAGS) $$($1_$2_THIS_FILE) -c
   235         $1_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST_JVM)
   239     $1_$2_COMP := $5
   236       else ifeq ($$($1_OPTIMIZATION), SIZE)
   240     $1_$2_DEP_FLAG := $(C_FLAG_DEPS)
   237         $1_OPT_CFLAGS := $(C_O_FLAG_SIZE)
   241   else ifneq ($$(filter %.m, $2), )
   238         $1_OPT_CXXFLAGS := $(CXX_O_FLAG_SIZE)
   242     # Compile as an Objective-C file
   239       else
   243     $1_$2_FLAGS := -x objective-c $(CFLAGS_CCACHE) $$($1_$2_USE_PCH_FLAGS) $4 \
   240         $$(error Unknown value for file OPTIMIZATION: $$($1_OPTIMIZATION))
   244         $$($1_$(notdir $2)_OPT_CFLAGS) \
   241       endif
   245         $$($1_$(notdir $2)_CFLAGS) $$($1_$2_THIS_FILE) -c
   242     endif
   246     $1_$2_COMP := $5
   243 
   247     $1_$2_DEP_FLAG := $(C_FLAG_DEPS)
   244     ifneq ($$($$($1_BASE)_PRECOMPILED_HEADER), )
   248   else ifneq ($$(filter %.s %.S, $2), )
   245       ifeq ($$(filter $$($1_FILENAME), $$($$($1_BASE)_PRECOMPILED_HEADER_EXCLUDE)), )
   249     # Compile as assembler file
   246         $1_USE_PCH_FLAGS := $$($$($1_BASE)_USE_PCH_FLAGS)
   250     $1_$2_FLAGS := $8
   247       endif
   251     $1_$2_COMP := $(AS)
   248     endif
   252     $1_$2_DEP_FLAG :=
   249 
   253   else ifneq ($$(filter %.cpp, $2)$$(filter %.cc, $2)$$(filter %.mm, $2), )
   250     $1_BASE_CFLAGS :=  $$($$($1_BASE)_CFLAGS) $$($$($1_BASE)_EXTRA_CFLAGS) \
   254     # Compile as a C++ or Objective-C++ file
   251         $$($$($1_BASE)_SYSROOT_CFLAGS)
   255     $1_$2_FLAGS := $(CFLAGS_CCACHE) $$($1_$2_USE_PCH_FLAGS) $6 \
   252     $1_BASE_CXXFLAGS := $$($$($1_BASE)_CXXFLAGS) $$($$($1_BASE)_EXTRA_CXXFLAGS) \
   256         $$($1_$(notdir $2)_OPT_CXXFLAGS) \
   253         $$($$($1_BASE)_SYSROOT_CFLAGS) $$($1_EXTRA_CXXFLAGS)
   257         $$($1_$(notdir $2)_CXXFLAGS) $$($1_$2_THIS_FILE) -c
   254 
   258     $1_$2_COMP := $7
   255     ifneq ($$(filter %.c, $$($1_FILENAME)), )
   259     $1_$2_DEP_FLAG := $(CXX_FLAG_DEPS)
   256       # Compile as a C file
   260   else
   257       $1_FLAGS := $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) $$($1_BASE_CFLAGS) \
   261     $$(error Internal error in NativeCompilation.gmk: no compiler for file $2)
   258           $$($1_OPT_CFLAGS) $$($1_CFLAGS) $$($1_THIS_FILE) -c
   262   endif
   259       $1_COMPILER := $$($$($1_BASE)_CC)
   263   # Generate the .o (.obj) file name and place it in the bin dir.
   260       $1_DEP_FLAG := $(C_FLAG_DEPS)
   264   $1_$2_OBJ := $3/$$(call replace_with_obj_extension, $$(notdir $2))
   261     else ifneq ($$(filter %.m, $$($1_FILENAME)), )
   265   # Only continue if this object file hasn't been processed already. This lets the first found
   262       # Compile as an Objective-C file
   266   # source file override any other with the same name.
   263       $1_FLAGS := -x objective-c $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) \
   267   ifeq ($$(findstring $$($1_$2_OBJ), $$($1_OBJS_SO_FAR)), )
   264           $$($1_BASE_CFLAGS) $$($1_OPT_CFLAGS) $$($1_CFLAGS) $$($1_THIS_FILE) -c
   268     $1_OBJS_SO_FAR += $$($1_$2_OBJ)
   265       $1_COMPILER := $$($$($1_BASE)_CC)
   269     ifeq ($$(filter %.s %.S, $2), )
   266       $1_DEP_FLAG := $(C_FLAG_DEPS)
       
   267     else ifneq ($$(filter %.s %.S, $$($1_FILENAME)), )
       
   268       # Compile as assembler file
       
   269       $1_FLAGS := $$($$($1_BASE)_ASFLAGS)
       
   270       $1_COMPILER := $(AS)
       
   271       $1_DEP_FLAG :=
       
   272     else ifneq ($$(filter %.cpp %.cc %.mm, $$($1_FILENAME)), )
       
   273       # Compile as a C++ or Objective-C++ file
       
   274       $1_FLAGS := $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) $$($1_BASE_CXXFLAGS) \
       
   275           $$($1_OPT_CXXFLAGS) $$($1_CXXFLAGS) $$($1_THIS_FILE) -c
       
   276       $1_COMPILER := $$($$($1_BASE)_CXX)
       
   277       $1_DEP_FLAG := $(CXX_FLAG_DEPS)
       
   278     else
       
   279       $$(error Internal error in NativeCompilation.gmk: no compiler for file $$($1_FILENAME))
       
   280     endif
       
   281 
       
   282     ifeq ($$(filter %.s %.S, $$($1_FILENAME)), )
   270       # And this is the dependency file for this obj file.
   283       # And this is the dependency file for this obj file.
   271       $1_$2_DEP := $$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ))
   284       $1_DEP := $$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_OBJ))
   272       # The dependency target file lists all dependencies as empty targets
   285       # The dependency target file lists all dependencies as empty targets to
   273       # to avoid make error "No rule to make target" for removed files
   286       # avoid make error "No rule to make target" for removed files
   274       $1_$2_DEP_TARGETS := $$(patsubst %$(OBJ_SUFFIX),%.d.targets,$$($1_$2_OBJ))
   287       $1_DEP_TARGETS := $$(patsubst %$(OBJ_SUFFIX),%.d.targets,$$($1_OBJ))
   275 
   288 
   276       # Include previously generated dependency information. (if it exists)
   289       # Include previously generated dependency information. (if it exists)
   277       -include $$($1_$2_DEP)
   290       -include $$($1_DEP)
   278       -include $$($1_$2_DEP_TARGETS)
   291       -include $$($1_DEP_TARGETS)
   279 
   292     endif
   280       ifeq ($(TOOLCHAIN_TYPE), microsoft)
   293 
   281         # To avoid name clashes between pdbs for objects and libs/execs, put
   294     ifneq ($$(strip $$($1_CFLAGS) $$($1_CXXFLAGS) $$($1_OPTIMIZATION)), )
   282         # object pdbs in a separate subdir.
   295       $1_VARDEPS := $$($1_CFLAGS) $$($1_CXXFLAGS) $$($1_OPTIMIZATION)
   283         $1_$2_DEBUG_OUT_FLAGS := -Fd$$(strip $$(patsubst $$($1_OBJECT_DIR)/%, \
   296       $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_OBJ).vardeps)
   284             $$($1_OBJECT_DIR)/pdb/%, $$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ))))
   297     endif
   285       endif
   298 
   286     endif
   299     $$($1_OBJ): $$($1_SRC_FILE) $$($$($1_BASE)_COMPILE_VARDEPS_FILE) \
   287 
   300         $$($$($1_BASE)_EXTRA_DEPS) $$($1_VARDEPS_FILE) | $$($$($1_BASE)_BUILD_INFO)
   288     ifneq ($$(strip $$($1_$(notdir $2)_CFLAGS) $$($1_$(notdir $2)_CXXFLAGS) \
   301 	$$(call LogInfo, Compiling $$($1_FILENAME) (for $$($$($1_BASE)_BASENAME)))
   289         $$($1_$(notdir $2)_OPTIMIZATION)), )
   302 	$$(call MakeDir, $$(@D))
   290       $1_$2_VARDEPS := $$($1_$(notdir $2)_CFLAGS) $$($1_$(notdir $2)_CXXFLAGS) \
       
   291           $$($1_$(notdir $2)_OPT_CFLAGS) $$($1_$(notdir $2)_OPT_CXXFLAGS)
       
   292       $1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, $$($1_$2_OBJ).vardeps)
       
   293     endif
       
   294 
       
   295     $$($1_$2_OBJ) : $2 $$($1_COMPILE_VARDEPS_FILE) $$($1_$2_VARDEPS_FILE) | $$($1_BUILD_INFO)
       
   296 	$$(call LogInfo, Compiling $$(notdir $2) (for $$($1_BASENAME)))
       
   297 	$$(call MakeDir, $$(@D) $$(@D)/pdb)
       
   298         ifneq ($(TOOLCHAIN_TYPE), microsoft)
   303         ifneq ($(TOOLCHAIN_TYPE), microsoft)
   299           ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s, $2), solstudio)
   304           ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s, $$($1_FILENAME)), solstudio)
   300             # The Solaris studio compiler doesn't output the full path to the object file in the
   305             # The Solaris studio compiler doesn't output the full path to the
   301             # generated deps files. Fixing it with sed. If compiling assembly, don't try this.
   306             # object file in the generated deps files. Fixing it with sed. If
       
   307             # compiling assembly, don't try this.
   302 	    $$(call ExecuteWithLog, $$@, \
   308 	    $$(call ExecuteWithLog, $$@, \
   303 	        $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP).tmp $(CC_OUT_OPTION)$$($1_$2_OBJ) $2)
   309 	        $$($1_COMPILER) $$($1_FLAGS) $$($1_DEP_FLAG) $$($1_DEP).tmp \
   304 	    $(SED) 's|^$$(@F):|$$@:|' $$($1_$2_DEP).tmp > $$($1_$2_DEP)
   310 	            $(CC_OUT_OPTION)$$($1_OBJ) $$($1_SRC_FILE))
       
   311 	    $(SED) 's|^$$(@F):|$$@:|' $$($1_DEP).tmp > $$($1_DEP)
   305           else
   312           else
   306 	    $$(call ExecuteWithLog, $$@, \
   313 	    $$(call ExecuteWithLog, $$@, \
   307 	        $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2)
   314 	        $$($1_COMPILER) $$($1_FLAGS) $$($1_DEP_FLAG) $$($1_DEP) \
       
   315 	            $(CC_OUT_OPTION)$$($1_OBJ) $$($1_SRC_FILE))
   308           endif
   316           endif
   309           # Create a dependency target file from the dependency file.
   317           # Create a dependency target file from the dependency file.
   310           # Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
   318           # Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
   311           ifneq ($$($1_$2_DEP), )
   319           ifneq ($$($1_DEP), )
   312 	    $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS)
   320 	    $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEP) > $$($1_DEP_TARGETS)
   313           endif
   321           endif
   314         else
   322         else
   315           # The Visual Studio compiler lacks a feature for generating make dependencies, but by
   323           # The Visual Studio compiler lacks a feature for generating make
   316           # setting -showIncludes, all included files are printed. These are filtered out and
   324           # dependencies, but by setting -showIncludes, all included files are
   317           # parsed into make dependences.
   325           # printed. These are filtered out and parsed into make dependences.
   318           # Keep as much as possible on one execution line for best performance on Windows.
   326           #
   319           # No need to save exit code from compilation since pipefail is always active on
   327           # Keep as much as possible on one execution line for best performance
   320           # Windows.
   328           # on Windows. No need to save exit code from compilation since
       
   329           # pipefail is always active on Windows.
   321 	  $$(call ExecuteWithLog, $$@, \
   330 	  $$(call ExecuteWithLog, $$@, \
   322 	      $$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) \
   331 	      $$($1_COMPILER) $$($1_FLAGS) -showIncludes \
   323 	          $(CC_OUT_OPTION)$$($1_$2_OBJ) $2) \
   332 	          $(CC_OUT_OPTION)$$($1_OBJ) $$($1_SRC_FILE)) \
   324 	      | $(GREP) -v -e "^Note: including file:" \
   333 	      | $(TR) -d '\r' | $(GREP) -v -e "^Note: including file:" \
   325 	          -e "^$(notdir $2)$$$$" || test "$$$$?" = "1" ; \
   334 	          -e "^$$($1_FILENAME)$$$$" || test "$$$$?" = "1" ; \
   326 	  $(ECHO) $$@: \\ > $$($1_$2_DEP) ; \
   335 	  $(ECHO) $$@: \\ > $$($1_DEP) ; \
   327 	  $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_$2_OBJ).log \
   336 	  $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_OBJ).log \
   328 	      | $(SORT) -u >> $$($1_$2_DEP) ; \
   337 	      | $(SORT) -u >> $$($1_DEP) ; \
   329 	  $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS)
   338 	  $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEP) > $$($1_DEP_TARGETS)
   330         endif
   339         endif
   331   endif
   340   endif
   332 endef
   341 endef
   333 
   342 
   334 # Setup make rules for creating a native binary (a shared library or an
   343 # Setup make rules for creating a native binary (a shared library or an
   355 #   INCLUDE_FILES only compile exactly these files!
   364 #   INCLUDE_FILES only compile exactly these files!
   356 #   EXCLUDE_FILES with these names
   365 #   EXCLUDE_FILES with these names
   357 #   EXCLUDE_PATTERN exclude files matching any of these substrings
   366 #   EXCLUDE_PATTERN exclude files matching any of these substrings
   358 #   EXTRA_FILES List of extra files not in any of the SRC dirs
   367 #   EXTRA_FILES List of extra files not in any of the SRC dirs
   359 #   EXTRA_OBJECT_FILES List of extra object files to include when linking
   368 #   EXTRA_OBJECT_FILES List of extra object files to include when linking
       
   369 #   EXTRA_DEPS List of extra dependencies to be added to each compiled file
   360 #   VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run
   370 #   VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run
   361 #   RC_FLAGS flags for RC.
   371 #   RC_FLAGS flags for RC.
   362 #   EMBED_MANIFEST if true, embed manifest on Windows.
   372 #   EMBED_MANIFEST if true, embed manifest on Windows.
   363 #   MAPFILE mapfile
   373 #   MAPFILE mapfile
   364 #   REORDER reorder file
   374 #   REORDER reorder file
   376 #       symbols in the binary, if the toolchain allows for it
   386 #       symbols in the binary, if the toolchain allows for it
   377 #   DEBUG_SYMBOLS Set to false to disable generation of debug symbols
   387 #   DEBUG_SYMBOLS Set to false to disable generation of debug symbols
   378 #   COPY_DEBUG_SYMBOLS Set to false to override global setting of debug symbol copying
   388 #   COPY_DEBUG_SYMBOLS Set to false to override global setting of debug symbol copying
   379 #   ZIP_EXTERNAL_DEBUG_SYMBOLS Set to false to override global setting of debug symbol
   389 #   ZIP_EXTERNAL_DEBUG_SYMBOLS Set to false to override global setting of debug symbol
   380 #       zipping
   390 #       zipping
   381 #   CFLAGS_DEBUG_SYMBOLS Overrides the default cflags for enabling debug symbols
       
   382 #   CXXFLAGS_DEBUG_SYMBOLS Overrides the default cxxflags for enabling debug symbols
       
   383 #   STRIPFLAGS Optionally change the flags given to the strip command
   391 #   STRIPFLAGS Optionally change the flags given to the strip command
   384 #   PRECOMPILED_HEADER Header file to use as precompiled header
   392 #   PRECOMPILED_HEADER Header file to use as precompiled header
   385 #   PRECOMPILED_HEADER_EXCLUDE List of source files that should not use PCH
   393 #   PRECOMPILED_HEADER_EXCLUDE List of source files that should not use PCH
       
   394 #
       
   395 # After being called, some variables are exported from this macro, all prefixed
       
   396 # with parameter 1 followed by a '_':
       
   397 #   TARGET The library or executable created by the macro
       
   398 #   TARGET_DEPS All prerequisites for the target calculated by the macro
       
   399 #   ALL_OBJS All object files
       
   400 #   IMPORT_LIBRARY The import library created for a shared library on Windows
   386 SetupNativeCompilation = $(NamedParamsMacroTemplate)
   401 SetupNativeCompilation = $(NamedParamsMacroTemplate)
   387 define SetupNativeCompilationBody
   402 define SetupNativeCompilationBody
   388 
   403 
   389   # If type is unspecified, default to LIBRARY
   404   # If type is unspecified, default to LIBRARY
   390   ifeq ($$($1_TYPE), )
   405   ifeq ($$($1_TYPE), )
   557   ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)), )
   572   ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)), )
   558     $1_EXTRA_CXXFLAGS := $$($1_EXTRA_CFLAGS)
   573     $1_EXTRA_CXXFLAGS := $$($1_EXTRA_CFLAGS)
   559   endif
   574   endif
   560 
   575 
   561   ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true)
   576   ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true)
   562     $$(call SetIfEmpty, $1_CFLAGS_DEBUG_SYMBOLS, $(CFLAGS_DEBUG_SYMBOLS))
   577     $1_EXTRA_CFLAGS += $$(CFLAGS_DEBUG_SYMBOLS)
   563     $$(call SetIfEmpty, $1_CXXFLAGS_DEBUG_SYMBOLS, $(CXXFLAGS_DEBUG_SYMBOLS))
   578     $1_EXTRA_CXXFLAGS += $$(CFLAGS_DEBUG_SYMBOLS)
   564     $1_EXTRA_CFLAGS += $$($1_CFLAGS_DEBUG_SYMBOLS)
       
   565     $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_DEBUG_SYMBOLS)
       
   566   endif
   579   endif
   567 
   580 
   568   ifneq ($$($1_REORDER), )
   581   ifneq ($$($1_REORDER), )
   569     $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER)
   582     $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER)
   570     $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER)
   583     $1_EXTRA_CXXFLAGS += $$(C_FLAG_REORDER)
   571   endif
   584   endif
   572 
   585 
   573   # Pass the library name for static JNI library naming
   586   # Pass the library name for static JNI library naming
   574   ifeq ($$($1_TYPE), STATIC_LIBRARY)
   587   ifeq ($$($1_TYPE), STATIC_LIBRARY)
   575     $1_EXTRA_CFLAGS += -DLIBRARY_NAME=$$($1_NAME)
   588     $1_EXTRA_CFLAGS += -DLIBRARY_NAME=$$($1_NAME)
   639       ifeq ($(TOOLCHAIN_TYPE), microsoft)
   652       ifeq ($(TOOLCHAIN_TYPE), microsoft)
   640         $1_PCH_FILE := $$($1_OBJECT_DIR)/$1.pch
   653         $1_PCH_FILE := $$($1_OBJECT_DIR)/$1.pch
   641         $1_GENERATED_PCH_SRC := $$($1_OBJECT_DIR)/$1_pch.cpp
   654         $1_GENERATED_PCH_SRC := $$($1_OBJECT_DIR)/$1_pch.cpp
   642         $1_GENERATED_PCH_OBJ := $$($1_OBJECT_DIR)/$1_pch.obj
   655         $1_GENERATED_PCH_OBJ := $$($1_OBJECT_DIR)/$1_pch.obj
   643 
   656 
   644         $$(eval $$(call add_native_source,$1,$$($1_GENERATED_PCH_SRC), \
   657         $$(eval $$(call SetupCompileNativeFile, $1_$$(notdir $$($1_GENERATED_PCH_SRC)), \
   645             $$($1_OBJECT_DIR),,, \
   658             FILE := $$($1_GENERATED_PCH_SRC), \
   646             $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) $$($1_SYSROOT_CFLAGS) \
   659             BASE := $1, \
   647                 -Fp$$($1_PCH_FILE) -Yc$$(notdir $$($1_PRECOMPILED_HEADER)), \
   660             EXTRA_CXXFLAGS := -Fp$$($1_PCH_FILE) -Yc$$(notdir $$($1_PRECOMPILED_HEADER)), \
   648             $$($1_CXX),,no_this_file))
   661             DISABLE_THIS_FILE_DEFINE := true, \
       
   662         ))
   649 
   663 
   650         $1_USE_PCH_FLAGS := \
   664         $1_USE_PCH_FLAGS := \
   651             -Fp$$($1_PCH_FILE) -Yu$$(notdir $$($1_PRECOMPILED_HEADER))
   665             -Fp$$($1_PCH_FILE) -Yu$$(notdir $$($1_PRECOMPILED_HEADER))
   652 
   666 
   653         $$($1_ALL_OBJS): $$($1_GENERATED_PCH_OBJ)
   667         $$($1_ALL_OBJS): $$($1_GENERATED_PCH_OBJ)
   686 
   700 
   687       endif
   701       endif
   688     endif
   702     endif
   689   endif
   703   endif
   690 
   704 
   691   # Now call add_native_source for each source file we are going to compile.
   705   # Now call SetupCompileNativeFile for each source file we are going to compile.
   692   $$(foreach p, $$($1_SRCS), \
   706   $$(foreach file, $$($1_SRCS), \
   693       $$(eval $$(call add_native_source,$1,$$p,$$($1_OBJECT_DIR), \
   707       $$(eval $$(call SetupCompileNativeFile, $1_$$(notdir $$(file)),\
   694           $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $$($1_SYSROOT_CFLAGS), \
   708           FILE := $$(file), \
   695           $$($1_CC), \
   709           BASE := $1, \
   696           $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) $$($1_SYSROOT_CFLAGS), \
   710       )) \
   697           $$($1_CXX), $$($1_ASFLAGS))))
   711   )
   698 
   712 
   699   # Setup rule for printing progress info when compiling source files.
   713   # Setup rule for printing progress info when compiling source files.
   700   # This is a rough heuristic and may not always print accurate information.
   714   # This is a rough heuristic and may not always print accurate information.
   701   $$($1_BUILD_INFO): $$($1_SRCS) $$($1_COMPILE_VARDEPS_FILE)
   715   $$($1_BUILD_INFO): $$($1_SRCS) $$($1_COMPILE_VARDEPS_FILE)
   702         ifeq ($$(wildcard $$($1_TARGET)), )
   716         ifeq ($$(wildcard $$($1_TARGET)), )
   726       $$($1_RES): $$($1_VERSIONINFO_RESOURCE) $$($1_RES_VARDEPS_FILE)
   740       $$($1_RES): $$($1_VERSIONINFO_RESOURCE) $$($1_RES_VARDEPS_FILE)
   727 		$$(call LogInfo, Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$($1_BASENAME)))
   741 		$$(call LogInfo, Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$($1_BASENAME)))
   728 		$$(call MakeDir, $$(@D) $$($1_OBJECT_DIR))
   742 		$$(call MakeDir, $$(@D) $$($1_OBJECT_DIR))
   729 		$$(call ExecuteWithLog, $$@, \
   743 		$$(call ExecuteWithLog, $$@, \
   730 		    $$($1_RC) $$($1_RC_FLAGS) $$($1_SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \
   744 		    $$($1_RC) $$($1_RC_FLAGS) $$($1_SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \
   731 		    $$($1_VERSIONINFO_RESOURCE))
   745 		    $$($1_VERSIONINFO_RESOURCE) 2>&1 )
   732                 # Windows RC compiler does not support -showIncludes, so we mis-use CL
   746                 # Windows RC compiler does not support -showIncludes, so we mis-use CL
   733                 # for this. Filter out RC specific arguments that are unknown to CL.
   747                 # for this. Filter out RC specific arguments that are unknown to CL.
   734                 # For some unknown reason, in this case CL actually outputs the show
   748                 # For some unknown reason, in this case CL actually outputs the show
   735                 # includes to stderr so need to redirect it to hide the output from the
   749                 # includes to stderr so need to redirect it to hide the output from the
   736                 # main log.
   750                 # main log.
   737 		$$(call ExecuteWithLog, $$($1_RES_DEP).obj, \
   751 		$$(call ExecuteWithLog, $$($1_RES_DEP).obj, \
   738 		    $$($1_CC) $$(filter-out -l%, $$($1_RC_FLAGS)) \
   752 		    $$($1_CC) $$(filter-out -l%, $$($1_RC_FLAGS)) \
   739 		        $$($1_SYSROOT_CFLAGS) -showIncludes -nologo -TC \
   753 		        $$($1_SYSROOT_CFLAGS) -showIncludes -nologo -TC \
   740 		        $(CC_OUT_OPTION)$$($1_RES_DEP).obj -P -Fi$$($1_RES_DEP).pp \
   754 		        $(CC_OUT_OPTION)$$($1_RES_DEP).obj -P -Fi$$($1_RES_DEP).pp \
   741 		        $$($1_VERSIONINFO_RESOURCE)) 2>&1 \
   755 		        $$($1_VERSIONINFO_RESOURCE)) 2>&1 \
   742 		    | $(GREP) -v -e "^Note: including file:" \
   756 		    | $(TR) -d '\r' | $(GREP) -v -e "^Note: including file:" \
   743 		        -e "^$$(notdir $$($1_VERSIONINFO_RESOURCE))$$$$" || test "$$$$?" = "1" ; \
   757 		        -e "^$$(notdir $$($1_VERSIONINFO_RESOURCE))$$$$" || test "$$$$?" = "1" ; \
   744 		$(ECHO) $$($1_RES): \\ > $$($1_RES_DEP) ; \
   758 		$(ECHO) $$($1_RES): \\ > $$($1_RES_DEP) ; \
   745 		$(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_RES_DEP).obj.log >> $$($1_RES_DEP) ; \
   759 		$(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_RES_DEP).obj.log >> $$($1_RES_DEP) ; \
   746 		$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_RES_DEP) > $$($1_RES_DEP_TARGETS)
   760 		$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_RES_DEP) > $$($1_RES_DEP_TARGETS)
   747     endif
   761     endif
   789         ifeq ($(OPENJDK_TARGET_OS), windows)
   803         ifeq ($(OPENJDK_TARGET_OS), windows)
   790           $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \
   804           $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \
   791               "-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map"
   805               "-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map"
   792           $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \
   806           $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \
   793               $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map
   807               $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map
   794           # No separate command is needed for debuginfo on windows, instead
       
   795           # touch target to make sure it has a later time stamp than the debug
       
   796           # symbol files to avoid unnecessary relinking on rebuild.
       
   797           $1_CREATE_DEBUGINFO_CMDS := $(TOUCH) $$($1_TARGET)
       
   798 
   808 
   799         else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
   809         else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
   800           $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo
   810           $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo
   801           # Setup the command line creating debuginfo files, to be run after linking.
   811           # Setup the command line creating debuginfo files, to be run after linking.
   802           # It cannot be run separately since it updates the original target file
   812           # It cannot be run separately since it updates the original target file
   807 
   817 
   808         else ifeq ($(OPENJDK_TARGET_OS), macosx)
   818         else ifeq ($(OPENJDK_TARGET_OS), macosx)
   809           $1_DEBUGINFO_FILES := \
   819           $1_DEBUGINFO_FILES := \
   810               $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
   820               $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
   811               $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
   821               $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
   812           # On Macosx, the debuginfo generation doesn't touch the linked binary, but
       
   813           # to avoid always relinking, touch it anyway to force a later timestamp than
       
   814           # the dSYM files.
       
   815           $1_CREATE_DEBUGINFO_CMDS := \
   822           $1_CREATE_DEBUGINFO_CMDS := \
   816               $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET) $$(NEWLINE) \
   823               $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET)
   817               $(TOUCH) $$($1_TARGET)
       
   818         endif # OPENJDK_TARGET_OS
   824         endif # OPENJDK_TARGET_OS
   819 
   825 
       
   826         # Since the link rule creates more than one file that we want to track,
       
   827         # we have to use some tricks to get make to cooperate. To properly
       
   828         # trigger downstream dependants of $$($1_DEBUGINFO_FILES), we must have
       
   829         # a recipe in the rule below. To avoid rerunning the recipe every time
       
   830         # have it touch the target. If a debuginfo file is deleted by something
       
   831         # external, explicitly delete the TARGET to trigger a rebuild of both.
       
   832         ifneq ($$(wildcard $$($1_DEBUGINFO_FILES)), $$($1_DEBUGINFO_FILES))
       
   833           $$(call LogDebug, Deleting $$($1_BASENAME) because debuginfo files are missing)
       
   834           $$(shell $(RM) $$($1_TARGET))
       
   835         endif
   820         $$($1_DEBUGINFO_FILES): $$($1_TARGET)
   836         $$($1_DEBUGINFO_FILES): $$($1_TARGET)
       
   837 		$$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \
       
   838 		  $$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \
       
   839 		)
       
   840 		$(TOUCH) $$@
   821 
   841 
   822         $1 += $$($1_DEBUGINFO_FILES)
   842         $1 += $$($1_DEBUGINFO_FILES)
   823 
   843 
   824         ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
   844         ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
   825           $1_DEBUGINFO_ZIP := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).diz
   845           $1_DEBUGINFO_ZIP := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).diz
   846       $1_STRIPFLAGS ?= $(STRIPFLAGS)
   866       $1_STRIPFLAGS ?= $(STRIPFLAGS)
   847       $1_STRIP_CMD := $$($1_STRIP) $$($1_STRIPFLAGS) $$($1_TARGET)
   867       $1_STRIP_CMD := $$($1_STRIP) $$($1_STRIPFLAGS) $$($1_TARGET)
   848     endif
   868     endif
   849   endif
   869   endif
   850 
   870 
   851   ifeq ($$($1_TYPE), LIBRARY)
   871   ifeq ($$($1_TYPE), STATIC_LIBRARY)
   852     # Generating a dynamic library.
   872     $1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \
   853     $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
   873         $$($1_EXTRA_LIBS)
       
   874     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
       
   875         $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
       
   876 
       
   877     # Generating a static library, ie object file archive.
       
   878     ifeq ($(STATIC_BUILD), true)
       
   879       ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
       
   880         STATIC_MAPFILE_DEP := $$($1_MAPFILE)
       
   881       endif
       
   882     endif
       
   883 
       
   884     $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP)
       
   885 
       
   886     $$($1_TARGET): $$($1_TARGET_DEPS)
       
   887 	$$(call LogInfo, Building static library $$($1_BASENAME))
       
   888 	$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
       
   889 	    $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \
       
   890 	        $$($1_RES))
       
   891         ifeq ($(STATIC_BUILD), true)
       
   892           ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
       
   893 	    $(CP) $$($1_MAPFILE) $$(@D)/$$(basename $$(@F)).symbols
       
   894           else
       
   895 	    $(GetSymbols)
       
   896           endif
       
   897         endif
       
   898   else
       
   899     # A shared dynamic library or an executable binary has been specified
       
   900     ifeq ($$($1_TYPE), LIBRARY)
       
   901       # Generating a dynamic library.
       
   902       $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
       
   903 
       
   904       # Create loadmap on AIX. Helps in diagnosing some problems.
       
   905       ifneq ($(COMPILER_BINDCMD_FILE_FLAG), )
       
   906         $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap
       
   907       endif
       
   908     endif
       
   909 
   854     ifeq ($(OPENJDK_TARGET_OS), windows)
   910     ifeq ($(OPENJDK_TARGET_OS), windows)
   855       $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_NAME).lib"
   911       ifeq ($$($1_EMBED_MANIFEST), true)
   856       # Create a rule for the import lib so that other rules may depend on it
   912         $1_EXTRA_LDFLAGS += -manifest:embed
   857       $$($1_OBJECT_DIR)/$$($1_NAME).lib: $$($1_TARGET)
   913       endif
   858     endif
   914 
   859 
   915       $1_IMPORT_LIBRARY := $$($1_OBJECT_DIR)/$$($1_NAME).lib
   860     # Create loadmap on AIX. Helps in diagnosing some problems.
   916       $1_EXTRA_LDFLAGS += "-implib:$$($1_IMPORT_LIBRARY)"
   861     ifneq ($(COMPILER_BINDCMD_FILE_FLAG), )
   917       ifeq ($$($1_TYPE), LIBRARY)
   862       $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap
   918         # To properly trigger downstream dependants of the import library, just as
       
   919         # for debug files, we must have a recipe in the rule. To avoid rerunning
       
   920         # the recipe every time have it touch the target. If an import library
       
   921         # file is deleted by something external, explicitly delete the target to
       
   922         # trigger a rebuild of both.
       
   923         ifneq ($$(wildcard $$($1_IMPORT_LIBRARY)), $$($1_IMPORT_LIBRARY))
       
   924           $$(call LogDebug, Deleting $$($1_BASENAME) because import library is missing)
       
   925           $$(shell $(RM) $$($1_TARGET))
       
   926         endif
       
   927         $$($1_IMPORT_LIBRARY): $$($1_TARGET)
       
   928 		$$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \
       
   929 		  $$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \
       
   930 		)
       
   931 		$(TOUCH) $$@
       
   932       endif
   863     endif
   933     endif
   864 
   934 
   865     $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
   935     $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
   866         $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_CREATE_DEBUGINFO_CMDS) \
   936         $$(GLOBAL_LIBS) $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \
       
   937         $$($1_CODESIGN) $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \
   867         $$($1_STRIP_CMD)
   938         $$($1_STRIP_CMD)
   868     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
   939     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
   869         $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
   940         $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
   870 
   941 
   871     $1_LD_OBJ_ARG := $$($1_ALL_OBJS)
   942     $1_LD_OBJ_ARG := $$($1_ALL_OBJS)
   900           $1_ALL_OBJS_RELATIVE := $$(patsubst $$(OUTPUTDIR)/%, %, $$($1_ALL_OBJS))
   971           $1_ALL_OBJS_RELATIVE := $$(patsubst $$(OUTPUTDIR)/%, %, $$($1_ALL_OBJS))
   901         endif
   972         endif
   902       endif
   973       endif
   903     endif
   974     endif
   904 
   975 
   905     $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) \
   976     $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
   906         $$($1_VARDEPS_FILE)
   977         $$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE)
       
   978 
       
   979     $$($1_TARGET): $$($1_TARGET_DEPS)
   907                 ifneq ($$($1_OBJ_FILE_LIST), )
   980                 ifneq ($$($1_OBJ_FILE_LIST), )
   908                   ifeq ($$($1_LINK_OBJS_RELATIVE), true)
   981                   ifeq ($$($1_LINK_OBJS_RELATIVE), true)
   909 		    $$(eval $$(call ListPathsSafely, $1_ALL_OBJS_RELATIVE, $$($1_OBJ_FILE_LIST)))
   982 		    $$(eval $$(call ListPathsSafely, $1_ALL_OBJS_RELATIVE, $$($1_OBJ_FILE_LIST)))
   910                   else
   983                   else
   911 		    $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST)))
   984 		    $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST)))
   915                 # on Windows
   988                 # on Windows
   916 		$$(call LogInfo, Linking $$($1_BASENAME))
   989 		$$(call LogInfo, Linking $$($1_BASENAME))
   917                 ifeq ($(OPENJDK_TARGET_OS), windows)
   990                 ifeq ($(OPENJDK_TARGET_OS), windows)
   918 		  $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
   991 		  $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
   919 		      $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
   992 		      $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
   920 		      $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \
   993 		          $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
   921 		      $$($1_EXTRA_LIBS)) \
   994 		          $$($1_LIBS) $$($1_EXTRA_LIBS)) \
   922 		      | $(GREP) -v "^   Creating library .*\.lib and object .*\.exp" || \
   995 		      | $(GREP) -v "^   Creating library .*\.lib and object .*\.exp" || \
   923 		      test "$$$$?" = "1" ; \
   996 		          test "$$$$?" = "1" ; \
   924 		  $$($1_CREATE_DEBUGINFO_CMDS)
   997 		  $$($1_CREATE_DEBUGINFO_CMDS)
   925 		  $$($1_STRIP_CMD)
   998 		  $$($1_STRIP_CMD)
   926                 else
   999                 else
   927 		  $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
  1000 		  $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
   928 		      $$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \
  1001 		      $$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \
   929 		      $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
  1002 		      $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
   930 		      $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \
  1003 		          $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
   931 		      $$($1_EXTRA_LIBS)) ; \
  1004 		          $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \
   932 		  $$($1_CREATE_DEBUGINFO_CMDS)
  1005 		  $$($1_CREATE_DEBUGINFO_CMDS)
   933 		  $$($1_STRIP_CMD)
  1006 		  $$($1_STRIP_CMD)
   934                 endif
  1007                 endif
   935 
       
   936   endif
       
   937 
       
   938   ifeq ($$($1_TYPE), STATIC_LIBRARY)
       
   939     $1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \
       
   940         $$($1_EXTRA_LIBS)
       
   941     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
       
   942         $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
       
   943 
       
   944     # Generating a static library, ie object file archive.
       
   945     ifeq ($(STATIC_BUILD), true)
       
   946       ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
       
   947         STATIC_MAPFILE_DEP := $$($1_MAPFILE)
       
   948       endif
       
   949     endif
       
   950 
       
   951     $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP)
       
   952 	$$(call LogInfo, Building static library $$($1_BASENAME))
       
   953 	$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
       
   954 	    $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \
       
   955 	        $$($1_RES))
       
   956         ifeq ($(STATIC_BUILD), true)
       
   957           ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
       
   958 	    $(CP) $$($1_MAPFILE) $$(@D)/$$(basename $$(@F)).symbols
       
   959           else
       
   960 	    $(GetSymbols)
       
   961           endif
       
   962         endif
       
   963   endif
       
   964 
       
   965   ifeq ($$($1_TYPE), EXECUTABLE)
       
   966     # A executable binary has been specified, setup the target for it.
       
   967     $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
       
   968         $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \
       
   969         $$($1_CODESIGN) $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \
       
   970         $$($1_STRIP_CMD)
       
   971     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
       
   972         $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
       
   973 
       
   974     ifeq ($(OPENJDK_TARGET_OS), windows)
       
   975       ifeq ($$($1_EMBED_MANIFEST), true)
       
   976         $1_EXTRA_LDFLAGS += -manifest:embed
       
   977       endif
       
   978     endif
       
   979 
       
   980     $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
       
   981         $$($1_VARDEPS_FILE)
       
   982 		$$(call LogInfo, Linking executable $$($1_BASENAME))
       
   983 		$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
       
   984 		    $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
       
   985 		        $(EXE_OUT_OPTION)$$($1_TARGET) \
       
   986 		        $$($1_ALL_OBJS) $$($1_RES) \
       
   987 		        $$($1_LIBS) $$($1_EXTRA_LIBS))
       
   988                 ifeq ($(OPENJDK_TARGET_OS), windows)
  1008                 ifeq ($(OPENJDK_TARGET_OS), windows)
   989                   ifneq ($$($1_MANIFEST), )
  1009                   ifneq ($$($1_MANIFEST), )
   990 		    $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1
  1010 		    $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1
   991                   endif
  1011                   endif
   992                 endif
  1012                 endif
   995                 ifneq ($(CODESIGN), )
  1015                 ifneq ($(CODESIGN), )
   996                   ifneq ($$($1_CODESIGN), )
  1016                   ifneq ($$($1_CODESIGN), )
   997 		    $(CODESIGN) -s openjdk_codesign $$@
  1017 		    $(CODESIGN) -s openjdk_codesign $$@
   998                   endif
  1018                   endif
   999                 endif
  1019                 endif
  1000 		$$($1_CREATE_DEBUGINFO_CMDS)
       
  1001 		$$($1_STRIP_CMD)
       
  1002 
       
  1003   endif
  1020   endif
  1004 endef
  1021 endef
  1005 
  1022 
  1006 endif # _NATIVE_COMPILATION_GMK
  1023 endif # _NATIVE_COMPILATION_GMK