make/common/NativeCompilation.gmk
branchihse-nativecompilation-branch
changeset 56196 a96f5d80fa35
parent 47253 92fd0e04e0e1
child 56198 89aab97c5335
--- a/make/common/NativeCompilation.gmk	Tue Feb 27 09:54:47 2018 +0100
+++ b/make/common/NativeCompilation.gmk	Tue Feb 27 10:48:24 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 ifndef _NATIVE_COMPILATION_GMK
 _NATIVE_COMPILATION_GMK := 1
 
-ifeq (,$(_MAKEBASE_GMK))
+ifeq ($(_MAKEBASE_GMK), )
   $(error You must include MakeBase.gmk prior to including NativeCompilation.gmk)
 endif
 
@@ -231,32 +231,32 @@
     endif
   endif
 
-  ifneq (,$$(filter %.c,$2))
+  ifneq ($$(filter %.c, $2), )
     # Compile as a C file
-    $1_$2_FLAGS=$(CFLAGS_CCACHE) $$($1_$2_USE_PCH_FLAGS) $4 \
+    $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
-    $1_$2_COMP=$5
-    $1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
-  else ifneq (,$$(filter %.m,$2))
+    $1_$2_COMP := $5
+    $1_$2_DEP_FLAG := $(C_FLAG_DEPS)
+  else ifneq ($$(filter %.m, $2), )
     # Compile as an Objective-C file
-    $1_$2_FLAGS=-x objective-c $(CFLAGS_CCACHE) $$($1_$2_USE_PCH_FLAGS) $4 \
+    $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
-    $1_$2_COMP=$5
-    $1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
-  else ifneq (,$$(filter %.s %.S,$2))
+    $1_$2_COMP := $5
+    $1_$2_DEP_FLAG := $(C_FLAG_DEPS)
+  else ifneq ($$(filter %.s %.S, $2), )
     # Compile as assembler file
-    $1_$2_FLAGS=$8
-    $1_$2_COMP=$(AS)
-    $1_$2_DEP_FLAG:=
-  else ifneq (,$$(filter %.cpp,$2)$$(filter %.cc,$2)$$(filter %.mm,$2))
+    $1_$2_FLAGS := $8
+    $1_$2_COMP := $(AS)
+    $1_$2_DEP_FLAG :=
+  else ifneq ($$(filter %.cpp, $2)$$(filter %.cc, $2)$$(filter %.mm, $2), )
     # Compile as a C++ or Objective-C++ file
-    $1_$2_FLAGS=$(CFLAGS_CCACHE) $$($1_$2_USE_PCH_FLAGS) $6 \
+    $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
-    $1_$2_COMP=$7
-    $1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS)
+    $1_$2_COMP := $7
+    $1_$2_DEP_FLAG := $(CXX_FLAG_DEPS)
   else
     $$(error Internal error in NativeCompilation.gmk: no compiler for file $2)
   endif
@@ -264,14 +264,14 @@
   $1_$2_OBJ := $3/$$(call replace_with_obj_extension, $$(notdir $2))
   # 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.
-  ifeq (,$$(findstring $$($1_$2_OBJ),$$($1_OBJS_SO_FAR)))
-    $1_OBJS_SO_FAR+=$$($1_$2_OBJ)
-    ifeq (,$$(filter %.s %.S,$2))
+  ifeq ($$(findstring $$($1_$2_OBJ), $$($1_OBJS_SO_FAR)), )
+    $1_OBJS_SO_FAR += $$($1_$2_OBJ)
+    ifeq ($$(filter %.s %.S, $2), )
       # And this is the dependency file for this obj file.
-      $1_$2_DEP:=$$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ))
+      $1_$2_DEP := $$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ))
       # 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))
+      $1_$2_DEP_TARGETS := $$(patsubst %$(OBJ_SUFFIX),%.d.targets,$$($1_$2_OBJ))
 
       # Include previously generated dependency information. (if it exists)
       -include $$($1_$2_DEP)
@@ -280,7 +280,7 @@
       ifeq ($(TOOLCHAIN_TYPE), microsoft)
         # 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_$2_DEBUG_OUT_FLAGS := -Fd$$(strip $$(patsubst $$($1_OBJECT_DIR)/%, \
             $$($1_OBJECT_DIR)/pdb/%, $$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ))))
       endif
     endif
@@ -293,10 +293,10 @@
     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))))
+	$$(call LogInfo, Compiling $$(notdir $2) (for $$($1_BASENAME)))
 	$$(call MakeDir, $$(@D) $$(@D)/pdb)
         ifneq ($(TOOLCHAIN_TYPE), microsoft)
-          ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s,$2), solstudio)
+          ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s, $2), solstudio)
             # 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.
 	    $$(call ExecuteWithLog, $$@, \
@@ -308,7 +308,7 @@
           endif
           # 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),)
+          ifneq ($$($1_$2_DEP), )
 	    $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS)
           endif
         else
@@ -338,6 +338,9 @@
 # and the targets generated are listed in a variable by that name.
 #
 # Remaining parameters are named arguments. These include:
+#   NAME The base name for the resulting binary, excluding decorations (like *.exe)
+#   TYPE Type of binary (EXECUTABLE, LIBRARY or STATIC_LIBRARY). Default is LIBRARY.
+#   SUFFIX Override the default suffix for the output file
 #   TOOLCHAIN Name of toolchain setup to use. Defaults to TOOLCHAIN_DEFAULT.
 #   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++.
@@ -347,8 +350,6 @@
 #   ARFLAGS the archiver flags to be used
 #   OBJECT_DIR the directory where we store the object files
 #   OUTPUT_DIR the directory where the resulting binary is put
-#   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!
@@ -385,105 +386,59 @@
 SetupNativeCompilation = $(NamedParamsMacroTemplate)
 define SetupNativeCompilationBody
 
+  # If type is unspecified, default to LIBRARY
+  ifeq ($$($1_TYPE), )
+    $1_TYPE := LIBRARY
+  endif
+
   # 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 :=
+    ifeq ($$($1_TYPE), LIBRARY)
+      $1_TYPE := STATIC_LIBRARY
     endif
   endif
 
-  ifneq (,$$($1_BIN))
-    $$(error BIN has been replaced with OBJECT_DIR)
-  endif
-
-  ifneq (,$$($1_LIB))
-    $$(error LIB has been replaced with LIBRARY)
-  endif
-
-  ifneq (,$$($1_EXE))
-    $$(error EXE has been replaced with PROGRAM)
-  endif
-
-  ifneq (,$$($1_LIBRARY))
-    ifeq (,$$($1_OUTPUT_DIR))
-      $$(error LIBRARY requires OUTPUT_DIR)
-    endif
-
-    ifneq ($$($1_LIBRARY),$(basename $$($1_LIBRARY)))
-      $$(error directory of LIBRARY should be specified using OUTPUT_DIR)
-    endif
-
-    ifneq (,$(findstring $(SHARED_LIBRARY_SUFFIX),$$($1_LIBRARY)))
-      $$(error LIBRARY should be specified without SHARED_LIBRARY_SUFFIX: $(SHARED_LIBRARY_SUFFIX))
-    endif
-
-    ifneq (,$(findstring $(LIBRARY_PREFIX),$$($1_LIBRARY)))
-      $$(error LIBRARY should be specified without LIBRARY_PREFIX: $(LIBRARY_PREFIX))
-    endif
-
-    ifeq ($$($1_SUFFIX), )
-      $1_SUFFIX := $(SHARED_LIBRARY_SUFFIX)
-    endif
-
-    $1_BASENAME:=$(LIBRARY_PREFIX)$$($1_LIBRARY)$$($1_SUFFIX)
-    $1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME)
-    $1_NOSUFFIX:=$(LIBRARY_PREFIX)$$($1_LIBRARY)
-  endif
-
-  ifneq (,$$($1_STATIC_LIBRARY))
-    ifeq (,$$($1_OUTPUT_DIR))
-      $$(error STATIC_LIBRARY requires OUTPUT_DIR)
-    endif
-
-    ifneq ($$($1_STATIC_LIBRARY),$(basename $$($1_STATIC_LIBRARY)))
-      $$(error directory of STATIC_LIBRARY should be specified using OUTPUT_DIR)
-    endif
-
-    ifneq (,$(findstring $(STATIC_LIBRARY_SUFFIX),$$($1_STATIC_LIBRARY)))
-      $$(error STATIC_LIBRARY should be specified without STATIC_LIBRARY_SUFFIX: $(STATIC_LIBRARY_SUFFIX))
-    endif
-
-    ifneq (,$(findstring $(LIBRARY_PREFIX),$$($1_STATIC_LIBRARY)))
-      $$(error STATIC_LIBRARY should be specified without LIBRARY_PREFIX: $(LIBRARY_PREFIX))
-    endif
-
-    ifeq ($$($1_SUFFIX), )
-      $1_SUFFIX := $(STATIC_LIBRARY_SUFFIX)
-    endif
-
-    $1_BASENAME:=$(LIBRARY_PREFIX)$$($1_STATIC_LIBRARY)$$($1_SUFFIX)
-    $1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME)
-    $1_NOSUFFIX:=$(LIBRARY_PREFIX)$$($1_STATIC_LIBRARY)
-  endif
-
-  ifneq (,$$($1_PROGRAM))
-    ifeq (,$$($1_OUTPUT_DIR))
-      $$(error PROGRAM requires OUTPUT_DIR)
-    endif
-
-    ifneq ($$($1_PROGRAM),$(basename $$($1_PROGRAM)))
-      $$(error directory of PROGRAM should be specified using OUTPUT_DIR)
-    endif
-
-    ifneq (,$(findstring $(EXE_SUFFIX),$$($1_PROGRAM)))
-      $$(error PROGRAM should be specified without EXE_SUFFIX: $(EXE_SUFFIX))
-    endif
-
+  ifeq ($$($1_TYPE), EXECUTABLE)
+    $1_PREFIX :=
     ifeq ($$($1_SUFFIX), )
       $1_SUFFIX := $(EXE_SUFFIX)
     endif
+  else
+    $1_PREFIX := $(LIBRARY_PREFIX)
+    ifeq ($$($1_TYPE), LIBRARY)
+      ifeq ($$($1_SUFFIX), )
+        $1_SUFFIX := $(SHARED_LIBRARY_SUFFIX)
+      endif
+    else ifeq ($$($1_TYPE), STATIC_LIBRARY)
+      ifeq ($$($1_SUFFIX), )
+        $1_SUFFIX := $(STATIC_LIBRARY_SUFFIX)
+      endif
+    endif
+  endif
 
-    $1_BASENAME:=$$($1_PROGRAM)$$($1_SUFFIX)
-    $1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME)
-    $1_NOSUFFIX:=$$($1_PROGRAM)
+  ifneq ($$($1_NAME), $(basename $$($1_NAME)))
+    $$(error NAME must not contain any directory path in $1)
   endif
-  $1_SAFE_NAME := $$(strip $$(subst /,_, $1))
+  ifneq ($(findstring $$($1_SUFFIX), $$($1_NAME)))
+    $$(error NAME should be specified without suffix: $$($1_SUFFIX) in $1)
+  endif
+  ifneq ($(findstring $$($1_PREFIX), $$($1_NAME)))
+    $$(error NAME should be specified without prefix: $$($1_PREFIX) in $1)
+  endif
+  ifeq ($$($1_OUTPUT_DIR), )
+    $$(error OUTPUT_DIR is missing in $1)
+  endif
+  ifneq ($$($1_MANIFEST), )
+    ifeq ($$($1_MANIFEST_VERSION), )
+      $$(error If MANIFEST is provided, then MANIFEST_VERSION is required in $1)
+    endif
+  endif
 
-  ifeq (,$$($1_TARGET))
-    $$(error Neither PROGRAM, LIBRARY nor STATIC_LIBRARY has been specified for SetupNativeCompilation)
-  endif
+  $1_BASENAME := $$($1_PREFIX)$$($1_NAME)$$($1_SUFFIX)
+  $1_TARGET := $$($1_OUTPUT_DIR)/$$($1_BASENAME)
+  $1_NOSUFFIX := $$($1_PREFIX)$$($1_NAME)
+  $1_SAFE_NAME := $$(strip $$(subst /,_, $1))
 
   # Setup the toolchain to be used
   $$(call SetIfEmpty, $1_TOOLCHAIN, TOOLCHAIN_DEFAULT)
@@ -499,41 +454,35 @@
   $$(call SetIfEmpty, $1_SYSROOT_CFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_CFLAGS))
   $$(call SetIfEmpty, $1_SYSROOT_LDFLAGS, $$($$($1_TOOLCHAIN)_SYSROOT_LDFLAGS))
 
-  ifneq ($$($1_MANIFEST), )
-    ifeq ($$($1_MANIFEST_VERSION), )
-      $$(error If MANIFEST is provided, then MANIFEST_VERSION is required in $1)
-    endif
-  endif
-
   # Make sure the dirs exist.
-  $$(call MakeDir,$$($1_OBJECT_DIR) $$($1_OUTPUT_DIR))
-  $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),, \
+  $$(call MakeDir, $$($1_OBJECT_DIR) $$($1_OUTPUT_DIR))
+  $$(foreach d, $$($1_SRC), $$(if $$(wildcard $$d), , \
       $$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d)))
 
   # Find all files in the source trees. Preserve order.
-  $1_SRCS := $$(foreach s, $$($1_SRC), $$(call CacheFind,$$(s)))
+  $1_SRCS := $$(foreach s, $$($1_SRC), $$(call CacheFind, $$(s)))
   $1_SRCS := $$(filter $$(NATIVE_SOURCE_EXTENSIONS), $$($1_SRCS))
   # Extract the C/C++ files.
   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 \
+    $$(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
-  ifneq ($$($1_EXCLUDE_FILES),)
+  ifneq ($$($1_EXCLUDE_FILES), )
     $1_ALL_EXCLUDE_FILES += $$($1_EXCLUDE_FILES)
   endif
-  ifneq ($$($1_ALL_EXCLUDE_FILES),)
+  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))
+        $$(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))
   endif
   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))
+    $1_INCLUDE_FILES_PAT := $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$($1_INCLUDE_FILES)))
+    $1_SRCS := $$(filter $$($1_INCLUDE_FILES_PAT), $$($1_SRCS))
   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))
@@ -541,29 +490,29 @@
   # 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))
+  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),)
-    $1_SRC_EXCLUDES := $$(addsuffix /%,$$($1_EXCLUDES))
-    $1_SRC_EXCLUDES += $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES))))
-    $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
+  ifneq ($$($1_EXCLUDES), )
+    $1_SRC_EXCLUDES := $$(addsuffix /%, $$($1_EXCLUDES))
+    $1_SRC_EXCLUDES += $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$(addsuffix /%, $$($1_EXCLUDES))))
+    $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES), $$($1_SRCS))
   endif
 
   $1_SRCS += $$($1_EXTRA_FILES)
 
-  ifeq (,$$($1_SRCS))
+  ifeq ($$($1_SRCS), )
     $$(error No sources found for $1 when looking inside the dirs $$($1_SRC))
   endif
 
   # Calculate the expected output from compiling the sources
   $1_EXPECTED_OBJS_FILENAMES := $$(call replace_with_obj_extension, $$(notdir $$($1_SRCS)))
-  $1_EXPECTED_OBJS := $$(addprefix $$($1_OBJECT_DIR)/,$$($1_EXPECTED_OBJS_FILENAMES))
+  $1_EXPECTED_OBJS := $$(addprefix $$($1_OBJECT_DIR)/, $$($1_EXPECTED_OBJS_FILENAMES))
   # 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)))
+  $1_SUPERFLOUS_OBJS := $$(sort $$(filter-out $$($1_EXPECTED_OBJS), $$($1_BINS)))
   # Clean out the superfluous object files.
-  ifneq ($$($1_SUPERFLUOUS_OBJS),)
+  ifneq ($$($1_SUPERFLUOUS_OBJS), )
     $$(shell $(RM) -f $$($1_SUPERFLUOUS_OBJS))
   endif
   # Sort to remove dupliates and provide a reproducable order on the input files to the linker.
@@ -571,42 +520,42 @@
 
   # Pickup extra OPENJDK_TARGET_OS_TYPE, OPENJDK_TARGET_OS, and/or OPENJDK_TARGET_OS plus
   # OPENJDK_TARGET_CPU pair dependent variables for CFLAGS.
-  $1_EXTRA_CFLAGS:=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CFLAGS_$(OPENJDK_TARGET_OS)) \
+  $1_EXTRA_CFLAGS := $$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CFLAGS_$(OPENJDK_TARGET_OS)) \
       $$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU))
-  ifneq ($(DEBUG_LEVEL),release)
+  ifneq ($(DEBUG_LEVEL), release)
     # Pickup extra debug dependent variables for CFLAGS
-    $1_EXTRA_CFLAGS+=$$($1_CFLAGS_debug)
-    $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug)
-    $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_debug)
-    $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU)_debug)
+    $1_EXTRA_CFLAGS += $$($1_CFLAGS_debug)
+    $1_EXTRA_CFLAGS += $$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug)
+    $1_EXTRA_CFLAGS += $$($1_CFLAGS_$(OPENJDK_TARGET_OS)_debug)
+    $1_EXTRA_CFLAGS += $$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU)_debug)
   else
-    $1_EXTRA_CFLAGS+=$$($1_CFLAGS_release)
-    $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release)
-    $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_release)
-    $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU)_release)
+    $1_EXTRA_CFLAGS += $$($1_CFLAGS_release)
+    $1_EXTRA_CFLAGS += $$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release)
+    $1_EXTRA_CFLAGS += $$($1_CFLAGS_$(OPENJDK_TARGET_OS)_release)
+    $1_EXTRA_CFLAGS += $$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU)_release)
   endif
 
   # 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))
-  ifneq ($(DEBUG_LEVEL),release)
+  $1_EXTRA_CXXFLAGS := $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS))
+  ifneq ($(DEBUG_LEVEL), release)
     # Pickup extra debug dependent variables for CXXFLAGS
-    $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_debug)
-    $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug)
-    $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_debug)
+    $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_debug)
+    $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug)
+    $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_debug)
   else
-    $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_release)
-    $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release)
-    $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_release)
+    $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_release)
+    $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release)
+    $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_release)
   endif
 
   # 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)
+  ifeq ($$($1_CXXFLAGS), )
+    $1_CXXFLAGS := $$($1_CFLAGS)
   endif
-  ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)),)
-    $1_EXTRA_CXXFLAGS:=$$($1_EXTRA_CFLAGS)
+  ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)), )
+    $1_EXTRA_CXXFLAGS := $$($1_EXTRA_CFLAGS)
   endif
 
   ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true)
@@ -616,19 +565,19 @@
     $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_DEBUG_SYMBOLS)
   endif
 
-  ifneq (,$$($1_REORDER))
+  ifneq ($$($1_REORDER), )
     $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER)
     $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER)
   endif
 
   # 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)
+  ifeq ($$($1_TYPE), STATIC_LIBRARY)
+    $1_EXTRA_CFLAGS += -DLIBRARY_NAME=$$($1_NAME)
+    $1_EXTRA_CXXFLAGS += -DLIBRARY_NAME=$$($1_NAME)
   endif
 
   # Pick up disabled warnings, if possible on this platform.
-  ifneq ($(DISABLE_WARNING_PREFIX),)
+  ifneq ($(DISABLE_WARNING_PREFIX), )
     $1_EXTRA_CFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), \
         $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)) \
         $$($1_DISABLED_WARNINGS_C_$(TOOLCHAIN_TYPE)))
@@ -639,8 +588,8 @@
 
   # 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),)
+  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)
@@ -740,7 +689,7 @@
   endif
 
   # Now call add_native_source for each source file we are going to compile.
-  $$(foreach p,$$($1_SRCS), \
+  $$(foreach p, $$($1_SRCS), \
       $$(eval $$(call add_native_source,$1,$$p,$$($1_OBJECT_DIR), \
           $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $$($1_SYSROOT_CFLAGS), \
           $$($1_CC), \
@@ -750,7 +699,7 @@
   # 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)),)
+        ifeq ($$(wildcard $$($1_TARGET)), )
 	  $(ECHO) 'Creating $$(subst $$(OUTPUTDIR)/,,$$($1_TARGET)) from $$(words \
 	      $$(filter-out %.vardeps, $$?)) file(s)'
         else
@@ -763,10 +712,10 @@
 
   # 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
-      $1_RES_DEP:=$$($1_RES).d
-      $1_RES_DEP_TARGETS:=$$($1_RES).d.targets
+    ifneq ($$($1_VERSIONINFO_RESOURCE), )
+      $1_RES := $$($1_OBJECT_DIR)/$$($1_BASENAME).res
+      $1_RES_DEP := $$($1_RES).d
+      $1_RES_DEP_TARGETS := $$($1_RES).d.targets
       -include $$($1_RES_DEP)
       -include $$($1_RES_DEP_TARGETS)
 
@@ -775,7 +724,7 @@
           $$($1_RES).vardeps)
 
       $$($1_RES): $$($1_VERSIONINFO_RESOURCE) $$($1_RES_VARDEPS_FILE)
-		$$(call LogInfo, Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$(notdir $$($1_TARGET))))
+		$$(call LogInfo, Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$($1_BASENAME)))
 		$$(call MakeDir, $$(@D) $$($1_OBJECT_DIR))
 		$$(call ExecuteWithLog, $$@, \
 		    $$($1_RC) $$($1_RC_FLAGS) $$($1_SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \
@@ -798,10 +747,10 @@
     endif
   endif
 
-  ifneq ($(DISABLE_MAPFILES),true)
+  ifneq ($(DISABLE_MAPFILES), true)
     $1_REAL_MAPFILE := $$($1_MAPFILE)
-    ifneq ($(OPENJDK_TARGET_OS),windows)
-      ifneq (,$$($1_REORDER))
+    ifneq ($(OPENJDK_TARGET_OS), windows)
+      ifneq ($$($1_REORDER), )
         $1_REAL_MAPFILE := $$($1_OBJECT_DIR)/mapfile
 
         $$($1_REAL_MAPFILE) : $$($1_MAPFILE) $$($1_REORDER)
@@ -815,9 +764,9 @@
 
   # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables
   # for LDFLAGS and LIBS
-  $1_EXTRA_LDFLAGS:=$$($1_LDFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS))
-  $1_EXTRA_LIBS:=$$($1_LIBS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LIBS_$(OPENJDK_TARGET_OS))
-  ifneq (,$$($1_REAL_MAPFILE))
+  $1_EXTRA_LDFLAGS := $$($1_LDFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS))
+  $1_EXTRA_LIBS := $$($1_LIBS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LIBS_$(OPENJDK_TARGET_OS))
+  ifneq ($$($1_REAL_MAPFILE), )
     $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE))
   endif
 
@@ -835,7 +784,7 @@
   ifeq ($$($1_COPY_DEBUG_SYMBOLS), true)
     ifneq ($$($1_DEBUG_SYMBOLS), false)
       # Only copy debug symbols for dynamic libraries and programs.
-      ifeq ($$($1_STATIC_LIBRARY), )
+      ifneq ($$($1_TYPE), STATIC_LIBRARY)
         # Generate debuginfo files.
         ifeq ($(OPENJDK_TARGET_OS), windows)
           $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \
@@ -899,17 +848,17 @@
     endif
   endif
 
-  ifneq (,$$($1_LIBRARY))
+  ifeq ($$($1_TYPE), LIBRARY)
     # Generating a dynamic library.
     $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
     ifeq ($(OPENJDK_TARGET_OS), windows)
-      $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib"
+      $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_NAME).lib"
       # Create a rule for the import lib so that other rules may depend on it
-      $$($1_OBJECT_DIR)/$$($1_LIBRARY).lib: $$($1_TARGET)
+      $$($1_OBJECT_DIR)/$$($1_NAME).lib: $$($1_TARGET)
     endif
 
     # Create loadmap on AIX. Helps in diagnosing some problems.
-    ifneq ($(COMPILER_BINDCMD_FILE_FLAG),)
+    ifneq ($(COMPILER_BINDCMD_FILE_FLAG), )
       $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap
     endif
 
@@ -924,7 +873,7 @@
     # If there are many object files, use an @-file...
     ifneq ($$(word 17, $$($1_ALL_OBJS)), )
       $1_OBJ_FILE_LIST := $$($1_OBJECT_DIR)/_$1_objectfilenames.txt
-      ifneq ($(COMPILER_COMMAND_FILE_FLAG),)
+      ifneq ($(COMPILER_COMMAND_FILE_FLAG), )
         $1_LD_OBJ_ARG := $(COMPILER_COMMAND_FILE_FLAG)$$($1_OBJ_FILE_LIST)
       else
         # ...except for toolchains which don't support them.
@@ -986,7 +935,7 @@
 
   endif
 
-  ifneq (,$$($1_STATIC_LIBRARY))
+  ifeq ($$($1_TYPE), STATIC_LIBRARY)
     $1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \
         $$($1_EXTRA_LIBS)
     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
@@ -1000,7 +949,7 @@
     endif
 
     $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP)
-	$$(call LogInfo, Archiving $$($1_STATIC_LIBRARY))
+	$$(call LogInfo, Building static library $$($1_BASENAME))
 	$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
 	    $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \
 	        $$($1_RES))
@@ -1013,7 +962,7 @@
         endif
   endif
 
-  ifneq (,$$($1_PROGRAM))
+  ifeq ($$($1_TYPE), EXECUTABLE)
     # A executable binary has been specified, setup the target for it.
     $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
         $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \
@@ -1038,13 +987,13 @@
 		        $$($1_LIBS) $$($1_EXTRA_LIBS))
                 ifeq ($(OPENJDK_TARGET_OS), windows)
                   ifneq ($$($1_MANIFEST), )
-		    $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_PROGRAM).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1
+		    $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1
                   endif
                 endif
                 # This only works if the openjdk_codesign identity is present on the system. Let
                 # silently fail otherwise.
-                ifneq (,$(CODESIGN))
-                  ifneq (,$$($1_CODESIGN))
+                ifneq ($(CODESIGN), )
+                  ifneq ($$($1_CODESIGN), )
 		    $(CODESIGN) -s openjdk_codesign $$@
                   endif
                 endif